aglinxinyuan commented on code in PR #4444:
URL: https://github.com/apache/texera/pull/4444#discussion_r3151739252


##########
amber/src/main/scala/org/apache/texera/amber/engine/architecture/controller/ControllerProcessor.scala:
##########
@@ -43,8 +43,36 @@ class ControllerProcessor(
   val workflowExecution: WorkflowExecution = WorkflowExecution()
   val workflowScheduler: WorkflowScheduler =
     new WorkflowScheduler(workflowContext, actorId)
+  // The coordinator consumes regions through callbacks rather than reading 
Schedule directly.
+  // This cursor tracks the next ranked level to execute and can be reset when 
control flow
+  // requests jumping back to the region containing a target operator.
+  private var nextRegionLevel: Option[Int] = None
   val workflowExecutionCoordinator: WorkflowExecutionCoordinator = new 
WorkflowExecutionCoordinator(
-    () => this.workflowScheduler.getNextRegions,
+    () => {
+      Option(this.workflowScheduler.getSchedule)
+        .map { schedule =>
+          if (nextRegionLevel.isEmpty) {
+            nextRegionLevel = Some(schedule.startingLevel)
+          }
+          nextRegionLevel
+            .filter(schedule.levelSets.contains)
+            .map { level =>
+              nextRegionLevel = Some(level + 1)
+              schedule.levelSets(level)
+            }
+            .getOrElse(Set.empty)
+        }
+        .getOrElse(Set.empty)
+    },

Review Comment:
   I replaced the two inline lambdas with named methods in 
`ControllerProcessor`:
   - `getNextScheduledRegions()`
   - `jumpToRegionContainingOperator(...)`
   
   I also added comments to explain why the controller owns the cursor and why 
the coordinator consumes regions through callbacks instead of reading the 
schedule directly.



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