Skip to content

Commit 4d5aad6

Browse files
committed
refine the check logic
1 parent e65b69a commit 4d5aad6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/query/storages/fuse/src/io/read/block_reader_parquet.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,13 @@ impl BlockReader {
328328
}
329329
let now = SystemTime::now();
330330
let mut final_result = Vec::new();
331-
let mut merge_results = futures::future::try_join_all(merge_io_handlers).await?;
332-
merge_results.sort_by(|a, b| a.0.cmp(&b.0));
331+
let merge_results = futures::future::try_join_all(merge_io_handlers).await?;
333332
for index in indices.keys() {
334333
let column_meta = &part.columns_meta[index];
335334
let column_start = column_meta.offset;
336335
let column_end = column_start + column_meta.len;
337336

337+
// Find the range index and range.
338338
let range_idx = range_merger.get(column_start..column_end);
339339
let (idx, range) = match range_idx {
340340
None => Err(ErrorCode::Internal(format!(
@@ -343,9 +343,19 @@ impl BlockReader {
343343
))),
344344
Some((i, r)) => Ok((i, r)),
345345
}?;
346-
let data = &merge_results[idx].1;
347-
let column_data = data
348-
[(column_start - range.start) as usize..(column_end - column_start) as usize]
346+
347+
// For loop but not move data.
348+
let mut range_data = None;
349+
for (i, data) in &merge_results {
350+
if *i == idx {
351+
range_data = Some(data);
352+
break;
353+
}
354+
}
355+
356+
// Here has data copy.
357+
let column_data = range_data.unwrap()[(column_start - range.start - 1) as usize
358+
..(column_end - column_start - 1) as usize]
349359
.to_vec();
350360
final_result.push((*index, column_data));
351361
}

0 commit comments

Comments
 (0)