vsop-479 commented on code in PR #13596:
URL: https://github.com/apache/lucene/pull/13596#discussion_r1753771874


##########
lucene/test-framework/src/java/org/apache/lucene/tests/index/PerThreadPKLookup.java:
##########
@@ -97,5 +174,28 @@ public int lookup(BytesRef id) throws IOException {
     return -1;
   }
 
-  // TODO: add reopen method to carry over re-used enums...?
+  /**
+   * Reuse loaded segments' termsEnum and postingsEnum.
+   *
+   * @return null if there are no changes; else, a new PerThreadPKLookup 
instance which you must
+   *     eventually close its reader by {@link #closeReader}.
+   * @throws IOException if there is a low-level IO error.
+   */
+  public PerThreadPKLookup reopen() throws IOException {
+    DirectoryReader newReader = 
DirectoryReader.openIfChanged((DirectoryReader) reader);
+    if (newReader == null) {
+      return null;
+    }
+
+    return new PerThreadPKLookup(this, newReader);

Review Comment:
   I added a `Map<SegmentInfo, Integer> segmentInfoMap` to record each 
segment's index in `termsEnums`, and apply reuse common TermsEnums by getting 
SegmentInfo‘s index when create a new `PerThreadPKLookup` by new reader, in 
current version.
   
   Do you mean use `LeafReader#getCoreCacheHelper` to instead of `SegmentInfo` 
as the key?



-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to