Disclaimer: I did not find any documentation of KVQuery covering the expected behavior, so this might even be expected but I strongly refuse to believe it is.
When calling getSlice() or getSlices(), these methods receive a KVQuery object as a parameter to define the query. This object includes both a limit for the number of results returned and a KeySelector which filters all considered keys. This can cause the following problem:
Assume the following keys in the database:
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
Furthermore, assume a range [1, 16) and a limit of 8. The given KeySelector accepts all even keys while rejecting odd ones.
Now the limit enforcement will narrow down the retreived keys to {0, 1, 2, 3, 4, 5, 6, 7} from which the KeySelector will select {0, 2, 4, 8}. Consequently, only four key-value pairs are returned although there are eight keys within the range that satisfy the conditions.
Looking at the way getRange() works in FoundationDB, I don't see any particularly good solution other than extending the limit over and over again until enough matching values are found.
Disclaimer: I did not find any documentation of
KVQuery
covering the expected behavior, so this might even be expected but I strongly refuse to believe it is.When calling
getSlice()
orgetSlices()
, these methods receive aKVQuery
object as a parameter to define the query. This object includes both a limit for the number of results returned and aKeySelector
which filters all considered keys. This can cause the following problem:Assume the following keys in the database: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
Furthermore, assume a range [1, 16) and a limit of 8. The given
KeySelector
accepts all even keys while rejecting odd ones. Now the limit enforcement will narrow down the retreived keys to {0, 1, 2, 3, 4, 5, 6, 7} from which theKeySelector
will select {0, 2, 4, 8}. Consequently, only four key-value pairs are returned although there are eight keys within the range that satisfy the conditions.Looking at the way
getRange()
works in FoundationDB, I don't see any particularly good solution other than extending the limit over and over again until enough matching values are found.