diff --git a/src/box/lua/box_net.lua b/src/box/lua/box_net.lua index 3f81b56923453e6ed3a0d8a3ccf5f6d28371a49e..13d39ca501b3a95b33cbb07acc572bcd0f9ae37a 100644 --- a/src/box/lua/box_net.lua +++ b/src/box/lua/box_net.lua @@ -216,19 +216,6 @@ box.net = { [box.net.box.TUPLE] = {...}})) end, - eselect = function(self, sno, ino, key, opts) - local res = self:call('box.net.self:eselect', sno, ino, key, opts) - if opts and opts.limit == nil then - if res[1] ~= nil then - return res[1] - else - return - end - end - return res - end, - - -- To make use of timeouts safe across multiple -- concurrent fibers do not store timeouts as -- part of conection state, but put it inside @@ -264,23 +251,6 @@ box.net = { return box.process(...) end, - - eselect = function(self, sno, ino, key, opts) - local space = box.space[ sno ] - if space == nil then - box.raise(box.error.ER_NO_SUCH_SPACE, - sprintf("No such space #%s", tostring(sno))) - end - local index = space.index[ ino ] - if index == nil then - box.raise(box.error.ER_NO_SUCH_INDEX, - sprintf("No such index #%s in space #%s", - tostring(sno), tostring(ino))) - end - - return index:eselect(key, opts) - end, - -- for compatibility with the networked version, -- implement call call = function(self, proc_name, ...) diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index e92e5f60124a50d4d466bf9aeb477d5613f88c9f..6c35a289107c880bb8003848e67c9a8afbffd593 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -112,8 +112,7 @@ box.schema.index.create = function(space_id, name, options) local iid = 0 -- max local tuple = _index.index[0] - :eselect(space_id, { limit = 1, iterator = 'LE' }) - tuple = tuple[1] + :select(space_id, { limit = 1, iterator = 'LE' })[1] if tuple then local id = tuple[0] if id == space_id then @@ -266,9 +265,9 @@ function box.schema.space.bless(space) if index.type == 'HASH' then box.raise(box.error.ER_UNSUPPORTED, 'HASH does not support min()') end - local lst = index:eselect(key, { iterator = 'GE', limit = 1 }) - if lst[1] ~= nil then - return lst[1] + local lst = index:select(key, { iterator = 'GE', limit = 1 })[1] + if lst ~= nil then + return lst else return end @@ -277,9 +276,9 @@ function box.schema.space.bless(space) if index.type == 'HASH' then box.raise(box.error.ER_UNSUPPORTED, 'HASH does not support max()') end - local lst = index:eselect(key, { iterator = 'LE', limit = 1 }) - if lst[1] ~= nil then - return lst[1] + local lst = index:select(key, { iterator = 'LE', limit = 1 })[1] + if lst ~= nil then + return lst else return end @@ -341,72 +340,6 @@ function box.schema.space.bless(space) end end - -- eselect - index_mt.eselect = function(index, key, opts) - -- user can catch link to index - check_index(box.space[index.n], index.id) - - if opts == nil then - opts = {} - end - - local iterator = opts.iterator - - if iterator == nil then - iterator = box.index.EQ - end - if type(iterator) == 'string' then - if box.index[ iterator ] == nil then - error(string.format("Wrong iterator: %s", tostring(iterator))) - end - iterator = box.index[ iterator ] - end - - local result = {} - local offset = 0 - local skip = 0 - local count = 0 - if opts.offset ~= nil then - offset = tonumber(opts.offset) - end - local limit = opts.limit - local grep = opts.grep - local map = opts.map - - if limit == 0 then - return result - end - - local state, tuple - for state, tuple in index:pairs(key, { iterator = iterator }) do - if grep == nil or grep(tuple) then - if skip < offset then - skip = skip + 1 - else - if map == nil then - table.insert(result, tuple) - else - table.insert(result, map(tuple)) - end - count = count + 1 - - if limit == nil then - if count > 1 then - box.raise(box.error.ER_MORE_THAN_ONE_TUPLE, - "More than one tuple found without 'limit'") - end - elseif count >= limit then - break - end - end - end - end - if limit == nil then - return result[1] - end - return result - end - index_mt.get = function(index, key) local key, key_end = msgpackffi.encode_tuple(key) port.size = 0; @@ -481,10 +414,6 @@ function box.schema.space.bless(space) space_mt.len = function(space) return space.index[0]:len() end space_mt.__newindex = index_mt.__newindex - space_mt.eselect = function(space, key, opts) - check_index(space, 0) - return space.index[0]:eselect(key, opts) - end space_mt.get = function(space, key) check_index(space, 0) return space.index[0]:get(key) diff --git a/test/big/lua.result b/test/big/lua.result index 524b6a6a3e201b520da9361934e0186d0a8ebcaf..ac735f27458e3a7b657b5afe8296c2040cbcd970 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -135,12 +135,12 @@ space:insert{00000001ULL, 'of', 'might', 'and', 'magic'} --- - [1, 'of', 'might', 'and', 'magic'] ... -space.index['minmax']:eselect('of', { limit = 2, iterator = 'GE' }) +space.index['minmax']:select('of', { limit = 2, iterator = 'GE' }) --- - - [1, 'of', 'might', 'and', 'magic'] - [0, 'of', 'puppets'] ... -space.index['minmax']:eselect('of', { limit = 2, iterator = 'LE' }) +space.index['minmax']:select('of', { limit = 2, iterator = 'LE' }) --- - - [0, 'of', 'puppets'] - [1, 'of', 'might', 'and', 'magic'] @@ -321,7 +321,7 @@ space:insert{9, 0} --- - [9, 0] ... -space.index['range']:eselect({}, { limit = 10, iterator = 'GE' }) +space.index['range']:select({}, { limit = 10, iterator = 'GE' }) --- - - [0, 0] - [1, 0] @@ -334,7 +334,7 @@ space.index['range']:eselect({}, { limit = 10, iterator = 'GE' }) - [8, 0] - [9, 0] ... -space.index['range']:eselect({}, { limit = 10, iterator = 'LE' }) +space.index['range']:select({}, { limit = 10, iterator = 'LE' }) --- - - [9, 0] - [8, 0] @@ -347,7 +347,7 @@ space.index['range']:eselect({}, { limit = 10, iterator = 'LE' }) - [1, 0] - [0, 0] ... -space.index['range']:eselect({}, { limit = 4, iterator = 'LE' }) +space.index['range']:select({}, { limit = 4, iterator = 'LE' }) --- - - [9, 0] - [8, 0] @@ -472,7 +472,7 @@ t = {} ... index:pairs('sid_t', { iterator = 'wrong_iterator_type' }) --- -- error: '[string "-- schema.lua (internal file)..."]:299: Wrong iterator type: wrong_iterator_type' +- error: '[string "-- schema.lua (internal file)..."]:298: Wrong iterator type: wrong_iterator_type' ... index = nil --- diff --git a/test/big/lua.test.lua b/test/big/lua.test.lua index b96493075571849fc8f96b50cff58e5c0abfaa90..a6d64be50fe3b25f808c714bb3f44177443eeca5 100644 --- a/test/big/lua.test.lua +++ b/test/big/lua.test.lua @@ -52,8 +52,8 @@ space:create_index('minmax', { type = 'tree', parts = {1, 'str', 2, 'str'}, uniq space:insert{1234567, 'new', 'world'} space:insert{0, 'of', 'puppets'} space:insert{00000001ULL, 'of', 'might', 'and', 'magic'} -space.index['minmax']:eselect('of', { limit = 2, iterator = 'GE' }) -space.index['minmax']:eselect('of', { limit = 2, iterator = 'LE' }) +space.index['minmax']:select('of', { limit = 2, iterator = 'GE' }) +space.index['minmax']:select('of', { limit = 2, iterator = 'LE' }) space:truncate() -- @@ -121,9 +121,9 @@ space:insert{6, 0} space:insert{7, 0} space:insert{8, 0} space:insert{9, 0} -space.index['range']:eselect({}, { limit = 10, iterator = 'GE' }) -space.index['range']:eselect({}, { limit = 10, iterator = 'LE' }) -space.index['range']:eselect({}, { limit = 4, iterator = 'LE' }) +space.index['range']:select({}, { limit = 10, iterator = 'GE' }) +space.index['range']:select({}, { limit = 10, iterator = 'LE' }) +space.index['range']:select({}, { limit = 4, iterator = 'LE' }) space:drop() -- diff --git a/test/big/sql.result b/test/big/sql.result index cfc2318c3830c2e180de7baa72704d45e44fe972..787aef83f8eac8678dae60bb4768878f653b34db 100644 --- a/test/big/sql.result +++ b/test/big/sql.result @@ -89,11 +89,11 @@ select * from t0 where k1='Britney' --- - ['Spears', 'Britney'] ... -s.index[0]:eselect('Spears', { limit = 100, iterator = 'GE' }) +s.index[0]:select('Spears', { limit = 100, iterator = 'GE' }) --- - - ['Spears', 'Britney'] ... -s.index[1]:eselect('Britney', { limit = 100, iterator = 'GE' }) +s.index[1]:select('Britney', { limit = 100, iterator = 'GE' }) --- - - ['Spears', 'Britney'] ... @@ -150,18 +150,18 @@ select * from t0 where k1='part1' - ['key2', 'part1', 'part2_a'] - ['key3', 'part1', 'part2_b'] ... -s.index[1]:eselect('part1', { limit = 100, iterator = 'GE' }) +s.index[1]:select('part1', { limit = 100, iterator = 'GE' }) --- - - ['key1', 'part1', 'part2'] - ['key2', 'part1', 'part2_a'] - ['key3', 'part1', 'part2_b'] ... -s.index[0]:eselect('key2', { limit = 100, iterator = 'GE' }) +s.index[0]:select('key2', { limit = 100, iterator = 'GE' }) --- - - ['key2', 'part1', 'part2_a'] - ['key3', 'part1', 'part2_b'] ... -s.index[1]:eselect({ 'part1', 'part2_a' }, { limit = 100, iterator = 'GE' }) +s.index[1]:select({ 'part1', 'part2_a' }, { limit = 100, iterator = 'GE' }) --- - - ['key2', 'part1', 'part2_a'] - ['key3', 'part1', 'part2_b'] diff --git a/test/big/sql.test.py b/test/big/sql.test.py index 1d3854dbd55669c6b3b36dbe52ee511a2d538d5d..558103d06b9172280a03d06be15c309e929d862d 100644 --- a/test/big/sql.test.py +++ b/test/big/sql.test.py @@ -45,8 +45,8 @@ sql("select * from t0 where k0='Spears'") sql("select * from t0 where k1='Anything'") sql("select * from t0 where k1='Britney'") -admin("s.index[0]:eselect('Spears', { limit = 100, iterator = 'GE' })") -admin("s.index[1]:eselect('Britney', { limit = 100, iterator = 'GE' })") +admin("s.index[0]:select('Spears', { limit = 100, iterator = 'GE' })") +admin("s.index[1]:select('Britney', { limit = 100, iterator = 'GE' })") sql("delete from t0 where k0='Spears'") @@ -69,9 +69,9 @@ sql("select * from t0 where k0='key1'") sql("select * from t0 where k0='key2'") sql("select * from t0 where k0='key3'") sql("select * from t0 where k1='part1'") -admin("s.index[1]:eselect('part1', { limit = 100, iterator = 'GE' })") -admin("s.index[0]:eselect('key2', { limit = 100, iterator = 'GE' })") -admin("s.index[1]:eselect({ 'part1', 'part2_a' }, { limit = 100, iterator = 'GE' })") +admin("s.index[1]:select('part1', { limit = 100, iterator = 'GE' })") +admin("s.index[0]:select('key2', { limit = 100, iterator = 'GE' })") +admin("s.index[1]:select({ 'part1', 'part2_a' }, { limit = 100, iterator = 'GE' })") sql("select * from t0 where k0='key1'") sql("select * from t0 where k0='key2'") sql("select * from t0 where k0='key3'") diff --git a/test/big/tree_pk.result b/test/big/tree_pk.result index 0eeee0869a33fc62c1863689aad2996c03e05940..303b1e24c28693f9a31e6edefae6c9a5284376b2 100644 --- a/test/big/tree_pk.result +++ b/test/big/tree_pk.result @@ -96,11 +96,11 @@ box.snapshot() --- - ok ... -s1.index['primary']:eselect('second', { limit = 100, iterator = 'GE' }) +s1.index['primary']:select('second', { limit = 100, iterator = 'GE' }) --- - - ['second', 'tuple 2'] ... -s1.index['primary']:eselect('identifier', { limit = 100, iterator = 'GE' }) +s1.index['primary']:select('identifier', { limit = 100, iterator = 'GE' }) --- - - ['identifier', 'tuple'] - ['second', 'tuple 2'] @@ -248,7 +248,7 @@ s1:insert{'abcdc_'} --- - ['abcdc_'] ... -box.sort(s1.index['primary']:eselect('abcdb', { limit = 3, iterator = 'GE' })) +box.sort(s1.index['primary']:select('abcdb', { limit = 3, iterator = 'GE' })) --- - - ['abcdb'] - ['abcdb_'] diff --git a/test/big/tree_pk.test.lua b/test/big/tree_pk.test.lua index e950f3be2e9e24058c471e5511913585006e5670..04ffddee1ab79c0071c08834eb35adb8590e69a4 100644 --- a/test/big/tree_pk.test.lua +++ b/test/big/tree_pk.test.lua @@ -36,8 +36,8 @@ s1:insert{'identifier', 'tuple'} box.snapshot() s1:insert{'second', 'tuple 2'} box.snapshot() -s1.index['primary']:eselect('second', { limit = 100, iterator = 'GE' }) -s1.index['primary']:eselect('identifier', { limit = 100, iterator = 'GE' }) +s1.index['primary']:select('second', { limit = 100, iterator = 'GE' }) +s1.index['primary']:select('identifier', { limit = 100, iterator = 'GE' }) s1:insert{'third', 'tuple 3'} s1.index['primary']:get{'identifier'} @@ -96,7 +96,7 @@ s1:insert{'abcdb__'} s1:insert{'abcdb___'} s1:insert{'abcdc'} s1:insert{'abcdc_'} -box.sort(s1.index['primary']:eselect('abcdb', { limit = 3, iterator = 'GE' })) +box.sort(s1.index['primary']:select('abcdb', { limit = 3, iterator = 'GE' })) s1:drop() s1 = nil s2:drop() diff --git a/test/box/admin.result b/test/box/admin.result index 6a8cf5c744b7d2f02b1f9f5f2b13ea0e236d19e0..29757534ecb0eecf5913c9331e3792b5bb30b3df 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -14,7 +14,7 @@ box.stat() total: 0 rps: 0 SELECT: - total: 0 + total: 1 rps: 0 REPLACE: total: 0 @@ -76,7 +76,7 @@ box.stat() total: 0 rps: 0 SELECT: - total: 0 + total: 1 rps: 0 REPLACE: total: 0 diff --git a/test/box/net.box.result b/test/box/net.box.result index dd3197dea4afb15a1e4cb56ac5f7e7a44e5aad63..335d6819a6808dc7964d5641bee860ee625e1081 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -268,17 +268,17 @@ space:select{345} --- - - [345, 'test1-replaced', 'test2-replaced'] ... -space:eselect({}, { iterator = 'GE', limit = 1000 }) +space:select({}, { iterator = 'GE', limit = 1000 }) --- - - [123, 'test1-updated', 'test2-updated'] - [345, 'test1-replaced', 'test2-replaced'] ... -box.net.self:eselect(space.n, 0, {}, { iterator = 'GE', limit = 1000 }) +box.net.self:select(space.n, {}, { iterator = 'GE', limit = 1000 }) --- - - [123, 'test1-updated', 'test2-updated'] - [345, 'test1-replaced', 'test2-replaced'] ... -remote:eselect(space.n, 0, {}, { limit = 1000, iterator = 'GE' }) +remote:select(space.n, {}, { limit = 1000, iterator = 'GE' }) --- - - [123, 'test1-updated', 'test2-updated'] - [345, 'test1-replaced', 'test2-replaced'] @@ -413,10 +413,6 @@ box.net.self.rpc.box.space.tweedledum.index.primary:select(12345) --- - - - [12345, 'test11', 'test2'] ... -remote.rpc.box.space.tweedledum.index.primary:eselect(12345) ---- -- - [12345, 'test11', 'test2'] -... remote.rpc.box.space.tweedledum.index.primary:get(12345) --- - - [12345, 'test11', 'test2'] @@ -431,11 +427,11 @@ remote:close() ... remote:close() --- -- error: '[string "-- box_net.lua (internal file)..."]:558: box.net.box: already closed' +- error: '[string "-- box_net.lua (internal file)..."]:528: box.net.box: already closed' ... remote:ping() --- -- error: '[string "-- box_net.lua (internal file)..."]:563: box.net.box: connection +- error: '[string "-- box_net.lua (internal file)..."]:533: box.net.box: connection was closed' ... space:drop() diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 01a55fa75071d8c5437422169140fe25d24b413f..388922aeafc115ef42fc93e49bc581c4c329362b 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -84,9 +84,9 @@ remote:replace(space.n, {345, 'test1-replaced', 'test2-replaced'}) space:get{345} space:select{345} -space:eselect({}, { iterator = 'GE', limit = 1000 }) -box.net.self:eselect(space.n, 0, {}, { iterator = 'GE', limit = 1000 }) -remote:eselect(space.n, 0, {}, { limit = 1000, iterator = 'GE' }) +space:select({}, { iterator = 'GE', limit = 1000 }) +box.net.self:select(space.n, {}, { iterator = 'GE', limit = 1000 }) +remote:select(space.n, {}, { limit = 1000, iterator = 'GE' }) space:get{345} space:select{345} remote:get(space.n, {345}) @@ -141,7 +141,6 @@ box.time() - pstart < 0.5 box.net.self.rpc.box.space.tweedledum.index.primary:get(12345) box.net.self.rpc.box.space.tweedledum.index.primary:select(12345) -remote.rpc.box.space.tweedledum.index.primary:eselect(12345) remote.rpc.box.space.tweedledum.index.primary:get(12345) remote.rpc.box.space.tweedledum.index.primary:select(12345) diff --git a/test/box/select.result b/test/box/select.result index 87fc606668d19ee54f46a60a9a8ff2ce33af9794..85a57e6171db7b36ed4401f9c25b9b98665d1f1a 100644 --- a/test/box/select.result +++ b/test/box/select.result @@ -1,7 +1,4 @@ -print('eselect') ---- -... -s = box.schema.create_space('eselect', { temporary = true }) +s = box.schema.create_space('select', { temporary = true }) --- ... index = s:create_index('primary', { type = 'tree' }) @@ -13,101 +10,6 @@ s:create_index('second', { type = 'tree', unique = true, parts = {1, 'num', 0, for i = 1, 20 do s:insert({ i, 1, 2, 3 }) end --- ... -s.index[0]:eselect(nil, { iterator = 'ALL', offset = 0, limit = 4294967295 }) ---- -- - [1, 1, 2, 3] - - [2, 1, 2, 3] - - [3, 1, 2, 3] - - [4, 1, 2, 3] - - [5, 1, 2, 3] - - [6, 1, 2, 3] - - [7, 1, 2, 3] - - [8, 1, 2, 3] - - [9, 1, 2, 3] - - [10, 1, 2, 3] - - [11, 1, 2, 3] - - [12, 1, 2, 3] - - [13, 1, 2, 3] - - [14, 1, 2, 3] - - [15, 1, 2, 3] - - [16, 1, 2, 3] - - [17, 1, 2, 3] - - [18, 1, 2, 3] - - [19, 1, 2, 3] - - [20, 1, 2, 3] -... -s.index[0]:eselect({}, { iterator = 'ALL', offset = 0, limit = 4294967295 }) ---- -- - [1, 1, 2, 3] - - [2, 1, 2, 3] - - [3, 1, 2, 3] - - [4, 1, 2, 3] - - [5, 1, 2, 3] - - [6, 1, 2, 3] - - [7, 1, 2, 3] - - [8, 1, 2, 3] - - [9, 1, 2, 3] - - [10, 1, 2, 3] - - [11, 1, 2, 3] - - [12, 1, 2, 3] - - [13, 1, 2, 3] - - [14, 1, 2, 3] - - [15, 1, 2, 3] - - [16, 1, 2, 3] - - [17, 1, 2, 3] - - [18, 1, 2, 3] - - [19, 1, 2, 3] - - [20, 1, 2, 3] -... -s.index[0]:eselect(1) ---- -- [1, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = box.index.EQ }) ---- -- [1, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'EQ' }) ---- -- [1, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'GE' }) ---- -- error: More than one tuple found without 'limit' -... -s.index[0]:eselect(1, { iterator = 'GE', limit = 2 }) ---- -- - [1, 1, 2, 3] - - [2, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'LE', limit = 2 }) ---- -- - [1, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'GE', offset = 10, limit = 2 }) ---- -- - [11, 1, 2, 3] - - [12, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'GE', grep = function(t) if math.fmod(t[0], 2) == 0 then return true end end, limit = 2 }) ---- -- - [2, 1, 2, 3] - - [4, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'GE', grep = function(t) if math.fmod(t[0], 2) == 0 then return true end end, limit = 2, offset = 1 }) ---- -- - [4, 1, 2, 3] - - [6, 1, 2, 3] -... -s.index[0]:eselect(1, { iterator = 'GE', grep = function(t) if math.fmod(t[0], 2) == 0 then return true end end, limit = 2, offset = 1, map = function(t) return { t[0] } end }) ---- -- - - 4 - - - 6 -... -s:eselect(2) ---- -- [2, 1, 2, 3] -... -------------------------------------------------------------------------------- -- get tests -------------------------------------------------------------------------------- @@ -534,6 +436,105 @@ s.index[1]:select({1, 2}) --- - - [2, 1, 2, 3] ... +s.index[0]:select(nil, { iterator = 'ALL', offset = 0, limit = 4294967295 }) +--- +- - [1, 1, 2, 3] + - [2, 1, 2, 3] + - [3, 1, 2, 3] + - [4, 1, 2, 3] + - [5, 1, 2, 3] + - [6, 1, 2, 3] + - [7, 1, 2, 3] + - [8, 1, 2, 3] + - [9, 1, 2, 3] + - [10, 1, 2, 3] + - [11, 1, 2, 3] + - [12, 1, 2, 3] + - [13, 1, 2, 3] + - [14, 1, 2, 3] + - [15, 1, 2, 3] + - [16, 1, 2, 3] + - [17, 1, 2, 3] + - [18, 1, 2, 3] + - [19, 1, 2, 3] + - [20, 1, 2, 3] +... +s.index[0]:select({}, { iterator = 'ALL', offset = 0, limit = 4294967295 }) +--- +- - [1, 1, 2, 3] + - [2, 1, 2, 3] + - [3, 1, 2, 3] + - [4, 1, 2, 3] + - [5, 1, 2, 3] + - [6, 1, 2, 3] + - [7, 1, 2, 3] + - [8, 1, 2, 3] + - [9, 1, 2, 3] + - [10, 1, 2, 3] + - [11, 1, 2, 3] + - [12, 1, 2, 3] + - [13, 1, 2, 3] + - [14, 1, 2, 3] + - [15, 1, 2, 3] + - [16, 1, 2, 3] + - [17, 1, 2, 3] + - [18, 1, 2, 3] + - [19, 1, 2, 3] + - [20, 1, 2, 3] +... +s.index[0]:select(1) +--- +- - [1, 1, 2, 3] +... +s.index[0]:select(1, { iterator = box.index.EQ }) +--- +- - [1, 1, 2, 3] +... +s.index[0]:select(1, { iterator = 'EQ' }) +--- +- - [1, 1, 2, 3] +... +s.index[0]:select(1, { iterator = 'GE' }) +--- +- - [1, 1, 2, 3] + - [2, 1, 2, 3] + - [3, 1, 2, 3] + - [4, 1, 2, 3] + - [5, 1, 2, 3] + - [6, 1, 2, 3] + - [7, 1, 2, 3] + - [8, 1, 2, 3] + - [9, 1, 2, 3] + - [10, 1, 2, 3] + - [11, 1, 2, 3] + - [12, 1, 2, 3] + - [13, 1, 2, 3] + - [14, 1, 2, 3] + - [15, 1, 2, 3] + - [16, 1, 2, 3] + - [17, 1, 2, 3] + - [18, 1, 2, 3] + - [19, 1, 2, 3] + - [20, 1, 2, 3] +... +s.index[0]:select(1, { iterator = 'GE', limit = 2 }) +--- +- - [1, 1, 2, 3] + - [2, 1, 2, 3] +... +s.index[0]:select(1, { iterator = 'LE', limit = 2 }) +--- +- - [1, 1, 2, 3] +... +s.index[0]:select(1, { iterator = 'GE', offset = 10, limit = 2 }) +--- +- - [11, 1, 2, 3] + - [12, 1, 2, 3] +... +s:select(2) +--- +- - [2, 1, 2, 3] +... s:drop() --- ... diff --git a/test/box/select.test.lua b/test/box/select.test.lua index 2fd3018a1196312e6d8b4fdeee03540588692e13..b98a061d66d306cf477bf9929704f70d1075586c 100644 --- a/test/box/select.test.lua +++ b/test/box/select.test.lua @@ -1,30 +1,8 @@ -print('eselect') - -s = box.schema.create_space('eselect', { temporary = true }) +s = box.schema.create_space('select', { temporary = true }) index = s:create_index('primary', { type = 'tree' }) s:create_index('second', { type = 'tree', unique = true, parts = {1, 'num', 0, 'num'}}) - for i = 1, 20 do s:insert({ i, 1, 2, 3 }) end - -s.index[0]:eselect(nil, { iterator = 'ALL', offset = 0, limit = 4294967295 }) -s.index[0]:eselect({}, { iterator = 'ALL', offset = 0, limit = 4294967295 }) - -s.index[0]:eselect(1) -s.index[0]:eselect(1, { iterator = box.index.EQ }) -s.index[0]:eselect(1, { iterator = 'EQ' }) -s.index[0]:eselect(1, { iterator = 'GE' }) -s.index[0]:eselect(1, { iterator = 'GE', limit = 2 }) -s.index[0]:eselect(1, { iterator = 'LE', limit = 2 }) -s.index[0]:eselect(1, { iterator = 'GE', offset = 10, limit = 2 }) - -s.index[0]:eselect(1, { iterator = 'GE', grep = function(t) if math.fmod(t[0], 2) == 0 then return true end end, limit = 2 }) -s.index[0]:eselect(1, { iterator = 'GE', grep = function(t) if math.fmod(t[0], 2) == 0 then return true end end, limit = 2, offset = 1 }) -s.index[0]:eselect(1, { iterator = 'GE', grep = function(t) if math.fmod(t[0], 2) == 0 then return true end end, limit = 2, offset = 1, map = function(t) return { t[0] } end }) - - -s:eselect(2) - -------------------------------------------------------------------------------- -- get tests -------------------------------------------------------------------------------- @@ -84,4 +62,17 @@ s.index[1]:select({1, 2}, {iterator = 'EQ'}) s.index[1]:select({1, 2}, {iterator = box.index.REQ}) s.index[1]:select({1, 2}) +s.index[0]:select(nil, { iterator = 'ALL', offset = 0, limit = 4294967295 }) +s.index[0]:select({}, { iterator = 'ALL', offset = 0, limit = 4294967295 }) + +s.index[0]:select(1) +s.index[0]:select(1, { iterator = box.index.EQ }) +s.index[0]:select(1, { iterator = 'EQ' }) +s.index[0]:select(1, { iterator = 'GE' }) +s.index[0]:select(1, { iterator = 'GE', limit = 2 }) +s.index[0]:select(1, { iterator = 'LE', limit = 2 }) +s.index[0]:select(1, { iterator = 'GE', offset = 10, limit = 2 }) + +s:select(2) + s:drop() diff --git a/test/box/stat.result b/test/box/stat.result index 809b150120014f502a471c6e74f7453278c6bcbd..a6bf3953ff026edc5174c2423131a02277a821a3 100644 --- a/test/box/stat.result +++ b/test/box/stat.result @@ -18,7 +18,7 @@ box.stat() total: 0 rps: 0 SELECT: - total: 0 + total: 1 rps: 0 REPLACE: total: 0