Idempotently open the array on this core, looking the schema up from the shared `ArrayCatalogHandle`. Read handlers (Slice / Project / Aggregate / Elementwise) call this at entry so that a SQL read against a per-core engine that has not yet seen an explicit `OpenArray` dispatch (e.g. the very first read after a restart) auto-opens via the catalog instead of erroring.
(
&mut self,
task: &ExecutionTask,
array_id: &ArrayId,
)
| 130 | /// explicit `OpenArray` dispatch (e.g. the very first read after a |
| 131 | /// restart) auto-opens via the catalog instead of erroring. |
| 132 | pub(in crate::data::executor) fn ensure_array_open( |
| 133 | &mut self, |
| 134 | task: &ExecutionTask, |
| 135 | array_id: &ArrayId, |
| 136 | ) -> Result<(), Response> { |
| 137 | let (schema_msgpack, schema_hash) = { |
| 138 | let cat = self.array_catalog.read().map_err(|_| { |
| 139 | self.response_error( |
| 140 | task, |
| 141 | ErrorCode::Internal { |
| 142 | detail: "array catalog lock poisoned".to_string(), |
| 143 | }, |
| 144 | ) |
| 145 | })?; |
| 146 | let entry = cat.lookup_by_name(&array_id.name).ok_or_else(|| { |
| 147 | self.response_error( |
| 148 | task, |
| 149 | ErrorCode::Internal { |
| 150 | detail: format!("array '{}' not found in catalog", array_id.name), |
| 151 | }, |
| 152 | ) |
| 153 | })?; |
| 154 | (entry.schema_msgpack.clone(), entry.schema_hash) |
| 155 | }; |
| 156 | let schema: ArraySchema = zerompk::from_msgpack(&schema_msgpack).map_err(|e| { |
| 157 | self.response_error( |
| 158 | task, |
| 159 | ErrorCode::Internal { |
| 160 | detail: format!("array schema decode: {e}"), |
| 161 | }, |
| 162 | ) |
| 163 | })?; |
| 164 | self.array_engine |
| 165 | .open_array(array_id.clone(), Arc::new(schema), schema_hash) |
| 166 | .map_err(|e| { |
| 167 | self.response_error( |
| 168 | task, |
| 169 | ErrorCode::Internal { |
| 170 | detail: format!("array engine open: {e}"), |
| 171 | }, |
| 172 | ) |
| 173 | }) |
| 174 | } |
| 175 | } |
no test coverage detected