fillLiveDocsWords cast every non-null liveDocs to LiveDocs. That holds
only for readers opened from a commit, where the codec returns
DenseLiveDocs or SparseLiveDocs. An NRT reader whose segment has deletes
since the last flush gets PendingDeletes' read-only FixedBits view, which
is a Bits but not a LiveDocs, so the first match-all query after a delete
failed with ClassCastException until the node was restarted.
Match-all path: route every non-LiveDocs shape through Bits#applyMask on
an all-alive slice; FixedBits and FixedBitSet implement it word-level.
The codec LiveDocs branches are unchanged.
Predicate path: liveIntersection previously led the conjunction only for
DenseLiveDocs, so an NRT segment fell back to the raw scorer with a
per-doc liveDocs.get regardless of how many docs were deleted. It now
also leads for a non-LiveDocs Bits when the leaf's deletion rate is
above the codec's own sparse/dense threshold (delCount / maxDoc > 0.01),
materialising the live set once per collector with FixedBitSet.copyOf,
a word clone for FixedBits. Below the threshold the raw-scorer path is
kept, matching what SparseLiveDocs gets.
Tests: buildIndex gains an nrt flag that leaves deletes uncommitted and
opens the reader on the writer; NRT cases cover dense (25%), sparse
(0.3%) and exactly-1% deletes for both match-all and predicate. A
document-level-security style reader wrapper covers live docs replaced
by a FixedBitSet and by a SparseFixedBitSet on both paths.
Signed-off-by: Somesh Gupta <someshgupta987@gmail.com>
fillLiveDocsWords cast every non-null liveDocs to LiveDocs. That holds only for readers opened from a commit, where the codec returns DenseLiveDocs or SparseLiveDocs. An NRT reader whose segment has deletes since the last flush gets PendingDeletes' read-only FixedBits view, which is a Bits but not a LiveDocs, so the first match-all query after a delete failed with ClassCastException until the node was restarted.
Match-all path: route every non-LiveDocs shape through Bits#applyMask on an all-alive slice; FixedBits and FixedBitSet implement it word-level. The codec LiveDocs branches are unchanged.
Predicate path: liveIntersection previously led the conjunction only for DenseLiveDocs, so an NRT segment fell back to the raw scorer with a per-doc liveDocs.get regardless of how many docs were deleted. It now also leads for a non-LiveDocs Bits when the leaf's deletion rate is above the codec's own sparse/dense threshold (delCount / maxDoc > 0.01), materialising the live set once per collector with FixedBitSet.copyOf, a word clone for FixedBits. Below the threshold the raw-scorer path is kept, matching what SparseLiveDocs gets.
Tests: buildIndex gains an nrt flag that leaves deletes uncommitted and opens the reader on the writer; NRT cases cover dense (25%), sparse (0.3%) and exactly-1% deletes for both match-all and predicate. A document-level-security style reader wrapper covers live docs replaced by a FixedBitSet and by a SparseFixedBitSet on both paths.
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.