use common::ReadOnlyBitSet;
use crate::DocAddress;
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum MappingType {
Stacked,
StackedWithDeletes,
}
#[derive(Clone)]
pub(crate) struct SegmentDocIdMapping {
pub(crate) new_doc_id_to_old_doc_addr: Vec<DocAddress>,
pub(crate) alive_bitsets: Vec<Option<ReadOnlyBitSet>>,
mapping_type: MappingType,
}
impl SegmentDocIdMapping {
pub(crate) fn new(
new_doc_id_to_old_doc_addr: Vec<DocAddress>,
mapping_type: MappingType,
alive_bitsets: Vec<Option<ReadOnlyBitSet>>,
) -> Self {
Self {
new_doc_id_to_old_doc_addr,
mapping_type,
alive_bitsets,
}
}
pub fn mapping_type(&self) -> MappingType {
self.mapping_type
}
pub(crate) fn iter_old_doc_addrs(&self) -> impl Iterator<Item = DocAddress> + '_ {
self.new_doc_id_to_old_doc_addr.iter().copied()
}
}