Skip to content

Commit 86634a5

Browse files
committed
fix C++ test
Signed-off-by: Andrew Duffy <[email protected]>
1 parent 8138d66 commit 86634a5

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

vortex-cxx/cpp/tests/basic_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ TEST_F(VortexTest, ScanBuilderWithRowRangeWithIncludeByIndex) {
242242

243243
RunScanBuilderTest(
244244
[&include_by_index](vortex::ScanBuilder &scan_builder) {
245-
return std::move(scan_builder.WithRowRange(2, 6).WithIncludeByIndex(include_by_index.data(),
245+
return std::move(scan_builder.WithRowRange(2, 5).WithIncludeByIndex(include_by_index.data(),
246246
include_by_index.size()))
247247
.IntoStream();
248248
},

vortex-layout/src/layouts/chunked/reader.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::sync::Arc;
88
use futures::future::BoxFuture;
99
use futures::stream::FuturesOrdered;
1010
use futures::{FutureExt, TryStreamExt};
11+
use itertools::Itertools;
1112
use vortex_array::arrays::ChunkedArray;
1213
use vortex_array::{ArrayRef, MaskFuture};
1314
use vortex_dtype::{DType, FieldMask};
@@ -152,18 +153,30 @@ impl LayoutReader for ChunkedReader {
152153
row_range: &Range<u64>,
153154
splits: &mut BTreeSet<u64>,
154155
) -> VortexResult<()> {
155-
let mut offset = row_range.start;
156-
for i in 0..self.layout.nchildren() {
157-
// Bail early if the row range only overlaps with a subset of the chunks
158-
if offset >= row_range.end {
156+
for (index, (&start, &end)) in self
157+
.chunk_offsets
158+
.iter()
159+
.tuple_windows::<(_, _)>()
160+
.enumerate()
161+
{
162+
if end < row_range.start {
163+
continue;
164+
}
165+
166+
if start >= row_range.end {
159167
break;
160168
}
161169

162-
let child = self.chunk_reader(i)?;
163-
let child_range = offset..offset + child.row_count();
170+
// Child overlaps in whole or in part with split
171+
let child = self.chunk_reader(index)?;
172+
let child_range =
173+
std::cmp::max(row_range.start, start)..std::cmp::min(row_range.end, end);
174+
175+
// Register any splits from the child
164176
child.register_splits(field_mask, &child_range, splits)?;
165-
offset = child_range.end;
166-
splits.insert(offset);
177+
178+
// Register the split indicating the end of this chunk
179+
splits.insert(child_range.end);
167180
}
168181

169182
Ok(())

0 commit comments

Comments
 (0)