pub type AvroStreamWriter<W> = Writer<W, AvroSoeFormat>;展开描述
Avro 单个对象编码 (Single Object Encoding) 流写入器的别名。
§示例
此写入器会根据指纹策略,在每个记录的 Avro 主体前自动添加适当的每记录前缀。默认使用 Rabin 指纹的单个对象编码 (SOE)。
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());别名类型§
pub struct AvroStreamWriter<W> {
writer: W,
schema: Arc<Schema>,
format: AvroSoeFormat,
compression: Option<CompressionCodec>,
capacity: usize,
encoder: RecordEncoder,
}字段§
§writer: W§schema: Arc<Schema>§format: AvroSoeFormat§compression: Option<CompressionCodec>§capacity: usize§encoder: RecordEncoder