MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / execute_sparse_insert

Method execute_sparse_insert

nodedb/src/data/executor/handlers/vector_sparse.rs:45–80  ·  view source on GitHub ↗

Insert a sparse vector for a document.

(
        &mut self,
        task: &ExecutionTask,
        tid: u64,
        collection: &str,
        field_name: &str,
        doc_id: &str,
        entries: &[(u32, f32)],
    )

Source from the content-addressed store, hash-verified

43
44 /// Insert a sparse vector for a document.
45 pub(in crate::data::executor) fn execute_sparse_insert(
46 &mut self,
47 task: &ExecutionTask,
48 tid: u64,
49 collection: &str,
50 field_name: &str,
51 doc_id: &str,
52 entries: &[(u32, f32)],
53 ) -> Response {
54 debug!(
55 core = self.core_id,
56 %collection,
57 %field_name,
58 %doc_id,
59 nnz = entries.len(),
60 "sparse insert"
61 );
62
63 let sv = match nodedb_types::SparseVector::from_entries(entries.to_vec()) {
64 Ok(sv) => sv,
65 Err(e) => {
66 return self.response_error(
67 task,
68 ErrorCode::RejectedConstraint {
69 detail: String::new(),
70 constraint: e.to_string(),
71 },
72 );
73 }
74 };
75
76 let index = self.get_or_create_sparse_index(tid, collection, field_name);
77 index.insert(doc_id, &sv);
78 self.checkpoint_coordinator.mark_dirty("vector", 1);
79 self.response_ok(task)
80 }
81
82 /// Search the sparse inverted index via dot-product scoring.
83 pub(in crate::data::executor) fn execute_sparse_search(

Callers 1

dispatch_vectorMethod · 0.80

Calls 7

response_errorMethod · 0.80
to_stringMethod · 0.80
mark_dirtyMethod · 0.80
response_okMethod · 0.80
to_vecMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected