Struct serde_arrow::arrow::ArrayBuilder
source · pub struct ArrayBuilder { /* private fields */ }Expand description
Build a single array item by item
Example:
use arrow::datatypes::{Field, DataType};
use serde_arrow::arrow::ArrayBuilder;
let field = Field::new("value", DataType::Int64, false);
let mut builder = ArrayBuilder::new(&field).unwrap();
builder.push(&-1_i64).unwrap();
builder.push(&2_i64).unwrap();
builder.push(&-3_i64).unwrap();
builder.extend(&[4_i64, -5, 6]).unwrap();
let array = builder.build_array().unwrap();
assert_eq!(array.len(), 6);Implementations§
source§impl ArrayBuilder
impl ArrayBuilder
sourcepub fn new(field: &Field) -> Result<Self>
pub fn new(field: &Field) -> Result<Self>
Construct a new build for the given field
This method may fail for an unsupported data type of the given field.
sourcepub fn push<T: Serialize + ?Sized>(&mut self, item: &T) -> Result<()>
pub fn push<T: Serialize + ?Sized>(&mut self, item: &T) -> Result<()>
Add a single item to the arrays
sourcepub fn extend<T: Serialize + ?Sized>(&mut self, items: &T) -> Result<()>
pub fn extend<T: Serialize + ?Sized>(&mut self, items: &T) -> Result<()>
Add multiple item to the arrays
sourcepub fn build_array(&mut self) -> Result<ArrayRef>
pub fn build_array(&mut self) -> Result<ArrayRef>
Build the array from the rows pushed to far.
This operation will reset the underlying buffers and start a new batch.