pub struct UNIT_RECORD_BATCH { /* private fields */ }Methods from Deref<Target = RecordBatch>§
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 Deref for UNIT_RECORD_BATCH
impl Deref for UNIT_RECORD_BATCH
Source§type Target = RecordBatch
type Target = RecordBatch
Source§fn deref(&self) -> &RecordBatch
fn deref(&self) -> &RecordBatch
impl LazyStatic for UNIT_RECORD_BATCH
Auto Trait Implementations§
impl Freeze for UNIT_RECORD_BATCH
impl RefUnwindSafe for UNIT_RECORD_BATCH
impl Send for UNIT_RECORD_BATCH
impl Sync for UNIT_RECORD_BATCH
impl Unpin for UNIT_RECORD_BATCH
impl UnwindSafe for UNIT_RECORD_BATCH
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request