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

Method handle_array_open

nodedb/src/data/executor/dispatch/array/open.rs:16–125  ·  view source on GitHub ↗
(
        &mut self,
        task: &ExecutionTask,
        array_id: &ArrayId,
        schema_msgpack: &[u8],
        schema_hash: u64,
        prefix_bits: u8,
    )

Source from the content-addressed store, hash-verified

14
15impl CoreLoop {
16 pub(in crate::data::executor) fn handle_array_open(
17 &mut self,
18 task: &ExecutionTask,
19 array_id: &ArrayId,
20 schema_msgpack: &[u8],
21 schema_hash: u64,
22 prefix_bits: u8,
23 ) -> Response {
24 // Verify-or-register against the in-memory catalog. Persistence
25 // into `_system.arrays` is owned by the Control-Plane DDL path
26 // (`SystemCatalog::put_array`), not the Data Plane — redb is
27 // Control-Plane-only.
28 {
29 let cat = match self.array_catalog.read() {
30 Ok(g) => g,
31 Err(_) => {
32 return self.response_error(
33 task,
34 ErrorCode::Internal {
35 detail: "array catalog lock poisoned".to_string(),
36 },
37 );
38 }
39 };
40 if let Some(existing) = cat.lookup_by_name(&array_id.name) {
41 if existing.schema_hash != schema_hash {
42 return self.response_error(
43 task,
44 ErrorCode::Unsupported {
45 detail: format!(
46 "array '{}' already registered with different schema hash ({:#x} != {:#x})",
47 array_id.name, existing.schema_hash, schema_hash
48 ),
49 },
50 );
51 }
52 } else {
53 drop(cat);
54 let entry = ArrayCatalogEntry {
55 array_id: array_id.clone(),
56 name: array_id.name.clone(),
57 schema_msgpack: schema_msgpack.to_vec(),
58 schema_hash,
59 created_at_ms: now_epoch_ms(),
60 prefix_bits,
61 audit_retain_ms: None,
62 minimum_audit_retain_ms: None,
63 };
64 let mut cat = match self.array_catalog.write() {
65 Ok(g) => g,
66 Err(_) => {
67 return self.response_error(
68 task,
69 ErrorCode::Internal {
70 detail: "array catalog lock poisoned".to_string(),
71 },
72 );
73 }

Callers 1

dispatch_arrayMethod · 0.80

Calls 12

encode_countFunction · 0.85
response_errorMethod · 0.80
to_stringMethod · 0.80
lookup_by_nameMethod · 0.80
open_arrayMethod · 0.80
response_with_payloadMethod · 0.80
now_epoch_msFunction · 0.70
readMethod · 0.45
cloneMethod · 0.45
to_vecMethod · 0.45
writeMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected