pub struct SorbetBatch {
schema: SorbetSchema,
batch: RecordBatch,
}
Expand description
Any rerun-compatible [ArrowRecordBatch
].
This is a wrapper around a SorbetSchema
and a [ArrowRecordBatch
].
Fields§
§schema: SorbetSchema
§batch: RecordBatch
Implementations§
Source§impl SorbetBatch
impl SorbetBatch
pub fn try_new( batch_type: BatchType, schema: SorbetSchema, row_ids: Option<ArrowArrayRef>, index_arrays: Vec<ArrowArrayRef>, data_arrays: Vec<ArrowArrayRef>, ) -> Result<Self, ArrowError>
Sourcepub fn drop_all_rows(self) -> Self
pub fn drop_all_rows(self) -> Self
Returns self but with all rows removed.
Source§impl SorbetBatch
impl 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.
Source§impl SorbetBatch
impl SorbetBatch
Sourcepub fn try_from_record_batch(
batch: &ArrowRecordBatch,
batch_type: BatchType,
) -> Result<Self, SorbetError>
pub fn try_from_record_batch( batch: &ArrowRecordBatch, batch_type: BatchType, ) -> Result<Self, SorbetError>
Will automatically wrap data columns in ListArrays
if they are not already.
Will also migrate old types to new types.
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<RecordBatch> for SorbetBatch
impl AsRef<RecordBatch> for SorbetBatch
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 SorbetBatch
impl Clone for SorbetBatch
Source§fn clone(&self) -> SorbetBatch
fn clone(&self) -> SorbetBatch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SorbetBatch
impl Debug for SorbetBatch
Source§impl Deref for SorbetBatch
impl Deref for SorbetBatch
Source§impl Display for SorbetBatch
impl Display for SorbetBatch
Source§impl From<&SorbetBatch> for RecordBatch
impl From<&SorbetBatch> for RecordBatch
Source§fn from(batch: &SorbetBatch) -> Self
fn from(batch: &SorbetBatch) -> Self
Source§impl From<SorbetBatch> for RecordBatch
impl From<SorbetBatch> for RecordBatch
Source§fn from(batch: SorbetBatch) -> Self
fn from(batch: SorbetBatch) -> Self
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 SorbetBatch
impl !RefUnwindSafe for SorbetBatch
impl Send for SorbetBatch
impl Sync for SorbetBatch
impl Unpin for SorbetBatch
impl !UnwindSafe for SorbetBatch
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