jeqo commented on a change in pull request #9137: URL: https://github.com/apache/kafka/pull/9137#discussion_r469225368
########## File path: streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBRangeIterator.java ########## @@ -29,32 +29,41 @@ // comparator to be pluggable, and the default is lexicographic, so it's // safe to just force lexicographic comparator here for now. private final Comparator<byte[]> comparator = Bytes.BYTES_LEXICO_COMPARATOR; - private final byte[] rawToKey; + private final byte[] rawLastKey; + private final boolean reverse; RocksDBRangeIterator(final String storeName, final RocksIterator iter, final Set<KeyValueIterator<Bytes, byte[]>> openIterators, final Bytes from, - final Bytes to) { - super(storeName, iter, openIterators); - iter.seek(from.get()); - rawToKey = to.get(); - if (rawToKey == null) { + final Bytes to, + final boolean reverse) { + super(storeName, iter, openIterators, reverse); + this.reverse = reverse; + if (reverse) { + iter.seekForPrev(to.get()); + rawLastKey = from.get(); + } else { + iter.seek(from.get()); + rawLastKey = to.get(); + } + if (rawLastKey == null) { throw new NullPointerException("RocksDBRangeIterator: RawToKey is null for key " + to); Review comment: right. I've moved this into each condition to set a correct exception message. ---------------------------------------------------------------- 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: us...@infra.apache.org