Skip to main content

Signature

Struct Signature 

Source
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

Source

pub fn of(values: &[(&str, &[u8])]) -> Signature

The signature of a set of attribute and value pairs.

Source

pub fn insert(&mut self, attribute: &str, value: &[u8])

Add one attribute and value pair to what this signature covers.

For a caller that meets the pairs one at a time rather than holding them all in a slice, which is what building a tag out of a document’s indexed fields looks like.

Source

pub fn insert_bytes(&mut self, attribute: &[u8], value: &[u8])

The same for an attribute that is already bytes, which is what a document path is.

Source

pub fn bits(self) -> u64

The signature as the tag to hand to Partitions::insert_tagged.

Source

pub fn from_bits(bits: u64) -> Signature

The signature of a tag that came back out of the index.

Source

pub fn covers(self, want: Signature) -> bool

Whether this has every bit want has, which is the test the scan runs.

Trait Implementations§

Source§

impl Clone for Signature

Source§

fn clone(&self) -> Signature

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Signature

Source§

impl Debug for Signature

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Signature

Source§

fn default() -> Signature

Returns the “default value” for a type. Read more
Source§

impl Eq for Signature

Source§

impl Filter for Signature

Source§

fn allows(&self, tag: u64) -> bool

Whether a member with this tag is worth ranking.
Source§

fn exact(&self, _id: u64) -> bool

The second test, on the member’s id rather than on its tag. Read more
Source§

fn narrowing(&self) -> bool

Whether this filter can turn members away. Read more
Source§

impl PartialEq for Signature

Source§

fn eq(&self, other: &Signature) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Signature

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.