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

source

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.

source

pub fn push<T: Serialize + ?Sized>(&mut self, item: &T) -> Result<()>

Add a single item to the arrays

source

pub fn extend<T: Serialize + ?Sized>(&mut self, items: &T) -> Result<()>

Add multiple item to the arrays

source

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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.