use std::path::PathBuf;
use crate::collection::types::Collection;
use crate::distance::DistanceMetric;
use crate::error::Result;
use crate::quantization::StorageMode;
use super::VectorCollection;
impl VectorCollection {
pub fn create(
path: PathBuf,
_name: &str,
dimension: usize,
metric: DistanceMetric,
storage_mode: StorageMode,
) -> Result<Self> {
Ok(Self {
inner: Collection::create_with_options(path, dimension, metric, storage_mode)?,
})
}
pub fn create_with_hnsw(
path: PathBuf,
_name: &str,
dimension: usize,
metric: DistanceMetric,
storage_mode: StorageMode,
m: Option<usize>,
ef_construction: Option<usize>,
) -> Result<Self> {
let mut params = crate::index::hnsw::HnswParams::auto(dimension);
if let Some(m) = m {
params.max_connections = m;
}
if let Some(ef) = ef_construction {
params.ef_construction = ef;
}
params.storage_mode = storage_mode;
Ok(Self {
inner: Collection::create_with_hnsw_params(
path,
dimension,
metric,
storage_mode,
params,
)?,
})
}
pub fn open(path: PathBuf) -> Result<Self> {
Ok(Self {
inner: Collection::open(path)?,
})
}
pub fn flush(&self) -> Result<()> {
self.inner.flush()
}
pub fn flush_full(&self) -> Result<()> {
self.inner.flush_full()
}
}