Skip to content

Commit cf48e25

Browse files
olegrokAnaNek
andauthored
Use "merger" for fetch&sort tuples on router (#38)
Before this patch we used hand-crafted heap to sort tuples on router. This patch removes it and changes to "merger" module written in C. "Merger" is available since Tarantool 2.2. Later "tuple-merger" was introduced it's a version that is compatible with some Tarantool 1.10 versions. In fact support several Tarantool versions is quite complex task. Some msgpack helpers is not avaliable in Tarantool 1.10 to solve this problem small compatibility lawer is implemented. Also "tuple-keydef" doesn't support collation_id options and it's not so for built-in "key_def" module. We need to normalize index parts and change "collation_id" to "collation" when create "key_def" instance. For versions where merger is not supported/available yet (before 1.10.8 and before 2.3.3) we use previous approach with lua-implemented heap. crud.select.compat.select - default module with merged crud.select.compat.select_old - compatibility module without merger support written in Lua Co-authored-by: AnaNek <[email protected]>
1 parent adf8df5 commit cf48e25

19 files changed

+930
-383
lines changed

.github/workflows/test_on_push.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
run: |
2222
curl -L https://tarantool.io/installer.sh | sudo VER=${{ matrix.tarantool-version }} bash
2323
sudo apt install -y tarantool-dev
24+
tarantool --version
2425
./deps.sh
2526
2627
# This server starts and listen on 8084 port that is used for tests
@@ -50,6 +51,7 @@ jobs:
5051
rm -f tarantool-enterprise-bundle-${{ matrix.bundle_version }}.tar.gz
5152
sudo cp tarantool-enterprise/tarantool /usr/bin/tarantool
5253
source tarantool-enterprise/env.sh
54+
tarantool --version
5355
./deps.sh
5456
5557
# This server starts and listen on 8084 port that is used for tests

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ install(
2828
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cartridge
2929
DESTINATION ${TARANTOOL_INSTALL_LUADIR}
3030
)
31+
32+
# Don't include to rockspec as some Tarantool versions (e.g. 2.2 and 2.3)
33+
# don't have symbols required by "tuple-merger" and "tuple-keydef" modules.
34+
execute_process(
35+
COMMAND bash "-c" "tarantoolctl rocks install tuple-merger 0.0.1"
36+
)

crud/common/call.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ local NotInitializedError = errors.new_class('NotInitialized')
1010

1111
local call = {}
1212

13-
local DEFAULT_VSHARD_CALL_TIMEOUT = 2
13+
call.DEFAULT_VSHARD_CALL_TIMEOUT = 2
1414

15-
local function get_vshard_call_name(mode, prefer_replica, balance)
15+
function call.get_vshard_call_name(mode, prefer_replica, balance)
1616
dev_checks('string', '?boolean', '?boolean')
1717

1818
if mode == 'write' then
@@ -74,9 +74,9 @@ function call.map(func_name, func_args, opts)
7474
})
7575
opts = opts or {}
7676

77-
local vshard_call_name = get_vshard_call_name(opts.mode, opts.prefer_replica, opts.balance)
77+
local vshard_call_name = call.get_vshard_call_name(opts.mode, opts.prefer_replica, opts.balance)
7878

79-
local timeout = opts.timeout or DEFAULT_VSHARD_CALL_TIMEOUT
79+
local timeout = opts.timeout or call.DEFAULT_VSHARD_CALL_TIMEOUT
8080

8181
local replicasets, err
8282
if opts.replicasets ~= nil then
@@ -112,7 +112,7 @@ function call.map(func_name, func_args, opts)
112112
return nil, wrap_vshard_err(err, func_name, replicaset_uuid)
113113
end
114114

115-
results[replicaset_uuid] = result[1]
115+
results[replicaset_uuid] = result
116116
end
117117

118118
return results
@@ -126,9 +126,9 @@ function call.single(bucket_id, func_name, func_args, opts)
126126
timeout = '?number',
127127
})
128128

129-
local vshard_call_name = get_vshard_call_name(opts.mode, opts.prefer_replica, opts.balance, opts.mode)
129+
local vshard_call_name = call.get_vshard_call_name(opts.mode, opts.prefer_replica, opts.balance, opts.mode)
130130

131-
local timeout = opts.timeout or DEFAULT_VSHARD_CALL_TIMEOUT
131+
local timeout = opts.timeout or call.DEFAULT_VSHARD_CALL_TIMEOUT
132132

133133
local res, err = vshard.router[vshard_call_name](bucket_id, func_name, func_args, {
134134
timeout = timeout,

0 commit comments

Comments
 (0)