jorgecarleitao commented on a change in pull request #8428:
URL: https://github.com/apache/arrow/pull/8428#discussion_r502821593
##########
File path: rust/datafusion/src/datasource/memory.rs
##########
@@ -59,13 +61,22 @@ impl MemTable {
pub async fn load(t: &dyn TableProvider, batch_size: usize) ->
Result<Self> {
let schema = t.schema();
let exec = t.scan(&None, batch_size)?;
+ let partition_count = exec.output_partitioning().partition_count();
+
+ let mut tasks = Vec::with_capacity(partition_count);
+ for partition in 0..partition_count {
+ let exec = exec.clone();
+ let task: JoinHandle<Result<Vec<RecordBatch>>> = task::spawn(async
move {
+ let it = exec.execute(partition).await?;
+ Ok(it.into_iter().collect::<ArrowResult<Vec<RecordBatch>>>()?)
Review comment:
```suggestion
it.into_iter().collect::<ArrowResult<Vec<RecordBatch>>>()
```
##########
File path: rust/datafusion/src/datasource/memory.rs
##########
@@ -59,13 +61,22 @@ impl MemTable {
pub async fn load(t: &dyn TableProvider, batch_size: usize) ->
Result<Self> {
let schema = t.schema();
let exec = t.scan(&None, batch_size)?;
+ let partition_count = exec.output_partitioning().partition_count();
+
+ let mut tasks = Vec::with_capacity(partition_count);
+ for partition in 0..partition_count {
+ let exec = exec.clone();
+ let task: JoinHandle<Result<Vec<RecordBatch>>> = task::spawn(async
move {
+ let it = exec.execute(partition).await?;
+ Ok(it.into_iter().collect::<ArrowResult<Vec<RecordBatch>>>()?)
+ });
+ tasks.push(task)
+ }
- let mut data: Vec<Vec<RecordBatch>> =
- Vec::with_capacity(exec.output_partitioning().partition_count());
- for partition in 0..exec.output_partitioning().partition_count() {
- let it = exec.execute(partition).await?;
- let partition_batches =
it.into_iter().collect::<ArrowResult<Vec<_>>>()?;
- data.push(partition_batches);
+ let mut data: Vec<Vec<RecordBatch>> =
Vec::with_capacity(partition_count);
+ for task in tasks {
+ let result = task.await.unwrap()?;
Review comment:
```suggestion
let result = task.await.expect("To have some data on every
recordBatch")?;
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]