I'm using BDB cursor and calling getSaerchKeyRange. From the docs
getSaerchKeyRange: returns the smallest key greater than or equal to the specified key
Lets say our DB is the following
Key Value
1 a
2 b
3 c
4 d
5 e
After running cursor.getSearchKeyRange(6)
does the cursor
So far I've tried reading multiple sources of documentation but the answer isn't clear to me.
It returns "not found". The way it returns "not found" depends on which programming language you're using. If you're using Java, it returns OperationStatus.NOTFOUND
.
In your example, there are no keys in the database that are greater than or equal to your search key of 6. This line in the documentation describes the behavior:
The returned key/data pair is for the smallest key greater than or equal to the specified key (as determined by the key comparison function), permitting partial key matches and range searches. source: Oracle Sleepycat Docs
To round this out, expand on your example by adding some more larger keys:
Key Value
1 a
2 b
3 c
4 d
5 e
37 f
52 g
Now, if you do a getSearchKeyRange(6)
, it returns key 37
. That's the first key that's greater than or equal to 6.