github-advanced-security[bot] commented on code in PR #19238:
URL: https://github.com/apache/druid/pull/19238#discussion_r3013575647


##########
processing/src/test/java/org/apache/druid/frame/processor/SummingFrameCombiner.java:
##########
@@ -61,105 +74,123 @@
   @Override
   public void reset(final Frame frame, final int row)
   {
-    this.keyCursor = FrameProcessors.makeCursor(frame, frameReader);
-    this.keyCursor.setCurrentRow(row);
-    this.summedValue = readLongValue(frame, row);
+    final FrameCursor cursor = getCursor(frame);
+    cursor.setCurrentRow(row);
+    this.summedValue = cachedSumSelector.getLong();
   }
 
   @Override
   public void combine(final Frame frame, final int row)
   {
-    this.summedValue += readLongValue(frame, row);
+    final FrameCursor cursor = getCursor(frame);
+    cursor.setCurrentRow(row);
+    this.summedValue += cachedSumSelector.getLong();
   }
 
   @Override
   public ColumnSelectorFactory getCombinedColumnSelectorFactory()
   {
-    return new ColumnSelectorFactory()
+    return combinedColumnSelectorFactory;
+  }
+
+  private FrameCursor getCursor(final Frame frame)
+  {
+    //noinspection ObjectEquality
+    if (frame != cachedFrame) {
+      cachedFrame = frame;
+      cachedCursor = FrameProcessors.makeCursor(frame, frameReader);
+
+      final String sumColumnName = signature.getColumnName(sumColumnNumber);
+      cachedSumSelector = 
cachedCursor.getColumnSelectorFactory().makeColumnValueSelector(sumColumnName);
+    }
+    return cachedCursor;
+  }
+
+  private class CombinedColumnSelectorFactory implements ColumnSelectorFactory
+  {
+    private final Map<String, TrackingColumnValueSelector> 
columnValueSelectorCache = new HashMap<>();
+    private final Map<DimensionSpec, TrackingDimensionSelector> 
dimensionSelectorCache = new HashMap<>();
+
+    @Override
+    public DimensionSelector makeDimensionSelector(final DimensionSpec 
dimensionSpec)
     {
-      @Override
-      public DimensionSelector makeDimensionSelector(final DimensionSpec 
dimensionSpec)
-      {
-        final int columnNumber = 
signature.indexOf(dimensionSpec.getDimension());
-        if (columnNumber < 0) {
-          return DimensionSelector.constant(null, 
dimensionSpec.getExtractionFn());
-        } else if (columnNumber == sumColumnNumber) {
-          throw new UnsupportedOperationException();
-        } else {
-          return 
keyCursor.getColumnSelectorFactory().makeDimensionSelector(dimensionSpec);
-        }
+      final int columnNumber = signature.indexOf(dimensionSpec.getDimension());
+      if (columnNumber < 0) {
+        return DimensionSelector.constant(null, 
dimensionSpec.getExtractionFn());

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [DimensionSpec.getExtractionFn](1) should be avoided because it has 
been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10942)



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