pub type AvroStreamWriter<W> = Writer<W, AvroSoeFormat>;
Expand description
Alias for an Avro Single Object Encoding stream writer.
§Example
This writer automatically adds the appropriate per-record prefix (based on the fingerprint strategy) before the Avro body of each record. The default is Single Object Encoding (SOE) with a Rabin fingerprint.
use std::sync::Arc;
use arrow_array::{ArrayRef, Int64Array, RecordBatch};
use arrow_schema::{DataType, Field, Schema};
use arrow_avro::writer::AvroStreamWriter;
// One‑column Arrow batch
let schema = Schema::new(vec![Field::new("x", DataType::Int64, false)]);
let batch = RecordBatch::try_new(
Arc::new(schema.clone()),
vec![Arc::new(Int64Array::from(vec![10, 20])) as ArrayRef],
)?;
// Write an Avro Single Object Encoding stream to a Vec<u8>
let sink: Vec<u8> = Vec::new();
let mut w = AvroStreamWriter::new(sink, schema)?;
w.write(&batch)?;
w.finish()?;
let bytes = w.into_inner();
assert!(!bytes.is_empty());
Aliased Type§
pub struct AvroStreamWriter<W> {
writer: W,
schema: Arc<Schema>,
format: AvroSoeFormat,
compression: Option<CompressionCodec>,
capacity: usize,
encoder: RecordEncoder,
}
Fields§
§writer: W
§schema: Arc<Schema>
§format: AvroSoeFormat
§compression: Option<CompressionCodec>
§capacity: usize
§encoder: RecordEncoder