Skip to content
Snippets Groups Projects
Commit 55295f5f authored by Ilya Verbin's avatar Ilya Verbin Committed by Vladimir Davydov
Browse files

box: populate index_object.parts with key_def module methods

This patch adds 4 methods of the key_def module instance to the
`index_object.parts`, see the docbot request for details. The rest
methods (new() and totable()) are not applicable here, because the
instance is already created and pushed to the stack as a table.

Closes #7356

@TarantoolBot document
Title: `index_object.parts` methods
Product: Tarantool
Since: 3.0
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/parts/

`index_object.parts` has the following methods: `extract_key()`,
`compare()`, `compare_with_key()`, `merge()`.
For their description and usage examples, refer to
[Module key_def](https://www.tarantool.io/en/doc/latest/reference/reference_lua/key_def/#lua-object.key_def.key_def_object).

---

Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/key_def/

`index_object.parts` can be used like a key_def module instance for calling
the corresponding methods. Example:

```lua
box.schema.space.create('T')
i = box.space.T:create_index('I', {parts={3, 'string', 1, 'unsigned'}})
box.space.T:insert{1, 99.5, 'X', nil, 99.5}
i.parts:extract_key(box.space.T:get({'X', 1}))
```

The code above is equivalent to:

```lua
key_def = require('key_def')
box.schema.space.create('T')
i = box.space.T:create_index('I', {parts={3, 'string', 1, 'unsigned'}})
box.space.T:insert{1, 99.5, 'X', nil, 99.5}
k = key_def.new(i.parts)
k:extract_key(box.space.T:get({'X', 1}))
```
parent 2e1fea40
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment