Struct cbor_tag_index::DnfQuery
source · [−]pub struct DnfQuery<T> { /* private fields */ }
Expand description
A compact representation of a seq of tag sets, to be used as a DNF query.
The internal repesentation is using a bitmap for efficiency. So assuming string tags, e.g. (“a” & “b”) | (“b” & “c”) | (“d”) would be encoded as
{
tags: ["a", "b", "c", "d"],
sets: [
b0011,
b0110,
b1000,
]
}
so the possibly large tags have to be stored only once, and operations can work on bit sets.
Implementations
sourceimpl<T> DnfQuery<T>
impl<T> DnfQuery<T>
sourcepub fn is_all(&self) -> bool
pub fn is_all(&self) -> bool
Are we a dnf query containing an empty set, which matches everything?
sourcepub fn terms(&self) -> impl Iterator<Item = impl Iterator<Item = &T>>
pub fn terms(&self) -> impl Iterator<Item = impl Iterator<Item = &T>>
get back the terms making up the dnf query
Note that there is no guarantee that there will be the same number of terms or that tags in each term will be ordered in the same way.
pub fn len(&self) -> usize
sourceimpl<T: Tag> DnfQuery<T>
impl<T: Tag> DnfQuery<T>
sourcepub fn new(
terms: impl IntoIterator<Item = impl IntoIterator<Item = T>>
) -> Result<Self>
pub fn new(
terms: impl IntoIterator<Item = impl IntoIterator<Item = T>>
) -> Result<Self>
Build a new DnfQuery from a sequence of terms, where each term contains a sequence of tags.
sourcepub fn matching(&self, index: &TagIndex<T>) -> Vec<bool>
pub fn matching(&self, index: &TagIndex<T>) -> Vec<bool>
Helper method to return the matching indexes, mostly for tests
sourcepub fn set_matching(&self, index: &TagIndex<T>, matches: &mut [bool])
pub fn set_matching(&self, index: &TagIndex<T>, matches: &mut [bool])
given a bitmap of matches, corresponding to the events in the index, set those bytes to false that do not match.