fresh-borzoni commented on code in PR #154:
URL: https://github.com/apache/fluss-rust/pull/154#discussion_r2729577746
##########
bindings/python/src/table.rs:
##########
@@ -960,31 +960,56 @@ impl LogScanner {
.block_on(async {
self.inner.poll(Duration::from_millis(500)).await });
match batch_result {
- Ok(scan_records) => {
- let mut result_records: Vec<fcore::record::ScanRecord>
= vec![];
- for (bucket, records) in
scan_records.into_records_by_buckets() {
- let stopping_offset =
stopping_offsets.get(&bucket.bucket_id());
-
- if stopping_offset.is_none() {
- // not to include this bucket, skip records
for this bucket
- // since we already reach end offset for this
bucket
- continue;
- }
- if let Some(last_record) = records.last() {
- let offset = last_record.offset();
- result_records.extend(records);
- if offset >= stopping_offset.unwrap() - 1 {
-
stopping_offsets.remove(&bucket.bucket_id());
+ Ok(scan_batches) => {
+ for scan_batch in scan_batches {
+ let bucket_id = scan_batch.bucket().bucket_id();
+
+ // Extract stopping_offset once to avoid double
unwrap
+ let stop_exclusive = match
stopping_offsets.get(&bucket_id) {
+ Some(&offset) => offset,
+ None => {
+ // we already reached end offset for this
bucket
+ continue;
}
- }
- }
+ };
+
+ // Compute the inclusive last offset we want
(stop_exclusive - 1)
+ let stop_inclusive = match
stop_exclusive.checked_sub(1) {
+ Some(v) => v,
+ None => {
+ // stop_exclusive was 0 or negative -
nothing to read
Review Comment:
Yes, I messed here, thx for a nice suggestion 👍
--
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]