Skip to content

Commit

Permalink
Start porting fallbacks to arrow-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 18, 2024
1 parent 905c2fc commit bf74a2a
Show file tree
Hide file tree
Showing 25 changed files with 193 additions and 162 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6559,6 +6559,7 @@ dependencies = [
"glam",
"itertools 0.13.0",
"nohash-hasher",
"re_arrow2",
"re_chunk_store",
"re_entity_db",
"re_log",
Expand Down Expand Up @@ -6872,6 +6873,7 @@ dependencies = [
"ahash",
"anyhow",
"arboard",
"arrow",
"bit-vec",
"bitflags 2.6.0",
"bytemuck",
Expand Down Expand Up @@ -6949,6 +6951,7 @@ name = "re_viewport_blueprint"
version = "0.21.0-alpha.1+dev"
dependencies = [
"ahash",
"arrow",
"egui",
"egui_tiles",
"itertools 0.13.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn generate_component_reflection(
|| contents.contains(&format!("impl Default for super::{}", &obj.name))
});
let custom_placeholder = if auto_derive_default || has_custom_default_impl {
quote! { Some(#type_name::default().to_arrow2()?) }
quote! { Some(#type_name::default().to_arrow()?) }
} else {
quote! { None }
};
Expand Down
16 changes: 12 additions & 4 deletions crates/store/re_chunk/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use arrow::array::ArrayRef;
use arrow2::array::Array as Arrow2Array;

use re_log_types::{TimeInt, Timeline};
Expand Down Expand Up @@ -262,7 +263,14 @@ impl UnitChunkShared {

/// Returns the raw data for the specified component.
#[inline]
pub fn component_batch_raw(
pub fn component_batch_raw(&self, component_name: &ComponentName) -> Option<ArrayRef> {
self.component_batch_raw_arrow2(component_name)
.map(|array| array.into())
}

/// Returns the raw data for the specified component.
#[inline]
pub fn component_batch_raw_arrow2(
&self,
component_name: &ComponentName,
) -> Option<Box<dyn Arrow2Array>> {
Expand All @@ -276,7 +284,7 @@ impl UnitChunkShared {
/// Returns an error if the data cannot be deserialized.
#[inline]
pub fn component_batch<C: Component>(&self) -> Option<ChunkResult<Vec<C>>> {
let data = C::from_arrow2(&*self.component_batch_raw(&C::name())?);
let data = C::from_arrow2(&*self.component_batch_raw_arrow2(&C::name())?);
Some(data.map_err(Into::into))
}

Expand All @@ -291,7 +299,7 @@ impl UnitChunkShared {
component_name: &ComponentName,
instance_index: usize,
) -> Option<ChunkResult<Box<dyn Arrow2Array>>> {
let array = self.component_batch_raw(component_name)?;
let array = self.component_batch_raw_arrow2(component_name)?;
if array.len() > instance_index {
Some(Ok(array.sliced(instance_index, 1)))
} else {
Expand Down Expand Up @@ -334,7 +342,7 @@ impl UnitChunkShared {
&self,
component_name: &ComponentName,
) -> Option<ChunkResult<Box<dyn Arrow2Array>>> {
let array = self.component_batch_raw(component_name)?;
let array = self.component_batch_raw_arrow2(component_name)?;
if array.len() == 1 {
Some(Ok(array.sliced(0, 1)))
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk_store/tests/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn query_latest_array(
})
.max_by_key(|(index, _chunk)| *index)?;

unit.component_batch_raw(&component_name)
unit.component_batch_raw_arrow2(&component_name)
.map(|array| (data_time, row_id, array))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk_store/tests/reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn query_latest_array(
})
.max_by_key(|(index, _chunk)| *index)?;

unit.component_batch_raw(&component_desc.component_name)
unit.component_batch_raw_arrow2(&component_desc.component_name)
.map(|array| (data_time, row_id, array))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_query/examples/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn main() -> anyhow::Result<()> {
// data directly:
let colors = colors
.context("missing")?
.component_batch_raw(&MyColor::name())
.component_batch_raw_arrow2(&MyColor::name())
.context("invalid")?;
let colors = colors
.as_any()
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_query/src/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl LatestAtResults {
) -> Option<Box<dyn Arrow2Array>> {
self.components
.get(component_name)
.and_then(|unit| unit.component_batch_raw(component_name))
.and_then(|unit| unit.component_batch_raw_arrow2(component_name))
}

/// Returns the deserialized data for the specified component.
Expand Down
Loading

0 comments on commit bf74a2a

Please sign in to comment.