Myasuka commented on a change in pull request #18305:
URL: https://github.com/apache/flink/pull/18305#discussion_r783931040
##########
File path:
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBIncrementalCheckpointUtils.java
##########
@@ -46,28 +47,58 @@
/**
* Evaluates state handle's "score" regarding to the target range when
choosing the best state
* handle to init the initial db for recovery, if the overlap fraction is
less than {@link
- * #OVERLAP_FRACTION_THRESHOLD}, then just return -1 to mean the handle
has not chance to be the
- * initial handle.
+ * #OVERLAP_FRACTION_THRESHOLD}, then just return {@code Score.MIN} to
mean the handle has no
+ * chance to be the initial handle.
*/
- private static final BiFunction<KeyedStateHandle, KeyGroupRange, Double>
- STATE_HANDLE_EVALUATOR =
- (stateHandle, targetKeyGroupRange) -> {
- final KeyGroupRange handleKeyGroupRange =
stateHandle.getKeyGroupRange();
- final KeyGroupRange intersectGroup =
-
handleKeyGroupRange.getIntersection(targetKeyGroupRange);
-
- final double overlapFraction =
- (double) intersectGroup.getNumberOfKeyGroups()
- /
handleKeyGroupRange.getNumberOfKeyGroups();
-
- if (overlapFraction < OVERLAP_FRACTION_THRESHOLD) {
- return -1.0;
- }
-
- return intersectGroup.getNumberOfKeyGroups()
- * overlapFraction
- * overlapFraction;
- };
+ private static final BiFunction<KeyedStateHandle, KeyGroupRange, Score>
STATE_HANDLE_EVALUATOR =
+ (stateHandle, targetKeyGroupRange) -> {
+ final KeyGroupRange handleKeyGroupRange =
stateHandle.getKeyGroupRange();
+ final KeyGroupRange intersectGroup =
+
handleKeyGroupRange.getIntersection(targetKeyGroupRange);
+
+ final double overlapFraction =
+ (double) intersectGroup.getNumberOfKeyGroups()
+ / handleKeyGroupRange.getNumberOfKeyGroups();
+
+ if (overlapFraction < OVERLAP_FRACTION_THRESHOLD) {
+ return Score.MIN;
+ }
+
+ return new Score(intersectGroup.getNumberOfKeyGroups(),
overlapFraction);
+ };
+
+ /**
+ * Score of the state handle, intersect group range is compared first, and
then compare the
+ * overlap fraction.
+ */
+ private static class Score implements Comparable<Score> {
+
+ public static Score MIN = new Score(Integer.MIN_VALUE, -1.0);
Review comment:
(naming) StaticVariableName: Name 'MIN' must match pattern
'^[a-z][a-zA-Z0-9]*_?$'.
--
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]