Struct Index

Source
pub struct Index { /* private fields */ }
Expand description

An index is a group of key values and pointers.

Implementations§

Source§

impl Index

Source

pub fn get<K>(&self, key: &K) -> Result<Option<Tuple>, Error>
where K: AsTuple,

Get a tuple from index by the key.

Please note that this function works much more faster than select

  • key - encoded key in MsgPack Array format ([part1, part2, ...]).

Returns a tuple or None if index is empty

Source

pub fn select<K>( &self, iterator_type: IteratorType, key: &K, ) -> Result<IndexIterator, Error>
where K: AsTuple,

Allocate and initialize iterator for index.

This is an alternative to space.select() which goes via a particular index and can make use of additional parameter that specify the iterator type.

  • type - iterator type
  • key - encoded key in MsgPack Array format ([part1, part2, ...]).
Source

pub fn delete<K>(&mut self, key: &K) -> Result<Option<Tuple>, Error>
where K: AsTuple,

Delete a tuple identified by a key.

Same as space.delete(), but key is searched in this index instead of in the primary-key index. This index ought to be unique.

  • key - encoded key in MsgPack Array format ([part1, part2, ...]).

Returns the deleted tuple

Source

pub fn update<K, Op>( &mut self, key: &K, ops: &Vec<Op>, ) -> Result<Option<Tuple>, Error>
where K: AsTuple, Op: AsTuple,

Update a tuple.

Same as space.update(), but key is searched in this index instead of primary key. This index ought to be unique.

  • key - encoded key in MsgPack Array format ([part1, part2, ...]).
  • ops - encoded operations in MsgPack array format, e.g. [['=', field_id, value], ['!', 2, 'xxx']]

Returns a new tuple.

See also: index.upsert()

Source

pub fn upsert<T, Op>( &mut self, value: &T, ops: &Vec<Op>, ) -> Result<Option<Tuple>, Error>
where T: AsTuple, Op: AsTuple,

Execute an UPSERT request.

Will try to insert tuple. Update if already exists.

  • value - encoded tuple in MsgPack Array format ([field1, field2, ...])
  • ops - encoded operations in MsgPack array format, e.g. [['=', field_id, value], ['!', 2, 'xxx']]

Returns a new tuple.

See also: index.update()

Source

pub fn len(&self) -> Result<usize, Error>

Return the number of elements in the index.

Source

pub fn bsize(&self) -> Result<usize, Error>

Return the number of bytes used in memory by the index.

Source

pub fn random(&self, seed: u32) -> Result<Option<Tuple>, Error>

Return a random tuple from the index (useful for statistical analysis).

  • rnd - random seed
Source

pub fn min<K>(&self, key: &K) -> Result<Option<Tuple>, Error>
where K: AsTuple,

Return a first (minimal) tuple matched the provided key.

  • key - encoded key in MsgPack Array format ([part1, part2, ...]).

Returns a tuple or None if index is empty

Source

pub fn max<K>(&self, key: &K) -> Result<Option<Tuple>, Error>
where K: AsTuple,

Return a last (maximal) tuple matched the provided key.

  • key - encoded key in MsgPack Array format ([part1, part2, ...]).

Returns a tuple or None if index is empty

Source

pub fn count<K>( &self, iterator_type: IteratorType, key: &K, ) -> Result<usize, Error>
where K: AsTuple,

Count the number of tuple matched the provided key.

  • type - iterator type
  • key - encoded key in MsgPack Array format ([part1, part2, ...]).
Source

pub fn extract_key(&self, tuple: Tuple) -> Tuple

Extract key from tuple according to key definition of given index. Returned buffer is allocated on box_txn_alloc() with this key.

  • tuple - tuple from which need to extract key.

Auto Trait Implementations§

§

impl Freeze for Index

§

impl RefUnwindSafe for Index

§

impl Send for Index

§

impl Sync for Index

§

impl Unpin for Index

§

impl UnwindSafe for Index

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.