ankitsultana commented on code in PR #13999:
URL: https://github.com/apache/pinot/pull/13999#discussion_r1762430749


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/timeseries/TimeSeriesAggregationOperator.java:
##########
@@ -0,0 +1,251 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.timeseries;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.NotImplementedException;
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.core.common.BlockValSet;
+import org.apache.pinot.core.common.Operator;
+import org.apache.pinot.core.operator.BaseOperator;
+import org.apache.pinot.core.operator.BaseProjectOperator;
+import org.apache.pinot.core.operator.ExecutionStatistics;
+import org.apache.pinot.core.operator.blocks.ValueBlock;
+import org.apache.pinot.core.operator.blocks.results.TimeSeriesResultsBlock;
+import org.apache.pinot.tsdb.spi.AggInfo;
+import org.apache.pinot.tsdb.spi.TimeBuckets;
+import org.apache.pinot.tsdb.spi.series.BaseTimeSeriesBuilder;
+import org.apache.pinot.tsdb.spi.series.TimeSeries;
+import org.apache.pinot.tsdb.spi.series.TimeSeriesBlock;
+import org.apache.pinot.tsdb.spi.series.TimeSeriesBuilderFactory;
+
+
+/**
+ * Segment level operator which converts data in relational model to a 
time-series model, by aggregating on a
+ * configured aggregation expression.
+ */
+public class TimeSeriesAggregationOperator extends 
BaseOperator<TimeSeriesResultsBlock> {
+  private static final String EXPLAIN_NAME = "TIME_SERIES_AGGREGATION";
+  private final String _timeColumn;
+  private final TimeUnit _storedTimeUnit;
+  private final Long _timeOffset;
+  private final AggInfo _aggInfo;
+  private final ExpressionContext _valueExpression;
+  private final List<String> _groupByExpressions;
+  private final BaseProjectOperator<? extends ValueBlock> _projectOperator;
+  private final TimeBuckets _timeBuckets;
+  private final TimeSeriesBuilderFactory _seriesBuilderFactory;
+
+  public TimeSeriesAggregationOperator(
+      String timeColumn,
+      TimeUnit timeUnit,
+      Long timeOffset,
+      AggInfo aggInfo,
+      ExpressionContext valueExpression,
+      List<String> groupByExpressions,
+      TimeBuckets timeBuckets,
+      BaseProjectOperator<? extends ValueBlock> projectOperator,
+      TimeSeriesBuilderFactory seriesBuilderFactory) {
+    _timeColumn = timeColumn;
+    _storedTimeUnit = timeUnit;
+    _timeOffset = timeOffset;
+    _aggInfo = aggInfo;
+    _valueExpression = valueExpression;
+    _groupByExpressions = groupByExpressions;
+    _projectOperator = projectOperator;
+    _timeBuckets = timeBuckets;
+    _seriesBuilderFactory = seriesBuilderFactory;
+  }
+
+  @Override
+  protected TimeSeriesResultsBlock getNextBlock() {
+    ValueBlock transformBlock = _projectOperator.nextBlock();
+    BlockValSet blockValSet = transformBlock.getBlockValueSet(_timeColumn);
+    long[] timeValues = blockValSet.getLongValuesSV();
+    if (_timeOffset != null && _timeOffset != 0L) {
+      timeValues = applyTimeshift(_timeOffset, timeValues);
+    }
+    int[] timeValueIndexes = getTimeValueIndex(timeValues, _storedTimeUnit);
+    Object[][] tagValues = new Object[_groupByExpressions.size()][];
+    Map<Long, BaseTimeSeriesBuilder> seriesBuilderMap = new HashMap<>(1024);

Review Comment:
   Yeah this is the initial capacity. I had set it up thinking that this is a 
reasonable number, but I don't have a benchmark to verify if this is efficient 
in most scenarios. I can revert it to use the default ctor if required. Lmk.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to