Struct tarantool::space::Space

source ·
pub struct Space { /* private fields */ }

Implementations§

Return a space builder.

  • name - name of space to be created

Find space by name.

This function performs SELECT request to _vspace system space.

  • name - space name

Returns:

  • None if not found
  • Some(space) otherwise

Memorized version of Space::find function.

The function performs SELECT request to _vspace system space only if it was never called for target space.

  • name - space name

NOTE the cache can become invalid for a number of reasons. If an operation with a space returned from this function results in a TarantoolError with code NoSuchSpace, try calling clear_cache before trying to find the space again.

Returns:

  • None if not found
  • Some(space) otherwise

Get space ID.

Find index by name.

This function performs SELECT request to _vindex system space.

  • name - index name

Returns:

  • None if not found
  • Some(index) otherwise

Memorized version of Space::index function.

This function performs SELECT request to _vindex system space.

  • name - index name

NOTE the cache can become invalid for a number of reasons. If an operation with an index returned from this function results in a TarantoolError with code NoSuchSpace or NoSuchIndexID, try calling clear_cache before trying to get the index again.

Returns:

  • None if not found
  • Some(index) otherwise

Returns index with id = 0

Insert a tuple into a space.

  • value - tuple value to insert

Returns a new tuple.

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

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.

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

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

Return the number of tuples in the space.

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

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, excluding index keys. For a measure of index size, see index.bsize().

Search for a tuple in the given space.

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 the MsgPack Array format ([part1, part2, ...]).

Return the number of tuples. 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 the MsgPack Array format ([part1, part2, ...]).

Delete a tuple identified by a primary key.

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

Returns the deleted tuple

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 the MsgPack Array format ([part1, part2, ...]).
  • ops - encoded operations in the MsgPack array format, e.g. [['=', field_id, value], ['!', 2, 'xxx']]

Returns a new tuple.

See also: space.upsert()

👎Deprecated: use update_raw instead

Update a tuple using ops already encoded in the message pack format.

This function is similar to update but instead of a generic type parameter Op it accepts preencoded message pack values. This is usefull when the operations have values of different types.

Returns a new tuple.

Safety

ops must be a slice of valid msgpack arrays.

Update a tuple using already encoded arguments.

This function is similar to update but instead of generic type parameters T & Op it accepts preencoded message pack arrays. This is usefull when the operations have values of different types.

Safety

key must be a valid msgpack array. ops must be a valid msgpack array of msgpack arrays.

Update or insert a tuple.

If there is an existing tuple which matches the tuple key fields, 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 tuple key fields, 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 cautious use.

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

See also: space.update()

👎Deprecated: use upsert_raw instead

Upsert a tuple using ops already encoded in the message pack format.

This function is similar to upsert but instead of a generic type parameter Op it accepts preencoded message pack values. This is usefull when the operations have values of different types.

Safety

ops must be a slice of valid msgpack arrays.

Upsert a tuple using already encoded arguments.

This function is similar to upsert but instead of generic type parameters T & Op it accepts preencoded message pack arrays. This is usefull when the operations have values of different types.

Safety

value must be a valid msgpack array. ops must be a valid msgpack array of msgpack arrays.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.