showuon commented on a change in pull request #11227:
URL: https://github.com/apache/kafka/pull/11227#discussion_r713675956
##########
File path:
streams/src/main/java/org/apache/kafka/streams/state/internals/InMemoryWindowStore.java
##########
@@ -462,14 +460,34 @@ public boolean hasNext() {
}
final Bytes key = getKey(next.key);
- if (key.compareTo(getKey(keyFrom)) >= 0 &&
key.compareTo(getKey(keyTo)) <= 0) {
+ if (isKeyWithinRange(key)) {
return true;
} else {
next = null;
return hasNext();
}
}
+ private boolean isKeyWithinRange(final Bytes key) {
+ boolean isKeyInRange = false;
+ // split all cases for readability and avoid
BooleanExpressionComplexity checkstyle warning
+ if (keyFrom == null && keyTo == null) {
+ // fetch all
+ isKeyInRange = true;
+ } else if (keyFrom == null && key.compareTo(getKey(keyTo)) <= 0) {
+ // start from the beginning
+ isKeyInRange = true;
+ } else if (key.compareTo(getKey(keyFrom)) >= 0 && keyTo == null) {
Review comment:
Nice refactor! Thanks.
--
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]