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

Function ceiling_resolve_cell

nodedb-array/src/query/ceiling.rs:56–85  ·  view source on GitHub ↗

Resolve the Ceiling for a single cell coordinate. `tile_versions_newest_first` — `(TileId, raw_cell_bytes)` pairs ordered newest-first by `system_from_ms`. The caller is responsible for the ordering; this function additionally defends against misuse with a guard that skips entries where `tile_id.system_from_ms > params.system_as_of`. For each version the function applies: 1. System-time guard:

(
    tile_versions_newest_first: I,
    _coord: &[CoordValue],
    params: &CeilingParams,
)

Source from the content-addressed store, hash-verified

54///
55/// If the iterator is exhausted without a match, returns `NotFound`.
56pub fn ceiling_resolve_cell<'a, I>(
57 tile_versions_newest_first: I,
58 _coord: &[CoordValue],
59 params: &CeilingParams,
60) -> ArrayResult<CeilingResult>
61where
62 I: IntoIterator<Item = (TileId, &'a [u8])>,
63{
64 for (tile_id, bytes) in tile_versions_newest_first {
65 if tile_id.system_from_ms > params.system_as_of {
66 continue;
67 }
68 if is_cell_tombstone(bytes) {
69 return Ok(CeilingResult::Tombstoned);
70 }
71 if is_cell_gdpr_erasure(bytes) {
72 return Ok(CeilingResult::Erased);
73 }
74 let payload = CellPayload::decode(bytes).map_err(|e| ArrayError::SegmentCorruption {
75 detail: format!("ceiling_resolve_cell: {e}"),
76 })?;
77 match params.valid_at_ms {
78 Some(vt) if !(payload.valid_from_ms <= vt && vt < payload.valid_until_ms) => {
79 continue;
80 }
81 _ => return Ok(CeilingResult::Live(payload)),
82 }
83 }
84 Ok(CeilingResult::NotFound)
85}
86
87#[cfg(test)]
88mod tests {

Calls 3

is_cell_tombstoneFunction · 0.85
is_cell_gdpr_erasureFunction · 0.85
decodeFunction · 0.50