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

Method execute_kv_batch_get

nodedb/src/data/executor/handlers/kv/batch.rs:14–44  ·  view source on GitHub ↗
(
        &self,
        task: &ExecutionTask,
        tid: u64,
        collection: &str,
        keys: &[Vec<u8>],
    )

Source from the content-addressed store, hash-verified

12
13impl CoreLoop {
14 pub(in crate::data::executor) fn execute_kv_batch_get(
15 &self,
16 task: &ExecutionTask,
17 tid: u64,
18 collection: &str,
19 keys: &[Vec<u8>],
20 ) -> Response {
21 debug!(core = self.core_id, %collection, count = keys.len(), "kv batch get");
22 let now_ms = current_ms();
23 let results = self.kv_engine.batch_get(tid, collection, keys, now_ms);
24
25 let json_results: Vec<serde_json::Value> = results
26 .into_iter()
27 .map(|opt| match opt {
28 Some(v) => serde_json::Value::String(base64::Engine::encode(
29 &base64::engine::general_purpose::STANDARD,
30 &v,
31 )),
32 None => serde_json::Value::Null,
33 })
34 .collect();
35 match response_codec::encode_json_vec(&json_results) {
36 Ok(payload) => self.response_with_payload(task, payload),
37 Err(e) => self.response_error(
38 task,
39 ErrorCode::Internal {
40 detail: e.to_string(),
41 },
42 ),
43 }
44 }
45
46 pub(in crate::data::executor) fn execute_kv_batch_put(
47 &mut self,

Callers 1

execute_kvMethod · 0.80

Calls 8

encode_json_vecFunction · 0.85
batch_getMethod · 0.80
collectMethod · 0.80
response_with_payloadMethod · 0.80
response_errorMethod · 0.80
to_stringMethod · 0.80
current_msFunction · 0.50
encodeFunction · 0.50

Tested by

no test coverage detected