Xiao-zhen-Liu commented on code in PR #6729:
URL: https://github.com/apache/texera/pull/6729#discussion_r3696748190


##########
amber/src/main/scala/org/apache/texera/amber/engine/architecture/coordinator/execution/ExecutionUtils.scala:
##########
@@ -81,20 +82,30 @@ object ExecutionUtils {
     )
   }
 
+  /**
+    * Rolls a group of execution states up into one workflow-level state.
+    *
+    * When `cachedState` is provided and every state equals it, the group is
+    * reported as CACHE_REUSED. `cachedState` defaults to None, so an
+    * empty cache leaves this method byte-identical to before.
+    */
   def aggregateStates[T](
       states: Iterable[T],
       completedState: T,
       terminatedState: T,
       runningState: T,
       uninitializedState: T,
       pausedState: T,
-      readyState: T
+      readyState: T,
+      cachedState: Option[T] = None
   ): WorkflowAggregatedState = {
     states match {
       case _ if states.isEmpty                      => 
WorkflowAggregatedState.UNINITIALIZED
       case _ if states.forall(_ == completedState)  => 
WorkflowAggregatedState.COMPLETED
       case _ if states.forall(_ == terminatedState) => 
WorkflowAggregatedState.COMPLETED
-      case _ if states.exists(_ == runningState)    => 
WorkflowAggregatedState.RUNNING
+      case _ if cachedState.isDefined && states.forall(_ == cachedState.get) =>

Review Comment:
   Adopted, thanks. Rebased onto #6011's merged terminal branch and treated 
cached as terminal there:
   
   - all cached returns CACHE_REUSED, checked first
   - completed plus cached returns COMPLETED
   - cached plus paused or ready returns PAUSED or RUNNING
   
   One deviation: the remainder step drops completed and cached but not 
terminated. Dropping terminated would change results with no cache involved, 
for example terminated plus paused is UNKNOWN on main today and would become 
PAUSED. There is a comment and a test for it.
   
   Empty cache is unchanged: with `cachedState = None` each branch reduces to 
main's. I ran both versions over every input up to length 4, no differences.
   



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