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


##########
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:
   @ChenSammi Most of our usecase for iteration is, paginated iteration with 
count limit, and starting position as prefix. So this change may limit 
iteration and even stop paginated iteration with upper bound logic.
   
   So I think if there is any specific case where we need iterate all (without 
paginated / count based iteration) with defined prefix, like all keys within 
directory as prefix - /<vol>/<bucket>/<parent dir id>/, then its useful. But 
with above case, this may not work.
   



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