From 732771127bf6ef679afe9ba37bf53bf6ef9d6a78 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 20 Dec 2024 11:50:29 +0100 Subject: [PATCH] remove all the deprecated stuff --- crates/store/re_chunk/src/iter.rs | 344 ------------------ crates/viewer/re_view/src/results_ext.rs | 89 ----- .../visualizers/utilities/entity_iterator.rs | 92 ----- 3 files changed, 525 deletions(-) diff --git a/crates/store/re_chunk/src/iter.rs b/crates/store/re_chunk/src/iter.rs index e4dc3ff857ce..fba566278edb 100644 --- a/crates/store/re_chunk/src/iter.rs +++ b/crates/store/re_chunk/src/iter.rs @@ -201,350 +201,6 @@ impl Chunk { } } - /// Returns an iterator over the raw primitive values of a [`Chunk`], for a given component. - /// - /// This is a very fast path: the entire column will be downcasted at once, and then every - /// component batch will be a slice reference into that global slice. - /// Use this when working with simple arrow datatypes and performance matters (e.g. scalars, - /// points, etc). - /// - /// See also: - /// * [`Self::iter_primitive_array`] - /// * [`Self::iter_primitive_array_list`] - /// * [`Self::iter_string`] - /// * [`Self::iter_buffer`]. - /// * [`Self::iter_component`]. - #[inline] - pub fn iter_primitive( - &self, - component_name: &ComponentName, - ) -> impl Iterator + '_ { - let Some(list_array) = self.get_first_component(component_name) else { - return Either::Left(std::iter::empty()); - }; - - let Some(values) = list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - let values = values.values().as_slice(); - - // NOTE: No need for validity checks here, `iter_offsets` already takes care of that. - Either::Right( - self.iter_component_offsets(component_name) - .map(move |(idx, len)| &values[idx..idx + len]), - ) - } - - /// Returns an iterator over the raw boolean values of a [`Chunk`], for a given component. - /// - /// This is a very fast path: the entire column will be downcasted at once, and then every - /// component batch will be a slice reference into that global slice. - /// Use this when working with simple arrow datatypes and performance matters. - /// - /// See also: - /// * [`Self::iter_primitive_array`] - /// * [`Self::iter_primitive_array_list`] - /// * [`Self::iter_string`] - /// * [`Self::iter_buffer`]. - /// * [`Self::iter_component`]. - #[inline] - pub fn iter_bool( - &self, - component_name: &ComponentName, - ) -> impl Iterator + '_ { - let Some(list_array) = self.get_first_component(component_name) else { - return Either::Left(std::iter::empty()); - }; - - let Some(values) = list_array - .values() - .as_any() - .downcast_ref::() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - let values = values.values().clone(); - - // NOTE: No need for validity checks here, `iter_offsets` already takes care of that. - Either::Right( - self.iter_component_offsets(component_name) - .map(move |(idx, len)| values.clone().sliced(idx, len)), - ) - } - - /// Returns an iterator over the raw primitive arrays of a [`Chunk`], for a given component. - /// - /// This is a very fast path: the entire column will be downcasted at once, and then every - /// component batch will be a slice reference into that global slice. - /// Use this when working with simple arrow datatypes and performance matters (e.g. scalars, - /// points, etc). - /// - /// See also: - /// * [`Self::iter_primitive`] - /// * [`Self::iter_string`] - /// * [`Self::iter_buffer`]. - /// * [`Self::iter_component`]. - pub fn iter_primitive_array( - &self, - component_name: &ComponentName, - ) -> impl Iterator + '_ - where - [T; N]: bytemuck::Pod, - { - let Some(list_array) = self.get_first_component(component_name) else { - return Either::Left(std::iter::empty()); - }; - - let Some(fixed_size_list_array) = list_array - .values() - .as_any() - .downcast_ref::() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let Some(values) = fixed_size_list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let size = fixed_size_list_array.size(); - let values = values.values().as_slice(); - - // NOTE: No need for validity checks here, `iter_offsets` already takes care of that. - Either::Right( - self.iter_component_offsets(component_name) - .map(move |(idx, len)| { - bytemuck::cast_slice(&values[idx * size..idx * size + len * size]) - }), - ) - } - - /// Returns an iterator over the raw list of primitive arrays of a [`Chunk`], for a given component. - /// - /// This is a very fast path: the entire column will be downcasted at once, and then every - /// component batch will be a slice reference into that global slice. - /// Use this when working with simple arrow datatypes and performance matters (e.g. strips, etc). - /// - /// See also: - /// * [`Self::iter_primitive`] - /// * [`Self::iter_primitive_array`] - /// * [`Self::iter_string`] - /// * [`Self::iter_buffer`]. - /// * [`Self::iter_component`]. - pub fn iter_primitive_array_list( - &self, - component_name: &ComponentName, - ) -> impl Iterator> + '_ - where - [T; N]: bytemuck::Pod, - { - let Some(list_array) = self.get_first_component(component_name) else { - return Either::Left(std::iter::empty()); - }; - - let Some(inner_list_array) = list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let inner_offsets = inner_list_array.offsets(); - let inner_lengths = inner_list_array.offsets().lengths().collect_vec(); - - let Some(fixed_size_list_array) = inner_list_array - .values() - .as_any() - .downcast_ref::() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let Some(values) = fixed_size_list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let size = fixed_size_list_array.size(); - let values = values.values(); - - // NOTE: No need for validity checks here, `iter_offsets` already takes care of that. - Either::Right( - self.iter_component_offsets(component_name) - .map(move |(idx, len)| { - let inner_offsets = &inner_offsets.as_slice()[idx..idx + len]; - let inner_lengths = &inner_lengths.as_slice()[idx..idx + len]; - izip!(inner_offsets, inner_lengths) - .map(|(&idx, &len)| { - let idx = idx as usize; - bytemuck::cast_slice(&values[idx * size..idx * size + len * size]) - }) - .collect_vec() - }), - ) - } - - /// Returns an iterator over the raw strings of a [`Chunk`], for a given component. - /// - /// This is a very fast path: the entire column will be downcasted at once, and then every - /// component batch will be a slice reference into that global slice. - /// Use this when working with simple arrow datatypes and performance matters (e.g. labels, etc). - /// - /// See also: - /// * [`Self::iter_primitive`] - /// * [`Self::iter_primitive_array`] - /// * [`Self::iter_primitive_array_list`] - /// * [`Self::iter_buffer`]. - /// * [`Self::iter_component`]. - pub fn iter_string( - &self, - component_name: &ComponentName, - ) -> impl Iterator> + '_ { - let Some(list_array) = self.get_first_component(component_name) else { - return Either::Left(std::iter::empty()); - }; - - let Some(utf8_array) = list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let values = utf8_array.values(); - let offsets = utf8_array.offsets(); - let lengths = utf8_array.offsets().lengths().collect_vec(); - - // NOTE: No need for validity checks here, `iter_offsets` already takes care of that. - Either::Right( - self.iter_component_offsets(component_name) - .map(move |(idx, len)| { - let offsets = &offsets.as_slice()[idx..idx + len]; - let lengths = &lengths.as_slice()[idx..idx + len]; - izip!(offsets, lengths) - .map(|(&idx, &len)| ArrowString::from(values.clone().sliced(idx as _, len))) - .collect_vec() - }), - ) - } - - /// Returns an iterator over the raw buffers of a [`Chunk`], for a given component. - /// - /// This is a very fast path: the entire column will be downcasted at once, and then every - /// component batch will be a slice reference into that global slice. - /// Use this when working with simple arrow datatypes and performance matters (e.g. blobs, etc). - /// - /// See also: - /// * [`Self::iter_primitive`] - /// * [`Self::iter_primitive_array`] - /// * [`Self::iter_primitive_array_list`] - /// * [`Self::iter_string`]. - /// * [`Self::iter_component`]. - pub fn iter_buffer( - &self, - component_name: &ComponentName, - ) -> impl Iterator>> + '_ { - let Some(list_array) = self.get_first_component(component_name) else { - return Either::Left(std::iter::empty()); - }; - - let Some(inner_list_array) = list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let Some(values) = inner_list_array - .values() - .as_any() - .downcast_ref::>() - else { - if cfg!(debug_assertions) { - panic!("downcast failed for {component_name}, data discarded"); - } else { - re_log::error_once!("downcast failed for {component_name}, data discarded"); - } - return Either::Left(std::iter::empty()); - }; - - let values = values.values(); - let offsets = inner_list_array.offsets(); - let lengths = inner_list_array.offsets().lengths().collect_vec(); - - // NOTE: No need for validity checks here, `iter_offsets` already takes care of that. - Either::Right( - self.iter_component_offsets(component_name) - .map(move |(idx, len)| { - let offsets = &offsets.as_slice()[idx..idx + len]; - let lengths = &lengths.as_slice()[idx..idx + len]; - izip!(offsets, lengths) - // NOTE: Not an actual clone, just a refbump of the underlying buffer. - .map(|(&idx, &len)| values.clone().sliced(idx as _, len).into()) - .collect_vec() - }), - ) - } - /// Returns an iterator over the all the sliced component batches in a [`Chunk`]'s column, for /// a given component. /// diff --git a/crates/viewer/re_view/src/results_ext.rs b/crates/viewer/re_view/src/results_ext.rs index 406b2e04fa29..12f2907388f9 100644 --- a/crates/viewer/re_view/src/results_ext.rs +++ b/crates/viewer/re_view/src/results_ext.rs @@ -3,7 +3,6 @@ use std::{borrow::Cow, sync::Arc}; use itertools::Itertools as _; use re_chunk_store::{Chunk, LatestAtQuery, RangeQuery, UnitChunkShared}; -use re_log_types::external::arrow2::bitmap::Bitmap as Arrow2Bitmap; use re_log_types::hash::Hash64; use re_query::{LatestAtResults, RangeResults}; use re_types::ArchetypeFieldName; @@ -436,94 +435,6 @@ impl<'a> HybridResultsChunkIter<'a> { }) } - /// Iterate as indexed booleans. - /// - /// See [`Chunk::iter_bool`] for more information. - pub fn bool(&'a self) -> impl Iterator + 'a { - self.chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&self.timeline, &self.component_name), - chunk.iter_bool(&self.component_name) - ) - }) - } - - /// Iterate as indexed primitives. - /// - /// See [`Chunk::iter_primitive`] for more information. - pub fn primitive( - &'a self, - ) -> impl Iterator + 'a { - self.chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&self.timeline, &self.component_name), - chunk.iter_primitive::(&self.component_name) - ) - }) - } - - /// Iterate as indexed primitive arrays. - /// - /// See [`Chunk::iter_primitive_array`] for more information. - pub fn primitive_array( - &'a self, - ) -> impl Iterator + 'a - where - [T; N]: bytemuck::Pod, - { - self.chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&self.timeline, &self.component_name), - chunk.iter_primitive_array::(&self.component_name) - ) - }) - } - - /// Iterate as indexed list of primitive arrays. - /// - /// See [`Chunk::iter_primitive_array_list`] for more information. - pub fn primitive_array_list( - &'a self, - ) -> impl Iterator)> + 'a - where - [T; N]: bytemuck::Pod, - { - self.chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&self.timeline, &self.component_name), - chunk.iter_primitive_array_list::(&self.component_name) - ) - }) - } - - /// Iterate as indexed UTF-8 strings. - /// - /// See [`Chunk::iter_string`] for more information. - pub fn string( - &'a self, - ) -> impl Iterator)> + 'a { - self.chunks.iter().flat_map(|chunk| { - itertools::izip!( - chunk.iter_component_indices(&self.timeline, &self.component_name), - chunk.iter_string(&self.component_name) - ) - }) - } - - /// Iterate as indexed buffers. - /// - /// See [`Chunk::iter_buffer`] for more information. - pub fn buffer( - &'a self, - ) -> impl Iterator>)> + 'a { - self.chunks.iter().flat_map(|chunk| { - itertools::izip!( - chunk.iter_component_indices(&self.timeline, &self.component_name), - chunk.iter_buffer(&self.component_name) - ) - }) - } - /// Iterate as indexed, sliced, deserialized component batches. /// /// See [`Chunk::iter_slices`] for more information. diff --git a/crates/viewer/re_view_spatial/src/visualizers/utilities/entity_iterator.rs b/crates/viewer/re_view_spatial/src/visualizers/utilities/entity_iterator.rs index f9195f510b6e..f0e276257e52 100644 --- a/crates/viewer/re_view_spatial/src/visualizers/utilities/entity_iterator.rs +++ b/crates/viewer/re_view_spatial/src/visualizers/utilities/entity_iterator.rs @@ -135,7 +135,6 @@ use re_chunk_store::external::re_chunk; /// Iterate `chunks` as indexed deserialized batches. /// /// See [`Chunk::iter_component`] for more information. -#[allow(unused)] pub fn iter_component<'a, C: re_types::Component>( chunks: &'a std::borrow::Cow<'a, [Chunk]>, timeline: Timeline, @@ -149,97 +148,6 @@ pub fn iter_component<'a, C: re_types::Component>( }) } -/// Iterate `chunks` as indexed primitives. -/// -/// See [`Chunk::iter_primitive`] for more information. -#[allow(unused)] -pub fn iter_primitive<'a, T: arrow2::types::NativeType>( - chunks: &'a std::borrow::Cow<'a, [Chunk]>, - timeline: Timeline, - component_name: ComponentName, -) -> impl Iterator + 'a { - chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&timeline, &component_name), - chunk.iter_primitive::(&component_name) - ) - }) -} - -/// Iterate `chunks` as indexed primitive arrays. -/// -/// See [`Chunk::iter_primitive_array`] for more information. -#[allow(unused)] -pub fn iter_primitive_array<'a, const N: usize, T: arrow2::types::NativeType>( - chunks: &'a std::borrow::Cow<'a, [Chunk]>, - timeline: Timeline, - component_name: ComponentName, -) -> impl Iterator + 'a -where - [T; N]: bytemuck::Pod, -{ - chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&timeline, &component_name), - chunk.iter_primitive_array::(&component_name) - ) - }) -} - -/// Iterate `chunks` as indexed list of primitive arrays. -/// -/// See [`Chunk::iter_primitive_array_list`] for more information. -#[allow(unused)] -pub fn iter_primitive_array_list<'a, const N: usize, T: arrow2::types::NativeType>( - chunks: &'a std::borrow::Cow<'a, [Chunk]>, - timeline: Timeline, - component_name: ComponentName, -) -> impl Iterator)> + 'a -where - [T; N]: bytemuck::Pod, -{ - chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&timeline, &component_name), - chunk.iter_primitive_array_list::(&component_name) - ) - }) -} - -/// Iterate `chunks` as indexed UTF-8 strings. -/// -/// See [`Chunk::iter_string`] for more information. -#[allow(unused)] -pub fn iter_string<'a>( - chunks: &'a std::borrow::Cow<'a, [Chunk]>, - timeline: Timeline, - component_name: ComponentName, -) -> impl Iterator)> + 'a { - chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&timeline, &component_name), - chunk.iter_string(&component_name) - ) - }) -} - -/// Iterate `chunks` as indexed buffers. -/// -/// See [`Chunk::iter_buffer`] for more information. -#[allow(unused)] -pub fn iter_buffer<'a, T: arrow::datatypes::ArrowNativeType + arrow2::types::NativeType>( - chunks: &'a std::borrow::Cow<'a, [Chunk]>, - timeline: Timeline, - component_name: ComponentName, -) -> impl Iterator>)> + 'a { - chunks.iter().flat_map(move |chunk| { - itertools::izip!( - chunk.iter_component_indices(&timeline, &component_name), - chunk.iter_buffer(&component_name) - ) - }) -} - /// Iterate `chunks` as indexed primitives. /// /// See [`Chunk::iter_slices`] for more information.