Struct SearchIndexBTreeRange

Source
pub struct SearchIndexBTreeRange<P, V> { /* private fields */ }
Expand description

SearchIndexBTreeRange is a index backed by a BTreeMap that can match Exact, InRange, OutRange, Minimum and Maximum queries.

§Example

use attribute_search_engine::{SearchIndex, SearchIndexBTreeRange};
use std::collections::HashSet;
use attribute_search_engine::Query;

let mut index_age = SearchIndexBTreeRange::<usize, i32>::new();
index_age.insert(0, 17);
index_age.insert(1, 42);
index_age.insert(2, 31);
index_age.insert(3, 26);

let result = index_age.search(&Query::Exact("<unused>".into(), "42".into()));
assert_eq!(result, Ok(HashSet::from_iter(vec![1])));

let result = index_age.search(&Query::InRange("<unused>".into(), "20".into(), "40".into()));
assert_eq!(result, Ok(HashSet::from_iter(vec![2, 3])));

Implementations§

Source§

impl<P, V> SearchIndexBTreeRange<P, V>
where P: Eq + Hash + Clone + 'static, V: Ord + FromStr + 'static,

Source

pub fn new() -> Self

Creates a new SearchIndexBTreeRange.

§Example
use attribute_search_engine::SearchIndexBTreeRange;

let index = SearchIndexBTreeRange::<usize, i32>::new();
Source

pub fn insert(&mut self, primary_id: P, attribute_value: V)

Insert a new entry in the index.

§Example
use attribute_search_engine::SearchIndexBTreeRange;

let mut index = SearchIndexBTreeRange::<usize, i32>::new();

// You insert an entry by giving a row / primary id and an attribute value:
index.insert(123, 42);
// The same row / primary id can have multiple attributes assigned:
index.insert(123, 69);
// Add as much entries as you want for as many rows you want:
index.insert(124, 32);

Trait Implementations§

Source§

impl<P, V> Default for SearchIndexBTreeRange<P, V>
where P: Eq + Hash + Clone + 'static, V: Ord + FromStr + 'static,

Source§

fn default() -> Self

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

impl<P, V> SearchIndex<P> for SearchIndexBTreeRange<P, V>
where P: Eq + Hash + Clone + 'static, V: Ord + FromStr + 'static,

Source§

fn search(&self, query: &Query) -> Result<HashSet<P>>

Perform a search on an index. Read more
Source§

fn supported_queries(&self) -> SupportedQueries

Returns which queries are directly supported by an index. Read more

Auto Trait Implementations§

§

impl<P, V> Freeze for SearchIndexBTreeRange<P, V>

§

impl<P, V> RefUnwindSafe for SearchIndexBTreeRange<P, V>

§

impl<P, V> Send for SearchIndexBTreeRange<P, V>
where V: Send, P: Send,

§

impl<P, V> Sync for SearchIndexBTreeRange<P, V>
where V: Sync, P: Sync,

§

impl<P, V> Unpin for SearchIndexBTreeRange<P, V>

§

impl<P, V> UnwindSafe for SearchIndexBTreeRange<P, V>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.