pub struct FileWriter<M: ManifestProvider + Send + Sync> {
pub object_writer: ObjectWriter,
/* private fields */
}
Expand description
FileWriter writes Arrow RecordBatch to one Lance file.
use lance::io::FileWriter;
use futures::stream::Stream;
let mut file_writer = FileWriter::new(object_store, &path, &schema);
while let Ok(batch) = stream.next().await {
file_writer.write(&batch).unwrap();
}
// Need to close file writer to flush buffer and footer.
file_writer.shutdown();
Fields§
§object_writer: ObjectWriter
Implementations§
Source§impl<M: ManifestProvider + Send + Sync> FileWriter<M>
impl<M: ManifestProvider + Send + Sync> FileWriter<M>
pub async fn try_new( object_store: &ObjectStore, path: &Path, schema: Schema, options: &FileWriterOptions, ) -> Result<Self>
pub fn with_object_writer( object_writer: ObjectWriter, schema: Schema, options: &FileWriterOptions, ) -> Result<Self>
Sourcepub async fn write(&mut self, batches: &[RecordBatch]) -> Result<()>
pub async fn write(&mut self, batches: &[RecordBatch]) -> Result<()>
Write a RecordBatch to the open file. All RecordBatch will be treated as one RecordBatch on disk
Returns Err if the schema does not match with the batch.
Sourcepub fn add_metadata(&mut self, key: &str, value: &str)
pub fn add_metadata(&mut self, key: &str, value: &str)
Add schema metadata, as (key, value) pair to the file.
pub async fn finish_with_metadata( &mut self, metadata: &HashMap<String, String>, ) -> Result<usize>
pub async fn finish(&mut self) -> Result<usize>
Sourcepub fn next_batch_id(&self) -> i32
pub fn next_batch_id(&self) -> i32
Return the id of the next batch to be written.
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl<M> Freeze for FileWriter<M>
impl<M> !RefUnwindSafe for FileWriter<M>
impl<M> Send for FileWriter<M>
impl<M> !Sync for FileWriter<M>
impl<M> Unpin for FileWriter<M>where
M: Unpin,
impl<M> !UnwindSafe for FileWriter<M>
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.