zhuzhurk commented on a change in pull request #10079: [FLINK-14594] Fix
matching logics of ResourceSpec/ResourceProfile/Resource considering double
values
URL: https://github.com/apache/flink/pull/10079#discussion_r346868195
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/ResourceProfile.java
##########
@@ -367,13 +348,22 @@ public int hashCode() {
return result;
}
+ /**
+ * Note: Avoid to use this method to do resource checking,
+ * unless a strict comparison is desired regarding the double values.
+ * Use {@link #isMatching(ResourceProfile)} or {@link
#hasSameResources(ResourceProfile)}
+ * instead to compare resources ignoring smaller deltas of double
values.
Review comment:
This is a really good question.
This doc is outdated since the initial version introduces a `ResourceValue`
class to manage the double value and its precision. `#equals` needs to retain
the transitive property but resource checking ignoring deltas can not ensure
that (possibly abs(a -b) < delta, abs(b - c) < delta, but abs(a - c) > delta) .
That's why we have to introduce a separate `#hasSameResources`.
However, with BigDecimal, we can achieve that since we can do strict value
comparisons. I will drop the change for #equal usages and change #equal
implementation instead.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services