pub type AvroStreamWriter<W> = Writer<W, AvroBinaryFormat>;
Expand description
Alias for a raw Avro binary stream writer.
§Example
This writes only the Avro body bytes — no OCF header/sync and no single‑object or Confluent framing. If you need those frames, add them externally.
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 a raw Avro 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: AvroBinaryFormat,
compression: Option<CompressionCodec>,
capacity: usize,
encoder: RecordEncoder,
}
Fields§
§writer: W
§schema: Arc<Schema>
§format: AvroBinaryFormat
§compression: Option<CompressionCodec>
§capacity: usize
§encoder: RecordEncoder