Skip to content

Conversation

@swamirishi
Copy link
Contributor

@swamirishi swamirishi commented Dec 25, 2025

What changes were proposed in this pull request?

Currently for prefix based iteration, the comparison happens on Java side which is inefficient firstly because this incurs an additional buffer copy cost in each and every call of hasNext on iteration i.e. in case of RDBStoreCodecBufferIterator it is going to be a copy b/w 2 direct byte buffer and in case of RDBStoreByteArrayIterator it is going to be a direct to heap byte array allocation which is expensive.

Moreover the prefix check is also inefficient on java side and this would be very efficient on c++ since rocksdb internally does a memcmp which is going to be way more efficient than the O(n) comparator written in java side.

The patch aims to set lowerBound and upperBound in readOptions on rocksItr initialize and offload all the comparisons to rocksdb side.

Here the lowerBound is going to be the prefix itself and upperBound is going to be nextHigherByteArray entry. If the prefix is going to have all bytes start with 0xFF or if it is empty then there can be no upper bound for the iterator and lower bound is going to be just and the iteration has to happen beginning from the prefix and iterate till the end of the table.

BTW we have already been using this kinda model in snapshot code introduced in the PersistentMap impl
#4722
I am planning to completely get rid of PersistentMap impl which I feel is completely redundant as part of this umbrella jira
https://issues.apache.org/jira/browse/HDDS-14031

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14242

How was this patch tested?

Added unit tests and also depending on pre existing rocksdb test cases in class TestRDBTableStore

@swamirishi swamirishi force-pushed the HDDS-14242 branch 2 times, most recently from 0950480 to 8c638bf Compare December 25, 2025 10:31
@swamirishi swamirishi force-pushed the HDDS-14242 branch 2 times, most recently from ec3cf0f to 982ef18 Compare December 26, 2025 13:35
…or prefix based iteration

Change-Id: I3acf410885571d0b26da9b89a801d9f2f9070e33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant