[][src]Struct tarantool_module::space::Space

pub struct Space { /* fields omitted */ }

Implementations

impl Space[src]

pub fn find(name: &str) -> Option<Self>[src]

Find space by name.

This function performs SELECT request to _vspace system space.

  • name - space name

Returns:

  • None if not found
  • Some(space) otherwise

pub fn index(&self, name: &str) -> Option<Index>[src]

Find index by name.

This function performs SELECT request to _vindex system space.

  • name - index name

Returns:

  • None if not found
  • Some(index) otherwise

pub fn primary_key(&self) -> Index[src]

Returns index with id = 0

pub fn insert<T>(&mut self, value: &T) -> Result<Option<Tuple>, Error> where
    T: AsTuple
[src]

Insert a tuple into a space.

  • value - tuple value to insert

Returns a new tuple.

See also: box.space[space_id]:insert(tuple)

pub fn replace<T>(&mut self, value: &T) -> Result<Option<Tuple>, Error> where
    T: AsTuple
[src]

Insert a tuple into a space. If a tuple with the same primary key already exists, space.replace() replaces the existing tuple with a new one. The syntax variants space.replace() and space.put() have the same effect; the latter is sometimes used to show that the effect is the converse of space.get().

  • value - tuple value to replace with

Returns a new tuple.

pub fn put<T>(&mut self, value: &T) -> Result<Option<Tuple>, Error> where
    T: AsTuple
[src]

Insert a tuple into a space. If a tuple with the same primary key already exists, replaces the existing tuple with a new one. Alias for space.replace()

pub fn truncate(&mut self) -> Result<(), Error>[src]

Deletes all tuples. The method is performed in background and doesn’t block consequent requests.

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

Return the number of tuples in the space.

If compared with space.count(), this method works faster because space.len() does not scan the entire space to count the tuples.

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

Number of bytes in the space.

This number, which is stored in Tarantool’s internal memory, represents the total number of bytes in all tuples, not including index keys. For a measure of index size, see index.bsize().

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

Search for a tuple in the given space.

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

Search for a tuple or a set of tuples in the given space. This method doesn’t yield (for details see Сooperative multitasking).

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

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

Return the number of tuples. If compared with space.len(), this method works slower because space.count() scans the entire space to count the tuples.

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

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

Delete a tuple identified by a primary key.

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

Returns the deleted tuple

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

Update a tuple.

The update function supports operations on fields — assignment, arithmetic (if the field is numeric), cutting and pasting fragments of a field, deleting or inserting a field. Multiple operations can be combined in a single update request, and in this case they are performed atomically and sequentially. Each operation requires specification of a field number. When multiple operations are present, the field number for each operation is assumed to be relative to the most recent state of the tuple, that is, as if all previous operations in a multi-operation update have already been applied. In other words, it is always safe to merge multiple update invocations into a single invocation, with no change in semantics.

  • 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: space.upsert()

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

Update or insert a tuple.

If there is an existing tuple which matches the key fields of tuple, then the request has the same effect as space.update() and the {{operator, field_no, value}, ...} parameter is used. If there is no existing tuple which matches the key fields of tuple, then the request has the same effect as space.insert() and the {tuple} parameter is used. However, unlike insert or update, upsert will not read a tuple and perform error checks before returning – this is a design feature which enhances throughput but requires more caution on the part of the user.

  • 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: space.update()

Trait Implementations

impl Into<Space> for SystemSpace[src]

Auto Trait Implementations

impl RefUnwindSafe for Space

impl Send for Space

impl Sync for Space

impl Unpin for Space

impl UnwindSafe for Space

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.