vigyasharma commented on code in PR #15428:
URL: https://github.com/apache/lucene/pull/15428#discussion_r2550779056
##########
lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java:
##########
@@ -226,6 +339,50 @@ public static DirectoryReader
openIfChanged(DirectoryReader oldReader, IndexWrit
return openIfChanged(oldReader, writer, true);
}
+ /**
+ * Expert: If there changes (committed or not) in the {@link IndexWriter}
versus what the provided
+ * reader is searching, then open and return a new IndexReader searching
both committed and
+ * uncommitted changes from the writer; else, return null (though, the
current implementation
+ * never returns null).
+ *
+ * <p>This provides "near real-time" searching, in that changes made during
an {@link IndexWriter}
+ * session can be quickly made available for searching without closing the
writer or calling
+ * {@link IndexWriter#commit}.
+ *
+ * <p>It's <i>near</i> real-time because there is no hard guarantee on how
quickly you can get a
+ * new reader after making changes with IndexWriter. You'll have to
experiment in your situation
+ * to determine if it's fast enough. As this is a new and experimental
feature, please report back
+ * on your findings so we can learn, improve and iterate.
+ *
+ * <p>The very first time this method is called, this writer instance will
make every effort to
+ * pool the readers that it opens for doing merges, applying deletes, etc.
This means additional
+ * resources (RAM, file descriptors, CPU time) will be consumed.
+ *
+ * <p>For lower latency on reopening a reader, you should call {@link
+ * IndexWriterConfig#setMergedSegmentWarmer} to pre-warm a newly merged
segment before it's
+ * committed to the index. This is important for minimizing index-to-search
delay after a large
+ * merge.
+ *
+ * <p>If an addIndexes* call is running in another thread, then this reader
will only search those
+ * segments from the foreign index that have been successfully copied over,
so far.
+ *
+ * <p><b>NOTE</b>: Once the writer is closed, any outstanding readers may
continue to be used.
+ * However, if you attempt to reopen any of those readers, you'll hit an
{@link
+ * org.apache.lucene.store.AlreadyClosedException}.
+ *
+ * @return DirectoryReader that covers entire index plus all changes made so
far by this
+ * IndexWriter instance, or null if there are no new changes
+ * @param writer The IndexWriter to open from
+ * @param executorService Provides intra-open concurrency
Review Comment:
Minor: "intra-open concurrency" feels a little hard to understand. I have
context on this change so I _think_ i know what this means, but let's simplify
for the java doc? How about something like:
```java
/**
* ...
* @param executorService used to open segment readers in parallel
*/
```
##########
lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java:
##########
@@ -86,18 +93,15 @@ protected DirectoryReader doBody(String segmentFileName)
throws IOException {
}
SegmentInfos sis =
SegmentInfos.readCommit(directory, segmentFileName,
minSupportedMajorVersion);
- final SegmentReader[] readers = new SegmentReader[sis.size()];
+ SegmentReader[] readers = new SegmentReader[sis.size()];
Review Comment:
Do we need to allocate this array here anymore? looks like
`createSegmentReader` allocates its own array?
--
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]