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

Method iter_tile_versions

nodedb-array/src/segment/reader.rs:221–247  ·  view source on GitHub ↗

Returns an iterator over all tile versions for `hilbert_prefix` whose `system_from_ms <= system_as_of`, ordered **newest-first** by `system_from_ms`. Callers supply this to [`nodedb_array::query::ceiling`] to resolve the bitemporal ceiling for every coordinate in the prefix.

(
        &self,
        hilbert_prefix: u64,
        system_as_of: i64,
    )

Source from the content-addressed store, hash-verified

219 /// Callers supply this to [`nodedb_array::query::ceiling`] to resolve the
220 /// bitemporal ceiling for every coordinate in the prefix.
221 pub fn iter_tile_versions(
222 &self,
223 hilbert_prefix: u64,
224 system_as_of: i64,
225 ) -> ArrayResult<impl Iterator<Item = ArrayResult<(crate::types::TileId, TilePayload)>> + '_>
226 {
227 let tiles = &self.footer.tiles;
228
229 // Find the contiguous slice of entries whose hilbert_prefix matches.
230 let first = tiles.partition_point(|e| e.tile_id.hilbert_prefix < hilbert_prefix);
231 let past_prefix = tiles.partition_point(|e| e.tile_id.hilbert_prefix <= hilbert_prefix);
232
233 // Within [first..past_prefix], entries are ascending by system_from_ms.
234 // Restrict to those at or before the cutoff.
235 let cutoff_pos =
236 tiles[first..past_prefix].partition_point(|e| e.tile_id.system_from_ms <= system_as_of);
237 // Global index range: [first .. first+cutoff_pos).
238 let qualifying_start = first;
239 let qualifying_end = first + cutoff_pos;
240
241 // Iterate in reverse (newest-first).
242 let indices: Vec<usize> = (qualifying_start..qualifying_end).rev().collect();
243 Ok(indices.into_iter().map(move |idx| {
244 let tile_id = tiles[idx].tile_id;
245 self.read_tile(idx).map(|payload| (tile_id, payload))
246 }))
247 }
248
249 /// Decode tile #`idx`. CRC is checked by the framing layer.
250 pub fn read_tile(&self, idx: usize) -> ArrayResult<TilePayload> {

Calls 2

collectMethod · 0.80
read_tileMethod · 0.80