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


##########
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:
   I checked code, startKey and prefixKey are separated. So under pagination, 
startKey keeps changing for every page, but prefixKey remains constant. So this 
change should be fine.
   
   prefix - mostly used in om with <vol>/<buc>/<parent>/ pattern, and expected 
to get all starting with this only, with startKey being variable.
   
   So currently seems no risk with this.



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