Skip to content

Commit f84143b

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 b5db485 commit f84143b

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
@@ -34,7 +34,7 @@ function sharding.tuple_get_bucket_id(tuple, space, specified_bucket_id)
3434
end
3535
sharding_index_parts = sharding_key_fieldnos.parts
3636
end
37-
local key = utils.extract_key(tuple, sharding_index_parts)
37+
local key = utils.extract_from_tuple(tuple, sharding_index_parts)
3838

3939
return sharding.key_get_bucket_id(key)
4040
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
@@ -208,7 +208,7 @@ function select_plan.new(space, conditions, opts)
208208
local key_def = keydef_lib.new(scan_index.parts)
209209
scan_value = key_def:extract_key(scan_after_tuple)
210210
else
211-
scan_value = utils.extract_key(scan_after_tuple, scan_index.parts)
211+
scan_value = utils.extract_from_tuple(scan_after_tuple, scan_index.parts)
212212
end
213213
else
214214
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)