pub struct SorbetBatch { /* private fields */ }Expand description
Any rerun-compatible ArrowRecordBatch.
This is a wrapper around a SorbetSchema and a ArrowRecordBatch.
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>§
Sourcepub fn schema_ref(&self) -> &Arc<Schema>
pub fn schema_ref(&self) -> &Arc<Schema>
Returns a reference to the Schema of the record batch.
Sourcepub fn project(&self, indices: &[usize]) -> Result<RecordBatch, ArrowError>
pub fn project(&self, indices: &[usize]) -> Result<RecordBatch, ArrowError>
Projects the schema onto the specified columns
Sourcepub 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 Fields 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": Utf8Note 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);Sourcepub 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);Sourcepub 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);Sourcepub 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.
Sourcepub 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.
Sourcepub 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§fn as_ref(&self) -> &ArrowRecordBatch
fn as_ref(&self) -> &ArrowRecordBatch
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§type Target = RecordBatch
type Target = RecordBatch
Source§fn deref(&self) -> &ArrowRecordBatch
fn deref(&self) -> &ArrowRecordBatch
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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