module api/lua: add luaT_tuple_encode()
It is the same as luaT_tuple_new(), but returns raw MsgPack data (not <box_tuple_t>) allocated on the box region. The reason to expose this function is to provide ability to use box_tuple_compare_with_key() function from an external module for a key passed as a Lua table. The compare function has the following signature: | API_EXPORT int | box_tuple_compare_with_key(box_tuple_t *tuple_a, const char *key_b, | box_key_def_t *key_def); The second parameter is a key encoded as an MsgPack array, not a tuple structure. So luaT_tuple_new() is not applicable here (it is not worthful to create a tuple structure if we need just MsgPack data). Some complexity was introduced to support encoding on the Lua shared buffer and the box region both. The motivation is the following: - luaT_tuple_encode() is exposed with encoding to the box region, because it is more usual to the module API. In particular a user of the API able to control when the tuple data should be released. - Encoding to the Lua shared buffer is kept internally, because there is no strong reason to change it to the box region for box.tuple.new(). Part of #5273
Showing
- src/box/lua/tuple.c 87 additions, 14 deletionssrc/box/lua/tuple.c
- src/box/lua/tuple.h 17 additions, 0 deletionssrc/box/lua/tuple.h
- src/exports.h 1 addition, 0 deletionssrc/exports.h
- test/app-tap/module_api.c 115 additions, 0 deletionstest/app-tap/module_api.c
- test/app-tap/module_api.test.lua 1 addition, 1 deletiontest/app-tap/module_api.test.lua
Please register or sign in to comment