re_sorbet::chunk_batch

Struct ChunkBatch

Source
pub struct ChunkBatch {
    schema: ChunkSchema,
    sorbet_batch: SorbetBatch,
}
Expand description

The [ArrowRecordBatch] representation of a Rerun chunk.

This is a wrapper around a ChunkSchema and a [ArrowRecordBatch].

Each ChunkBatch contains logging data for a single [EntityPath]. It always has a [re_types_core::RowId] column.

Fields§

§schema: ChunkSchema§sorbet_batch: SorbetBatch

Implementations§

Source§

impl ChunkBatch

Source

pub fn try_new( schema: ChunkSchema, row_ids: ArrowArrayRef, index_arrays: Vec<ArrowArrayRef>, data_arrays: Vec<ArrowArrayRef>, ) -> Result<Self, SorbetError>

Source§

impl ChunkBatch

Source

pub fn chunk_schema(&self) -> &ChunkSchema

The parsed rerun schema of this chunk.

Source

pub fn chunk_id(&self) -> ChunkId

The globally unique ID of this chunk.

Source

pub fn entity_path(&self) -> &EntityPath

Which entity is this chunk for?

Source

pub fn fields(&self) -> &ArrowFields

Source

pub fn row_id_column(&self) -> (&RowIdColumnDescriptor, &FixedSizeBinaryArray)

The RowId column.

Source

pub fn drop_all_rows(self) -> Self

Returns self but with all rows removed.

Methods from Deref<Target = SorbetBatch>§

Source

pub fn sorbet_schema(&self) -> &SorbetSchema

The parsed rerun schema of this batch.

Source

pub fn heap_size_bytes(&self) -> Option<u64>

The heap size of this batch in bytes, if known.

Source

pub fn fields(&self) -> &ArrowFields

Source

pub fn arrow_batch_metadata(&self) -> &ArrowBatchMetadata

Source

pub fn row_id_column( &self, ) -> Option<(&RowIdColumnDescriptor, &ArrowStructArray)>

The RowId column, if any.

Source

pub fn all_columns( &self, ) -> impl Iterator<Item = (ColumnDescriptorRef<'_>, &ArrowArrayRef)>

All the columns along with their descriptors.

Source

pub fn index_columns( &self, ) -> impl Iterator<Item = (&IndexColumnDescriptor, &ArrowArrayRef)>

The columns of the indices (timelines).

Source

pub fn component_columns( &self, ) -> impl Iterator<Item = (&ComponentColumnDescriptor, &ArrowArrayRef)>

The columns of the components.

Methods from Deref<Target = ArrowRecordBatch>§

pub fn schema(&self) -> Arc<Schema>

Returns the [Schema] of the record batch.

pub fn schema_ref(&self) -> &Arc<Schema>

Returns a reference to the [Schema] of the record batch.

pub fn project(&self, indices: &[usize]) -> Result<RecordBatch, ArrowError>

Projects the schema onto the specified columns

pub fn normalize( &self, separator: &str, max_level: Option<usize>, ) -> Result<RecordBatch, ArrowError>

Normalize a semi-structured [RecordBatch] into a flat table.

Nested [Field]s will generate names separated by separator, up to a depth of max_level (unlimited if None).

e.g. given a [RecordBatch] with schema:

    "foo": StructArray<"bar": Utf8>

A separator of "." would generate a batch with the schema:

    "foo.bar": Utf8

Note that giving a depth of Some(0) to max_level is the same as passing in None; it will be treated as unlimited.

§Example
let animals: ArrayRef = Arc::new(StringArray::from(vec!["Parrot", ""]));
let n_legs: ArrayRef = Arc::new(Int64Array::from(vec![Some(2), Some(4)]));

let animals_field = Arc::new(Field::new("animals", DataType::Utf8, true));
let n_legs_field = Arc::new(Field::new("n_legs", DataType::Int64, true));

let a = Arc::new(StructArray::from(vec![
    (animals_field.clone(), Arc::new(animals.clone()) as ArrayRef),
    (n_legs_field.clone(), Arc::new(n_legs.clone()) as ArrayRef),
]));

let schema = Schema::new(vec![
    Field::new(
        "a",
        DataType::Struct(Fields::from(vec![animals_field, n_legs_field])),
        false,
    )
]);

let normalized = RecordBatch::try_new(Arc::new(schema), vec![a])
    .expect("valid conversion")
    .normalize(".", None)
    .expect("valid normalization");

let expected = RecordBatch::try_from_iter_with_nullable(vec![
    ("a.animals", animals.clone(), true),
    ("a.n_legs", n_legs.clone(), true),
])
.expect("valid conversion");

assert_eq!(expected, normalized);

pub fn num_columns(&self) -> usize

Returns the number of columns in the record batch.

§Example

let id_array = Int32Array::from(vec![1, 2, 3, 4, 5]);
let schema = Schema::new(vec![
    Field::new("id", DataType::Int32, false)
]);

let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id_array)]).unwrap();

assert_eq!(batch.num_columns(), 1);

pub fn num_rows(&self) -> usize

Returns the number of rows in each column.

§Example

let id_array = Int32Array::from(vec![1, 2, 3, 4, 5]);
let schema = Schema::new(vec![
    Field::new("id", DataType::Int32, false)
]);

let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id_array)]).unwrap();

assert_eq!(batch.num_rows(), 5);

pub fn column(&self, index: usize) -> &Arc<dyn Array>

Get a reference to a column’s array by index.

§Panics

Panics if index is outside of 0..num_columns.

pub fn column_by_name(&self, name: &str) -> Option<&Arc<dyn Array>>

Get a reference to a column’s array by name.

pub fn columns(&self) -> &[Arc<dyn Array>]

Get a reference to all columns in the record batch.

pub fn slice(&self, offset: usize, length: usize) -> RecordBatch

Return a new RecordBatch where each column is sliced according to offset and length

§Panics

Panics if offset with length is greater than column length.

pub fn get_array_memory_size(&self) -> usize

Returns the total number of bytes of memory occupied physically by this batch.

Note that this does not always correspond to the exact memory usage of a RecordBatch (might overestimate), since multiple columns can share the same buffers or slices thereof, the memory used by the shared buffers might be counted multiple times.

Trait Implementations§

Source§

impl AsRef<SorbetBatch> for ChunkBatch

Source§

fn as_ref(&self) -> &SorbetBatch

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ChunkBatch

Source§

fn clone(&self) -> ChunkBatch

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 ChunkBatch

Source§

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

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

impl Deref for ChunkBatch

Source§

type Target = SorbetBatch

The resulting type after dereferencing.
Source§

fn deref(&self) -> &SorbetBatch

Dereferences the value.
Source§

impl Display for ChunkBatch

Source§

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

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

impl From<&ChunkBatch> for RecordBatch

Source§

fn from(chunk: &ChunkBatch) -> Self

Converts to this type from the input type.
Source§

impl From<ChunkBatch> for RecordBatch

Source§

fn from(chunk: ChunkBatch) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<&RecordBatch> for ChunkBatch

Source§

fn try_from(batch: &ArrowRecordBatch) -> Result<Self, Self::Error>

Will automatically wrap data columns in ListArrays if they are not already.

Source§

type Error = SorbetError

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

impl TryFrom<SorbetBatch> for ChunkBatch

Source§

fn try_from(sorbet_batch: SorbetBatch) -> Result<Self, Self::Error>

Will automatically wrap data columns in ListArrays if they are not already.

Source§

type Error = SorbetError

The type returned in the event of a conversion error.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

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

§

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.
§

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.
§

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.
§

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.
§

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

§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

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,

Source§

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> 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>,

Source§

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>,

Source§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

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