pub struct Signature(/* private fields */);Expand description
A tag built by setting one bit per attribute value, so that a conjunction of required values is a subset test.
Superimposed coding, which is old and still the right answer when the test has to be one instruction on a value that is already in a register. Each attribute and value pair hashes to one of 64 bits. A member’s tag is the bits for the values it has. A query’s tag is the bits for the values it requires. The member is worth ranking when it has all of the query’s bits.
Two different values can land on the same bit, so a member can pass a filter it does not really match. It can never fail one it does match, which is the direction that matters: the answers are a superset of the truth and the caller’s own predicate cuts them down, where the other way round would lose answers silently.
use yo_vector::Signature;
// What a document is tagged with, and what a query asks for.
let doc = Signature::of(&[("lang", "en".as_bytes()), ("topic", "finance".as_bytes())]);
let english = Signature::of(&[("lang", "en".as_bytes())]);
assert!(doc.covers(english));
// The other way round only holds if the two bits happened to collide.
assert!(!english.covers(doc) || english.bits() == doc.bits());Implementations§
Source§impl Signature
impl Signature
Sourcepub fn of(values: &[(&str, &[u8])]) -> Signature
pub fn of(values: &[(&str, &[u8])]) -> Signature
The signature of a set of attribute and value pairs.
Sourcepub fn bits(self) -> u64
pub fn bits(self) -> u64
The signature as the tag to hand to Partitions::insert_tagged.