Struct Space

Source
pub struct Space { /* private fields */ }

Implementations§

Source§

impl Space

Source

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

Find space by name.

This function performs SELECT request to _vspace system space.

  • name - space name

Returns:

  • None if not found
  • Some(space) otherwise
Source

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

Find index by name.

This function performs SELECT request to _vindex system space.

  • name - index name

Returns:

  • None if not found
  • Some(index) otherwise
Source

pub fn primary_key(&self) -> Index

Returns index with id = 0

Source

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

Insert a tuple into a space.

  • value - tuple value to insert

Returns a new tuple.

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

Source

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

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.

Source

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

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()

Source

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

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

Source

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

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.

Source

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

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().

Source

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

Search for a tuple in the given space.

Source

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

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, ...]).
Source

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

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, ...]).
Source

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

Delete a tuple identified by a primary key.

  • 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.

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()

Source

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

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§

Source§

impl Into<Space> for SystemSpace

Source§

fn into(self) -> Space

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl Freeze for Space

§

impl RefUnwindSafe for Space

§

impl Send for Space

§

impl Sync for Space

§

impl Unpin for Space

§

impl UnwindSafe for Space

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.