java.lang.Object
org.apache.lucene.index.ReaderPool
- All Implemented Interfaces:
Closeable,AutoCloseable
Holds shared SegmentReader instances. IndexWriter uses SegmentReaders for 1) applying deletes/DV
updates, 2) doing merges, 3) handing out a real-time reader. This pool reuses instances of the
SegmentReaders in all these places if it is in "near real-time mode" (getReader() has been called
on this instance).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate final LongSupplierprivate final Directoryprivate final FieldInfos.FieldNumbersprivate final InfoStreamprivate final Directoryprivate booleanprivate final Map<SegmentCommitInfo, ReadersAndUpdates> private final SegmentInfosprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionReaderPool(Directory directory, Directory originalDirectory, SegmentInfos segmentInfos, FieldInfos.FieldNumbers fieldNumbers, LongSupplier completedDelGenSupplier, InfoStream infoStream, String softDeletesField, StandardDirectoryReader reader) -
Method Summary
Modifier and TypeMethodDescription(package private) booleanReturnstrueiff any of the buffered readers and updates has at least one pending delete(package private) booleanReturnstrueiff there are any buffered doc values updates.(package private) booleanAsserts this info still exists in IW's segment infosvoidclose()(package private) booleancommit(SegmentInfos infos) Commit live docs changes for the segment readers for the provided infos.(package private) booleandrop(SegmentCommitInfo info) Drops reader for the givenSegmentCommitInfoif it's pooled(package private) voiddropAll()Remove all our references to readers, and commits any pending changes.(package private) voidEnables reader pooling for this pool.(package private) ReadersAndUpdatesget(SegmentCommitInfo info, boolean create) Obtain a ReadersAndLiveDocs instance from the readerPool.(package private) List<ReadersAndUpdates> Returns a list of all currently maintained ReadersAndUpdates sorted by it's ram consumption largest to smallest.(package private) booleanprivate PendingDeletesprivate PendingDeletesnewPendingDeletes(SegmentReader reader, SegmentCommitInfo info) private booleannoDups()(package private) longReturns the sum of the ram used by all the buffered readers and updates in MB(package private) booleanrelease(ReadersAndUpdates rld, boolean assertInfoLive) Releases theReadersAndUpdates.(package private) booleanWrites all doc values updates to disk if there are any.(package private) booleanWrites all doc values updates to disk if there are any.
-
Field Details
-
readerMap
-
directory
-
originalDirectory
-
fieldNumbers
-
completedDelGenSupplier
-
infoStream
-
segmentInfos
-
softDeletesField
-
poolReaders
private volatile boolean poolReaders -
closed
-
-
Constructor Details
-
ReaderPool
ReaderPool(Directory directory, Directory originalDirectory, SegmentInfos segmentInfos, FieldInfos.FieldNumbers fieldNumbers, LongSupplier completedDelGenSupplier, InfoStream infoStream, String softDeletesField, StandardDirectoryReader reader) throws IOException - Throws:
IOException
-
-
Method Details
-
assertInfoIsLive
Asserts this info still exists in IW's segment infos -
drop
Drops reader for the givenSegmentCommitInfoif it's pooled- Returns:
trueif a reader is pooled- Throws:
IOException
-
ramBytesUsed
long ramBytesUsed()Returns the sum of the ram used by all the buffered readers and updates in MB -
anyDeletions
boolean anyDeletions()Returnstrueiff any of the buffered readers and updates has at least one pending delete -
enableReaderPooling
void enableReaderPooling()Enables reader pooling for this pool. This should be called once the readers in this pool are shared with an outside resource like an NRT reader. Once reader pooling is enabled aReadersAndUpdateswill be kept around in the reader pool on callingrelease(ReadersAndUpdates, boolean)until the segment get dropped via calls todrop(SegmentCommitInfo)ordropAll()orclose(). Reader pooling is disabled upon construction but can't be disabled again once it's enabled. -
isReaderPoolingEnabled
boolean isReaderPoolingEnabled() -
release
Releases theReadersAndUpdates. This should only be called if theget(SegmentCommitInfo, boolean)is called with the create paramter set to true.- Returns:
trueif any files were written by this release call.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
writeAllDocValuesUpdates
Writes all doc values updates to disk if there are any.- Returns:
trueiff any files where written- Throws:
IOException
-
writeDocValuesUpdatesForMerge
Writes all doc values updates to disk if there are any.- Returns:
trueiff any files where written- Throws:
IOException
-
getReadersByRam
List<ReadersAndUpdates> getReadersByRam()Returns a list of all currently maintained ReadersAndUpdates sorted by it's ram consumption largest to smallest. This list can also contain readers that don't consume any ram at this point ie. don't have any updates buffered. -
dropAll
Remove all our references to readers, and commits any pending changes.- Throws:
IOException
-
commit
Commit live docs changes for the segment readers for the provided infos.- Throws:
IOException- If there is a low-level I/O error
-
anyDocValuesChanges
boolean anyDocValuesChanges()Returnstrueiff there are any buffered doc values updates. Otherwisefalse. -
get
Obtain a ReadersAndLiveDocs instance from the readerPool. If create is true, you must later callrelease(ReadersAndUpdates, boolean). -
newPendingDeletes
-
newPendingDeletes
-
noDups
private boolean noDups()
-