clintropolis commented on code in PR #13297:
URL: https://github.com/apache/druid/pull/13297#discussion_r1012451787


##########
processing/src/main/java/org/apache/druid/segment/nested/NestedFieldLiteralColumnIndexSupplier.java:
##########
@@ -223,16 +214,41 @@ private <T> IntIntPair getLocalRangeFromDictionary(
       }
     }
     globalEndIndex = Math.max(globalStartIndex, globalEndIndex);
-    // end index is not inclusive, so we find the last value in the local 
dictionary that falls within the range
+
+    // with global dictionary id range settled, now lets map that onto a local 
dictionary id range
+    int localFound = localDictionary.indexOf(globalStartIndex);
+    if (localFound < 0) {
+      // the first valid global index is not within the local dictionary, so 
the insertion point is where we begin
+      localStartIndex = -(localFound + 1);
+      // if the computed local start index violates the global range, shift up 
by 1
+      int actualGlobalStartIndex = localDictionary.get(localStartIndex);
+      if (actualGlobalStartIndex < globalStartIndex) {

Review Comment:
   `FixedIndexed.indexOf` is the same-ish implementation as 
`GenericIndexed.indexOf`, both of which are basically the same as 
`Arrays.binarySearch`, so I think it is ok. Btw, range finder method is used 
for both `FixedIndexed` and `GenericIndexed` global dictionaries depending on 
if it is making `LexicographicalRangeIndex` for nested strings or 
`NumericRangeIndex` for nested numbers, though the local dictionary is always a 
`FixedIndexed`.
   
   Or did you mean something about how the range calculation is using `indexOf` 
to compute the ranges?
   
   btw, I did recently strengthen the contract of `indexOf` to be `(-(insertion 
point) - 1)` for missing values if `isSorted()` returns true, since these index 
things basically require the `(-(insertion point) - 1)` behavior to work 
correctly.



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