Struct rerun::external::re_log_types::DataCell

source ·
pub struct DataCell {
    pub inner: Arc<DataCellInner>,
}
Expand description

A cell’s worth of data, i.e. a uniform array of values for a given component type. This is the leaf type in our data model.

A DataCell can be constructed from either an iterable of native Components or directly from a slice of arrow data.

Behind the scenes, a DataCell is backed by an erased arrow array living on the heap, which is likely to point into a larger batch of contiguous memory that it shares with its peers. Cloning a DataCell is thus cheap (shallow, ref-counted).

§Layout

A cell is an array of component instances: [C, C, C, …].

Consider this example:

let points: &[MyPoint] = &[[10.0, 10.0].into(), [20.0, 20.0].into(), [30.0, 30.0].into()];
let cell = DataCell::from(points);
// Or, alternatively:
let cell = DataCell::from_component::<MyPoint>([[10.0, 10.0], [20.0, 20.0], [30.0, 30.0]]);

The cell’s datatype is now a StructArray:

Struct([
   Field { name: "x", data_type: Float32, is_nullable: false, metadata: {} },
   Field { name: "y", data_type: Float32, is_nullable: false, metadata: {} },
])

Or, visualized as a cell within a larger table:

┌──────────────────────────────────────────────────┐
│ rerun.components.Point2D                                    │
╞══════════════════════════════════════════════════╡
│ [{x: 10, y: 10}, {x: 20, y: 20}, {x: 30, y: 30}] │
└──────────────────────────────────────────────────┘

§Example

let points: &[MyPoint] = &[
    MyPoint { x: 10.0, y: 10.0 },
    MyPoint { x: 20.0, y: 20.0 },
    MyPoint { x: 30.0, y: 30.0 },
];
let _cell = DataCell::from(points);

// Or, alternatively:
let cell = DataCell::from_component::<MyPoint>([
    MyPoint { x: 10.0, y: 10.0 },
    MyPoint { x: 20.0, y: 20.0 },
    MyPoint { x: 30.0, y: 30.0 },
]);

eprintln!("{:#?}", cell.datatype());
eprintln!("{cell}");

Fields§

§inner: Arc<DataCellInner>

While the arrow data is already refcounted, the contents of the DataCell still have to be wrapped in an Arc to work around performance issues in arrow2.

See DataCellInner for more information.

Implementations§

source§

impl DataCell

source§

impl DataCell

source

pub fn from_component_batch( batch: &dyn ComponentBatch<Name = ComponentName> ) -> Result<DataCell, SerializationError>

Builds a new DataCell from a component batch.

source

pub fn try_from_native<'a, C>( values: impl IntoIterator<Item = impl Into<Cow<'a, C>>> ) -> Result<DataCell, DataCellError>
where C: Component + Clone + 'a,

Builds a new DataCell from a uniform iterable of native component values.

Fails if the given iterable cannot be serialized to arrow, which should never happen when using Rerun’s built-in components.

source

pub fn try_from_native_sparse<'a, C>( values: impl IntoIterator<Item = Option<impl Into<Cow<'a, C>>>> ) -> Result<DataCell, DataCellError>
where C: Component + Clone + 'a,

Builds a new DataCell from a uniform iterable of native component values.

Fails if the given iterable cannot be serialized to arrow, which should never happen when using Rerun’s built-in components.

source

pub fn from_native<'a, C>( values: impl IntoIterator<Item = impl Into<Cow<'a, C>>> ) -> DataCell
where C: Component + Clone + 'a,

Builds a new DataCell from a uniform iterable of native component values.

Panics if the given iterable cannot be serialized to arrow, which should never happen when using Rerun’s built-in components. See Self::try_from_native for the fallible alternative.

source

pub fn from_native_sparse<'a, C>( values: impl IntoIterator<Item = Option<impl Into<Cow<'a, C>>>> ) -> DataCell
where C: Component + Clone + 'a,

Builds a new DataCell from a uniform iterable of native component values.

Panics if the given iterable cannot be serialized to arrow, which should never happen when using Rerun’s built-in components. See Self::try_from_native for the fallible alternative.

source

pub fn from_component<'a, C>( values: impl IntoIterator<Item = impl Into<C>> ) -> DataCell
where C: Component + Clone + 'a + Into<Cow<'a, C>>,

Builds a cell from an iterable of items that can be turned into a Component.

source

pub fn from_component_sparse<'a, C>( values: impl IntoIterator<Item = Option<impl Into<C>>> ) -> DataCell
where C: Component + Clone + 'a + Into<Cow<'a, C>>,

Builds a cell from an iterable of items that can be turned into a Component.

source

pub fn try_from_arrow( name: ComponentName, values: Box<dyn Array> ) -> Result<DataCell, DataCellError>

Builds a new DataCell from an arrow array.

Fails if the array is not a valid list of components.

source

pub fn from_arrow(name: ComponentName, values: Box<dyn Array>) -> DataCell

Builds a new DataCell from an arrow array.

Panics if the array is not a valid list of components. See Self::try_from_arrow for the fallible alternative.

source

pub fn from_native_empty<C>() -> DataCell
where C: Component,

Builds an empty DataCell from a native component type.

source

pub fn try_from_arrow_empty( name: ComponentName, datatype: DataType ) -> Result<DataCell, DataCellError>

Builds an empty DataCell from an arrow datatype.

Fails if the datatype is not a valid component type.

source

pub fn from_arrow_empty(name: ComponentName, datatype: DataType) -> DataCell

Builds an empty DataCell from an arrow datatype.

Panics if the datatype is not a valid component type. See Self::try_from_arrow_empty for a fallible alternative.

source

pub fn to_arrow(&self) -> Box<dyn Array>

Returns the contents of the cell as an arrow array (shallow clone).

Avoid using raw arrow arrays unless you absolutely have to: prefer working directly with DataCells, DataRows & DataTables instead. If you do use them, try to keep the scope as short as possible: holding on to a raw array might prevent the datastore from releasing memory from garbage collected data.

source

pub fn as_arrow_ref(&self) -> &(dyn Array + 'static)

Returns the contents of the cell as a reference to an arrow array.

Avoid using raw arrow arrays unless you absolutely have to: prefer working directly with DataCells, DataRows & DataTables instead. If you do use them, try to keep the scope as short as possible: holding on to a raw array might prevent the datastore from releasing memory from garbage collected data.

source

pub fn try_to_native<'a, C>(&'a self) -> Result<Vec<C>, DataCellError>
where C: Component + 'a,

Returns the contents of the cell as an iterator of native components.

Fails if the underlying arrow data cannot be deserialized into C.

source

pub fn try_to_native_mono<'a, C>(&'a self) -> Result<Option<C>, DataCellError>
where C: Component + 'a,

Returns the contents of an expected mono-component as an Option<C>.

Fails if the underlying arrow data cannot be deserialized into C.

source

pub fn to_native<'a, C>(&'a self) -> Vec<C>
where C: Component + 'a,

Returns the contents of the cell as an iterator of native components.

Panics if the underlying arrow data cannot be deserialized into C. See Self::try_to_native for a fallible alternative.

source

pub fn try_to_native_opt<'a, C>( &'a self ) -> Result<Vec<Option<C>>, DataCellError>
where C: Component + 'a,

Returns the contents of the cell as an iterator of native optional components.

Fails if the underlying arrow data cannot be deserialized into C.

source

pub fn to_native_opt<'a, C>(&'a self) -> Vec<Option<C>>
where C: Component + 'a,

Returns the contents of the cell as an iterator of native optional components.

Panics if the underlying arrow data cannot be deserialized into C. See Self::try_to_native_opt for a fallible alternative.

source§

impl DataCell

source

pub fn component_name(&self) -> ComponentName

The name of the component type stored in the cell.

source

pub fn datatype(&self) -> &DataType

The type of the component stored in the cell, i.e. the cell is an array of that type.

source

pub fn num_instances(&self) -> u32

The length of the cell’s array, i.e. how many component instances are in the cell?

source

pub fn is_empty(&self) -> bool

source

pub fn is_dense(&self) -> bool

Returns true if the underlying array is dense (no nulls).

source

pub fn is_sorted_and_unique(&self) -> Result<bool, DataCellError>

Returns true if the underlying array is both sorted (increasing order) and contains only unique values.

The cell must be dense, otherwise the result of this method is undefined.

source§

impl DataCell

source

pub fn compute_size_bytes(&mut self) -> bool

Compute and cache the total size (stack + heap) of the inner cell and its underlying arrow array, in bytes. This does nothing if the size has already been computed and cached before.

The caller must the sole owner of this cell, as this requires mutating an Arc under the hood. Returns false otherwise.

Beware: this is very costly!

Trait Implementations§

source§

impl Clone for DataCell

source§

fn clone(&self) -> DataCell

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DataCell

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Display for DataCell

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'a, C> From<&'a [C]> for DataCell
where C: Component + Clone + 'a, &'a C: Into<Cow<'a, C>>,

source§

fn from(values: &'a [C]) -> DataCell

Converts to this type from the input type.
source§

impl<'a, C> From<&'a Vec<C>> for DataCell
where C: Component + Clone + 'a, &'a C: Into<Cow<'a, C>>,

source§

fn from(c: &'a Vec<C>) -> DataCell

Converts to this type from the input type.
source§

impl<'a, C> From<[C; 1]> for DataCell
where C: Component + Clone + 'a + Into<Cow<'a, C>>,

source§

fn from(values: [C; 1]) -> DataCell

Converts to this type from the input type.
source§

impl<'a, C> From<Vec<C>> for DataCell
where C: Component + Clone + 'a + Into<Cow<'a, C>>,

source§

fn from(c: Vec<C>) -> DataCell

Converts to this type from the input type.
source§

impl PartialEq for DataCell

source§

fn eq(&self, rhs: &DataCell) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SizeBytes for DataCell

source§

fn heap_size_bytes(&self) -> u64

Returns the total size of self on the heap, in bytes.
source§

fn total_size_bytes(&self) -> u64

Returns the total size of self in bytes, accounting for both stack and heap space.
source§

fn stack_size_bytes(&self) -> u64

Returns the total size of self on the stack, in bytes. Read more
source§

fn is_pod() -> bool

Is Self just plain old data? Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,