Package org.apache.lucene.index
Class ReadersAndUpdates
- java.lang.Object
-
- org.apache.lucene.index.ReadersAndUpdates
-
final class ReadersAndUpdates extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ReadersAndUpdates.MergedDocValues<DocValuesInstance extends DocValuesIterator>
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
Fields Modifier and Type Field Description private int
indexCreatedVersionMajor
(package private) SegmentCommitInfo
info
private boolean
isMerging
private java.util.Map<java.lang.String,java.util.List<DocValuesFieldUpdates>>
mergingDVUpdates
private PendingDeletes
pendingDeletes
private java.util.Map<java.lang.String,java.util.List<DocValuesFieldUpdates>>
pendingDVUpdates
(package private) java.util.concurrent.atomic.AtomicLong
ramBytesUsed
private SegmentReader
reader
private java.util.concurrent.atomic.AtomicInteger
refCount
(package private) Sorter.DocMap
sortMap
-
Constructor Summary
Constructors Constructor Description ReadersAndUpdates(int indexCreatedVersionMajor, SegmentCommitInfo info, PendingDeletes pendingDeletes)
ReadersAndUpdates(int indexCreatedVersionMajor, SegmentReader reader, PendingDeletes pendingDeletes)
Init from a previously opened SegmentReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDVUpdate(DocValuesFieldUpdates update)
Adds a new resolved (meaning it maps docIDs to new values) doc values packet.private boolean
assertNoDupGen(java.util.List<DocValuesFieldUpdates> fieldUpdates, DocValuesFieldUpdates update)
private FieldInfo
cloneFieldInfo(FieldInfo fi, int fieldNumber)
private SegmentReader
createNewReaderWithLatestLiveDocs(SegmentReader reader)
void
decRef()
boolean
delete(int docID)
void
dropChanges()
void
dropMergingUpdates()
Drops all merging updates.void
dropReaders()
int
getDelCount()
Bits
getHardLiveDocs()
Returns the live-docs bits excluding documents that are not live due to soft-deletesprivate CodecReader
getLatestReader()
Bits
getLiveDocs()
Returns a snapshot of the live docs.java.util.Map<java.lang.String,java.util.List<DocValuesFieldUpdates>>
getMergingDVUpdates()
long
getNumDVUpdates()
SegmentReader
getReader(IOContext context)
Returns aSegmentReader
.(package private) MergePolicy.MergeReader
getReaderForMerge(IOContext context)
Returns a reader for merge, with the latest doc values updates and deletions.SegmentReader
getReadOnlyClone(IOContext context)
Returns a ref to a clone.private void
handleDVUpdates(FieldInfos infos, Directory dir, DocValuesFormat dvFormat, SegmentReader reader, java.util.Map<java.lang.Integer,java.util.Set<java.lang.String>> fieldFiles, long maxDelGen, InfoStream infoStream)
void
incRef()
boolean
isFullyDeleted()
(package private) boolean
isMerging()
(package private) boolean
keepFullyDeletedSegment(MergePolicy mergePolicy)
(package private) int
numDeletesToMerge(MergePolicy policy)
int
refCount()
void
release(SegmentReader sr)
(package private) void
setIsMerging()
private void
swapNewReaderWithLatestLiveDocs()
java.lang.String
toString()
private java.util.Set<java.lang.String>
writeFieldInfosGen(FieldInfos fieldInfos, Directory dir, FieldInfosFormat infosFormat)
boolean
writeFieldUpdates(Directory dir, FieldInfos.FieldNumbers fieldNumbers, long maxDelGen, InfoStream infoStream)
boolean
writeLiveDocs(Directory dir)
-
-
-
Field Detail
-
info
final SegmentCommitInfo info
-
refCount
private final java.util.concurrent.atomic.AtomicInteger refCount
-
reader
private SegmentReader reader
-
pendingDeletes
private final PendingDeletes pendingDeletes
-
indexCreatedVersionMajor
private final int indexCreatedVersionMajor
-
isMerging
private boolean isMerging
-
pendingDVUpdates
private final java.util.Map<java.lang.String,java.util.List<DocValuesFieldUpdates>> pendingDVUpdates
-
mergingDVUpdates
private final java.util.Map<java.lang.String,java.util.List<DocValuesFieldUpdates>> mergingDVUpdates
-
sortMap
Sorter.DocMap sortMap
-
ramBytesUsed
final java.util.concurrent.atomic.AtomicLong ramBytesUsed
-
-
Constructor Detail
-
ReadersAndUpdates
ReadersAndUpdates(int indexCreatedVersionMajor, SegmentCommitInfo info, PendingDeletes pendingDeletes)
-
ReadersAndUpdates
ReadersAndUpdates(int indexCreatedVersionMajor, SegmentReader reader, PendingDeletes pendingDeletes) throws java.io.IOException
Init from a previously opened SegmentReader.NOTE: steals incoming ref from reader.
- Throws:
java.io.IOException
-
-
Method Detail
-
incRef
public void incRef()
-
decRef
public void decRef()
-
refCount
public int refCount()
-
getDelCount
public int getDelCount()
-
assertNoDupGen
private boolean assertNoDupGen(java.util.List<DocValuesFieldUpdates> fieldUpdates, DocValuesFieldUpdates update)
-
addDVUpdate
public void addDVUpdate(DocValuesFieldUpdates update) throws java.io.IOException
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:
java.io.IOException
-
getNumDVUpdates
public long getNumDVUpdates()
-
getReader
public SegmentReader getReader(IOContext context) throws java.io.IOException
Returns aSegmentReader
.- Throws:
java.io.IOException
-
release
public void release(SegmentReader sr) throws java.io.IOException
- Throws:
java.io.IOException
-
delete
public boolean delete(int docID) throws java.io.IOException
- Throws:
java.io.IOException
-
dropReaders
public void dropReaders() throws java.io.IOException
- Throws:
java.io.IOException
-
getReadOnlyClone
public SegmentReader getReadOnlyClone(IOContext context) throws java.io.IOException
Returns a ref to a clone. NOTE: you should decRef() the reader when you're done (ie do not call close()).- Throws:
java.io.IOException
-
numDeletesToMerge
int numDeletesToMerge(MergePolicy policy) throws java.io.IOException
- Throws:
java.io.IOException
-
getLatestReader
private CodecReader getLatestReader() throws java.io.IOException
- Throws:
java.io.IOException
-
getLiveDocs
public Bits getLiveDocs()
Returns a snapshot of the live docs.
-
getHardLiveDocs
public Bits getHardLiveDocs()
Returns the live-docs bits excluding documents that are not live due to soft-deletes
-
dropChanges
public void dropChanges()
-
writeLiveDocs
public boolean writeLiveDocs(Directory dir) throws java.io.IOException
- Throws:
java.io.IOException
-
handleDVUpdates
private void handleDVUpdates(FieldInfos infos, Directory dir, DocValuesFormat dvFormat, SegmentReader reader, java.util.Map<java.lang.Integer,java.util.Set<java.lang.String>> fieldFiles, long maxDelGen, InfoStream infoStream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFieldInfosGen
private java.util.Set<java.lang.String> writeFieldInfosGen(FieldInfos fieldInfos, Directory dir, FieldInfosFormat infosFormat) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFieldUpdates
public boolean writeFieldUpdates(Directory dir, FieldInfos.FieldNumbers fieldNumbers, long maxDelGen, InfoStream infoStream) throws java.io.IOException
- Throws:
java.io.IOException
-
createNewReaderWithLatestLiveDocs
private SegmentReader createNewReaderWithLatestLiveDocs(SegmentReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
swapNewReaderWithLatestLiveDocs
private void swapNewReaderWithLatestLiveDocs() throws java.io.IOException
- Throws:
java.io.IOException
-
setIsMerging
void setIsMerging()
-
isMerging
boolean isMerging()
-
getReaderForMerge
MergePolicy.MergeReader getReaderForMerge(IOContext context) throws java.io.IOException
Returns a reader for merge, with the latest doc values updates and deletions.- Throws:
java.io.IOException
-
dropMergingUpdates
public void dropMergingUpdates()
Drops all merging updates. Called from IndexWriter after this segment finished merging (whether successfully or not).
-
getMergingDVUpdates
public java.util.Map<java.lang.String,java.util.List<DocValuesFieldUpdates>> getMergingDVUpdates()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isFullyDeleted
public boolean isFullyDeleted() throws java.io.IOException
- Throws:
java.io.IOException
-
keepFullyDeletedSegment
boolean keepFullyDeletedSegment(MergePolicy mergePolicy) throws java.io.IOException
- Throws:
java.io.IOException
-
-