Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Not A Problem
-
None
-
None
-
None
Description
Refactor RDBTable#getRangeKVs(), cleanup code and make getting prevKey more efficient.
Question
Why RDBTable#getRangeKVs() should return empty list if startKey is not found?
It makes getting all key-value pairs awkward.
Current
For example, if the keys in table are [10, 20, 30, 40, 50, 60, 70, 80], and we use count = 3 in each iteration.
- startKey = None, result = [10, 20, 30]
- startKey = 30, result = [30, 40, 50] (can't use 31 as strartKey or we will get empty result)
- startKey = 50, result = [50, 60, 70]
- startKey = 70, result = [70, 80]
And the total results is [10, 20, 30, 30, 40, 50, 50, 60, 70, 70, 80], note the startKey in each iteration is duplicated.
Approach 1
If we can seek for the next key if startKey does not exist, we can use 31 in the 2nd iteration and get [40, 50, 60].
- startKey = None, result = [10, 20, 30]
- startKey = 31, result = [40, 50, 60]
- startKey = 61, result = [70, 80]
Verified CI can pass if we remove the startKey exist check.
https://github.com/apache/ozone/pull/3339#issuecomment-1118150272
Approach 2
Or if we can change startKey to prevKey, the iterations will look more straightforward.
- prevKey = None, result = [10, 20, 30]
- prevKey = 30, result = [40, 50, 60]
- prevKey = 60, result = [70, 80]
However, this approach may require additional changes in the the codebase.
Attachments
Issue Links
- is fixed by
-
HDDS-6428 Add prefix iterator support to RDBTable.
- Resolved
- links to