Description
While prefix bloom filters are pretty simple in theory, they need a Trait the user needs to implement.
Possible API:
trait PrefixExtractor {
fn extract(&self, key: &[u8]) -> impl Iterator<Item = &[u8]>;
}
With the prefix extractor returning an iterator, we can implement both normal prefix extraction (e.g. the first 8 characters of all keys):
fn extract(&self, key: &[u8]) -> impl Iterator<Item = &[u8]> {
std::iter::once(key.get(0..8).unwrap())
}
or segmented prefixes (e.g. <account_id>#<user_id>
, that could index both the hashes of <account_id>#<user_id>
and <account_id>
, which would allow filtering for queries on both account ID and account ID + user ID).