Skip to content

Commit

Permalink
remove every last trace of arrow2-convert
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Oct 18, 2023
1 parent e8d34ac commit 3d6bae9
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 173 deletions.
75 changes: 0 additions & 75 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/re_log_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ arrow2 = { workspace = true, features = [
"io_print",
"compute_concatenate",
] }
arrow2_convert.workspace = true
backtrace.workspace = true
bytemuck.workspace = true
document-features.workspace = true
Expand Down
10 changes: 3 additions & 7 deletions crates/re_log_types/src/data_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ pub type DataCellResult<T> = ::std::result::Result<T, DataCellError>;
/// ## Example
///
/// ```rust
/// # use arrow2_convert::field::ArrowField as _;
/// # use itertools::Itertools as _;
/// #
/// # use re_log_types::DataCell;
Expand All @@ -97,7 +96,7 @@ pub type DataCellResult<T> = ::std::result::Result<T, DataCellError>;
/// #
/// # assert_eq!(MyPoint::name(), cell.component_name());
/// # assert_eq!(3, cell.num_instances());
/// # assert_eq!(cell.datatype(), &MyPoint::data_type());
/// # assert_eq!(cell.datatype(), &MyPoint::arrow_datatype());
/// #
/// # assert_eq!(points, cell.to_native().as_slice());
/// ```
Expand Down Expand Up @@ -157,7 +156,6 @@ pub struct DataCellInner {
pub(crate) values: Box<dyn arrow2::array::Array>,
}

// TODO(cmc): We should be able to build a cell from non-reference types.
// TODO(#1696): We shouldn't have to specify the component name separately, this should be
// part of the metadata by using an extension.
// TODO(#1696): Check that the array is indeed a leaf / component type when building a cell from an
Expand Down Expand Up @@ -232,6 +230,7 @@ impl DataCell {
}

/// Builds a cell from an iterable of items that can be turned into a [`Component`].
#[inline]
pub fn from_component<'a, C>(values: impl IntoIterator<Item = impl Into<C>>) -> Self
where
C: Component + Clone + 'a,
Expand All @@ -241,10 +240,7 @@ impl DataCell {
}

/// Builds a cell from an iterable of items that can be turned into a [`Component`].
///
/// ⚠ Due to quirks in `arrow2-convert`, this requires consuming and collecting the passed-in
/// iterator into a vector first.
/// Prefer [`Self::from_native`] when performance matters.
#[inline]
pub fn from_component_sparse<'a, C>(
values: impl IntoIterator<Item = Option<impl Into<C>>>,
) -> Self
Expand Down
1 change: 1 addition & 0 deletions crates/re_log_types/src/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ impl DataTable {

(field, data)
}

/// Serializes all data columns into an arrow payload and schema.
///
/// They are optional, potentially sparse, and never deserialized on the server-side (not by
Expand Down
76 changes: 0 additions & 76 deletions crates/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,82 +395,6 @@ impl PathOp {
}
}

// ---------------------------------------------------------------------------

/// Implements [`::re_types::Component`] for `T: arrow2_convert::{Serialize, Deserialize}`.
#[doc(hidden)]
#[macro_export]
macro_rules! arrow2convert_component_shim {
($entity:ident as $fqname:expr) => {

impl ::re_types::Loggable for $entity {
type Name = ::re_types::ComponentName;

#[inline]
fn name() -> Self::Name {
$fqname.into()
}

#[inline]
fn arrow_datatype() -> arrow2::datatypes::DataType {
<Self as ::arrow2_convert::field::ArrowField>::data_type()
}

#[inline]
fn to_arrow_opt<'a>(
data: impl IntoIterator<Item = Option<impl Into<std::borrow::Cow<'a, Self>>>>,
) -> ::re_types::SerializationResult<Box<dyn arrow2::array::Array>>
where
Self: Clone + 'a,
{
let input = data.into_iter().map(|datum| {
let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into);
datum.map(|d| d.into_owned())
});

let vec: Vec<_> = input.collect();

let arrow = arrow2_convert::serialize::TryIntoArrow::try_into_arrow(vec.iter())
.map_err(|err| {
::re_types::SerializationError::ArrowConvertFailure(err.to_string())
})?;

Ok(arrow)
}

#[inline]
fn from_arrow_opt(data: &dyn ::arrow2::array::Array) -> ::re_types::DeserializationResult<Vec<Option<Self>>>
where
Self: Sized
{
let native = <
<Self as arrow2_convert::deserialize::ArrowDeserialize>::ArrayType as arrow2_convert::deserialize::ArrowArray
>::iter_from_array_ref(data);
Ok(
native
.into_iter()
.map(|item| <Self as arrow2_convert::deserialize::ArrowDeserialize>::arrow_deserialize(item))
.collect()
)
}
}

impl<'a> From<$entity> for ::std::borrow::Cow<'a, $entity> {
#[inline]
fn from(value: $entity) -> Self {
std::borrow::Cow::Owned(value)
}
}

impl<'a> From<&'a $entity> for ::std::borrow::Cow<'a, $entity> {
#[inline]
fn from(value: &'a $entity) -> Self {
std::borrow::Cow::Borrowed(value)
}
}
};
}

// ---

/// Build a ([`Timeline`], [`TimeInt`]) tuple from `log_time` suitable for inserting in a [`TimePoint`].
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query/src/dataframe_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use re_types_core::{components::InstanceKey, Archetype, Component, Loggable};

use crate::{ArchetypeView, ComponentWithInstances, QueryError};

/// Make it so that our arrays can be deserialized again by arrow2-convert
/// Make it so that our arrays can be deserialized again by `polars`.
fn fix_polars_nulls<C: Component>(array: &dyn Array) -> Box<dyn Array> {
// TODO(jleibs): This is an ugly work-around but gets our serializers
// working again
Expand Down Expand Up @@ -196,7 +196,7 @@ fn test_df_builder() {
eprintln!("{df:?}");
//
// ┌──────────────┬─────────────────┐
// │ rerun.components.Radius ┆ rerun.components.Color │
// │ Radius Color
// │ --- ┆ --- │
// │ f32 ┆ u32 │
// ╞══════════════╪═════════════════╡
Expand Down
16 changes: 4 additions & 12 deletions crates/re_types_core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ pub enum SerializationError {
backtrace: _Backtrace,
},

// TODO: del
#[error("arrow2-convert serialization failed: {0}")]
ArrowConvertFailure(String),

#[error("serde-based serialization (`attr.rust.serde_type`) failed: {reason}")]
SerdeFailure {
reason: String,
Expand Down Expand Up @@ -88,7 +84,7 @@ impl SerializationError {
Self::MissingExtensionMetadata { backtrace, .. }
| Self::SerdeFailure { backtrace, .. }
| Self::NotImplemented { backtrace, .. } => Some(backtrace.clone()),
SerializationError::Context { .. } | SerializationError::ArrowConvertFailure(_) => None,
SerializationError::Context { .. } => None,
}
}
}
Expand Down Expand Up @@ -171,10 +167,6 @@ pub enum DeserializationError {
backtrace: _Backtrace,
},

// TODO: del
#[error("arrow2-convert deserialization Failed: {0}")]
ArrowConvertFailure(String),

#[error("serde-based deserialization (`attr.rust.serde_type`) failed: {reason}")]
SerdeFailure {
reason: String,
Expand Down Expand Up @@ -313,9 +305,9 @@ impl DeserializationError {
| DeserializationError::OffsetOutOfBounds { backtrace, .. }
| DeserializationError::OffsetSliceOutOfBounds { backtrace, .. }
| DeserializationError::SerdeFailure { backtrace, .. } => Some(backtrace.clone()),
DeserializationError::ArrowConvertFailure(_)
| DeserializationError::DataCellError(_)
| DeserializationError::ValidationError(_) => None,
DeserializationError::DataCellError(_) | DeserializationError::ValidationError(_) => {
None
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ def main() -> None:
"./.github/workflows/reusable_checks.yml", # zombie TODO hunting job
"./CODE_STYLE.md",
"./crates/re_types_builder/src/reflection.rs", # auto-generated
"./examples/python/detect_and_track_objects/cache/version.txt",
"./examples/rust/objectron/src/objectron.rs", # auto-generated
"./scripts/lint.py", # we contain all the patterns we are linting against
"./scripts/zombie_todos.py",
Expand Down

0 comments on commit 3d6bae9

Please sign in to comment.