jtuglu1 commented on code in PR #18813:
URL: https://github.com/apache/druid/pull/18813#discussion_r2600773552


##########
extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramNumericVectorizedAggregator.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.spectator.histogram;
+
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import org.apache.druid.query.aggregation.VectorAggregator;
+import org.apache.druid.segment.vector.VectorValueSelector;
+
+import javax.annotation.Nullable;
+import java.nio.ByteBuffer;
+
+/*
+  Aggregator used during ingestion time when aggregating against numeric 
values.
+*/
+public class SpectatorHistogramNumericVectorizedAggregator implements 
VectorAggregator
+{
+  private final SpectatorHistogramAggregateHelper innerAggregator = new 
SpectatorHistogramAggregateHelper();
+  private final VectorValueSelector selector;
+
+  public SpectatorHistogramNumericVectorizedAggregator(VectorValueSelector 
selector)
+  {
+    this.selector = selector;
+  }
+
+  @Override
+  public void init(ByteBuffer buffer, int position)
+  {
+    // Map buf to a new histogram
+    innerAggregator.init(buffer, position);
+  }
+
+  @Override
+  public void aggregate(ByteBuffer buffer, int position, int startRow, int 
endRow)
+  {
+    boolean[] isNull = selector.getNullVector();
+    long[] vector = selector.getLongVector();
+    boolean hasNulls = isNull != null;
+    final SpectatorHistogram histogram = innerAggregator.get(buffer, position);
+
+    for (int i = startRow; i < endRow; ++i) {
+      if (!hasNulls || !isNull[i]) {
+        innerAggregator.merge(histogram, vector[i]);
+      }
+    }
+  }
+
+  @Override
+  public void aggregate(ByteBuffer buffer, int numRows, int[] positions, 
@Nullable int[] rows, int positionOffset)

Review Comment:
   I just followed the naming of the 
[interface](https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/query/aggregation/VectorAggregator.java#L70)
 – will keep as-is for the sake of uniforimity.



##########
extensions-contrib/spectator-histogram/src/main/java/org/apache/druid/spectator/histogram/SpectatorHistogramNumericVectorizedAggregator.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.spectator.histogram;
+
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import org.apache.druid.query.aggregation.VectorAggregator;
+import org.apache.druid.segment.vector.VectorValueSelector;
+
+import javax.annotation.Nullable;
+import java.nio.ByteBuffer;
+
+/*
+  Aggregator used during ingestion time when aggregating against numeric 
values.
+*/
+public class SpectatorHistogramNumericVectorizedAggregator implements 
VectorAggregator
+{
+  private final SpectatorHistogramAggregateHelper innerAggregator = new 
SpectatorHistogramAggregateHelper();
+  private final VectorValueSelector selector;
+
+  public SpectatorHistogramNumericVectorizedAggregator(VectorValueSelector 
selector)
+  {
+    this.selector = selector;
+  }
+
+  @Override
+  public void init(ByteBuffer buffer, int position)
+  {
+    // Map buf to a new histogram
+    innerAggregator.init(buffer, position);
+  }
+
+  @Override
+  public void aggregate(ByteBuffer buffer, int position, int startRow, int 
endRow)
+  {
+    boolean[] isNull = selector.getNullVector();
+    long[] vector = selector.getLongVector();
+    boolean hasNulls = isNull != null;
+    final SpectatorHistogram histogram = innerAggregator.get(buffer, position);
+
+    for (int i = startRow; i < endRow; ++i) {
+      if (!hasNulls || !isNull[i]) {
+        innerAggregator.merge(histogram, vector[i]);
+      }
+    }
+  }
+
+  @Override
+  public void aggregate(ByteBuffer buffer, int numRows, int[] positions, 
@Nullable int[] rows, int positionOffset)

Review Comment:
   I just followed the naming of the 
[interface](https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/query/aggregation/VectorAggregator.java#L70)
 – will keep as-is for the sake of uniformity.



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