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
impl ChunkBatch
pub fn try_new( schema: ChunkSchema, row_ids: ArrowArrayRef, index_arrays: Vec<ArrowArrayRef>, data_arrays: Vec<ArrowArrayRef>, ) -> Result<Self, SorbetError>
Source§impl ChunkBatch
impl ChunkBatch
Sourcepub fn chunk_schema(&self) -> &ChunkSchema
pub fn chunk_schema(&self) -> &ChunkSchema
The parsed rerun schema of this chunk.
Sourcepub fn entity_path(&self) -> &EntityPath
pub fn entity_path(&self) -> &EntityPath
Which entity is this chunk for?
pub fn fields(&self) -> &ArrowFields
Sourcepub fn row_id_column(&self) -> (&RowIdColumnDescriptor, &FixedSizeBinaryArray)
pub fn row_id_column(&self) -> (&RowIdColumnDescriptor, &FixedSizeBinaryArray)
The RowId
column.
Sourcepub fn drop_all_rows(self) -> Self
pub fn drop_all_rows(self) -> Self
Returns self but with all rows removed.
Methods from Deref<Target = SorbetBatch>§
Sourcepub fn sorbet_schema(&self) -> &SorbetSchema
pub fn sorbet_schema(&self) -> &SorbetSchema
The parsed rerun schema of this batch.
Sourcepub fn heap_size_bytes(&self) -> Option<u64>
pub fn heap_size_bytes(&self) -> Option<u64>
The heap size of this batch in bytes, if known.
pub fn fields(&self) -> &ArrowFields
pub fn arrow_batch_metadata(&self) -> &ArrowBatchMetadata
Sourcepub fn row_id_column(
&self,
) -> Option<(&RowIdColumnDescriptor, &ArrowStructArray)>
pub fn row_id_column( &self, ) -> Option<(&RowIdColumnDescriptor, &ArrowStructArray)>
The RowId
column, if any.
Sourcepub fn all_columns(
&self,
) -> impl Iterator<Item = (ColumnDescriptorRef<'_>, &ArrowArrayRef)>
pub fn all_columns( &self, ) -> impl Iterator<Item = (ColumnDescriptorRef<'_>, &ArrowArrayRef)>
All the columns along with their descriptors.
Sourcepub fn index_columns(
&self,
) -> impl Iterator<Item = (&IndexColumnDescriptor, &ArrowArrayRef)>
pub fn index_columns( &self, ) -> impl Iterator<Item = (&IndexColumnDescriptor, &ArrowArrayRef)>
The columns of the indices (timelines).
Sourcepub fn component_columns(
&self,
) -> impl Iterator<Item = (&ComponentColumnDescriptor, &ArrowArrayRef)>
pub fn component_columns( &self, ) -> impl Iterator<Item = (&ComponentColumnDescriptor, &ArrowArrayRef)>
The columns of the components.
Methods from Deref<Target = ArrowRecordBatch>§
pub fn schema_ref(&self) -> &Arc<Schema>
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>
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>
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
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
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_by_name(&self, name: &str) -> Option<&Arc<dyn Array>>
pub fn column_by_name(&self, name: &str) -> Option<&Arc<dyn Array>>
Get a reference to a column’s array by name.
pub fn slice(&self, offset: usize, length: usize) -> RecordBatch
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
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
impl AsRef<SorbetBatch> for ChunkBatch
Source§fn as_ref(&self) -> &SorbetBatch
fn as_ref(&self) -> &SorbetBatch
Source§impl Clone for ChunkBatch
impl Clone for ChunkBatch
Source§fn clone(&self) -> ChunkBatch
fn clone(&self) -> ChunkBatch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ChunkBatch
impl Debug for ChunkBatch
Source§impl Deref for ChunkBatch
impl Deref for ChunkBatch
Source§type Target = SorbetBatch
type Target = SorbetBatch
Source§fn deref(&self) -> &SorbetBatch
fn deref(&self) -> &SorbetBatch
Source§impl Display for ChunkBatch
impl Display for ChunkBatch
Source§impl From<&ChunkBatch> for RecordBatch
impl From<&ChunkBatch> for RecordBatch
Source§fn from(chunk: &ChunkBatch) -> Self
fn from(chunk: &ChunkBatch) -> Self
Source§impl From<ChunkBatch> for RecordBatch
impl From<ChunkBatch> for RecordBatch
Source§fn from(chunk: ChunkBatch) -> Self
fn from(chunk: ChunkBatch) -> Self
Source§impl TryFrom<&RecordBatch> for ChunkBatch
impl TryFrom<&RecordBatch> for ChunkBatch
Source§impl TryFrom<SorbetBatch> for ChunkBatch
impl TryFrom<SorbetBatch> for ChunkBatch
Source§fn try_from(sorbet_batch: SorbetBatch) -> Result<Self, Self::Error>
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
type Error = SorbetError
Auto Trait Implementations§
impl Freeze for ChunkBatch
impl !RefUnwindSafe for ChunkBatch
impl Send for ChunkBatch
impl Sync for ChunkBatch
impl Unpin for ChunkBatch
impl !UnwindSafe for ChunkBatch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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