pub struct SemanticEngine { /* private fields */ }Expand description
语义搜索引擎
内部委托 VecDb(sqlite-vec vec0 虚表)完成向量持久化与 KNN, 自身只做 embedding 生成与 CodeNode 序列化。
Implementations§
Source§impl SemanticEngine
impl SemanticEngine
Sourcepub fn open(
path: impl AsRef<Path>,
embedder: Arc<EmbeddingEngine>,
rt: Arc<Runtime>,
) -> Result<Self>
pub fn open( path: impl AsRef<Path>, embedder: Arc<EmbeddingEngine>, rt: Arc<Runtime>, ) -> Result<Self>
打开或创建语义搜索数据库
vec0 虚表延迟到首次插入时创建(维度首次探测)。
pub fn index(&mut self, node: &CodeNode, source_code: &str) -> Result<()>
pub fn index_batch(&mut self, items: &[(CodeNode, String)]) -> Result<()>
pub fn search(&self, query: &str, limit: usize) -> Result<Vec<(CodeNode, f32)>>
pub fn remove_by_file(&mut self, file_path: &str) -> Result<usize>
pub fn clear(&mut self) -> Result<()>
pub fn entry_count(&self) -> usize
Sourcepub fn table_dimension(&self) -> Result<Option<usize>>
pub fn table_dimension(&self) -> Result<Option<usize>>
当前 vec0 表的向量维度(表不存在返回 None)——U04/D2 维度探测用: 增量路径在回填前比对 embedding 产出维度,变化则回退全量重建。
返回 Result:数据库读取错误(损坏/权限)向上传播,由调用方决定 处理(lib.rs 维度探测失败 warn + 视为维度未知,不静默吞掉)。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SemanticEngine
impl !RefUnwindSafe for SemanticEngine
impl !Sync for SemanticEngine
impl !UnwindSafe for SemanticEngine
impl Send for SemanticEngine
impl Unpin for SemanticEngine
impl UnsafeUnpin for SemanticEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more