public static TimePeriod interval(Duration... durations) { // interval sec, min, time TimePeriod timePeriod = new TimePeriod(Operator.INTERVAL); Collections.addAll(timePeriod.durations, durations); return timePeriod; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } AggregationDefinition that = (AggregationDefinition) o; if (!basicSingleInputStream.equals(that.basicSingleInputStream)) { return false; } if (selector != null ? !selector.equals(that.selector) : that.selector != null) { return false; } if (!aggregateAttribute.equals(that.aggregateAttribute)) { return false; } if (timePeriod != null ? !timePeriod.equals(that.timePeriod) : that.timePeriod != null) { return false; } return annotations != null ? annotations.equals(that.annotations) : that.annotations == null; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + basicSingleInputStream.hashCode(); result = 31 * result + (selector != null ? selector.hashCode() : 0); result = 31 * result + aggregateAttribute.hashCode(); result = 31 * result + (timePeriod != null ? timePeriod.hashCode() : 0); result = 31 * result + (annotations != null ? annotations.hashCode() : 0); return result; }
/** * Generates AggregateByTimePeriod object with the given Siddhi TimePeriod * @param timePeriod Siddhi TimePeriod object * @return AggregateByTimePeriod object * @throws DesignGenerationException Unknown type of TimePeriod operator */ private AggregateByTimePeriod generateAggregateByTime(TimePeriod timePeriod) throws DesignGenerationException { preserveCodeSegment(timePeriod); if (("INTERVAL").equalsIgnoreCase(timePeriod.getOperator().toString())) { return generateAggregateByTimeInterval(timePeriod.getDurations()); } else if (("RANGE").equalsIgnoreCase(timePeriod.getOperator().toString())) { return generateAggregateByTimeRange(timePeriod.getDurations()); } throw new DesignGenerationException("Unable to generate AggregateByTime for TimePeriod of type unknown"); }
@Override public TimePeriod visitAggregation_time_interval(@NotNull SiddhiQLParser.Aggregation_time_intervalContext ctx) { List<TimePeriod.Duration> durations = new ArrayList<TimePeriod.Duration>(); for (SiddhiQLParser.Aggregation_time_durationContext context : ctx.aggregation_time_duration()) { durations.add((TimePeriod.Duration) visit(context)); } TimePeriod.Duration[] durationVarArg = new TimePeriod.Duration[durations.size()]; durationVarArg = durations.toArray(durationVarArg); TimePeriod timePeriod = TimePeriod.interval(durationVarArg); populateQueryContext(timePeriod, ctx); return timePeriod; }
@Override public TimePeriod visitAggregation_time_range(@NotNull SiddhiQLParser.Aggregation_time_rangeContext ctx) { // read left and right contexts SiddhiQLParser.Aggregation_time_durationContext left = ctx.aggregation_time_duration().get(0); SiddhiQLParser.Aggregation_time_durationContext right = ctx.aggregation_time_duration().get(1); // Visit left and right expression using above contexts and create a new // RangeTimeSpecifier object TimePeriod.Duration leftTimeDuration = visitAggregation_time_duration(left); TimePeriod.Duration rightTimeDuration = visitAggregation_time_duration(right); TimePeriod timePeriod = TimePeriod.range(leftTimeDuration, rightTimeDuration); populateQueryContext(timePeriod, ctx); return timePeriod; }
public static TimePeriod range(Duration begging, Duration end) { // range sec ... min TimePeriod timePeriod = new TimePeriod(Operator.RANGE); timePeriod.durations.add(begging); timePeriod.durations.add(end); return timePeriod; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + basicSingleInputStream.hashCode(); result = 31 * result + (selector != null ? selector.hashCode() : 0); result = 31 * result + aggregateAttribute.hashCode(); result = 31 * result + (timePeriod != null ? timePeriod.hashCode() : 0); result = 31 * result + (annotations != null ? annotations.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } AggregationDefinition that = (AggregationDefinition) o; if (!basicSingleInputStream.equals(that.basicSingleInputStream)) { return false; } if (selector != null ? !selector.equals(that.selector) : that.selector != null) { return false; } if (!aggregateAttribute.equals(that.aggregateAttribute)) { return false; } if (timePeriod != null ? !timePeriod.equals(that.timePeriod) : that.timePeriod != null) { return false; } return annotations != null ? annotations.equals(that.annotations) : that.annotations == null; }
public static TimePeriod interval(Duration... durations) { // interval sec, min, time TimePeriod timePeriod = new TimePeriod(Operator.INTERVAL); Collections.addAll(timePeriod.durations, durations); return timePeriod; }
public static TimePeriod range(Duration begging, Duration end) { // range sec ... min TimePeriod timePeriod = new TimePeriod(Operator.RANGE); timePeriod.durations.add(begging); timePeriod.durations.add(end); return timePeriod; }