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 AtomicBoolean
private final LongSupplier
private final Directory
private final FieldInfos.FieldNumbers
private final InfoStream
private final Directory
private boolean
private final Map
<SegmentCommitInfo, ReadersAndUpdates> private final SegmentInfos
private 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) boolean
Returnstrue
iff any of the buffered readers and updates has at least one pending delete(package private) boolean
Returnstrue
iff there are any buffered doc values updates.(package private) boolean
Asserts this info still exists in IW's segment infosvoid
close()
(package private) boolean
commit
(SegmentInfos infos) Commit live docs changes for the segment readers for the provided infos.(package private) boolean
drop
(SegmentCommitInfo info) Drops reader for the givenSegmentCommitInfo
if it's pooled(package private) void
dropAll()
Remove all our references to readers, and commits any pending changes.(package private) void
Enables reader pooling for this pool.(package private) ReadersAndUpdates
get
(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) boolean
private PendingDeletes
private PendingDeletes
newPendingDeletes
(SegmentReader reader, SegmentCommitInfo info) private boolean
noDups()
(package private) long
Returns the sum of the ram used by all the buffered readers and updates in MB(package private) boolean
release
(ReadersAndUpdates rld, boolean assertInfoLive) Releases theReadersAndUpdates
.(package private) boolean
Writes all doc values updates to disk if there are any.(package private) boolean
Writes 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 givenSegmentCommitInfo
if it's pooled- Returns:
true
if 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()Returnstrue
iff 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 aReadersAndUpdates
will 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' parameter set to true.- Returns:
true
if any files were written by this release call.- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
writeAllDocValuesUpdates
Writes all doc values updates to disk if there are any.- Returns:
true
iff any files where written- Throws:
IOException
-
writeDocValuesUpdatesForMerge
Writes all doc values updates to disk if there are any.- Returns:
true
iff 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 i.e. 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()Returnstrue
iff 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()
-