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

Function union_tiles

nodedb/src/data/executor/dispatch/array/elementwise.rs:209–266  ·  view source on GitHub ↗
(schema: &ArraySchema, tiles: Vec<TilePayload>)

Source from the content-addressed store, hash-verified

207}
208
209fn union_tiles(schema: &ArraySchema, tiles: Vec<TilePayload>) -> Result<SparseTile, ErrorCode> {
210 let mut b = SparseTileBuilder::new(schema);
211 for t in tiles {
212 let sparse = match t {
213 TilePayload::Sparse(s) => s,
214 TilePayload::Dense(_) => {
215 return Err(ErrorCode::Unsupported {
216 detail: "dense tile payload in elementwise".to_string(),
217 });
218 }
219 };
220 let n = sparse.row_count();
221 let mut live_idx = 0usize;
222 for row in 0..n {
223 let kind = sparse.row_kind(row).map_err(|e| ErrorCode::Internal {
224 detail: format!("array elementwise union row_kind: {e}"),
225 })?;
226 if kind != RowKind::Live {
227 continue;
228 }
229 let attr_row = live_idx;
230 live_idx += 1;
231 let coord: Vec<_> = sparse
232 .dim_dicts
233 .iter()
234 .map(|d| d.values[d.indices[row] as usize].clone())
235 .collect();
236 let attrs: Vec<_> = sparse
237 .attr_cols
238 .iter()
239 .map(|c| c[attr_row].clone())
240 .collect();
241 let surrogate = sparse
242 .surrogates
243 .get(row)
244 .copied()
245 .unwrap_or(nodedb_types::Surrogate::ZERO);
246 let valid_from_ms = sparse.valid_from_ms.get(row).copied().unwrap_or(0);
247 let valid_until_ms = sparse
248 .valid_until_ms
249 .get(row)
250 .copied()
251 .unwrap_or(nodedb_types::OPEN_UPPER);
252 b.push_row(SparseRow {
253 coord: &coord,
254 attrs: &attrs,
255 surrogate,
256 valid_from_ms,
257 valid_until_ms,
258 kind: RowKind::Live,
259 })
260 .map_err(|e| ErrorCode::Internal {
261 detail: format!("array elementwise union: {e}"),
262 })?;
263 }
264 }
265 Ok(b.build())
266}

Callers 1

Calls 9

to_stringMethod · 0.80
row_kindMethod · 0.80
collectMethod · 0.80
push_rowMethod · 0.80
row_countMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
getMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected