[−][src]Struct retriever::queries::secondary_index::SecondaryIndex
A secondary index of the records in a Storage
. You can attach as many SecondaryIndices
to a given Storage
as you want. Each SecondaryIndex
will index each stored element under
zero or more key values (but only one key type).
Type Parameters
ChunkKey
: The chunk key type of theStorage
.Element
: The element type of theStorage
.IndexKeys
: A collection containing the type parameterIndexKey
. This could be anOption
,HashSet
, etc.IndexKey
: The type of the secondary index key. This is the key you'll use to look upElements
via thisSecondaryIndex
.
How to choose IndexKeys
and IndexKey
.
Situation | IndexKeys | IndexKey |
---|---|---|
Index all emails marked "urgent" | Option<()> | () |
Index automobiles by model year | Option<i32> | i32 |
Index artwork by dominant color | HashSet<Color> | Color |
Panic
A SecondaryIndex
is associated with exactly one storage.
If you attempt to use a SecondaryIndex
with a Storage
other than the one it was
initialized with, it will panic.
Methods
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey> where
ChunkKey: BorrowedKey,
ChunkKey::Owned: ValidKey,
IndexKey: BorrowedKey,
IndexKey::Owned: ValidKey,
IndexKeys: Clone + Debug + Default + Eq + KeySet<'k, IndexKey>,
[src]
ChunkKey: BorrowedKey,
ChunkKey::Owned: ValidKey,
IndexKey: BorrowedKey,
IndexKey::Owned: ValidKey,
IndexKeys: Clone + Debug + Default + Eq + KeySet<'k, IndexKey>,
pub fn new<ItemKey: ?Sized, F>(
storage: &Storage<ChunkKey, ItemKey, Element>,
f: F
) -> Self where
ItemKey: BorrowedKey,
ItemKey::Owned: ValidKey,
Element: Record<ChunkKey, ItemKey>,
F: Fn(&Element) -> Cow<IndexKeys> + Clone + Send + Sync + 'static,
[src]
storage: &Storage<ChunkKey, ItemKey, Element>,
f: F
) -> Self where
ItemKey: BorrowedKey,
ItemKey::Owned: ValidKey,
Element: Record<ChunkKey, ItemKey>,
F: Fn(&Element) -> Cow<IndexKeys> + Clone + Send + Sync + 'static,
Create a new SecondaryIndex of a storage.
The indexing rule needs to return a collection of 0 or more IndexKeys
for each Element
.
Collection types that will work well include: Option
, HashSet
, and BTreeSet
.
Try to re-use SecondaryIndices
as much as possible. If you drop a SecondaryIndex
and then
re-create it, the index has to be rebuilt, which might take a long time.
pub fn validate<ItemKey: ?Sized>(
&self,
parent: &Storage<ChunkKey, ItemKey, Element>
) where
ItemKey: BorrowedKey,
ItemKey::Owned: ValidKey,
Element: Record<ChunkKey, ItemKey>,
[src]
&self,
parent: &Storage<ChunkKey, ItemKey, Element>
) where
ItemKey: BorrowedKey,
ItemKey::Owned: ValidKey,
Element: Record<ChunkKey, ItemKey>,
Panic if this storage is malformed or broken in any detectable way. This is a slow operation and you shouldn't use it unless you suspect a problem.
Trait Implementations
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> Clone for SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey> where
ChunkKey: BorrowedKey,
ChunkKey::Owned: ValidKey,
IndexKey: BorrowedKey,
IndexKey::Owned: ValidKey,
IndexKeys: Clone + Debug + Default + Eq + KeySet<'k, IndexKey>,
[src]
ChunkKey: BorrowedKey,
ChunkKey::Owned: ValidKey,
IndexKey: BorrowedKey,
IndexKey::Owned: ValidKey,
IndexKeys: Clone + Debug + Default + Eq + KeySet<'k, IndexKey>,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> Send for SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey> where
IndexKeys: Send + Sync,
<ChunkKey as ToOwned>::Owned: Send + Sync,
<IndexKey as ToOwned>::Owned: Send + Sync,
IndexKeys: Send + Sync,
<ChunkKey as ToOwned>::Owned: Send + Sync,
<IndexKey as ToOwned>::Owned: Send + Sync,
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> Sync for SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey> where
IndexKeys: Send + Sync,
<ChunkKey as ToOwned>::Owned: Send + Sync,
<IndexKey as ToOwned>::Owned: Send + Sync,
IndexKeys: Send + Sync,
<ChunkKey as ToOwned>::Owned: Send + Sync,
<IndexKey as ToOwned>::Owned: Send + Sync,
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> Unpin for SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey>
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> UnwindSafe for SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey>
impl<ChunkKey: ?Sized, Element, IndexKeys, IndexKey: ?Sized> RefUnwindSafe for SecondaryIndex<ChunkKey, Element, IndexKeys, IndexKey>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,