Open or attach to an array. Idempotent: if the array is already open with the same `schema_hash`, this is a no-op so SQL read handlers can call `open_array` lazily on every request without losing state. If the array is open with a *different* schema_hash, returns [`ArrayEngineError::SchemaMismatch`].
(
&mut self,
id: ArrayId,
schema: Arc<ArraySchema>,
schema_hash: u64,
)
| 93 | /// If the array is open with a *different* schema_hash, returns |
| 94 | /// [`ArrayEngineError::SchemaMismatch`]. |
| 95 | pub fn open_array( |
| 96 | &mut self, |
| 97 | id: ArrayId, |
| 98 | schema: Arc<ArraySchema>, |
| 99 | schema_hash: u64, |
| 100 | ) -> ArrayEngineResult<()> { |
| 101 | if let Some(existing) = self.arrays.get(&id) { |
| 102 | if existing.schema_hash() == schema_hash { |
| 103 | return Ok(()); |
| 104 | } |
| 105 | return Err(ArrayEngineError::SchemaMismatch { |
| 106 | name: id.name.clone(), |
| 107 | }); |
| 108 | } |
| 109 | let dir = array_dir(&self.cfg.root, &id); |
| 110 | let mut store = ArrayStore::open(dir, schema, schema_hash)?; |
| 111 | if let Some(kek) = &self.cfg.kek { |
| 112 | store.set_kek(kek.clone()); |
| 113 | } |
| 114 | self.arrays.insert(id, store); |
| 115 | Ok(()) |
| 116 | } |
| 117 | |
| 118 | pub fn array_ids(&self) -> impl Iterator<Item = &ArrayId> { |
| 119 | self.arrays.keys() |