Skip to content

Commit f58410b

Browse files
oleg-jukovecDifferentialOrange
authored andcommitted
select: improve behavior of select(nil) + after
Previously, the traverse always started from the beginning of the index, now after the after key.
1 parent 3f38b47 commit f58410b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Added
1111

1212
### Changed
13+
* Optimize `crud.select()` without conditions and with `after`.
1314

1415
### Fixed
1516
* `crud.select()` if a condition is '<=' and it's value < `after`.

crud/select/executor.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,24 @@ local generate_value
4343

4444
if has_keydef then
4545
generate_value = function(after_tuple, scan_value, index_parts, tarantool_iter)
46-
local cmp_operator = select_comparators.get_cmp_operator(tarantool_iter)
4746
local key_def = keydef_lib.new(index_parts)
47+
if #scan_value == 0 and after_tuple ~= nil then
48+
return key_def:extract_key(after_tuple)
49+
end
50+
local cmp_operator = select_comparators.get_cmp_operator(tarantool_iter)
4851
local cmp = key_def:compare_with_key(after_tuple, scan_value)
4952
if (cmp_operator == '<' and cmp < 0) or (cmp_operator == '>' and cmp > 0) then
5053
return key_def:extract_key(after_tuple)
5154
end
5255
end
5356
else
5457
generate_value = function(after_tuple, scan_value, index_parts, tarantool_iter)
58+
local after_tuple_key = utils.extract_key(after_tuple, index_parts)
59+
if #scan_value == 0 and after_tuple ~= nil then
60+
return after_tuple_key
61+
end
5562
local cmp_operator = select_comparators.get_cmp_operator(tarantool_iter)
5663
local scan_comparator = select_comparators.gen_tuples_comparator(cmp_operator, index_parts)
57-
local after_tuple_key = utils.extract_key(after_tuple, index_parts)
5864
if scan_comparator(after_tuple_key, scan_value) then
5965
return after_tuple_key
6066
end

0 commit comments

Comments
 (0)