use std::sync::Arc;
use async_trait::async_trait;
use uuid::Uuid;
use khive_types::SubstrateKind;
use crate::types::{
BatchWriteSummary, SparseRecord, SparseSearchHit, SparseSearchRequest, SparseVector,
StorageResult,
};
pub trait SparseStoreFactory: Send + Sync + 'static {
fn open(&self, model_key: &str, namespace: &str) -> StorageResult<Arc<dyn SparseStore>>;
}
#[async_trait]
pub trait SparseStore: Send + Sync + 'static {
async fn insert_sparse(
&self,
subject_id: Uuid,
kind: SubstrateKind,
namespace: &str,
field: &str,
vector: SparseVector,
) -> StorageResult<()>;
async fn insert_batch(&self, records: Vec<SparseRecord>) -> StorageResult<BatchWriteSummary>;
async fn delete(&self, subject_id: Uuid) -> StorageResult<bool>;
async fn search_sparse(
&self,
request: SparseSearchRequest,
) -> StorageResult<Vec<SparseSearchHit>>;
async fn count(&self) -> StorageResult<u64>;
}