zentol commented on a change in pull request #6599: [FLINK-10150][metrics] Fix
OperatorMetricGroup creation for Batch
URL: https://github.com/apache/flink/pull/6599#discussion_r214614670
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/TaskMetricGroup.java
##########
@@ -144,15 +144,17 @@ public OperatorMetricGroup addOperator(OperatorID
operatorID, String name) {
name = name.substring(0,
METRICS_OPERATOR_NAME_MAX_LENGTH);
}
OperatorMetricGroup operator = new
OperatorMetricGroup(this.registry, this, operatorID, name);
+ // unique OperatorIDs only exist in streaming, so we have to
rely on the name for batch operators
+ final String key = operatorID + name;
synchronized (this) {
- OperatorMetricGroup previous =
operators.put(operatorID, operator);
+ OperatorMetricGroup previous = operators.put(key,
operator);
Review comment:
I will rename the method but leave the code as is. It was intentionally
written that way so that we only do a single lookup on the happy path. The
default implementation of `putIfAbsent` is just syntactic sugar for separate
get/put calls. While the HashMap _implementation_ of this method is indeed more
efficient in this regard this is an implementation detail.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services