mjsax commented on code in PR #14477:
URL: https://github.com/apache/kafka/pull/14477#discussion_r1348226816


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:
##########
@@ -254,17 +254,37 @@ protected <R> QueryResult<R> runRangeQuery(final Query<R> 
query,
         final QueryResult<R> result;
         final RangeQuery<K, V> typedQuery = (RangeQuery<K, V>) query;
         final RangeQuery<Bytes, byte[]> rawRangeQuery;
+        final boolean isKeyAscending = typedQuery.isKeyAscending();
         if (typedQuery.getLowerBound().isPresent() && 
typedQuery.getUpperBound().isPresent()) {
-            rawRangeQuery = RangeQuery.withRange(
-                keyBytes(typedQuery.getLowerBound().get()),
-                keyBytes(typedQuery.getUpperBound().get())
-            );
+            if (isKeyAscending) {
+                rawRangeQuery = RangeQuery.withRange(
+                        keyBytes(typedQuery.getLowerBound().get()),
+                        keyBytes(typedQuery.getUpperBound().get())
+                );
+            } else {
+                rawRangeQuery = (RangeQuery<Bytes, byte[]>) (RangeQuery<?, ?>) 
RangeQuery.withRange(
+                        keyBytes(typedQuery.getLowerBound().get()),
+                        keyBytes(typedQuery.getUpperBound().get())
+                ).withDescendingKeys();

Review Comment:
   Was looking into this. It's a type erasure issue. You need to specify the 
type expliclity for this case when calling the static method so avoid the casts:
   ```
   rawRangeQuery = RangeQuery.<Bytes, byte[]>withRange(
       keyBytes(typedQuery.getLowerBound().get()),
       keyBytes(typedQuery.getUpperBound().get())
   ).withDescendingKeys();
   ```



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