Struct polars_io::parquet::BatchedWriter
source · pub struct BatchedWriter<W: Write> { /* private fields */ }Available on crate feature
feature only.Implementations§
source§impl<W: Write> BatchedWriter<W>
impl<W: Write> BatchedWriter<W>
sourcepub fn write_batch(&mut self, df: &DataFrame) -> PolarsResult<()>
pub fn write_batch(&mut self, df: &DataFrame) -> PolarsResult<()>
Write a batch to the parquet writer.
Panics
The caller must ensure the chunks in the given DataFrame are aligned.
Examples found in repository?
src/parquet/write.rs (line 185)
174 175 176 177 178 179 180 181 182 183 184 185 186 187
pub fn finish(self, df: &mut DataFrame) -> PolarsResult<u64> {
// ensures all chunks are aligned.
df.rechunk();
if let Some(n) = self.row_group_size {
let n_splits = df.height() / n;
if n_splits > 0 {
*df = accumulate_dataframes_vertical_unchecked(split_df(df, n_splits)?);
}
};
let mut batched = self.batched(&df.schema())?;
batched.write_batch(df)?;
batched.finish()
}sourcepub fn finish(&mut self) -> PolarsResult<u64>
pub fn finish(&mut self) -> PolarsResult<u64>
Writes the footer of the parquet file. Returns the total size of the file.
Examples found in repository?
src/parquet/write.rs (line 186)
174 175 176 177 178 179 180 181 182 183 184 185 186 187
pub fn finish(self, df: &mut DataFrame) -> PolarsResult<u64> {
// ensures all chunks are aligned.
df.rechunk();
if let Some(n) = self.row_group_size {
let n_splits = df.height() / n;
if n_splits > 0 {
*df = accumulate_dataframes_vertical_unchecked(split_df(df, n_splits)?);
}
};
let mut batched = self.batched(&df.schema())?;
batched.write_batch(df)?;
batched.finish()
}