use std::sync::Arc;
use arrow_array::RecordBatch;
use async_trait::async_trait;
use super::Query;
use crate::{
arrow::linalg::matrix::MatrixView,
index::{pb::Transform, Index},
io::{object_reader::ObjectReader, object_writer::ObjectWriter},
Result,
};
#[async_trait]
#[allow(clippy::redundant_pub_crate)]
pub(crate) trait VectorIndex: Send + Sync + std::fmt::Debug + Index {
async fn search(&self, query: &Query) -> Result<RecordBatch>;
fn is_loadable(&self) -> bool;
async fn load(
&self,
reader: &dyn ObjectReader,
offset: usize,
length: usize,
) -> Result<Arc<dyn VectorIndex>>;
}
#[async_trait]
pub trait Transformer: std::fmt::Debug + Sync + Send {
async fn train(&mut self, data: &MatrixView) -> Result<()>;
async fn transform(&self, data: &MatrixView) -> Result<MatrixView>;
async fn save(&self, writer: &mut ObjectWriter) -> Result<Transform>;
}