Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Going by #13976 and this dated stack overflow thread, it seems like there is desire for a reference managed MultiReader.
The implementation should provide a way to safely share a multi-reader across multiple threads, refresh underlying sub-readers periodically to pick new changes, and ensure that sub-readers are not closed until all threads have finished using them. I hacked together a quick prototype based on my understanding of the requirements. If this seems useful, I can add some tests and refine it. Or, @Shibi-bala, since you wrote the initial PR, feel free to take this further if you like.
Following discussions from the PR, this manager exposes a Multi-Reader and expects users to create their own IndexSearcher on top of it. The managed multi-reader uses
DirectoryReader.openIfChanged
to refresh its sub-readers, and as such, requires its sub-readers to beDirectoryReader
instances. I'm not sure if there are non DirectoryReader implementations that we want to handle via this manager.This manager will increase / decrease refCount for each subReader on acquire and release.
acquire
will fail if refCount cannot be incremented for any of the subReaders, i.e. if any of the sub-readers have closed.