pub(crate) struct RecordEncoder {
columns: Vec<FieldBinding>,
prefix: Option<Prefix>,
}Expand description
A pre-computed plan for encoding a RecordBatch to Avro.
Derived from an Avro schema and an Arrow schema. It maps top-level Avro fields to Arrow columns and contains a nested encoding plan for each column.
Fields§
§columns: Vec<FieldBinding>§prefix: Option<Prefix>Optional pre-built, variable-length prefix written before each record.
Implementations§
Source§impl RecordEncoder
impl RecordEncoder
fn prepare_for_batch<'a>( &'a self, batch: &'a RecordBatch, ) -> Result<Vec<FieldEncoder<'a>>, AvroError>
Sourcepub(crate) fn encode<W: Write>(
&self,
out: &mut W,
batch: &RecordBatch,
) -> Result<(), AvroError>
pub(crate) fn encode<W: Write>( &self, out: &mut W, batch: &RecordBatch, ) -> Result<(), AvroError>
Encode a RecordBatch using this encoder plan.
Tip: Wrap out in a std::io::BufWriter to reduce the overhead of many small writes.
Sourcepub(crate) fn encode_rows(
&self,
batch: &RecordBatch,
row_capacity: usize,
out: &mut BytesMut,
offsets: &mut Vec<usize>,
) -> Result<(), AvroError>
pub(crate) fn encode_rows( &self, batch: &RecordBatch, row_capacity: usize, out: &mut BytesMut, offsets: &mut Vec<usize>, ) -> Result<(), AvroError>
Encode rows into a single contiguous BytesMut and append row-end offsets.
§Invariants
offsetsmust be non-empty and seeded with0at index 0.offsets.last()must equalout.len()on entry.- On success, exactly
batch.num_rows()additional offsets are pushed, andoffsets.last()equals the newout.len().
Trait Implementations§
Source§impl Clone for RecordEncoder
impl Clone for RecordEncoder
Source§fn clone(&self) -> RecordEncoder
fn clone(&self) -> RecordEncoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RecordEncoder
impl RefUnwindSafe for RecordEncoder
impl Send for RecordEncoder
impl Sync for RecordEncoder
impl Unpin for RecordEncoder
impl UnwindSafe for RecordEncoder
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
Mutably borrows from an owned value. Read more