///|
/// One immutable Segment together with the tombstones captured by a manifest
/// generation.
pub struct SnapshotSegment {
segment : Segment
deleted_docs : ReadOnlyArray[DocId]
}
///|
pub fn SnapshotSegment::new(
segment : Segment,
deleted_docs : ReadOnlyArray[DocId],
) -> SnapshotSegment {
{ segment, deleted_docs }
}
///|
pub fn SnapshotSegment::is_deleted(
self : SnapshotSegment,
doc_id : DocId,
) -> Bool {
self.deleted_docs.search_by(deleted => deleted == doc_id) is Some(_)
}
///|
pub fn SnapshotSegment::live_doc_count(self : SnapshotSegment) -> Int {
self.segment.doc_count() - self.deleted_docs.length()
}
///|
pub fn live_snapshot(segment : Segment) -> SnapshotSegment {
SnapshotSegment::new(segment, ReadOnlyArray::from_array([]))
}