hudi-agent commented on code in PR #19117:
URL: https://github.com/apache/hudi/pull/19117#discussion_r3496905208


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/metrics/FlinkWriteCoordinatorMetrics.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.metrics;
+
+import org.apache.flink.metrics.MetricGroup;
+
+import java.util.function.IntSupplier;
+
+/**
+ * Metrics for Flink stream write operator coordinator.
+ */
+public class FlinkWriteCoordinatorMetrics extends HoodieFlinkMetrics {
+
+  private static final String PENDING_COMMIT_INSTANT_COUNT = 
"pendingCommitInstantCount";

Review Comment:
   🤖 nit: the parent class is `HoodieFlinkMetrics`, so this subclass would be 
more consistent with the project's `Hoodie`-prefix convention if it were named 
`HoodieFlinkWriteCoordinatorMetrics`.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/EventBuffers.java:
##########
@@ -171,7 +171,7 @@ public String getPendingInstants() {
    */
   public Map<Long, Pair<String, EventBuffer>> getAllCompletedEvents() {
     return this.eventBuffers.entrySet().stream()

Review Comment:
   🤖 nit: `entry.getValue().getRight()` is traversed twice in the same 
predicate — could you extract it to a local variable (e.g. `EventBuffer buf = 
entry.getValue().getRight()`) before the stream, or use a helper in the lambda, 
to make the two conditions easier to read?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/utils/EventBuffers.java:
##########
@@ -171,7 +171,7 @@ public String getPendingInstants() {
    */
   public Map<Long, Pair<String, EventBuffer>> getAllCompletedEvents() {
     return this.eventBuffers.entrySet().stream()
-        .filter(entry -> entry.getValue().getRight().allEventsCompleted())
+        .filter(entry -> entry.getValue().getRight().allEventsCompleted() && 
!entry.getValue().getRight().isEmptyDataWriteBuffer())

Review Comment:
   🤖 `getAllCompletedEvents()` isn't only used for the new metric — it's also 
the source serialized into coordinator checkpoint state in 
`checkpointCoordinator()` (StreamWriteOperatorCoordinator line 301). Adding 
`!isEmptyDataWriteBuffer()` here means empty-data-write buffers are now 
excluded from what gets persisted and restored on `resetToCheckpoint`. Is that 
intended? It looks consistent with `commitInstant`'s early-return for empty 
buffers, but on recovery those instants would no longer be restored at all, so 
the `reset(...)` + `writeClient.cleanResources(instant)` cleanup in 
`commitInstant` wouldn't run for them. Could you confirm recovery semantics are 
unaffected, or alternatively give the metric its own helper so the checkpoint 
path keeps its current behavior?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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