ChenSammi commented on code in PR #12109:
URL: https://github.com/apache/ozone/pull/12109#discussion_r4693674363


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java:
##########
@@ -245,14 +245,37 @@ public void deleteWithBatch(BatchOperation batch, byte[] 
key) {
   @Override
   public KeyValueIterator<byte[], byte[]> iterator(byte[] prefix, IteratorType 
type)
       throws RocksDatabaseException {
-    return new RDBStoreByteArrayIterator(db.newIterator(family, false), this,
-        prefix, type);
+    return new RDBStoreByteArrayIterator(db.newIterator(family, false, 
prefixUpperBound(prefix)), this, prefix, type);
   }
 
   KeyValueIterator<CodecBuffer, CodecBuffer> iterator(
       CodecBuffer prefix, IteratorType type) throws RocksDatabaseException {
-    return new RDBStoreCodecBufferIterator(db.newIterator(family, false),
-        this, prefix, type);
+    final byte[] upperBound = prefix == null ? null : 
prefixUpperBound(toArray(prefix.asReadOnlyByteBuffer()));
+    return new RDBStoreCodecBufferIterator(db.newIterator(family, false, 
upperBound), this, prefix, type);
+  }
+
+  /**
+   * @return the smallest key greater than every key starting with the given 
prefix,
+   *         or null if there is no such key (null, empty or all 0xFF prefix).
+   */
+  static byte[] prefixUpperBound(byte[] prefix) {

Review Comment:
   @sumitagrawl , this change will not break the pagination, since in Ozone, 
startKey is used to seek to the point, instead of as the prefix, otherwise the 
list will go wrong.  I also added a few new unit tests to further verify the 
pagination cases. 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to