Yicong-Huang commented on code in PR #8552:
URL: https://github.com/apache/texera/pull/8552#discussion_r4053545357


##########
frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.ts:
##########
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { OperatorRuntimeStatus, OperatorState } from 
"../../types/execute-workflow.interface";
+import { WorkflowRuntimeStatistics } from 
"../../../dashboard/type/workflow-runtime-statistics";
+
+/**
+ * Maps a persisted per-operator status code back to an OperatorState.
+ *
+ * The engine persists the codes written by Utils.maptoStatusCode: 0 =
+ * Uninitialized/Ready, 1 = Running, 2 = Paused, 3 = Completed. Codes 4
+ * (Failed), 5 (Killed) and -1 (other) have no OperatorState member, so they
+ * fall back to the neutral Uninitialized rather than a wrong state.
+ */
+export function operatorStateFromStatusCode(code: number): OperatorState {
+  switch (code) {
+    case 0:
+      return OperatorState.Uninitialized;
+    case 1:
+      return OperatorState.Running;
+    case 2:
+      return OperatorState.Paused;
+    case 3:
+      return OperatorState.Completed;
+    default:
+      return OperatorState.Uninitialized;
+  }
+}
+
+/**
+ * Reduces a persisted runtime-statistics time series to the latest snapshot
+ * per operator (by timestamp; the later row wins a tie, matching write
+ * order), mapped to the wire shape WorkflowStatusService ingests.
+ *
+ * The engine sums the ports away before persisting, so the port maps are left

Review Comment:
   **Must fix:**
   
   The PR description still reads "Port-level metrics are not persisted, so 
restored port labels read 0". This docstring and `joint-ui.service.ts:397` are 
what removed that behavior. It is the sentence a reader would quote when 
judging whether the feature is safe to ship, and it becomes the permanent 
record on merge.



##########
frontend/src/app/workspace/types/execute-workflow.interface.ts:
##########
@@ -82,10 +82,11 @@ export interface OperatorStatistics
   extends Readonly<{
     aggregatedInputRowCount: number;
     aggregatedInputSize?: number;
-    inputPortMetrics: Record<string, number>;
+    /** Absent when the snapshot has no per-port information at all; `{}` 
means every port was zero. */
+    inputPortMetrics?: Record<string, number>;

Review Comment:
   **Advisory:**
   
   The description never mentions that these fields became optional on the 
shared websocket-mirror type, or that `changeOperatorStatistics` gained a 
branch. That is the PR's only change outside the heat-map feature. The test 
table has drifted too: it claims 10 and 7 specs where the tree has 14 and 8. 
Neither it nor the `ng test --include` command names 
`joint-ui.service.spec.ts`, so the stated command skips the two specs covering 
half of the port-metrics fix.



##########
frontend/src/app/workspace/service/heatmap/heatmap-stats-restore.service.ts:
##########
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Injectable } from "@angular/core";
+import { EMPTY, Observable, defer, of } from "rxjs";

Review Comment:
   **Polish:**
   
   `of` is not referenced anywhere in this file. It predates the `defer` 
rewrite, so this one is my miss from last round rather than something you 
introduced.
   ```suggestion
   import { EMPTY, Observable, defer } from "rxjs";
   ```



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