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})) ```
Showing
- changelogs/unreleased/gh-7356-populate-index-with-keydef.md 5 additions, 0 deletionschangelogs/unreleased/gh-7356-populate-index-with-keydef.md
- src/box/lua/key_def.c 127 additions, 102 deletionssrc/box/lua/key_def.c
- src/box/lua/key_def.h 64 additions, 2 deletionssrc/box/lua/key_def.h
- src/box/lua/merger.c 2 additions, 2 deletionssrc/box/lua/merger.c
- src/box/lua/space.cc 119 additions, 2 deletionssrc/box/lua/space.cc
- test/box-luatest/gh_7356_index_parts_methods_test.lua 161 additions, 0 deletionstest/box-luatest/gh_7356_index_parts_methods_test.lua
- test/box-tap/key_def.test.lua 22 additions, 1 deletiontest/box-tap/key_def.test.lua
Loading
Please register or sign in to comment