Class DenseLiveDocs
LiveDocs implementation optimized for dense deletions.
This implementation stores LIVE documents using FixedBitSet, which is the traditional
approach used by Lucene. This provides:
- O(1) random access via
get(int) - Memory usage proportional to maxDoc
- Efficient iteration over live documents
This is most efficient when deletions are dense. For sparser deletions, SparseLiveDocs
should be used instead.
Standard semantics: Set bits represent LIVE documents, which is the traditional Lucene approach:
get(int)returnstrueif doc is LIVE (bit IS set in liveDocs)deletedDocsIterator()iterates documents where bit is NOT set in liveDocs
Immutability: This class is immutable once constructed. Instances are typically created
using the DenseLiveDocs.Builder via builder(FixedBitSet, int).
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for creating DenseLiveDocs instances with optional pre-computed deleted count.Nested classes/interfaces inherited from interface org.apache.lucene.util.Bits
Bits.MatchAllBits, Bits.MatchNoBits -
Field Summary
Fields inherited from interface org.apache.lucene.util.Bits
EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionstatic DenseLiveDocs.Builderbuilder(FixedBitSet liveDocs, int maxDoc) Creates a builder for constructing DenseLiveDocs instances.intReturns the number of deleted documents.Returns an iterator over deleted document IDs.booleanget(int index) Returns the value of the bit with the specifiedindex.intlength()Returns the number of bits in this setReturns an iterator over live document IDs.longReturns the memory usage in bytes.toString()
-
Method Details
-
builder
Creates a builder for constructing DenseLiveDocs instances.- Parameters:
liveDocs- bit set where set bits represent LIVE documentsmaxDoc- the maximum document ID (exclusive)- Returns:
- a new builder instance
-
get
public boolean get(int index) Description copied from interface:BitsReturns the value of the bit with the specifiedindex.- Specified by:
getin interfaceBits- Parameters:
index- index, should be non-negative and <Bits.length(). The result of passing negative or out of bounds values is undefined by this interface, just don't do it!- Returns:
trueif the bit is set,falseotherwise.
-
length
public int length()Description copied from interface:BitsReturns the number of bits in this set -
liveDocsIterator
Description copied from interface:LiveDocsReturns an iterator over live document IDs.The returned iterator provides sequential access to all live documents in ascending order. The iteration complexity depends on the implementation:
- For sparse deletions: O(maxDoc) - may need to scan all documents
- For dense deletions: O(liveDocs) - only visits live documents
Callers can use
DocIdSetIterator.cost()to determine the expected number of live documents.- Specified by:
liveDocsIteratorin interfaceLiveDocs- Returns:
- an iterator over live document IDs
-
deletedDocsIterator
Description copied from interface:LiveDocsReturns an iterator over deleted document IDs.The returned iterator provides sequential access to all deleted documents in ascending order. The iteration complexity depends on the implementation:
- For sparse deletions: O(deletedDocs) - only visits deleted documents
- For dense deletions: O(maxDoc) - may need to scan all documents
Callers can use
DocIdSetIterator.cost()to determine if sparse iteration would be beneficial for their use case.- Specified by:
deletedDocsIteratorin interfaceLiveDocs- Returns:
- an iterator over deleted document IDs, or an empty iterator if no documents are deleted
-
deletedCount
public int deletedCount()Description copied from interface:LiveDocsReturns the number of deleted documents.This can be used to determine deletion density and choose appropriate algorithms.
- Specified by:
deletedCountin interfaceLiveDocs- Returns:
- the number of deleted documents in this segment
-
ramBytesUsed
public long ramBytesUsed()Returns the memory usage in bytes.- Returns:
- estimated memory usage in bytes
-
toString
-