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


##########
processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndex.java:
##########
@@ -1207,177 +1227,151 @@
     }
   }
 
-  private static boolean allNull(Object[] dims, int startPosition)
-  {
-    for (int i = startPosition; i < dims.length; i++) {
-      if (dims[i] != null) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  public interface FactsHolder
-  {
-    /**
-     * @return the previous rowIndex associated with the specified key, or
-     * {@link IncrementalIndexRow#EMPTY_ROW_INDEX} if there was no mapping for 
the key.
-     */
-    int getPriorIndex(IncrementalIndexRow key);
-
-    long getMinTimeMillis();
-
-    long getMaxTimeMillis();
-
-    Iterator<IncrementalIndexRow> iterator(boolean descending);
-
-    Iterable<IncrementalIndexRow> timeRangeIterable(boolean descending, long 
timeStart, long timeEnd);
-
-    Iterable<IncrementalIndexRow> keySet();
-
-    /**
-     * Get all {@link IncrementalIndexRow} to persist, ordered with {@link 
Comparator<IncrementalIndexRow>}
-     *
-     * @return
-     */
-    Iterable<IncrementalIndexRow> persistIterable();
-
-    /**
-     * @return the previous rowIndex associated with the specified key, or
-     * {@link IncrementalIndexRow#EMPTY_ROW_INDEX} if there was no mapping for 
the key.
-     */
-    int putIfAbsent(IncrementalIndexRow key, int rowIndex);
-
-    void clear();
-  }
-
-  private final class LongMetricColumnSelector implements LongColumnSelector
+  private static final class LongMetricColumnSelector implements 
LongColumnSelector
   {
+    private final IncrementalIndexRowSelector rowSelector;
     private final IncrementalIndexRowHolder currEntry;
     private final int metricIndex;
 
-    public LongMetricColumnSelector(IncrementalIndexRowHolder currEntry, int 
metricIndex)
+    public LongMetricColumnSelector(
+        IncrementalIndexRowSelector rowSelector,
+        IncrementalIndexRowHolder currEntry,
+        int metricIndex
+    )
     {
+      this.rowSelector = rowSelector;
       this.currEntry = currEntry;
       this.metricIndex = metricIndex;
     }
 
     @Override
     public long getLong()
     {
-      assert NullHandling.replaceWithDefault() || !isNull();
-      return getMetricLongValue(currEntry.get().getRowIndex(), metricIndex);
+      return rowSelector.getMetricLongValue(currEntry.get().getRowIndex(), 
metricIndex);
     }
 
     @Override
-    public void inspectRuntimeShape(RuntimeShapeInspector inspector)
+    public boolean isNull()
     {
-      inspector.visit("index", IncrementalIndex.this);
+      return rowSelector.isNull(currEntry.get().getRowIndex(), metricIndex);
     }
 
     @Override
-    public boolean isNull()
+    public void inspectRuntimeShape(RuntimeShapeInspector inspector)
     {
-      return IncrementalIndex.this.isNull(currEntry.get().getRowIndex(), 
metricIndex);
+      inspector.visit("index", rowSelector);
     }
   }
 
-  private final class ObjectMetricColumnSelector extends ObjectColumnSelector
+  private static final class FloatMetricColumnSelector implements 
FloatColumnSelector
   {
+    private final IncrementalIndexRowSelector rowSelector;
     private final IncrementalIndexRowHolder currEntry;
     private final int metricIndex;
-    private Class classOfObject;
 
-    public ObjectMetricColumnSelector(
-        MetricDesc metricDesc,
+    public FloatMetricColumnSelector(
+        IncrementalIndexRowSelector rowSelector,
         IncrementalIndexRowHolder currEntry,
         int metricIndex
     )
     {
       this.currEntry = currEntry;
+      this.rowSelector = rowSelector;
       this.metricIndex = metricIndex;
-      classOfObject = 
ComplexMetrics.getSerdeForType(metricDesc.getType()).getObjectStrategy().getClazz();
     }
 
-    @Nullable
     @Override
-    public Object getObject()
+    public float getFloat()
     {
-      return getMetricObjectValue(currEntry.get().getRowIndex(), metricIndex);
+      return rowSelector.getMetricFloatValue(currEntry.get().getRowIndex(), 
metricIndex);
     }
 
     @Override
-    public Class classOfObject()
+    public void inspectRuntimeShape(RuntimeShapeInspector inspector)
     {
-      return classOfObject;
+      inspector.visit("index", rowSelector);
     }
 
     @Override
-    public void inspectRuntimeShape(RuntimeShapeInspector inspector)
+    public boolean isNull()
     {
-      inspector.visit("index", IncrementalIndex.this);
+      return rowSelector.isNull(currEntry.get().getRowIndex(), metricIndex);
     }
   }
 
-  private final class FloatMetricColumnSelector implements FloatColumnSelector
+  private static final class DoubleMetricColumnSelector implements 
DoubleColumnSelector
   {
+    private final IncrementalIndexRowSelector rowSelector;
     private final IncrementalIndexRowHolder currEntry;
     private final int metricIndex;
 
-    public FloatMetricColumnSelector(IncrementalIndexRowHolder currEntry, int 
metricIndex)
+    public DoubleMetricColumnSelector(
+        IncrementalIndexRowSelector rowSelector,
+        IncrementalIndexRowHolder currEntry,
+        int metricIndex
+    )
     {
       this.currEntry = currEntry;
+      this.rowSelector = rowSelector;
       this.metricIndex = metricIndex;
     }
 
     @Override
-    public float getFloat()
+    public double getDouble()
     {
       assert NullHandling.replaceWithDefault() || !isNull();
-      return getMetricFloatValue(currEntry.get().getRowIndex(), metricIndex);
+      return rowSelector.getMetricDoubleValue(currEntry.get().getRowIndex(), 
metricIndex);
     }
 
     @Override
-    public void inspectRuntimeShape(RuntimeShapeInspector inspector)
+    public boolean isNull()
     {
-      inspector.visit("index", IncrementalIndex.this);
+      return rowSelector.isNull(currEntry.get().getRowIndex(), metricIndex);
     }
 
     @Override
-    public boolean isNull()
+    public void inspectRuntimeShape(RuntimeShapeInspector inspector)
     {
-      return IncrementalIndex.this.isNull(currEntry.get().getRowIndex(), 
metricIndex);
+      inspector.visit("index", rowSelector);
     }
   }
 
-  private final class DoubleMetricColumnSelector implements 
DoubleColumnSelector
+  private static final class ObjectMetricColumnSelector extends 
ObjectColumnSelector
   {
+    private final IncrementalIndexRowSelector rowSelector;
     private final IncrementalIndexRowHolder currEntry;
     private final int metricIndex;
+    private final Class<?> classOfObject;
 
-    public DoubleMetricColumnSelector(IncrementalIndexRowHolder currEntry, int 
metricIndex)
+    public ObjectMetricColumnSelector(
+        IncrementalIndexRowSelector rowSelector,
+        IncrementalIndexRowHolder currEntry,
+        MetricDesc metricDesc
+    )
     {
       this.currEntry = currEntry;
-      this.metricIndex = metricIndex;
+      this.rowSelector = rowSelector;
+      this.metricIndex = metricDesc.getIndex();
+      this.classOfObject = 
ComplexMetrics.getSerdeForType(metricDesc.getType()).getObjectStrategy().getClazz();

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



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