Struct mz_testdrive::format::avro::Writer
source · pub struct Writer<W> {
schema: Schema,
writer: W,
buffer: Vec<u8>,
num_values: usize,
codec: Option<Codec>,
marker: [u8; 16],
has_header: bool,
}
Expand description
Main interface for writing Avro Object Container Files.
Fields§
§schema: Schema
§writer: W
§buffer: Vec<u8>
§num_values: usize
§codec: Option<Codec>
§marker: [u8; 16]
§has_header: bool
Implementations§
source§impl<W> Writer<W>where
W: Write,
impl<W> Writer<W>where W: Write,
sourcepub fn new(schema: Schema, writer: W) -> Writer<W>
pub fn new(schema: Schema, writer: W) -> Writer<W>
Creates a Writer
for the Schema
and something implementing the std::io::Write
trait to write to.
This uses the no-compression Codec::Null
when appending records.
sourcepub fn with_codec(schema: Schema, writer: W, codec: Codec) -> Writer<W>
pub fn with_codec(schema: Schema, writer: W, codec: Codec) -> Writer<W>
sourcepub fn with_codec_opt(
schema: Schema,
writer: W,
codec: Option<Codec>
) -> Writer<W>
pub fn with_codec_opt( schema: Schema, writer: W, codec: Option<Codec> ) -> Writer<W>
Create a Writer
with the given parameters.
All parameters have the same meaning as with_codec
, but if codec
is None
then no compression will be used and the avro.codec
field in the header will be
omitted.
sourcepub fn append_to(file: W) -> Result<Writer<W>, Error>where
W: AvroRead + Seek + Unpin + Send,
pub fn append_to(file: W) -> Result<Writer<W>, Error>where W: AvroRead + Seek + Unpin + Send,
Creates a Writer
that appends to an existing OCF file.
sourcepub fn append<T>(&mut self, value: T) -> Result<usize, Error>where
T: ToAvro,
pub fn append<T>(&mut self, value: T) -> Result<usize, Error>where T: ToAvro,
Append a compatible value (implementing the ToAvro
trait) to a Writer
, also performing
schema validation.
Return the number of bytes written (it might be 0, see below).
NOTE This function is not guaranteed to perform any actual write, since it relies on
internal buffering for performance reasons. If you want to be sure the value has been
written, then call flush
.
sourcepub fn append_value_ref(&mut self, value: &Value) -> Result<usize, Error>
pub fn append_value_ref(&mut self, value: &Value) -> Result<usize, Error>
Append a compatible value to a Writer
, also performing schema validation.
Return the number of bytes written (it might be 0, see below).
NOTE This function is not guaranteed to perform any actual write, since it relies on
internal buffering for performance reasons. If you want to be sure the value has been
written, then call flush
.
sourcepub fn extend<I, T>(&mut self, values: I) -> Result<usize, Error>where
T: ToAvro,
I: IntoIterator<Item = T>,
pub fn extend<I, T>(&mut self, values: I) -> Result<usize, Error>where T: ToAvro, I: IntoIterator<Item = T>,
Extend a Writer
with an Iterator
of compatible values (implementing the ToAvro
trait), also performing schema validation.
Return the number of bytes written.
NOTE This function forces the written data to be flushed (an implicit
call to flush
is performed).
sourcepub fn extend_from_slice(&mut self, values: &[Value]) -> Result<usize, Error>
pub fn extend_from_slice(&mut self, values: &[Value]) -> Result<usize, Error>
Extend a Writer
by appending each Value
from a slice, while also performing schema
validation on each value appended.
Return the number of bytes written.
NOTE This function forces the written data to be flushed (an implicit
call to flush
is performed).
sourcepub fn flush(&mut self) -> Result<usize, Error>
pub fn flush(&mut self) -> Result<usize, Error>
Flush the content appended to a Writer
. Call this function to make sure all the content
has been written before releasing the Writer
.
Return the number of bytes written.
sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Return what the Writer
is writing to, consuming the Writer
itself.
NOTE This function doesn’t guarantee that everything gets written before consuming the
buffer. Please call flush
before.
Auto Trait Implementations§
impl<W> RefUnwindSafe for Writer<W>where W: RefUnwindSafe,
impl<W> Send for Writer<W>where W: Send,
impl<W> Sync for Writer<W>where W: Sync,
impl<W> Unpin for Writer<W>where W: Unpin,
impl<W> UnwindSafe for Writer<W>where W: UnwindSafe,
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
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.