pub struct AvroFileConsumer { /* private fields */ }Implementations§
Source§impl AvroFileConsumer
impl AvroFileConsumer
pub fn new( directory: impl Into<PathBuf>, file_prefix: Option<String>, dataset_rid: Option<ResourceIdentifier>, ) -> Result<Self>
Sourcepub fn new_with_full_path(
file_path: impl Into<PathBuf>,
overwrite: bool,
dataset_rid: Option<ResourceIdentifier>,
) -> Result<Self>
pub fn new_with_full_path( file_path: impl Into<PathBuf>, overwrite: bool, dataset_rid: Option<ResourceIdentifier>, ) -> Result<Self>
Opens file_path for writing and wraps it in an avro Writer.
If overwrite is true and the path already exists, its prior contents
are discarded. Truncation is required when reusing a path: the avro
container format is single-header-and-blocks, so opening a longer
existing file without truncating would leave leftover bytes from the
previous run past the new content’s end and produce a corrupt reader
stream.
If overwrite is false and the path already exists, an
io::ErrorKind::AlreadyExists error is returned and no file is
touched. This is the safe choice when the caller does not want to
silently destroy prior data.
If dataset_rid is provided, it is written to the avro file’s user
metadata under the nominal.dataset_rid key so downstream readers
can identify the dataset the file belongs to.
Trait Implementations§
Source§impl Clone for AvroFileConsumer
impl Clone for AvroFileConsumer
Source§fn clone(&self) -> AvroFileConsumer
fn clone(&self) -> AvroFileConsumer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AvroFileConsumer
impl Debug for AvroFileConsumer
Source§impl Drop for AvroFileConsumer
impl Drop for AvroFileConsumer
Source§fn drop(&mut self)
fn drop(&mut self)
Defensive flush-on-drop. In normal operation, records reach disk via
append_series → apache_avro::Writer::extend, which flushes at the
end of every call. But apache_avro::Writer itself does not flush on
drop, so any code path that bypasses extend (e.g. a direct
Writer::append, or a future writer call that forgets to flush) would
silently lose buffered records when the consumer goes out of scope.
This impl makes that failure mode impossible regardless of how the
inner writer is driven.
Source§impl WriteRequestConsumer for AvroFileConsumer
impl WriteRequestConsumer for AvroFileConsumer
fn consume(&self, request: &WriteRequestNominal) -> ConsumerResult<()>
Auto Trait Implementations§
impl Freeze for AvroFileConsumer
impl !RefUnwindSafe for AvroFileConsumer
impl Send for AvroFileConsumer
impl Sync for AvroFileConsumer
impl Unpin for AvroFileConsumer
impl UnsafeUnpin for AvroFileConsumer
impl !UnwindSafe for AvroFileConsumer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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