vyalamar commented on code in PR #12109:
URL: https://github.com/apache/ozone/pull/12109#discussion_r4724941507
##########
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:
Thanks @peterxcli . That helper works for the string prefixes used in the OM
snapshot code, but prefixUpperBound sits below the codec and receives raw bytes
from every table (OM, SCM, datanodes, Recon). For binary prefixes like the
datanode schema-v3 container ID (e.g. container 255 ending in 0xFF ,
https://ozone.apache.org/docs/next/system-internals/components/datanode/disk-layout/
), going through a String produces a bound that sorts below the prefix and
returns nothing. The byte-wise version handles the 0xFF carry correctly, so
may be its fine to keep it as is ?
--
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]