imply-cheddar commented on code in PR #13514:
URL: https://github.com/apache/druid/pull/13514#discussion_r1049142764


##########
processing/src/main/java/org/apache/druid/query/rowsandcols/semantic/DefaultFramedOnHeapAggregatable.java:
##########
@@ -0,0 +1,581 @@
+/*
+ * 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.druid.query.rowsandcols.semantic;
+
+import org.apache.druid.java.util.common.UOE;
+import org.apache.druid.query.aggregation.Aggregator;
+import org.apache.druid.query.aggregation.AggregatorFactory;
+import org.apache.druid.query.dimension.DimensionSpec;
+import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector;
+import org.apache.druid.query.operator.window.WindowFrame;
+import org.apache.druid.query.rowsandcols.RowsAndColumns;
+import org.apache.druid.query.rowsandcols.column.ConstantObjectColumn;
+import org.apache.druid.query.rowsandcols.column.ObjectArrayColumn;
+import org.apache.druid.segment.ColumnSelectorFactory;
+import org.apache.druid.segment.ColumnValueSelector;
+import org.apache.druid.segment.DimensionSelector;
+import org.apache.druid.segment.ObjectColumnSelector;
+import org.apache.druid.segment.column.ColumnCapabilities;
+import org.apache.druid.segment.column.ColumnCapabilitiesImpl;
+
+import javax.annotation.Nullable;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class DefaultFramedOnHeapAggregatable implements 
FramedOnHeapAggregatable
+{
+  private final AppendableRowsAndColumns rac;
+
+  public DefaultFramedOnHeapAggregatable(
+      AppendableRowsAndColumns rac
+  )
+  {
+    this.rac = rac;
+  }
+
+  @Override
+  public RowsAndColumns aggregateAll(
+      WindowFrame frame,
+      AggregatorFactory[] aggFactories
+  )
+  {
+    if (frame.isLowerUnbounded() && frame.isUpperUnbounded()) {
+      return computeUnboundedAggregates(aggFactories);
+    }
+
+
+    if (frame.getPeerType() == WindowFrame.PeerType.ROWS) {
+      if (frame.isLowerUnbounded()) {
+        return computeCumulativeAggregates(aggFactories, 
frame.getUpperOffset());
+      } else if (frame.isUpperUnbounded()) {
+        return computeReverseCumulativeAggregates(aggFactories, 
frame.getLowerOffset());
+      } else {
+        final int numRows = rac.numRows();
+        int lowerOffset = frame.getLowerOffset();
+        int upperOffset = frame.getUpperOffset();
+
+        if (numRows < lowerOffset + upperOffset + 1) {
+          // In this case, there are not enough rows to completely build up 
the full window aperture before it needs to
+          // also start contracting the aperture because of the upper offset. 
So we use a method that specifically
+          // handles checks for both expanding and reducing the aperture on 
every iteration.

Review Comment:
   little secret: I needed them for myself :P
   
   some code is "self documenting" some code is not, this code is not.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to