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


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/merger/TimeSeriesAggResultsBlockMerger.java:
##########
@@ -0,0 +1,66 @@
+/**
+ * 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.combine.merger;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.pinot.core.operator.blocks.results.TimeSeriesResultsBlock;
+import org.apache.pinot.tsdb.spi.AggInfo;
+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;
+
+
+public class TimeSeriesAggResultsBlockMerger implements 
ResultsBlockMerger<TimeSeriesResultsBlock> {
+  private final TimeSeriesBuilderFactory _seriesBuilderFactory;
+  private final AggInfo _aggInfo;
+
+  public TimeSeriesAggResultsBlockMerger(TimeSeriesBuilderFactory 
seriesBuilderFactory, AggInfo aggInfo) {
+    _seriesBuilderFactory = seriesBuilderFactory;
+    _aggInfo = aggInfo;
+  }
+
+  @Override
+  public void mergeResultsBlocks(TimeSeriesResultsBlock mergedBlock, 
TimeSeriesResultsBlock blockToMerge) {
+    TimeSeriesBlock currentTimeSeriesBlock = mergedBlock.getTimeSeriesBlock();
+    TimeSeriesBlock seriesBlockToMerge = blockToMerge.getTimeSeriesBlock();
+    for (var entry : seriesBlockToMerge.getSeriesMap().entrySet()) {
+      long seriesHash = entry.getKey();
+      List<TimeSeries> currentTimeSeriesList = 
currentTimeSeriesBlock.getSeriesMap().get(seriesHash);
+      TimeSeries currentTimeSeries = null;
+      if (currentTimeSeriesList != null && !currentTimeSeriesList.isEmpty()) {
+        currentTimeSeries = currentTimeSeriesList.get(0);
+      }
+      TimeSeries newTimeSeriesToMerge = entry.getValue().get(0);
+      if (currentTimeSeries == null) {

Review Comment:
   So under the combine operator we run per-segment level operators. The 
combine operator merges results across segments using the merger. It could be 
that a given segment yields a series: `city_name='Boston'`, which didn't exist 
in any other segment.
   
   In such a case, the current time series block will not have this series and 
this condition will be met. And that's why we don't need to merge anything here 
and we can simply add the series to the currentTimeSeriesBlock



-- 
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