Skip to content

Commit

Permalink
Revert "Remove unused Loggable::extended_arrow_datatype (#7260)"
Browse files Browse the repository at this point in the history
This reverts commit 0252f6b.
  • Loading branch information
emilk committed Aug 28, 2024
1 parent ec9d0a0 commit 13aaf3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 17 additions & 0 deletions crates/store/re_types_core/src/loggable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use crate::{
result::_Backtrace, DeserializationResult, ResultExt as _, SerializationResult, SizeBytes,
};
Expand Down Expand Up @@ -39,6 +41,21 @@ pub trait Loggable: 'static + Send + Sync + Clone + Sized + SizeBytes {
where
Self: 'a;

// --- Optional metadata methods ---

/// The underlying [`arrow2::datatypes::DataType`], including datatype extensions.
///
/// The default implementation will simply wrap [`Self::arrow_datatype`] in an extension called
/// [`Self::name`], which is what you want in most cases.
#[inline]
fn extended_arrow_datatype() -> arrow2::datatypes::DataType {
arrow2::datatypes::DataType::Extension(
Self::name().to_string(),
Arc::new(Self::arrow_datatype()),
None,
)
}

// --- Optional serialization methods ---

/// Given an iterator of owned or reference values to the current [`Loggable`], serializes
Expand Down
8 changes: 1 addition & 7 deletions crates/store/re_types_core/src/tuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,8 @@ impl Loggable for Tuid {
];
let validity = None;

let datatype = arrow2::datatypes::DataType::Extension(
Self::name().to_string(),
Arc::new(Self::arrow_datatype()),
None,
);

// TODO(cmc): We use the extended type here because we rely on it for formatting.
Ok(StructArray::new(datatype, values, validity).boxed())
Ok(StructArray::new(Self::extended_arrow_datatype(), values, validity).boxed())
}

fn from_arrow(array: &dyn ::arrow2::array::Array) -> crate::DeserializationResult<Vec<Self>> {
Expand Down

0 comments on commit 13aaf3e

Please sign in to comment.