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


##########
processing/src/main/java/org/apache/druid/segment/NestedDataColumnIndexer.java:
##########
@@ -151,7 +177,79 @@ public ColumnValueSelector<?> makeColumnValueSelector(
       IncrementalIndex.DimensionDesc desc
   )
   {
-    final int dimIndex = desc.getIndex();
+
+    if (fieldIndexers.size() == 1 && 
fieldIndexers.containsKey(NestedPathFinder.JSON_PATH_ROOT)) {
+      final LiteralFieldIndexer rootField = 
fieldIndexers.get(NestedPathFinder.JSON_PATH_ROOT);
+      if (rootField.getTypes().getSingleType() != null) {
+        return new ColumnValueSelector<Object>()
+        {
+          @Override
+          public boolean isNull()
+          {
+            final Object o = getObject();
+            return !(o instanceof Number);
+          }
+
+          @Override
+          public float getFloat()
+          {
+            Object value = getObject();
+            if (value == null) {
+              return 0;
+            }
+            return ((Number) value).floatValue();
+          }
+
+          @Override
+          public double getDouble()
+          {
+            Object value = getObject();
+            if (value == null) {
+              return 0;
+            }
+            return ((Number) value).doubleValue();
+          }
+
+          @Override
+          public long getLong()
+          {
+            Object value = getObject();
+            if (value == null) {
+              return 0;
+            }
+            return ((Number) value).longValue();
+          }
+
+          @Override
+          public void inspectRuntimeShape(RuntimeShapeInspector inspector)
+          {
+
+          }
+
+          @Nullable
+          @Override
+          public Object getObject()
+          {
+            final int dimIndex = desc.getIndex();

Review Comment:
   I think it would be nice to just grab it once and reuse instead of calling 
`getIndex()` each time?



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