@@ -6,8 +6,7 @@ local dev_checks = require('crud.common.dev_checks')
6
6
local call = require (' crud.common.call' )
7
7
local utils = require (' crud.common.utils' )
8
8
local schema = require (' crud.common.schema' )
9
- local has_keydef , Keydef = pcall (require , ' crud.compare.keydef' )
10
- local select_comparators = require (' crud.compare.comparators' )
9
+ local Keydef = require (' crud.compare.keydef' )
11
10
12
11
local BorderError = errors .new_class (' BorderError' , {capture_stack = false })
13
12
@@ -45,25 +44,14 @@ function borders.init()
45
44
_G ._crud .get_border_on_storage = get_border_on_storage
46
45
end
47
46
48
- local is_closer
49
-
50
- if has_keydef then
51
- is_closer = function (compare_sign , keydef , tuple , res_tuple )
52
- if res_tuple == nil then
53
- return true
54
- end
47
+ local is_closer = function (compare_sign , keydef , tuple , res_tuple )
48
+ if res_tuple == nil then
49
+ return true
50
+ end
55
51
56
- local cmp = keydef :compare (tuple , res_tuple )
52
+ local cmp = keydef :compare (tuple , res_tuple )
57
53
58
- return cmp * compare_sign > 0
59
- end
60
- else
61
- is_closer = function (_ , comparator , tuple , res_tuple )
62
- if res_tuple == nil then
63
- return true
64
- end
65
- return comparator (tuple , res_tuple )
66
- end
54
+ return cmp * compare_sign > 0
67
55
end
68
56
69
57
local function call_get_border_on_router (border_name , space_name , index_name , opts )
@@ -112,20 +100,7 @@ local function call_get_border_on_router(border_name, space_name, index_name, op
112
100
end
113
101
114
102
local compare_sign = border_name == ' max' and 1 or - 1
115
- local comparator
116
- if has_keydef then
117
- comparator = Keydef .new (space , field_names , index .id )
118
- else
119
- local tarantool_iter
120
- if compare_sign > 0 then
121
- tarantool_iter = box .index .GT
122
- else
123
- tarantool_iter = box .index .LT
124
- end
125
- local key_parts = utils .merge_primary_key_parts (index .parts , primary_index .parts )
126
- local cmp_operator = select_comparators .get_cmp_operator (tarantool_iter )
127
- comparator = select_comparators .gen_tuples_comparator (cmp_operator , key_parts , field_names , space :format ())
128
- end
103
+ local keydef = Keydef .new (space , field_names , index .id )
129
104
130
105
local res_tuple = nil
131
106
for _ , storage_result in pairs (results ) do
@@ -136,7 +111,7 @@ local function call_get_border_on_router(border_name, space_name, index_name, op
136
111
end
137
112
138
113
local tuple = storage_result .res
139
- if tuple ~= nil and is_closer (compare_sign , comparator , tuple , res_tuple ) then
114
+ if tuple ~= nil and is_closer (compare_sign , keydef , tuple , res_tuple ) then
140
115
res_tuple = tuple
141
116
end
142
117
end
0 commit comments