Skip to content

Commit

Permalink
Use raw vec instead of Cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed May 23, 2022
1 parent 2620f45 commit c57aa9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 2 additions & 4 deletions parquet/benches/arrow_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

#[macro_use]
extern crate criterion;

use criterion::{Criterion, Throughput};
use std::io::Cursor;

extern crate arrow;
extern crate parquet;
Expand Down Expand Up @@ -278,8 +276,8 @@ fn _create_nested_bench_batch(
#[inline]
fn write_batch(batch: &RecordBatch) -> Result<()> {
// Write batch to an in-memory writer
let cursor = Cursor::new(vec![]);
let mut writer = ArrowWriter::try_new(cursor, batch.schema(), None)?;
let buffer = vec![];
let mut writer = ArrowWriter::try_new(buffer, batch.schema(), None)?;

writer.write(batch)?;
writer.close()?;
Expand Down
7 changes: 2 additions & 5 deletions parquet/src/arrow/arrow_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ mod tests {
use super::*;

use std::fs::File;
use std::io::Cursor;
use std::sync::Arc;

use arrow::datatypes::ToByteSlice;
Expand Down Expand Up @@ -748,16 +747,14 @@ mod tests {
let expected_batch =
RecordBatch::try_new(schema.clone(), vec![Arc::new(a), Arc::new(b)]).unwrap();

let mut cursor = Cursor::new(vec![]);
let mut buffer = vec![];

{
let mut writer = ArrowWriter::try_new(&mut cursor, schema, None).unwrap();
let mut writer = ArrowWriter::try_new(&mut buffer, schema, None).unwrap();
writer.write(&expected_batch).unwrap();
writer.close().unwrap();
}

let buffer = cursor.into_inner();

let cursor = crate::file::serialized_reader::SliceableCursor::new(buffer);
let reader = SerializedFileReader::new(cursor).unwrap();
let mut arrow_reader = ParquetFileArrowReader::new(Arc::new(reader));
Expand Down

0 comments on commit c57aa9e

Please sign in to comment.