use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use mnemo_core::error::Result;
use mnemo_core::index::VectorIndex;
use uuid::Uuid;
pub struct PgVectorIndex {
count: AtomicUsize,
}
impl PgVectorIndex {
pub fn new() -> Self {
Self {
count: AtomicUsize::new(0),
}
}
}
impl Default for PgVectorIndex {
fn default() -> Self {
Self::new()
}
}
impl VectorIndex for PgVectorIndex {
fn add(&self, _id: Uuid, _vector: &[f32]) -> Result<()> {
self.count.fetch_add(1, Ordering::Relaxed);
Ok(())
}
fn remove(&self, _id: Uuid) -> Result<()> {
let _ = self
.count
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |n| {
if n > 0 { Some(n - 1) } else { Some(0) }
});
Ok(())
}
fn search(&self, _query: &[f32], _limit: usize) -> Result<Vec<(Uuid, f32)>> {
Ok(Vec::new())
}
fn filtered_search(
&self,
_query: &[f32],
_limit: usize,
_filter: &dyn Fn(Uuid) -> bool,
) -> Result<Vec<(Uuid, f32)>> {
Ok(Vec::new())
}
fn save(&self, _path: &Path) -> Result<()> {
Ok(())
}
fn load(&self, _path: &Path) -> Result<()> {
Ok(())
}
fn len(&self) -> usize {
self.count.load(Ordering::Relaxed)
}
}