Skip to content

Commit

Permalink
renames
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyxu committed Sep 3, 2022
1 parent d3f97f9 commit a8513c2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cpp/src/lance/io/exec/limit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ ::arrow::Result<ScanBatch> Limit::Next() {
if (batch.eof()) {
return batch;
}
// Find intersection of two range (offset, offset + limit) and (seen + batch_size).
auto num_rows = batch.batch->num_rows();
// Find intersection of two ranges (offset, offset + limit) and (seen, seen + batch_size).
auto batch_size = batch.batch->num_rows();
auto left = std::max(offset_, seen_);
auto right = std::min(seen_ + num_rows, offset_ + limit_);
auto right = std::min(seen_ + batch_size, offset_ + limit_);
std::shared_ptr<::arrow::RecordBatch> record_batch;
if (left < right) {
record_batch = batch.batch->Slice(left - seen_, right - left);
} else {
/// No interaction, skip the whole batch.
/// No intersection, skip the whole batch.
ARROW_ASSIGN_OR_RAISE(record_batch, ::arrow::RecordBatch::MakeEmpty(batch.batch->schema()));
}
seen_ += num_rows;
seen_ += batch_size;
return ScanBatch{record_batch, batch.batch_id};
}

Expand Down

0 comments on commit a8513c2

Please sign in to comment.