alamb commented on code in PR #12070:
URL: https://github.com/apache/arrow-rs/pull/12070#discussion_r4466886587
##########
arrow-ipc/benches/ipc_reader.rs:
##########
@@ -185,6 +188,47 @@ fn criterion_benchmark(c: &mut Criterion) {
}
})
});
+
+ for (name, nested) in [("flat", false), ("nested", true)] {
+ let buffer = wide_dictionary_ipc_stream(1000, nested);
+ group.bench_function(format!("StreamReader/dictionaries_1000/{name}"),
|b| {
+ b.iter(|| {
+ let mut reader = StreamReader::try_new(buffer.as_slice(),
None).unwrap();
+ reader.next().unwrap().unwrap();
+ assert!(reader.next().is_none());
+ })
+ });
+ }
+}
+
+/// Return an IPC stream with one small record batch of `num_columns`
dictionary columns, so the
+/// stream holds `num_columns` dictionary batches. With `nested`, each
dictionary is a list item.
+fn wide_dictionary_ipc_stream(num_columns: usize, nested: bool) -> Vec<u8> {
+ let dictionary: ArrayRef = Arc::new(
Review Comment:
would it make sense to also make a larger cardinality dictionary benchmark
as well (maybe 4k distinct values) in addition to this small dictionary?
##########
arrow-ipc/benches/ipc_reader.rs:
##########
@@ -185,6 +188,47 @@ fn criterion_benchmark(c: &mut Criterion) {
}
})
});
+
+ for (name, nested) in [("flat", false), ("nested", true)] {
+ let buffer = wide_dictionary_ipc_stream(1000, nested);
+ group.bench_function(format!("StreamReader/dictionaries_1000/{name}"),
|b| {
+ b.iter(|| {
+ let mut reader = StreamReader::try_new(buffer.as_slice(),
None).unwrap();
+ reader.next().unwrap().unwrap();
+ assert!(reader.next().is_none());
+ })
+ });
+ }
+}
+
+/// Return an IPC stream with one small record batch of `num_columns`
dictionary columns, so the
+/// stream holds `num_columns` dictionary batches. With `nested`, each
dictionary is a list item.
+fn wide_dictionary_ipc_stream(num_columns: usize, nested: bool) -> Vec<u8> {
+ let dictionary: ArrayRef = Arc::new(
+ ["a", "b", "a", "c"]
+ .into_iter()
+ .collect::<DictionaryArray<Int32Type>>(),
+ );
+ let column = if nested {
+ let item = Arc::new(Field::new("item", dictionary.data_type().clone(),
true));
+ Arc::new(ListArray::new(
+ item,
+ OffsetBuffer::from_lengths([2, 2]),
Review Comment:
this a 2 element list, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]