use std::marker::PhantomData;
use std::path::{Path, PathBuf};
use crate::blobstore::Blob;
use crate::common::bitvec::BitSlice;
use crate::common::universal_io::{CachedReadFs, UniversalRead, UniversalReadFs};
use super::super::Encodable;
use super::super::storage::read_only::ReadOnlyNumericIndexInner;
use super::ReadOnlyNumericIndex;
use crate::segment::common::operation_error::OperationResult;
use crate::segment::index::field_index::numeric_point::Numericable;
use crate::segment::index::field_index::on_disk_point_to_values::StoredValue;
use crate::segment::index::payload_config::IndexMutability;
impl<T: Encodable + Numericable + StoredValue + Send + Sync + Default, P, S: UniversalRead>
ReadOnlyNumericIndex<T, P, S>
where
Vec<T>: Blob,
{
pub fn preopen_appendable(
fs: &impl CachedReadFs<File = S>,
dir: PathBuf,
) -> OperationResult<bool> {
ReadOnlyNumericIndexInner::preopen_appendable(fs, dir)
}
pub fn preopen_immutable(
fs: &impl CachedReadFs<File = S>,
path: &Path,
is_on_disk: bool,
) -> OperationResult<bool> {
ReadOnlyNumericIndexInner::preopen_immutable(fs, path, is_on_disk)
}
pub fn open_appendable(
fs: &impl UniversalReadFs<File = S>,
dir: PathBuf,
) -> OperationResult<Option<Self>> {
Ok(
ReadOnlyNumericIndexInner::open_appendable(fs, dir)?.map(|inner| Self {
inner,
_phantom: PhantomData,
}),
)
}
pub fn open_immutable(
fs: &impl UniversalReadFs<File = S>,
path: &Path,
is_on_disk: bool,
deleted_points: &BitSlice,
) -> OperationResult<Option<Self>> {
Ok(
ReadOnlyNumericIndexInner::open_immutable(fs, path, is_on_disk, deleted_points)?.map(
|inner| Self {
inner,
_phantom: PhantomData,
},
),
)
}
pub fn get_mutability_type(&self) -> IndexMutability {
self.inner.get_mutability_type()
}
}