Kontinuation commented on code in PR #525:
URL: https://github.com/apache/sedona-db/pull/525#discussion_r2704397683


##########
rust/sedona-spatial-join/src/stream.rs:
##########
@@ -532,68 +626,117 @@ impl SpatialJoinBatchIterator {
             build_side: params.build_side,
             spatial_index: params.spatial_index,
             probe_evaluated_batch: params.probe_evaluated_batch,
-            current_probe_idx: 0,
             join_metrics: params.join_metrics,
             max_batch_size: params.max_batch_size,
             probe_side_ordered: params.probe_side_ordered,
-            build_batch_positions: Vec::new(),
-            probe_indices: Vec::new(),
-            is_complete: false,
             spatial_predicate: params.spatial_predicate,
             options: params.options,
+            progress: Some(ProbeProgress {
+                current_probe_idx: 0,
+                last_produced_probe_idx: -1,
+                build_batch_positions: Vec::new(),
+                probe_indices: Vec::new(),
+                pos: 0,
+            }),
         })
     }
 
     pub async fn next_batch(&mut self) -> Result<Option<RecordBatch>> {
-        if self.is_complete {
-            return Ok(None);
-        }
+        let progress_opt = std::mem::take(&mut self.progress);
+        let mut progress = progress_opt.expect("Progress should be available");
+        let res = self.next_batch_inner(&mut progress).await;
+        self.progress = Some(progress);
+        res

Review Comment:
   This is incorrect. We use `std::mem::take` to make the borrow checker happy. 
Applying this patch will yield the following compile error:
   
   ```
   error[E0502]: cannot borrow `*self` as immutable because it is also borrowed 
as mutable
      --> rust/sedona-spatial-join/src/stream.rs:654:9
       |
   650 |           let progress = self
       |  ________________________-
   651 | |                 .progress
       | |_________________________- mutable borrow occurs here
   ...
   654 |           self.next_batch_inner(progress).await
       |           ^^^^                  -------- mutable borrow later used here
       |           |
       |           immutable borrow occurs here
   ```



-- 
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]

Reply via email to