Add key prefix matching to KEYS command
Mergedprologic merged 5 commits from
master2 years ago
Reference in new issue
There is no content yet.
Delete Branch 'biozz/bitcask:keys-prefix-matching'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Related to #234 and !236.
This is the implementation that was requested in the original issue. I updated KEYS command to be redis-valid and implemented prefix search. There is also a rather interesting test, I could you use some feedback here.
I noticed that it might not be possible to reduce the complexity of the KEYS command. Because even if you use Scan, you will have to store the counter of all found keys before you do WriteBulk of the actual keys.
@prologic here is what you probably had in mind:
But there is no way to call
conn.WriteArray(n)with the number of keys until you iterate through all of them, hence the second loop over found keys.
Yeah you're right! YOu'd have to accumulate the metched keys sadly.
I think what you've done here in this PR is great though and it will perform much better with a database with a larger keyspace. Iteresting through hundreds or thousands of keys will be slow, so reducing that space with ascan is goo.d
@prologic @taigrr would you be so kind and give this PR a round of code review?
@biozz Oh yes so sorry! Work has been "flat out" 🤣
I actually looked at the code briefly before. This LGTM 👌
21a824e13einto master 2 years ago