Copilot commented on code in PR #18680:
URL: https://github.com/apache/pinot/pull/18680#discussion_r3367039028


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/json/MutableJsonIndexImpl.java:
##########
@@ -676,6 +956,23 @@ private Map<String, RoaringBitmap> 
getMatchingKeysMap(String key) {
         key + JsonIndexCreator.KEY_VALUE_SEPARATOR_NEXT_CHAR, false);
   }
 
+  private Map<String, MutableRoaringBitmap> getMatchingDocIdKeysMap(String 
key) {
+    return _docIdPostingListMap.subMap(key + 
JsonIndexCreator.KEY_VALUE_SEPARATOR, false,
+        key + JsonIndexCreator.KEY_VALUE_SEPARATOR_NEXT_CHAR, false);
+  }
+
+  private static boolean isDirectDocIdIndexEligibleKey(String key) {
+    return key.isEmpty() || (!key.endsWith(JsonUtils.KEY_SEPARATOR)
+        && !key.contains(JsonUtils.KEY_SEPARATOR + JsonUtils.KEY_SEPARATOR)
+        && !key.contains(JsonUtils.ARRAY_INDEX_KEY));
+  }
+
+  private static boolean isDirectDocIdIndexEligibleValue(String value) {
+    int separatorIndex = value.indexOf(JsonIndexCreator.KEY_VALUE_SEPARATOR);
+    String key = separatorIndex >= 0 ? value.substring(0, separatorIndex) : 
value;
+    return isDirectDocIdIndexEligibleKey(key);
+  }

Review Comment:
   The direct-doc-id eligibility logic is now duplicated across 
BaseJsonIndexCreator, ImmutableJsonIndexReader, and MutableJsonIndexImpl 
(isDirectDocIdIndexEligibleKey/isDirectDocIdIndexEligibleValue). This 
duplication is easy to let drift and could cause subtle correctness/perf 
mismatches between immutable vs realtime JSON index evaluation (e.g., one side 
accepting a key the other rejects). Consider centralizing this predicate in a 
shared utility (e.g., JsonUtils or a small json-index helper) and referencing 
it from all three places.



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