Package org.apache.lucene.index
Class ReadersAndUpdates
java.lang.Object
org.apache.lucene.index.ReadersAndUpdates
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
This class merges the current on-disk DV with an incoming update DV instance and merges the two instances giving the incoming update precedence in terms of values, in other words the values of the update always wins over the on-disk version. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
(package private) final SegmentCommitInfo
private boolean
private final Map<String,
List<DocValuesFieldUpdates>> private final PendingDeletes
private final Map<String,
List<DocValuesFieldUpdates>> (package private) final AtomicLong
private SegmentReader
private final AtomicInteger
(package private) Sorter.DocMap
-
Constructor Summary
ConstructorsConstructorDescriptionReadersAndUpdates
(int indexCreatedVersionMajor, SegmentCommitInfo info, PendingDeletes pendingDeletes) ReadersAndUpdates
(int indexCreatedVersionMajor, SegmentReader reader, PendingDeletes pendingDeletes) Init from a previously opened SegmentReader. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDVUpdate
(DocValuesFieldUpdates update) Adds a new resolved (meaning it maps docIDs to new values) doc values packet.private boolean
assertNoDupGen
(List<DocValuesFieldUpdates> fieldUpdates, DocValuesFieldUpdates update) private FieldInfo
cloneFieldInfo
(FieldInfo fi, int fieldNumber) private SegmentReader
void
decRef()
boolean
delete
(int docID) void
void
Drops all merging updates.void
int
Returns the live-docs bits excluding documents that are not live due to soft-deletesprivate CodecReader
Returns a snapshot of the live docs.long
Returns aSegmentReader
.(package private) MergePolicy.MergeReader
getReaderForMerge
(IOContext context) Returns a reader for merge, with the latest doc values updates and deletions.getReadOnlyClone
(IOContext context) Returns a ref to a clone.private void
handleDVUpdates
(FieldInfos infos, Directory dir, DocValuesFormat dvFormat, SegmentReader reader, Map<Integer, Set<String>> fieldFiles, long maxDelGen, InfoStream infoStream) void
incRef()
boolean
(package private) boolean
(package private) boolean
keepFullyDeletedSegment
(MergePolicy mergePolicy) (package private) int
numDeletesToMerge
(MergePolicy policy) int
refCount()
void
release
(SegmentReader sr) (package private) void
private void
toString()
writeFieldInfosGen
(FieldInfos fieldInfos, Directory dir, FieldInfosFormat infosFormat) boolean
writeFieldUpdates
(Directory dir, FieldInfos.FieldNumbers fieldNumbers, long maxDelGen, InfoStream infoStream) boolean
writeLiveDocs
(Directory dir)
-
Field Details
-
info
-
refCount
-
reader
-
pendingDeletes
-
indexCreatedVersionMajor
private final int indexCreatedVersionMajor -
isMerging
private boolean isMerging -
pendingDVUpdates
-
mergingDVUpdates
-
sortMap
Sorter.DocMap sortMap -
ramBytesUsed
-
-
Constructor Details
-
ReadersAndUpdates
ReadersAndUpdates(int indexCreatedVersionMajor, SegmentCommitInfo info, PendingDeletes pendingDeletes) -
ReadersAndUpdates
ReadersAndUpdates(int indexCreatedVersionMajor, SegmentReader reader, PendingDeletes pendingDeletes) throws IOException Init from a previously opened SegmentReader.NOTE: steals incoming ref from reader.
- Throws:
IOException
-
-
Method Details
-
incRef
public void incRef() -
decRef
public void decRef() -
refCount
public int refCount() -
getDelCount
public int getDelCount() -
assertNoDupGen
private boolean assertNoDupGen(List<DocValuesFieldUpdates> fieldUpdates, DocValuesFieldUpdates update) -
addDVUpdate
Adds a new resolved (meaning it maps docIDs to new values) doc values packet. We buffer these in RAM and write to disk when too much RAM is used or when a merge needs to kick off, or a commit/refresh.- Throws:
IOException
-
getNumDVUpdates
public long getNumDVUpdates() -
getReader
Returns aSegmentReader
.- Throws:
IOException
-
release
- Throws:
IOException
-
delete
- Throws:
IOException
-
dropReaders
- Throws:
IOException
-
getReadOnlyClone
Returns a ref to a clone. NOTE: you should decRef() the reader when you're done (ie do not call close()).- Throws:
IOException
-
numDeletesToMerge
- Throws:
IOException
-
getLatestReader
- Throws:
IOException
-
getLiveDocs
Returns a snapshot of the live docs. -
getHardLiveDocs
Returns the live-docs bits excluding documents that are not live due to soft-deletes -
dropChanges
public void dropChanges() -
writeLiveDocs
- Throws:
IOException
-
handleDVUpdates
private void handleDVUpdates(FieldInfos infos, Directory dir, DocValuesFormat dvFormat, SegmentReader reader, Map<Integer, Set<String>> fieldFiles, long maxDelGen, InfoStream infoStream) throws IOException- Throws:
IOException
-
writeFieldInfosGen
private Set<String> writeFieldInfosGen(FieldInfos fieldInfos, Directory dir, FieldInfosFormat infosFormat) throws IOException - Throws:
IOException
-
writeFieldUpdates
public boolean writeFieldUpdates(Directory dir, FieldInfos.FieldNumbers fieldNumbers, long maxDelGen, InfoStream infoStream) throws IOException - Throws:
IOException
-
cloneFieldInfo
-
createNewReaderWithLatestLiveDocs
- Throws:
IOException
-
swapNewReaderWithLatestLiveDocs
- Throws:
IOException
-
setIsMerging
void setIsMerging() -
isMerging
boolean isMerging() -
getReaderForMerge
Returns a reader for merge, with the latest doc values updates and deletions.- Throws:
IOException
-
dropMergingUpdates
public void dropMergingUpdates()Drops all merging updates. Called from IndexWriter after this segment finished merging (whether successfully or not). -
getMergingDVUpdates
-
toString
-
isFullyDeleted
- Throws:
IOException
-
keepFullyDeletedSegment
- Throws:
IOException
-