itschrispeck commented on code in PR #11739:
URL: https://github.com/apache/pinot/pull/11739#discussion_r1367990028


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/json/ImmutableJsonIndexReader.java:
##########
@@ -300,6 +305,92 @@ private int getDocId(int flattenedDocId) {
     return _docIdMapping.getInt((long) flattenedDocId << 2);
   }
 
+  /**
+   * ImmutableJsonIndexReaderContext holds a cache that is used to accelerate 
following reads. The cache is specific
+   * to a key, and therefore should NOT be reused for other keys. For each 
key, ImmutableJsonIndexReader.createContext()
+   * should be invoked to create a fresh context.
+   */
+  public static class ImmutableJsonIndexReaderContext implements 
JsonIndexReaderContext {
+    private final Int2ObjectOpenHashMap<RoaringBitmap> _cache;
+
+    public ImmutableJsonIndexReaderContext() {
+      _cache = new Int2ObjectOpenHashMap<>();
+    }
+
+    public Int2ObjectOpenHashMap<RoaringBitmap> getCache() {
+      return _cache;
+    }
+  }
+
+  @Override
+  public ImmutableJsonIndexReaderContext createContext() {
+    return new ImmutableJsonIndexReaderContext();
+  }
+
+  @Override
+  public String[] getValuesForKeyAndDocs(String key, int[] docIds, 
JsonIndexReaderContext context) {

Review Comment:
   Gotcha, thanks for the detailed explanation. Refactored to use `public 
Map<String, RoaringBitmap> getMatchingDocsMap(String key)` as you suggested. 



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