IndexReader

One index, read at one snapshot, with every sidecar it may consult pinned for its lifetime.

This returns candidates, never answers. An index over a segment says "this segment's newest version of key K carried that value". Whether the version a caller can see still carries it is a different question, because a newer version may live in a shallower segment or in a memtable neither of which this index covers. So every hit has to be rechecked against the visible document, and uncoveredSegments has to be scanned. IndexQuery is the reference implementation of both.

An index that could return the answer would be an index that could be wrong, and the design rule it would be wrong against is the one that matters most here: an index may change query speed, never query answers.

Sidecars are pinned up front, not per term. A compaction may retire a segment at any moment, and acquiring lazily would let one disappear between the second and third term of an IN (a, b, c). The pins are released by close, which must be called — on Windows a mapped file cannot be deleted at all, so a reader left open blocks reclamation of everything it touched.

Properties

Link copied to clipboard

Covered, stale and total, at this snapshot. See IndexCoverage.

Link copied to clipboard

Whether the store held documents outside a segment when this reader pinned.

Link copied to clipboard

The index this reads.

Link copied to clipboard

Whether the candidates alone are a superset of the answer.

Link copied to clipboard

The path indexed.

Link copied to clipboard

The snapshot this reader answers at.

Link copied to clipboard

Live segments this reader cannot answer for, which the caller must scan.

Link copied to clipboard

Segments this reader can answer for, ascending. The domain of every accessor below.

Functions

Link copied to clipboard

Candidate keys carrying no value at path. The NOT EXISTS case.

Link copied to clipboard
fun absentOrdinals(segmentNumber: Long): ReadableBitmap

Ordinals carrying no value at path, taken against documentOrdinals. NOT EXISTS.

Link copied to clipboard

Whether this index can answer for term at all. See IndexOptions.maxTermBytes.

Link copied to clipboard
fun candidateOrdinals(segmentNumber: Long, term: IndexTerm): ReadableBitmap

Candidate ordinals in segmentNumber whose indexed version carried term.

Candidate ordinals carrying any of terms. The IN case, unioned in one pass.

Link copied to clipboard

Candidate keys whose indexed version carried term.

Candidate keys whose indexed version carried any of terms. The IN case.

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun documentOrdinals(segmentNumber: Long): ReadableBitmap

The segment's live-document universe: ordinals whose newest version there is a document.

Link copied to clipboard

Candidate keys carrying any value at path. The EXISTS case.

Link copied to clipboard
fun isUniqueKey(key: Key, exceptSegment: Long): Boolean

Whether key appears in exactly one usable segment. See SegmentSelection.isUniqueKey.

Link copied to clipboard
fun keyAt(segmentNumber: Long, ordinal: Int): Key

The key at ordinal of segmentNumber. A key-block read, not a document read.

Link copied to clipboard
fun ordinalRange(segmentNumber: Long, from: Key?, to: Key?): IntRange

The ordinals of segmentNumber whose keys lie in [from, to], both bounds inclusive.

Link copied to clipboard
fun presentOrdinals(segmentNumber: Long): ReadableBitmap

Ordinals carrying any value at path. The EXISTS case.

Link copied to clipboard
open override fun toString(): String