soin08 commented on code in PR #28590:
URL: https://github.com/apache/flink/pull/28590#discussion_r3509072972


##########
flink-libraries/flink-state-processing-api/src/main/java/org/apache/flink/state/api/filter/SavepointKeyFilter.java:
##########
@@ -111,9 +112,18 @@ static <K> SavepointKeyFilter<K> exact(K value) {
 
     static <K extends Comparable<K>> SavepointKeyFilter<K> range(
             @Nullable K lower, boolean lowerInclusive, @Nullable K upper, 
boolean upperInclusive) {
-        BoundInfo lowerBoundInfo = lower != null ? new BoundInfo(lower, 
lowerInclusive) : null;
-        BoundInfo upperBoundInfo = upper != null ? new BoundInfo(upper, 
upperInclusive) : null;
-        return new RangeKeyFilter<>(lowerBoundInfo, upperBoundInfo);
+        return range(lower, lowerInclusive, upper, upperInclusive, 
Comparator.naturalOrder());
+    }
+
+    static <K> SavepointKeyFilter<K> range(
+            @Nullable K lower,
+            boolean lowerInclusive,
+            @Nullable K upper,
+            boolean upperInclusive,
+            Comparator<K> comparator) {

Review Comment:
   And a test in `SavepointReaderKeyedStateITCase`, for example: 
   ```
   @Test
       public void testReadKeyedStateWithCustomComparatorRangeFilter() throws 
Exception {
           Tuple2<Configuration, B> backendTuple = getStateBackendTuple();
           StreamExecutionEnvironment env =
                   
StreamExecutionEnvironment.getExecutionEnvironment(backendTuple.f0);
           env.setParallelism(4);
   
           applyStatefulPipeline(env);
   
           String savepointPath = takeSavepoint(env);
   
           SavepointReader savepoint = SavepointReader.read(env, savepointPath, 
backendTuple.f1);
           // Reverse (descending) order. Under natural order the bounds [6, 3] 
would be empty
           // (6 > 3); the descending order makes them the range {3, 4, 5, 6}.
           CountingReadResult result =
                   readKeyedStateWithCountingReader(
                           savepoint,
                           SavepointKeyFilter.range(6, true, 3, true, (a, b) -> 
Integer.compare(b, a)));
           assertThat(result.values).containsExactlyInAnyOrder(3, 4, 5, 6);
           assertThat(result.counter).isEqualTo(4);
       }
   ```
   which proves comparator correctness end-to-end



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