pub struct AsyncArrowWriter<W> { /* private fields */ }
Expand description

Encodes RecordBatch to parquet, outputting to an AsyncWrite

§Memory Usage

This writer eagerly writes data as soon as possible to the underlying AsyncWrite, permitting fine-grained control over buffering and I/O scheduling. However, the columnar nature of parquet forces data for an entire row group to be buffered in memory, before it can be flushed. Depending on the data and the configured row group size, this buffering may be substantial.

Memory usage can be limited by calling Self::flush to flush the in progress row group, although this will likely increase overall file size and reduce query performance. See ArrowWriter for more information.

let mut writer: AsyncArrowWriter<File> = todo!();
let batch: RecordBatch = todo!();
writer.write(&batch).await.unwrap();
// Trigger an early flush if buffered size exceeds 1_000_000
if writer.in_progress_size() > 1_000_000 {
    writer.flush().await.unwrap()
}

Implementations§

source§

impl<W: AsyncWrite + Unpin + Send> AsyncArrowWriter<W>

source

pub fn try_new( writer: W, arrow_schema: SchemaRef, props: Option<WriterProperties> ) -> Result<Self>

Try to create a new Async Arrow Writer

source

pub fn try_new_with_options( writer: W, arrow_schema: SchemaRef, options: ArrowWriterOptions ) -> Result<Self>

Try to create a new Async Arrow Writer with ArrowWriterOptions

source

pub fn flushed_row_groups(&self) -> &[RowGroupMetaDataPtr]

Returns metadata for any flushed row groups

source

pub fn in_progress_size(&self) -> usize

Returns the estimated length in bytes of the current in progress row group

source

pub fn in_progress_rows(&self) -> usize

Returns the number of rows buffered in the in progress row group

source

pub fn bytes_written(&self) -> usize

Returns the number of bytes written by this instance

source

pub async fn write(&mut self, batch: &RecordBatch) -> Result<()>

Enqueues the provided RecordBatch to be written

After every sync write by the inner ArrowWriter, the inner buffer will be checked and flush if at least half full

source

pub async fn flush(&mut self) -> Result<()>

Flushes all buffered rows into a new row group

source

pub fn append_key_value_metadata(&mut self, kv_metadata: KeyValue)

Append KeyValue metadata in addition to those in WriterProperties

This method allows to append metadata after RecordBatches are written.

source

pub async fn close(self) -> Result<FileMetaData>

Close and finalize the writer.

All the data in the inner buffer will be force flushed.

Auto Trait Implementations§

§

impl<W> Freeze for AsyncArrowWriter<W>
where W: Freeze,

§

impl<W> !RefUnwindSafe for AsyncArrowWriter<W>

§

impl<W> Send for AsyncArrowWriter<W>
where W: Send,

§

impl<W> !Sync for AsyncArrowWriter<W>

§

impl<W> Unpin for AsyncArrowWriter<W>
where W: Unpin,

§

impl<W> !UnwindSafe for AsyncArrowWriter<W>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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 T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.