-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement take for StreamArrayReader (#266)
- Loading branch information
Showing
10 changed files
with
535 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use std::io::Cursor; | ||
|
||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use itertools::Itertools; | ||
use vortex::array::primitive::PrimitiveArray; | ||
use vortex::{IntoArray, SerdeContext}; | ||
use vortex_ipc::iter::FallibleLendingIterator; | ||
use vortex_ipc::reader::StreamReader; | ||
use vortex_ipc::writer::StreamWriter; | ||
use vortex_schema::{DType, Nullability, Signedness}; | ||
|
||
// 100 record batches, 100k rows each | ||
// take from the first 20 batches and last batch | ||
// compare with arrow | ||
fn ipc_array_reader_take(c: &mut Criterion) { | ||
let indices = (0..20) | ||
.map(|i| i * 100_000 + 1) | ||
.chain([98 * 100_000 + 1]) | ||
.collect_vec(); | ||
let mut group = c.benchmark_group("ipc_array_reader_take"); | ||
|
||
group.bench_function("vortex", |b| { | ||
let mut buffer = vec![]; | ||
{ | ||
let mut cursor = Cursor::new(&mut buffer); | ||
let mut writer = StreamWriter::try_new(&mut cursor, SerdeContext::default()).unwrap(); | ||
writer | ||
.write_schema(&DType::Int( | ||
32.into(), | ||
Signedness::Signed, | ||
Nullability::Nullable, | ||
)) | ||
.unwrap(); | ||
(0..100i32).for_each(|i| { | ||
let data = PrimitiveArray::from(vec![i; 100_000]).into_array(); | ||
writer.write_batch(&data).unwrap(); | ||
}); | ||
} | ||
let indices = indices.clone().into_array(); | ||
|
||
b.iter(|| { | ||
let mut cursor = Cursor::new(&buffer); | ||
let mut reader = StreamReader::try_new(&mut cursor).unwrap(); | ||
let array_reader = reader.next().unwrap().unwrap(); | ||
black_box(array_reader.take(&indices)) | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, ipc_array_reader_take); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.