Skip to content

Commit cea3dbc

Browse files
committed
Rename utils.extract_key() -> extract_from_tuple()
We have functions that have similar purpose - extract key values: - sharding_key_module.extract_from_pk() - sharding_key_module.extract_from_index() Patch renames utils.extract_key() to utils.extract_from_tuple() to make function's names consistent and make code clear. Part of #166
1 parent 0df99f7 commit cea3dbc

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

crud/common/sharding.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function sharding.tuple_get_bucket_id(tuple, space, specified_bucket_id)
2929
if sharding_key_as_index_obj ~= nil then
3030
sharding_index_parts = sharding_key_as_index_obj.parts
3131
end
32-
local key = utils.extract_key(tuple, sharding_index_parts)
32+
local key = utils.extract_from_tuple(tuple, sharding_index_parts)
3333

3434
return sharding.key_get_bucket_id(key)
3535
end

crud/common/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function utils.unflatten(tuple, space_format)
140140
return object
141141
end
142142

143-
function utils.extract_key(tuple, key_parts)
143+
function utils.extract_from_tuple(tuple, key_parts)
144144
local key = {}
145145
for i, part in ipairs(key_parts) do
146146
key[i] = tuple[part.fieldno]

crud/compare/comparators.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ function comparators.gen_tuples_comparator(cmp_operator, key_parts, field_names,
171171
end
172172
else
173173
return function(lhs, rhs)
174-
local lhs_key = utils.extract_key(lhs, updated_key_parts)
175-
local rhs_key = utils.extract_key(rhs, updated_key_parts)
174+
local lhs_key = utils.extract_from_tuple(lhs, updated_key_parts)
175+
local rhs_key = utils.extract_from_tuple(rhs, updated_key_parts)
176176
return keys_comparator(lhs_key, rhs_key)
177177
end
178178
end

crud/select/executor.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ else
5151
generate_value = function(after_tuple, scan_value, index_parts, tarantool_iter)
5252
local cmp_operator = select_comparators.get_cmp_operator(tarantool_iter)
5353
local scan_comparator = select_comparators.gen_tuples_comparator(cmp_operator, index_parts)
54-
local after_tuple_key = utils.extract_key(after_tuple, index_parts)
54+
local after_tuple_key = utils.extract_from_tuple(after_tuple, index_parts)
5555
if scan_comparator(after_tuple_key, scan_value) then
5656
return after_tuple_key
5757
end

crud/select/plan.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function select_plan.new(space, conditions, opts)
207207
local key_def = keydef_lib.new(scan_index.parts)
208208
scan_value = key_def:extract_key(scan_after_tuple)
209209
else
210-
scan_value = utils.extract_key(scan_after_tuple, scan_index.parts)
210+
scan_value = utils.extract_from_tuple(scan_after_tuple, scan_index.parts)
211211
end
212212
else
213213
scan_value = nil

test/unit/serialization_test.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ g.test_unflatten = function()
150150
})
151151
end
152152

153-
g.test_extract_key = function()
153+
g.test_extract_from_tuple = function()
154154
local tuple = {1, nil, 'Marilyn', 50}
155155

156-
local key = utils.extract_key(tuple, {{fieldno = 1}})
156+
local key = utils.extract_from_tuple(tuple, {{fieldno = 1}})
157157
t.assert_equals(key, {1})
158158

159-
local key = utils.extract_key(tuple, {
159+
local key = utils.extract_from_tuple(tuple, {
160160
{fieldno = 3}, {fieldno = 2}, {fieldno = 1},
161161
})
162162
t.assert_equals(key, {'Marilyn', nil, 1})

0 commit comments

Comments
 (0)