Skip to content

Commit

Permalink
expose new API in entity_iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Dec 20, 2024
1 parent 8347807 commit 81cbd4f
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ where
// ---

use re_chunk::{Chunk, ChunkComponentIterItem, ComponentName, RowId};
use re_chunk_store::external::{re_chunk, re_chunk::external::arrow2};
use re_chunk_store::external::re_chunk;

/// Iterate `chunks` as indexed deserialized batches.
///
Expand Down Expand Up @@ -239,3 +239,19 @@ pub fn iter_buffer<'a, T: arrow::datatypes::ArrowNativeType + arrow2::types::Nat
)
})
}

/// Iterate `chunks` as indexed primitives.
///
/// See [`Chunk::iter_slices`] for more information.
pub fn iter_slices<'a, T: 'a + re_chunk::ChunkComponentSlicer>(
chunks: &'a std::borrow::Cow<'a, [Chunk]>,
timeline: Timeline,
component_name: ComponentName,
) -> impl Iterator<Item = ((TimeInt, RowId), T::Item<'a>)> + 'a {
chunks.iter().flat_map(move |chunk| {
itertools::izip!(
chunk.iter_component_indices(&timeline, &component_name),
chunk.iter_slices::<T>(component_name)
)
})
}

0 comments on commit 81cbd4f

Please sign in to comment.