andygrove commented on code in PR #2579:
URL:
https://github.com/apache/datafusion-ballista/pull/2579#discussion_r4276171535
##########
ballista/core/src/execution_plans/sort_shuffle/buffer.rs:
##########
@@ -129,58 +129,78 @@ mod tests {
use datafusion::arrow::datatypes::{DataType, Field, Schema};
use std::sync::Arc;
- fn create_test_schema() -> SchemaRef {
+ fn schema() -> SchemaRef {
Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, false)]))
}
- fn create_test_batch(schema: &SchemaRef, values: Vec<i32>) -> RecordBatch {
- let array = Int32Array::from(values);
- RecordBatch::try_new(schema.clone(), vec![Arc::new(array)]).unwrap()
+ fn batch(values: Vec<i32>) -> RecordBatch {
+ RecordBatch::try_new(schema(),
vec![Arc::new(Int32Array::from(values))]).unwrap()
+ }
+
+ /// Each partition `drain` visits, with its batches.
+ fn drain(bb: &mut BufferedBatches) -> Vec<(usize, Vec<RecordBatch>)> {
+ let mut out = vec![];
+ bb.drain(|p, batches| {
+ out.push((p, batches.collect::<Result<_>>()?));
+ Ok(())
+ })
+ .unwrap();
+ out
+ }
+
+ fn index_bytes(bb: &BufferedBatches) -> usize {
+ bb.indices
+ .iter()
+ .map(|v| v.capacity() * size_of::<(u32, u32)>())
+ .sum()
}
#[test]
- fn buffered_batches_pushes_and_partitions_indices() {
- let schema = create_test_schema();
- let mut bb = BufferedBatches::new(3, schema.clone());
+ fn drains_each_partition_in_arrival_order_and_batch_size() {
+ let mut bb = BufferedBatches::new(3, schema(), 2);
Review Comment:
With `batch_size` 2, partition 0's rows split exactly where the first input
batch ends, so this test can't tell "chunk by `batch_size`" from "one output
batch per input batch". With 3, the first output batch has to take rows from
both inputs:
```rust
let mut bb = BufferedBatches::new(3, schema(), 3);
// ...
(0, vec![batch(vec![10, 30, 50]), batch(vec![60])]),
```
That's what the coalescing layout in #2578 will have to reproduce, so it
seems worth pinning here.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]