diff --git a/test/big/hash.result b/test/big/hash.result index 0a1d8d16c397f5f015165dea428ab31aa39f2095..ad9121ba38187e45077b358c12b8030d2dfaaf66 100644 --- a/test/big/hash.result +++ b/test/big/hash.result @@ -7,15 +7,10 @@ dofile('utils.lua') ------------------------------------------------------------------------------- -- 32-bit hash insert fields tests ------------------------------------------------------------------------------- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +hash = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] -... -hash = box.space[0] +hash:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- ... -- Insert valid fields @@ -65,34 +60,34 @@ hash:replace('invalid key', 'value1 v1.0', 'value2 v1.0') -- 32-bit hash select fields test ------------------------------------------------------------------------------- -- select by valid keys -hash:select(0, 0) +hash.index['primary']:select(0) --- - [0, 'value1 v1.0', 'value2 v1.0'] ... -hash:select(0, 1) +hash.index['primary']:select(1) --- - [1, 'value1 v1.32', 'value2 1.72'] ... -hash:select(0, 2) +hash.index['primary']:select(2) --- - [2, 'value1 v1.43', 'value2 1.92'] ... -hash:select(0, 3) +hash.index['primary']:select(3) --- - [3, 'value1 v1.31', 'value2 1.12'] ... -hash:select(0, 4) +hash.index['primary']:select(4) --- ... -hash:select(0, 5) +hash.index['primary']:select(5) --- ... -- select by invalid keys -hash:select(0, 'invalid key') +hash.index['primary']:select('invalid key') --- - error: 'Supplied key type of part 0 does not match index part type: expected NUM' ... -hash:select(0, 1, 2) +hash.index['primary']:select(1, 2) --- - error: Invalid key part count (expected [0..1], got 2) ... @@ -140,13 +135,6 @@ hash:truncate() ------------------------------------------------------------------------------- -- 64-bit hash inset fields tests ------------------------------------------------------------------------------- -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] -... -hash = box.space[0] ---- -... -- Insert valid fields hash:insert(0ULL, 'value1 v1.0', 'value2 v1.0') --- @@ -222,57 +210,57 @@ hash:replace('invalid key', 'value1 v1.0', 'value2 v1.0') -- 64-bit hash select fields test ------------------------------------------------------------------------------- -- select by valid keys -hash:select(0, 0ULL) +hash.index['primary']:select(0ULL) --- - [0, 'value1 v1.0', 'value2 v1.0'] ... -hash:select(0, 1ULL) +hash.index['primary']:select(1ULL) --- - [1, 'value1 v1.32', 'value2 1.72'] ... -hash:select(0, 2ULL) +hash.index['primary']:select(2ULL) --- - [2, 'value1 v1.43', 'value2 1.92'] ... -hash:select(0, 3ULL) +hash.index['primary']:select(3ULL) --- - [3, 'value1 v1.31', 'value2 1.12'] ... -hash:select(0, 4ULL) +hash.index['primary']:select(4ULL) --- ... -hash:select(0, 5ULL) +hash.index['primary']:select(5ULL) --- ... -- select by valid NUM keys -hash:select(0, 0) +hash.index['primary']:select(0) --- - [0, 'value1 v1.0', 'value2 v1.0'] ... -hash:select(0, 1) +hash.index['primary']:select(1) --- - [1, 'value1 v1.32', 'value2 1.72'] ... -hash:select(0, 2) +hash.index['primary']:select(2) --- - [2, 'value1 v1.43', 'value2 1.92'] ... -hash:select(0, 3) +hash.index['primary']:select(3) --- - [3, 'value1 v1.31', 'value2 1.12'] ... -hash:select(0, 4) +hash.index['primary']:select(4) --- ... -hash:select(0, 5) +hash.index['primary']:select(5) --- ... -- select by invalid keys -hash:select(0, 'invalid key') +hash.index['primary']:select('invalid key') --- - error: 'Supplied key type of part 0 does not match index part type: expected NUM' ... -hash:select(0, '00000001', '00000002') +hash.index['primary']:select('00000001', '00000002') --- - error: Invalid key part count (expected [0..1], got 2) ... @@ -359,11 +347,10 @@ hash:truncate() ------------------------------------------------------------------------------- -- String hash inset fields tests ------------------------------------------------------------------------------- -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') +hash.index['primary']:drop() --- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'str'] ... -hash = box.space[0] +hash:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) --- ... -- Insert valid fields @@ -403,30 +390,30 @@ hash:replace('key 2', 'value1 v1.43', 'value2 1.92') -- String hash select fields test ------------------------------------------------------------------------------- -- select by valid keys -hash:select(0, 'key 0') +hash.index['primary']:select('key 0') --- - ['key 0', 'value1 v1.0', 'value2 v1.0'] ... -hash:select(0, 'key 1') +hash.index['primary']:select('key 1') --- - ['key 1', 'value1 v1.32', 'value2 1.72'] ... -hash:select(0, 'key 2') +hash.index['primary']:select('key 2') --- - ['key 2', 'value1 v1.43', 'value2 1.92'] ... -hash:select(0, 'key 3') +hash.index['primary']:select('key 3') --- - ['key 3', 'value1 v1.31', 'value2 1.12'] ... -hash:select(0, 'key 4') +hash.index['primary']:select('key 4') --- ... -hash:select(0, 'key 5') +hash.index['primary']:select('key 5') --- ... -- select by invalid keys -hash:select(0, 'key 1', 'key 2') +hash.index['primary']:select('key 1', 'key 2') --- - error: Invalid key part count (expected [0..1], got 2) ... @@ -467,23 +454,19 @@ hash:truncate() ------------------------ -- hash::replace tests ------------------------ -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +hash.index['primary']:drop() --- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] ... -box.replace(box.schema.INDEX_ID, 0, 1, 'field1', 'hash', 1, 1, 1, 'num') +hash:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- -- [0, 1, 'field1', 'hash', 1, 1, 1, 'num'] ... -box.replace(box.schema.INDEX_ID, 0, 2, 'field2', 'hash', 1, 1, 2, 'num') +hash:create_index('field1', 'hash', {parts = {1, 'num'}, unique = true }) --- -- [0, 2, 'field2', 'hash', 1, 1, 2, 'num'] ... -box.replace(box.schema.INDEX_ID, 0, 3, 'field3', 'hash', 1, 1, 3, 'num') +hash:create_index('field2', 'hash', {parts = {2, 'num'}, unique = true }) --- -- [0, 3, 'field3', 'hash', 1, 1, 3, 'num'] ... -hash = box.space[0] +hash:create_index('field3', 'hash', {parts = {3, 'num'}, unique = true }) --- ... hash:insert(0, 0, 0, 0) @@ -511,31 +494,31 @@ hash:replace_if_exists(1, 1, 1, 1) --- - [1, 1, 1, 1] ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -hash:select(0, 1) +hash.index['primary']:select(1) --- - [1, 1, 1, 1] ... -hash:select(1, 1) +hash.index['field1']:select(1) --- - [1, 1, 1, 1] ... -hash:select(2, 1) +hash.index['field2']:select(1) --- - [1, 1, 1, 1] ... -hash:select(3, 1) +hash.index['field3']:select(1) --- - [1, 1, 1, 1] ... @@ -548,16 +531,16 @@ hash:delete(10) --- - [10, 10, 10, 10] ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -- TupleFound (primary key) @@ -565,19 +548,19 @@ hash:insert(1, 10, 10, 10) --- - error: Duplicate key exists in unique index 0 ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -hash:select(0, 1) +hash.index['primary']:select(1) --- - [1, 1, 1, 1] ... @@ -586,16 +569,16 @@ hash:replace_if_exists(10, 10, 10, 10) --- - error: Tuple doesn't exist in index 0 ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -- TupleFound (key --1) @@ -603,19 +586,19 @@ hash:insert(10, 0, 10, 10) --- - error: Duplicate key exists in unique index 1 ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -hash:select(1, 0) +hash.index['field1']:select(0) --- - [0, 0, 0, 0] ... @@ -624,19 +607,19 @@ hash:replace_if_exists(2, 0, 10, 10) --- - error: Duplicate key exists in unique index 1 ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -hash:select(1, 0) +hash.index['field1']:select(0) --- - [0, 0, 0, 0] ... @@ -645,19 +628,19 @@ hash:insert(10, 10, 10, 0) --- - error: Duplicate key exists in unique index 3 ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -hash:select(3, 0) +hash.index['field3']:select(0) --- - [0, 0, 0, 0] ... @@ -666,19 +649,19 @@ hash:replace_if_exists(2, 10, 10, 0) --- - error: Duplicate key exists in unique index 3 ... -hash:select(0, 10) +hash.index['primary']:select(10) --- ... -hash:select(1, 10) +hash.index['field1']:select(10) --- ... -hash:select(2, 10) +hash.index['field2']:select(10) --- ... -hash:select(3, 10) +hash.index['field3']:select(10) --- ... -hash:select(3, 0) +hash.index['field3']:select(0) --- - [0, 0, 0, 0] ... diff --git a/test/big/hash.test.lua b/test/big/hash.test.lua index 8b50b5217cd6a2a30a36564345b2398f20d434cb..b12ae7600685020da47cc24bf9436aa5eca62ebc 100644 --- a/test/big/hash.test.lua +++ b/test/big/hash.test.lua @@ -6,11 +6,8 @@ dofile('utils.lua') ------------------------------------------------------------------------------- -- 32-bit hash insert fields tests ------------------------------------------------------------------------------- - -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') - -hash = box.space[0] +hash = box.schema.create_space('tweedledum') +hash:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) -- Insert valid fields hash:insert(0, 'value1 v1.0', 'value2 v1.0') @@ -38,16 +35,16 @@ hash:replace('invalid key', 'value1 v1.0', 'value2 v1.0') ------------------------------------------------------------------------------- -- select by valid keys -hash:select(0, 0) -hash:select(0, 1) -hash:select(0, 2) -hash:select(0, 3) -hash:select(0, 4) -hash:select(0, 5) +hash.index['primary']:select(0) +hash.index['primary']:select(1) +hash.index['primary']:select(2) +hash.index['primary']:select(3) +hash.index['primary']:select(4) +hash.index['primary']:select(5) -- select by invalid keys -hash:select(0, 'invalid key') -hash:select(0, 1, 2) +hash.index['primary']:select('invalid key') +hash.index['primary']:select(1, 2) ------------------------------------------------------------------------------- -- 32-bit hash delete fields test @@ -73,8 +70,6 @@ hash:truncate() ------------------------------------------------------------------------------- -- 64-bit hash inset fields tests ------------------------------------------------------------------------------- -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') -hash = box.space[0] -- Insert valid fields hash:insert(0ULL, 'value1 v1.0', 'value2 v1.0') @@ -109,24 +104,24 @@ hash:replace('invalid key', 'value1 v1.0', 'value2 v1.0') ------------------------------------------------------------------------------- -- select by valid keys -hash:select(0, 0ULL) -hash:select(0, 1ULL) -hash:select(0, 2ULL) -hash:select(0, 3ULL) -hash:select(0, 4ULL) -hash:select(0, 5ULL) +hash.index['primary']:select(0ULL) +hash.index['primary']:select(1ULL) +hash.index['primary']:select(2ULL) +hash.index['primary']:select(3ULL) +hash.index['primary']:select(4ULL) +hash.index['primary']:select(5ULL) -- select by valid NUM keys -hash:select(0, 0) -hash:select(0, 1) -hash:select(0, 2) -hash:select(0, 3) -hash:select(0, 4) -hash:select(0, 5) +hash.index['primary']:select(0) +hash.index['primary']:select(1) +hash.index['primary']:select(2) +hash.index['primary']:select(3) +hash.index['primary']:select(4) +hash.index['primary']:select(5) -- select by invalid keys -hash:select(0, 'invalid key') -hash:select(0, '00000001', '00000002') +hash.index['primary']:select('invalid key') +hash.index['primary']:select('00000001', '00000002') ------------------------------------------------------------------------------- -- 64-bit hash delete fields test @@ -164,8 +159,8 @@ hash:truncate() ------------------------------------------------------------------------------- -- String hash inset fields tests ------------------------------------------------------------------------------- -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') -hash = box.space[0] +hash.index['primary']:drop() +hash:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) -- Insert valid fields hash:insert('key 0', 'value1 v1.0', 'value2 v1.0') @@ -187,15 +182,15 @@ hash:replace('key 2', 'value1 v1.43', 'value2 1.92') ------------------------------------------------------------------------------- -- select by valid keys -hash:select(0, 'key 0') -hash:select(0, 'key 1') -hash:select(0, 'key 2') -hash:select(0, 'key 3') -hash:select(0, 'key 4') -hash:select(0, 'key 5') +hash.index['primary']:select('key 0') +hash.index['primary']:select('key 1') +hash.index['primary']:select('key 2') +hash.index['primary']:select('key 3') +hash.index['primary']:select('key 4') +hash.index['primary']:select('key 5') -- select by invalid keys -hash:select(0, 'key 1', 'key 2') +hash.index['primary']:select('key 1', 'key 2') ------------------------------------------------------------------------------- -- String hash delete fields test @@ -216,11 +211,11 @@ hash:truncate() ------------------------ -- hash::replace tests ------------------------ -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') -box.replace(box.schema.INDEX_ID, 0, 1, 'field1', 'hash', 1, 1, 1, 'num') -box.replace(box.schema.INDEX_ID, 0, 2, 'field2', 'hash', 1, 1, 2, 'num') -box.replace(box.schema.INDEX_ID, 0, 3, 'field3', 'hash', 1, 1, 3, 'num') -hash = box.space[0] +hash.index['primary']:drop() +hash:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) +hash:create_index('field1', 'hash', {parts = {1, 'num'}, unique = true }) +hash:create_index('field2', 'hash', {parts = {2, 'num'}, unique = true }) +hash:create_index('field3', 'hash', {parts = {3, 'num'}, unique = true }) hash:insert(0, 0, 0, 0) hash:insert(1, 1, 1, 1) @@ -230,67 +225,68 @@ hash:insert(2, 2, 2, 2) hash:replace_if_exists(1, 1, 1, 1) hash:replace_if_exists(1, 10, 10, 10) hash:replace_if_exists(1, 1, 1, 1) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) -hash:select(0, 1) -hash:select(1, 1) -hash:select(2, 1) -hash:select(3, 1) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) +hash.index['primary']:select(1) +hash.index['field1']:select(1) +hash.index['field2']:select(1) +hash.index['field3']:select(1) -- OK hash:insert(10, 10, 10, 10) hash:delete(10) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) -- TupleFound (primary key) hash:insert(1, 10, 10, 10) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) -hash:select(0, 1) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) +hash.index['primary']:select(1) -- TupleNotFound (primary key) hash:replace_if_exists(10, 10, 10, 10) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) -- TupleFound (key --1) hash:insert(10, 0, 10, 10) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) -hash:select(1, 0) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) +hash.index['field1']:select(0) -- TupleFound (key --1) hash:replace_if_exists(2, 0, 10, 10) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) -hash:select(1, 0) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) +hash.index['field1']:select(0) -- TupleFound (key --3) hash:insert(10, 10, 10, 0) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) -hash:select(3, 0) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) +hash.index['field3']:select(0) -- TupleFound (key --3) hash:replace_if_exists(2, 10, 10, 0) -hash:select(0, 10) -hash:select(1, 10) -hash:select(2, 10) -hash:select(3, 10) -hash:select(3, 0) +hash.index['primary']:select(10) +hash.index['field1']:select(10) +hash.index['field2']:select(10) +hash.index['field3']:select(10) +hash.index['field3']:select(0) + hash:drop() diff --git a/test/big/hash_multipart.result b/test/big/hash_multipart.result index b994650d238be04c8c708a4711e5135457af02a1..3f9b269cb2d9ecb0b7ef056450cc14255f6147c8 100644 --- a/test/big/hash_multipart.result +++ b/test/big/hash_multipart.result @@ -1,19 +1,13 @@ dofile('utils.lua') --- ... -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +hash = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 3, 0, 'num', 1, 'str', 2, 'num') +hash:create_index('primary', 'hash', {parts = {0, 'num', 1, 'str', 2, 'num'}, unique = true }) --- -- [0, 0, 'primary', 'hash', 1, 3, 0, 'num', 1, 'str', 2, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'unique', 'hash', 1, 2, 2, 'num', 4, 'num') ---- -- [0, 1, 'unique', 'hash', 1, 2, 2, 'num', 4, 'num'] -... -hash = box.space[0] +hash:create_index('unique', 'hash', {parts = {2, 'num', 4, 'num'}, unique = true }) --- ... -- insert rows @@ -58,7 +52,7 @@ hash:insert(1, 'bar', 1, '', 5) --# setopt delimiter ';' function box.select_all(space) local result = {} - for k, v in box.space[space]:pairs() do + for k, v in hash:pairs() do table.insert(result, v) end return result @@ -78,45 +72,45 @@ box.sort(box.select_all(0)) - [1, 'foo', 1, '', 2] ... -- primary index select -hash:select(0, 1, 'foo', 0) +hash.index['primary']:select({1, 'foo', 0}) --- - [1, 'foo', 0, '', 2] ... -hash:select(0, 1, 'bar', 0) +hash.index['primary']:select({1, 'bar', 0}) --- - [1, 'bar', 0, '', 4] ... -- primary index select with missing part -hash:select(0, 1, 'foo') +hash.index['primary']:select({1, 'foo'}) --- - error: Invalid key part count in an exact match (expected 3, got 2) ... -- primary index select with extra part -hash:select(0, 1, 'foo', 0, 0) +hash.index['primary']:select({1, 'foo', 0, 0}) --- - error: Invalid key part count (expected [0..3], got 4) ... -- primary index select with wrong type -hash:select(0, 1, 'foo', 'baz') +hash.index['primary']:select({1, 'foo', 'baz'}) --- - error: 'Supplied key type of part 2 does not match index part type: expected NUM' ... -- secondary index select -hash:select(1, 1, 4) +hash.index['unique']:select({1, 4}) --- - [1, 'bar', 1, '', 4] ... -- secondary index select with no such key -hash:select(1, 1, 5) +hash.index['unique']:select({1, 5}) --- ... -- secondary index select with missing part -hash:select(1, 1) +hash.index['unique']:select({1}) --- - error: Invalid key part count in an exact match (expected 2, got 1) ... -- secondary index select with wrong type -hash:select(1, 1, 'baz') +hash.index['unique']:select({1, 'baz'}) --- - error: 'Supplied key type of part 1 does not match index part type: expected NUM' ... diff --git a/test/big/hash_multipart.test.lua b/test/big/hash_multipart.test.lua index 471fdc0bceaed8c7c52c2b010b55f8c246810e49..ff3745afb2bc0a8085c4077295da070fb544365b 100644 --- a/test/big/hash_multipart.test.lua +++ b/test/big/hash_multipart.test.lua @@ -1,9 +1,8 @@ dofile('utils.lua') -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 3, 0, 'num', 1, 'str', 2, 'num') -box.insert(box.schema.INDEX_ID, 0, 1, 'unique', 'hash', 1, 2, 2, 'num', 4, 'num') -hash = box.space[0] +hash = box.schema.create_space('tweedledum') +hash:create_index('primary', 'hash', {parts = {0, 'num', 1, 'str', 2, 'num'}, unique = true }) +hash:create_index('unique', 'hash', {parts = {2, 'num', 4, 'num'}, unique = true }) -- insert rows hash:insert(0, 'foo', 0, '', 1) @@ -23,7 +22,7 @@ hash:insert(1, 'bar', 1, '', 5) --# setopt delimiter ';' function box.select_all(space) local result = {} - for k, v in box.space[space]:pairs() do + for k, v in hash:pairs() do table.insert(result, v) end return result @@ -32,23 +31,23 @@ end; box.sort(box.select_all(0)) -- primary index select -hash:select(0, 1, 'foo', 0) -hash:select(0, 1, 'bar', 0) +hash.index['primary']:select({1, 'foo', 0}) +hash.index['primary']:select({1, 'bar', 0}) -- primary index select with missing part -hash:select(0, 1, 'foo') +hash.index['primary']:select({1, 'foo'}) -- primary index select with extra part -hash:select(0, 1, 'foo', 0, 0) +hash.index['primary']:select({1, 'foo', 0, 0}) -- primary index select with wrong type -hash:select(0, 1, 'foo', 'baz') +hash.index['primary']:select({1, 'foo', 'baz'}) -- secondary index select -hash:select(1, 1, 4) +hash.index['unique']:select({1, 4}) -- secondary index select with no such key -hash:select(1, 1, 5) +hash.index['unique']:select({1, 5}) -- secondary index select with missing part -hash:select(1, 1) +hash.index['unique']:select({1}) -- secondary index select with wrong type -hash:select(1, 1, 'baz') +hash.index['unique']:select({1, 'baz'}) -- cleanup hash:truncate() diff --git a/test/big/iterator.result b/test/big/iterator.result index 79db6c043ac22d8d86c76139953d59e1077be5a3..be0b45e49fca186007e8a81550165613cc64125d 100644 --- a/test/big/iterator.result +++ b/test/big/iterator.result @@ -4,40 +4,30 @@ dofile('utils.lua') # Tree single-part unique --- ... -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'str') +space:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true}) --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'str'] ... -- Tree single-part non-unique -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 0, 1, 1, 'str') +space:create_index('i1', 'tree', {parts = {1, 'str'}, unique = false}) --- -- [0, 1, 'i1', 'tree', 0, 1, 1, 'str'] ... -- Tree multi-part unique -box.insert(box.schema.INDEX_ID, 0, 2, 'i2', 'tree', 1, 2, 1, 'str', 2, 'str') +space:create_index('i2', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true}) --- -- [0, 2, 'i2', 'tree', 1, 2, 1, 'str', 2, 'str'] ... -- Tree multi-part non-unique -box.insert(box.schema.INDEX_ID, 0, 3, 'i3', 'tree', 0, 2, 2, 'str', 3, 'str') +space:create_index('i3', 'tree', {parts = {2, 'str', 3, 'str'}, unique = false }) --- -- [0, 3, 'i3', 'tree', 0, 2, 2, 'str', 3, 'str'] ... -- Hash single-part unique -box.insert(box.schema.INDEX_ID, 0, 4, 'i4', 'hash', 1, 1, 0, 'str') +space:create_index('i4', 'hash', {parts = {0, 'str'}, unique = true}) --- -- [0, 4, 'i4', 'hash', 1, 1, 0, 'str'] ... -- Hash multi-part unique -box.insert(box.schema.INDEX_ID, 0, 5, 'i5', 'hash', 1, 2, 1, 'str', 2, 'str') ---- -- [0, 5, 'i5', 'hash', 1, 2, 1, 'str', 2, 'str'] -... -space = box.space[0] +space:create_index('i5', 'hash', {parts = {1, 'str', 2, 'str'}, unique = true}) --- ... space:insert('pid_001', 'sid_001', 'tid_998', 'a') @@ -83,7 +73,7 @@ space:insert('pid_023', 'sid_005', 'tid_994', 'a') ------------------------------------------------------------------------------- -- Iterator: tree single-part unique ------------------------------------------------------------------------------- -iterate(space.n, 0, 0, 1) +iterate('tweedledum', 'primary', 0, 1) --- - - $pid_001$ - $pid_002$ @@ -96,7 +86,7 @@ iterate(space.n, 0, 0, 1) - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.ALL) +iterate('tweedledum', 'primary', 0, 1, box.index.ALL) --- - - $pid_001$ - $pid_002$ @@ -109,7 +99,7 @@ iterate(space.n, 0, 0, 1, box.index.ALL) - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.EQ) +iterate('tweedledum', 'primary', 0, 1, box.index.EQ) --- - - $pid_001$ - $pid_002$ @@ -122,7 +112,7 @@ iterate(space.n, 0, 0, 1, box.index.EQ) - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.REQ) +iterate('tweedledum', 'primary', 0, 1, box.index.REQ) --- - - $pid_023$ - $pid_019$ @@ -135,7 +125,7 @@ iterate(space.n, 0, 0, 1, box.index.REQ) - $pid_002$ - $pid_001$ ... -iterate(space.n, 0, 0, 1, box.index.GE) +iterate('tweedledum', 'primary', 0, 1, box.index.GE) --- - - $pid_001$ - $pid_002$ @@ -148,7 +138,7 @@ iterate(space.n, 0, 0, 1, box.index.GE) - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.GT) +iterate('tweedledum', 'primary', 0, 1, box.index.GT) --- - - $pid_001$ - $pid_002$ @@ -161,7 +151,7 @@ iterate(space.n, 0, 0, 1, box.index.GT) - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.LE) +iterate('tweedledum', 'primary', 0, 1, box.index.LE) --- - - $pid_023$ - $pid_019$ @@ -174,7 +164,7 @@ iterate(space.n, 0, 0, 1, box.index.LE) - $pid_002$ - $pid_001$ ... -iterate(space.n, 0, 0, 1, box.index.LT) +iterate('tweedledum', 'primary', 0, 1, box.index.LT) --- - - $pid_023$ - $pid_019$ @@ -187,23 +177,23 @@ iterate(space.n, 0, 0, 1, box.index.LT) - $pid_002$ - $pid_001$ ... -iterate(space.n, 0, 0, 1, box.index.EQ, 'pid_003') +iterate('tweedledum', 'primary', 0, 1, box.index.EQ, 'pid_003') --- - - $pid_003$ ... -iterate(space.n, 0, 0, 1, box.index.REQ, 'pid_003') +iterate('tweedledum', 'primary', 0, 1, box.index.REQ, 'pid_003') --- - - $pid_003$ ... -iterate(space.n, 0, 0, 1, box.index.EQ, 'pid_666') +iterate('tweedledum', 'primary', 0, 1, box.index.EQ, 'pid_666') --- - [] ... -iterate(space.n, 0, 0, 1, box.index.REQ, 'pid_666') +iterate('tweedledum', 'primary', 0, 1, box.index.REQ, 'pid_666') --- - [] ... -iterate(space.n, 0, 0, 1, box.index.GE, 'pid_001') +iterate('tweedledum', 'primary', 0, 1, box.index.GE, 'pid_001') --- - - $pid_001$ - $pid_002$ @@ -216,7 +206,7 @@ iterate(space.n, 0, 0, 1, box.index.GE, 'pid_001') - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.GT, 'pid_001') +iterate('tweedledum', 'primary', 0, 1, box.index.GT, 'pid_001') --- - - $pid_002$ - $pid_003$ @@ -228,35 +218,35 @@ iterate(space.n, 0, 0, 1, box.index.GT, 'pid_001') - $pid_019$ - $pid_023$ ... -iterate(space.n, 0, 0, 1, box.index.GE, 'pid_999') +iterate('tweedledum', 'primary', 0, 1, box.index.GE, 'pid_999') --- - [] ... -iterate(space.n, 0, 0, 1, box.index.GT, 'pid_999') +iterate('tweedledum', 'primary', 0, 1, box.index.GT, 'pid_999') --- - [] ... -iterate(space.n, 0, 0, 1, box.index.LE, 'pid_002') +iterate('tweedledum', 'primary', 0, 1, box.index.LE, 'pid_002') --- - - $pid_002$ - $pid_001$ ... -iterate(space.n, 0, 0, 1, box.index.LT, 'pid_002') +iterate('tweedledum', 'primary', 0, 1, box.index.LT, 'pid_002') --- - - $pid_001$ ... -iterate(space.n, 0, 0, 1, box.index.LE, 'pid_000') +iterate('tweedledum', 'primary', 0, 1, box.index.LE, 'pid_000') --- - [] ... -iterate(space.n, 0, 0, 1, box.index.LT, 'pid_000') +iterate('tweedledum', 'primary', 0, 1, box.index.LT, 'pid_000') --- - [] ... ------------------------------------------------------------------------------- -- Iterator: tree single-part non-unique ------------------------------------------------------------------------------- -iterate(space.n, 1, 1, 2, box.index.ALL) +iterate('tweedledum', 'i1', 1, 2, box.index.ALL) --- - - $sid_001$ - $sid_001$ @@ -269,7 +259,7 @@ iterate(space.n, 1, 1, 2, box.index.ALL) - $sid_005$ - $sid_006$ ... -iterate(space.n, 1, 1, 2, box.index.EQ) +iterate('tweedledum', 'i1', 1, 2, box.index.EQ) --- - - $sid_001$ - $sid_001$ @@ -282,7 +272,7 @@ iterate(space.n, 1, 1, 2, box.index.EQ) - $sid_005$ - $sid_006$ ... -iterate(space.n, 1, 1, 2, box.index.REQ) +iterate('tweedledum', 'i1', 1, 2, box.index.REQ) --- - - $sid_006$ - $sid_005$ @@ -295,7 +285,7 @@ iterate(space.n, 1, 1, 2, box.index.REQ) - $sid_001$ - $sid_001$ ... -iterate(space.n, 1, 1, 2, box.index.GE) +iterate('tweedledum', 'i1', 1, 2, box.index.GE) --- - - $sid_001$ - $sid_001$ @@ -308,7 +298,7 @@ iterate(space.n, 1, 1, 2, box.index.GE) - $sid_005$ - $sid_006$ ... -iterate(space.n, 1, 1, 2, box.index.GT) +iterate('tweedledum', 'i1', 1, 2, box.index.GT) --- - - $sid_001$ - $sid_001$ @@ -321,7 +311,7 @@ iterate(space.n, 1, 1, 2, box.index.GT) - $sid_005$ - $sid_006$ ... -iterate(space.n, 1, 1, 2, box.index.LE) +iterate('tweedledum', 'i1', 1, 2, box.index.LE) --- - - $sid_006$ - $sid_005$ @@ -334,7 +324,7 @@ iterate(space.n, 1, 1, 2, box.index.LE) - $sid_001$ - $sid_001$ ... -iterate(space.n, 1, 1, 2, box.index.LT) +iterate('tweedledum', 'i1', 1, 2, box.index.LT) --- - - $sid_006$ - $sid_005$ @@ -347,38 +337,38 @@ iterate(space.n, 1, 1, 2, box.index.LT) - $sid_001$ - $sid_001$ ... -iterate(space.n, 1, 1, 2, box.index.EQ, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.EQ, 'sid_005') --- - - $sid_005$ - $sid_005$ - $sid_005$ ... -iterate(space.n, 1, 1, 2, box.index.REQ, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.REQ, 'sid_005') --- - - $sid_005$ - $sid_005$ - $sid_005$ ... -iterate(space.n, 1, 1, 2, box.index.GE, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.GE, 'sid_005') --- - - $sid_005$ - $sid_005$ - $sid_005$ - $sid_006$ ... -iterate(space.n, 1, 1, 2, box.index.GT, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.GT, 'sid_005') --- - - $sid_006$ ... -iterate(space.n, 1, 1, 2, box.index.GE, 'sid_999') +iterate('tweedledum', 'i1', 1, 2, box.index.GE, 'sid_999') --- - [] ... -iterate(space.n, 1, 1, 2, box.index.GT, 'sid_999') +iterate('tweedledum', 'i1', 1, 2, box.index.GT, 'sid_999') --- - [] ... -iterate(space.n, 1, 1, 2, box.index.LE, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.LE, 'sid_005') --- - - $sid_005$ - $sid_005$ @@ -390,7 +380,7 @@ iterate(space.n, 1, 1, 2, box.index.LE, 'sid_005') - $sid_001$ - $sid_001$ ... -iterate(space.n, 1, 1, 2, box.index.LT, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.LT, 'sid_005') --- - - $sid_004$ - $sid_003$ @@ -399,18 +389,18 @@ iterate(space.n, 1, 1, 2, box.index.LT, 'sid_005') - $sid_001$ - $sid_001$ ... -iterate(space.n, 1, 1, 2, box.index.LE, 'sid_000') +iterate('tweedledum', 'i1', 1, 2, box.index.LE, 'sid_000') --- - [] ... -iterate(space.n, 1, 1, 2, box.index.LT, 'sid_000') +iterate('tweedledum', 'i1', 1, 2, box.index.LT, 'sid_000') --- - [] ... ------------------------------------------------------------------------------- -- Iterator: tree multi-part unique ------------------------------------------------------------------------------- -iterate(space.n, 2, 1, 3, box.index.ALL) +iterate('tweedledum', 'i2', 1, 3, box.index.ALL) --- - - $sid_001$tid_997$ - $sid_001$tid_998$ @@ -423,7 +413,7 @@ iterate(space.n, 2, 1, 3, box.index.ALL) - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.EQ) +iterate('tweedledum', 'i2', 1, 3, box.index.EQ) --- - - $sid_001$tid_997$ - $sid_001$tid_998$ @@ -436,7 +426,7 @@ iterate(space.n, 2, 1, 3, box.index.EQ) - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.REQ) +iterate('tweedledum', 'i2', 1, 3, box.index.REQ) --- - - $sid_006$tid_996$ - $sid_005$tid_996$ @@ -449,7 +439,7 @@ iterate(space.n, 2, 1, 3, box.index.REQ) - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.GE) +iterate('tweedledum', 'i2', 1, 3, box.index.GE) --- - - $sid_001$tid_997$ - $sid_001$tid_998$ @@ -462,7 +452,7 @@ iterate(space.n, 2, 1, 3, box.index.GE) - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GT) +iterate('tweedledum', 'i2', 1, 3, box.index.GT) --- - - $sid_001$tid_997$ - $sid_001$tid_998$ @@ -475,7 +465,7 @@ iterate(space.n, 2, 1, 3, box.index.GT) - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.LE) +iterate('tweedledum', 'i2', 1, 3, box.index.LE) --- - - $sid_006$tid_996$ - $sid_005$tid_996$ @@ -488,7 +478,7 @@ iterate(space.n, 2, 1, 3, box.index.LE) - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LT) +iterate('tweedledum', 'i2', 1, 3, box.index.LT) --- - - $sid_006$tid_996$ - $sid_005$tid_996$ @@ -501,73 +491,73 @@ iterate(space.n, 2, 1, 3, box.index.LT) - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.EQ, 'sid_005') --- - - $sid_005$tid_994$ - $sid_005$tid_995$ - $sid_005$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.EQ, 'sid_005', 'tid_995') --- - - $sid_005$tid_995$ ... -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.EQ, 'sid_005', 'tid_999') --- - [] ... -iterate(space.n, 2, 1, 3, box.index.REQ, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.REQ, 'sid_005') --- - - $sid_005$tid_996$ - $sid_005$tid_995$ - $sid_005$tid_994$ ... -iterate(space.n, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.REQ, 'sid_005', 'tid_995') --- - - $sid_005$tid_995$ ... -iterate(space.n, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.REQ, 'sid_005', 'tid_999') --- - [] ... -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_005') --- - - $sid_005$tid_994$ - $sid_005$tid_995$ - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_005') --- - - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_005', 'tid_995') --- - - $sid_005$tid_995$ - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_005', 'tid_995') --- - - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_005', 'tid_999') --- - - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_005', 'tid_999') --- - - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_999') --- - [] ... -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_999') --- - [] ... -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_005') --- - - $sid_005$tid_996$ - $sid_005$tid_995$ @@ -579,7 +569,7 @@ iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005') - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_005') --- - - $sid_004$tid_996$ - $sid_003$tid_996$ @@ -588,7 +578,7 @@ iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005') - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_005', 'tid_997') --- - - $sid_005$tid_996$ - $sid_005$tid_995$ @@ -600,7 +590,7 @@ iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997') - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_005', 'tid_997') --- - - $sid_005$tid_996$ - $sid_005$tid_995$ @@ -612,7 +602,7 @@ iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997') - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_005', 'tid_000') --- - - $sid_004$tid_996$ - $sid_003$tid_996$ @@ -621,7 +611,7 @@ iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000') - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_005', 'tid_000') --- - - $sid_004$tid_996$ - $sid_003$tid_996$ @@ -630,18 +620,18 @@ iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000') - $sid_001$tid_998$ - $sid_001$tid_997$ ... -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_000') --- - [] ... -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_000') --- - [] ... ------------------------------------------------------------------------------- -- Iterator: tree multi-part non-unique ------------------------------------------------------------------------------- -iterate(space.n, 3, 2, 4, box.index.ALL) +iterate('tweedledum', 'i3', 2, 4, box.index.ALL) --- - - $tid_994$a$ - $tid_995$a$ @@ -654,7 +644,7 @@ iterate(space.n, 3, 2, 4, box.index.ALL) - $tid_997$b$ - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.EQ) +iterate('tweedledum', 'i3', 2, 4, box.index.EQ) --- - - $tid_994$a$ - $tid_995$a$ @@ -667,7 +657,7 @@ iterate(space.n, 3, 2, 4, box.index.EQ) - $tid_997$b$ - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.REQ) +iterate('tweedledum', 'i3', 2, 4, box.index.REQ) --- - - $tid_998$a$ - $tid_997$b$ @@ -680,7 +670,7 @@ iterate(space.n, 3, 2, 4, box.index.REQ) - $tid_995$a$ - $tid_994$a$ ... -iterate(space.n, 3, 2, 4, box.index.GE) +iterate('tweedledum', 'i3', 2, 4, box.index.GE) --- - - $tid_994$a$ - $tid_995$a$ @@ -693,7 +683,7 @@ iterate(space.n, 3, 2, 4, box.index.GE) - $tid_997$b$ - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.GT) +iterate('tweedledum', 'i3', 2, 4, box.index.GT) --- - - $tid_994$a$ - $tid_995$a$ @@ -706,7 +696,7 @@ iterate(space.n, 3, 2, 4, box.index.GT) - $tid_997$b$ - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.LE) +iterate('tweedledum', 'i3', 2, 4, box.index.LE) --- - - $tid_998$a$ - $tid_997$b$ @@ -719,7 +709,7 @@ iterate(space.n, 3, 2, 4, box.index.LE) - $tid_995$a$ - $tid_994$a$ ... -iterate(space.n, 3, 2, 4, box.index.LT) +iterate('tweedledum', 'i3', 2, 4, box.index.LT) --- - - $tid_998$a$ - $tid_997$b$ @@ -732,7 +722,7 @@ iterate(space.n, 3, 2, 4, box.index.LT) - $tid_995$a$ - $tid_994$a$ ... -iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996') +iterate('tweedledum', 'i3', 2, 4, box.index.EQ, 'tid_996') --- - - $tid_996$a$ - $tid_996$a$ @@ -740,16 +730,16 @@ iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996') - $tid_996$b$ - $tid_996$c$ ... -iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996', 'a') +iterate('tweedledum', 'i3', 2, 4, box.index.EQ, 'tid_996', 'a') --- - - $tid_996$a$ - $tid_996$a$ ... -iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996', 'z') +iterate('tweedledum', 'i3', 2, 4, box.index.EQ, 'tid_996', 'z') --- - [] ... -iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996') +iterate('tweedledum', 'i3', 2, 4, box.index.REQ, 'tid_996') --- - - $tid_996$c$ - $tid_996$b$ @@ -757,34 +747,34 @@ iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996') - $tid_996$a$ - $tid_996$a$ ... -iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996', 'a') +iterate('tweedledum', 'i3', 2, 4, box.index.REQ, 'tid_996', 'a') --- - - $tid_996$a$ - $tid_996$a$ ... -iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996', '0') +iterate('tweedledum', 'i3', 2, 4, box.index.REQ, 'tid_996', '0') --- - [] ... -iterate(space.n, 3, 2, 4, box.index.GE, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.GE, 'tid_997') --- - - $tid_997$a$ - $tid_997$b$ - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.GT, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.GT, 'tid_997') --- - - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.GE, 'tid_998') +iterate('tweedledum', 'i3', 2, 4, box.index.GE, 'tid_998') --- - - $tid_998$a$ ... -iterate(space.n, 3, 2, 4, box.index.GT, 'tid_998') +iterate('tweedledum', 'i3', 2, 4, box.index.GT, 'tid_998') --- - [] ... -iterate(space.n, 3, 2, 4, box.index.LE, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.LE, 'tid_997') --- - - $tid_997$b$ - $tid_997$a$ @@ -796,7 +786,7 @@ iterate(space.n, 3, 2, 4, box.index.LE, 'tid_997') - $tid_995$a$ - $tid_994$a$ ... -iterate(space.n, 3, 2, 4, box.index.LT, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.LT, 'tid_997') --- - - $tid_996$c$ - $tid_996$b$ @@ -806,22 +796,22 @@ iterate(space.n, 3, 2, 4, box.index.LT, 'tid_997') - $tid_995$a$ - $tid_994$a$ ... -iterate(space.n, 3, 2, 4, box.index.LE, 'tid_000') +iterate('tweedledum', 'i3', 2, 4, box.index.LE, 'tid_000') --- - [] ... -iterate(space.n, 3, 2, 4, box.index.LT, 'tid_000') +iterate('tweedledum', 'i3', 2, 4, box.index.LT, 'tid_000') --- - [] ... -iterate(space.n, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys') +iterate('tweedledum', 'i3', 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys') --- - error: Invalid key part count (expected [0..2], got 4) ... ------------------------------------------------------------------------------- -- Iterator: hash single-part unique ------------------------------------------------------------------------------- -iterate(space.n, 4, 0, 1) +iterate('tweedledum', 'i4', 0, 1) --- - - $pid_001$ - $pid_002$ @@ -834,7 +824,7 @@ iterate(space.n, 4, 0, 1) - $pid_019$ - $pid_023$ ... -iterate(space.n, 4, 0, 1, box.index.ALL) +iterate('tweedledum', 'i4', 0, 1, box.index.ALL) --- - - $pid_001$ - $pid_002$ @@ -847,11 +837,11 @@ iterate(space.n, 4, 0, 1, box.index.ALL) - $pid_019$ - $pid_023$ ... -iterate(space.n, 4, 0, 1, box.index.EQ) +iterate('tweedledum', 'i4', 0, 1, box.index.EQ) --- - error: Invalid key part count in an exact match (expected 1, got 0) ... -iterate(space.n, 4, 0, 1, box.index.GE) +iterate('tweedledum', 'i4', 0, 1, box.index.GE) --- - - $pid_001$ - $pid_002$ @@ -864,28 +854,28 @@ iterate(space.n, 4, 0, 1, box.index.GE) - $pid_019$ - $pid_023$ ... -iterate(space.n, 4, 0, 1, box.index.EQ, 'pid_003') +iterate('tweedledum', 'i4', 0, 1, box.index.EQ, 'pid_003') --- - - $pid_003$ ... -iterate(space.n, 4, 0, 1, box.index.EQ, 'pid_666') +iterate('tweedledum', 'i4', 0, 1, box.index.EQ, 'pid_666') --- - [] ... -iterate(space.n, 4, 0, 1, box.index.GE, 'pid_001') +iterate('tweedledum', 'i4', 0, 1, box.index.GE, 'pid_001') --- - - $pid_001$ - $pid_002$ - $pid_017$ ... -iterate(space.n, 4, 0, 1, box.index.GE, 'pid_999') +iterate('tweedledum', 'i4', 0, 1, box.index.GE, 'pid_999') --- - [] ... ------------------------------------------------------------------------------- -- Iterator: hash multi-part unique ------------------------------------------------------------------------------- -iterate(space.n, 5, 1, 3, box.index.ALL) +iterate('tweedledum', 'i5', 1, 3, box.index.ALL) --- - - $sid_001$tid_997$ - $sid_001$tid_998$ @@ -898,15 +888,15 @@ iterate(space.n, 5, 1, 3, box.index.ALL) - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 5, 1, 3, box.index.EQ) +iterate('tweedledum', 'i5', 1, 3, box.index.EQ) --- - error: Invalid key part count in an exact match (expected 2, got 0) ... -iterate(space.n, 5, 1, 3, box.index.EQ, 'sid_005') +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005') --- - error: Invalid key part count in an exact match (expected 2, got 1) ... -iterate(space.n, 5, 1, 3, box.index.GE) +iterate('tweedledum', 'i5', 1, 3, box.index.GE) --- - - $sid_001$tid_997$ - $sid_001$tid_998$ @@ -919,37 +909,37 @@ iterate(space.n, 5, 1, 3, box.index.GE) - $sid_005$tid_996$ - $sid_006$tid_996$ ... -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005', 'tid_995') --- - - $sid_005$tid_995$ ... -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005', 'tid_999') --- - [] ... -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a') +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a') --- - error: Invalid key part count (expected [0..2], got 3) ... -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') +iterate('tweedledum', 'i5', 1, 3, box.index.GE, 'sid_005', 'tid_995') --- -- - $sid_005$tid_995$ - - $sid_005$tid_996$ - - $sid_006$tid_996$ +- - $sid_002$tid_996$ + - $sid_004$tid_996$ + - $sid_005$tid_995$ ... -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') +iterate('tweedledum', 'i5', 1, 3, box.index.GE, 'sid_005', 'tid_999') --- -- - $sid_006$tid_996$ +- [] ... ------------------------------------------------------------------------------- -- Iterator: various ------------------------------------------------------------------------------- -space.index[0]:iterator(-666) +space.index['primary']:iterator(-666) --- - error: 'unknown iterator type: -666' ... -- Test cases for #123: box.index.count does not check arguments properly -space.index[0]:iterator(box.index.EQ, function() end) +space.index['primary']:iterator(box.index.EQ, function() end) --- - error: 'msgpack.encode: can not encode Lua type ''function''' ... diff --git a/test/big/iterator.test.lua b/test/big/iterator.test.lua index 15e939e208e08124f6639d5e4d6511868aee404f..742a57c0253f51b4e9383b10a3326ee40cf645c3 100644 --- a/test/big/iterator.test.lua +++ b/test/big/iterator.test.lua @@ -2,20 +2,18 @@ dofile('utils.lua') # Tree single-part unique -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'str') +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true}) -- Tree single-part non-unique -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 0, 1, 1, 'str') +space:create_index('i1', 'tree', {parts = {1, 'str'}, unique = false}) -- Tree multi-part unique -box.insert(box.schema.INDEX_ID, 0, 2, 'i2', 'tree', 1, 2, 1, 'str', 2, 'str') +space:create_index('i2', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true}) -- Tree multi-part non-unique -box.insert(box.schema.INDEX_ID, 0, 3, 'i3', 'tree', 0, 2, 2, 'str', 3, 'str') +space:create_index('i3', 'tree', {parts = {2, 'str', 3, 'str'}, unique = false }) -- Hash single-part unique -box.insert(box.schema.INDEX_ID, 0, 4, 'i4', 'hash', 1, 1, 0, 'str') +space:create_index('i4', 'hash', {parts = {0, 'str'}, unique = true}) -- Hash multi-part unique -box.insert(box.schema.INDEX_ID, 0, 5, 'i5', 'hash', 1, 2, 1, 'str', 2, 'str') - -space = box.space[0] +space:create_index('i5', 'hash', {parts = {1, 'str', 2, 'str'}, unique = true}) space:insert('pid_001', 'sid_001', 'tid_998', 'a') space:insert('pid_002', 'sid_001', 'tid_997', 'a') @@ -32,142 +30,142 @@ space:insert('pid_023', 'sid_005', 'tid_994', 'a') -- Iterator: tree single-part unique ------------------------------------------------------------------------------- -iterate(space.n, 0, 0, 1) -iterate(space.n, 0, 0, 1, box.index.ALL) -iterate(space.n, 0, 0, 1, box.index.EQ) -iterate(space.n, 0, 0, 1, box.index.REQ) -iterate(space.n, 0, 0, 1, box.index.GE) -iterate(space.n, 0, 0, 1, box.index.GT) -iterate(space.n, 0, 0, 1, box.index.LE) -iterate(space.n, 0, 0, 1, box.index.LT) -iterate(space.n, 0, 0, 1, box.index.EQ, 'pid_003') -iterate(space.n, 0, 0, 1, box.index.REQ, 'pid_003') -iterate(space.n, 0, 0, 1, box.index.EQ, 'pid_666') -iterate(space.n, 0, 0, 1, box.index.REQ, 'pid_666') -iterate(space.n, 0, 0, 1, box.index.GE, 'pid_001') -iterate(space.n, 0, 0, 1, box.index.GT, 'pid_001') -iterate(space.n, 0, 0, 1, box.index.GE, 'pid_999') -iterate(space.n, 0, 0, 1, box.index.GT, 'pid_999') -iterate(space.n, 0, 0, 1, box.index.LE, 'pid_002') -iterate(space.n, 0, 0, 1, box.index.LT, 'pid_002') -iterate(space.n, 0, 0, 1, box.index.LE, 'pid_000') -iterate(space.n, 0, 0, 1, box.index.LT, 'pid_000') +iterate('tweedledum', 'primary', 0, 1) +iterate('tweedledum', 'primary', 0, 1, box.index.ALL) +iterate('tweedledum', 'primary', 0, 1, box.index.EQ) +iterate('tweedledum', 'primary', 0, 1, box.index.REQ) +iterate('tweedledum', 'primary', 0, 1, box.index.GE) +iterate('tweedledum', 'primary', 0, 1, box.index.GT) +iterate('tweedledum', 'primary', 0, 1, box.index.LE) +iterate('tweedledum', 'primary', 0, 1, box.index.LT) +iterate('tweedledum', 'primary', 0, 1, box.index.EQ, 'pid_003') +iterate('tweedledum', 'primary', 0, 1, box.index.REQ, 'pid_003') +iterate('tweedledum', 'primary', 0, 1, box.index.EQ, 'pid_666') +iterate('tweedledum', 'primary', 0, 1, box.index.REQ, 'pid_666') +iterate('tweedledum', 'primary', 0, 1, box.index.GE, 'pid_001') +iterate('tweedledum', 'primary', 0, 1, box.index.GT, 'pid_001') +iterate('tweedledum', 'primary', 0, 1, box.index.GE, 'pid_999') +iterate('tweedledum', 'primary', 0, 1, box.index.GT, 'pid_999') +iterate('tweedledum', 'primary', 0, 1, box.index.LE, 'pid_002') +iterate('tweedledum', 'primary', 0, 1, box.index.LT, 'pid_002') +iterate('tweedledum', 'primary', 0, 1, box.index.LE, 'pid_000') +iterate('tweedledum', 'primary', 0, 1, box.index.LT, 'pid_000') ------------------------------------------------------------------------------- -- Iterator: tree single-part non-unique ------------------------------------------------------------------------------- -iterate(space.n, 1, 1, 2, box.index.ALL) -iterate(space.n, 1, 1, 2, box.index.EQ) -iterate(space.n, 1, 1, 2, box.index.REQ) -iterate(space.n, 1, 1, 2, box.index.GE) -iterate(space.n, 1, 1, 2, box.index.GT) -iterate(space.n, 1, 1, 2, box.index.LE) -iterate(space.n, 1, 1, 2, box.index.LT) -iterate(space.n, 1, 1, 2, box.index.EQ, 'sid_005') -iterate(space.n, 1, 1, 2, box.index.REQ, 'sid_005') -iterate(space.n, 1, 1, 2, box.index.GE, 'sid_005') -iterate(space.n, 1, 1, 2, box.index.GT, 'sid_005') -iterate(space.n, 1, 1, 2, box.index.GE, 'sid_999') -iterate(space.n, 1, 1, 2, box.index.GT, 'sid_999') -iterate(space.n, 1, 1, 2, box.index.LE, 'sid_005') -iterate(space.n, 1, 1, 2, box.index.LT, 'sid_005') -iterate(space.n, 1, 1, 2, box.index.LE, 'sid_000') -iterate(space.n, 1, 1, 2, box.index.LT, 'sid_000') +iterate('tweedledum', 'i1', 1, 2, box.index.ALL) +iterate('tweedledum', 'i1', 1, 2, box.index.EQ) +iterate('tweedledum', 'i1', 1, 2, box.index.REQ) +iterate('tweedledum', 'i1', 1, 2, box.index.GE) +iterate('tweedledum', 'i1', 1, 2, box.index.GT) +iterate('tweedledum', 'i1', 1, 2, box.index.LE) +iterate('tweedledum', 'i1', 1, 2, box.index.LT) +iterate('tweedledum', 'i1', 1, 2, box.index.EQ, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.REQ, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.GE, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.GT, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.GE, 'sid_999') +iterate('tweedledum', 'i1', 1, 2, box.index.GT, 'sid_999') +iterate('tweedledum', 'i1', 1, 2, box.index.LE, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.LT, 'sid_005') +iterate('tweedledum', 'i1', 1, 2, box.index.LE, 'sid_000') +iterate('tweedledum', 'i1', 1, 2, box.index.LT, 'sid_000') ------------------------------------------------------------------------------- -- Iterator: tree multi-part unique ------------------------------------------------------------------------------- -iterate(space.n, 2, 1, 3, box.index.ALL) -iterate(space.n, 2, 1, 3, box.index.EQ) -iterate(space.n, 2, 1, 3, box.index.REQ) -iterate(space.n, 2, 1, 3, box.index.GE) -iterate(space.n, 2, 1, 3, box.index.GT) -iterate(space.n, 2, 1, 3, box.index.LE) -iterate(space.n, 2, 1, 3, box.index.LT) -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005') -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') -iterate(space.n, 2, 1, 3, box.index.REQ, 'sid_005') -iterate(space.n, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995') -iterate(space.n, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999') -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005') -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_005') -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995') -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999') -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_999') -iterate(space.n, 2, 1, 3, box.index.GT, 'sid_999') -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005') -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005') -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997') -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997') -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000') -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000') -iterate(space.n, 2, 1, 3, box.index.LE, 'sid_000') -iterate(space.n, 2, 1, 3, box.index.LT, 'sid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.ALL) +iterate('tweedledum', 'i2', 1, 3, box.index.EQ) +iterate('tweedledum', 'i2', 1, 3, box.index.REQ) +iterate('tweedledum', 'i2', 1, 3, box.index.GE) +iterate('tweedledum', 'i2', 1, 3, box.index.GT) +iterate('tweedledum', 'i2', 1, 3, box.index.LE) +iterate('tweedledum', 'i2', 1, 3, box.index.LT) +iterate('tweedledum', 'i2', 1, 3, box.index.EQ, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.EQ, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.EQ, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.REQ, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.REQ, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.REQ, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_005', 'tid_995') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_005', 'tid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GE, 'sid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.GT, 'sid_999') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_005') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_005', 'tid_997') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_005', 'tid_997') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_005', 'tid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_005', 'tid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LE, 'sid_000') +iterate('tweedledum', 'i2', 1, 3, box.index.LT, 'sid_000') ------------------------------------------------------------------------------- -- Iterator: tree multi-part non-unique ------------------------------------------------------------------------------- -iterate(space.n, 3, 2, 4, box.index.ALL) -iterate(space.n, 3, 2, 4, box.index.EQ) -iterate(space.n, 3, 2, 4, box.index.REQ) -iterate(space.n, 3, 2, 4, box.index.GE) -iterate(space.n, 3, 2, 4, box.index.GT) -iterate(space.n, 3, 2, 4, box.index.LE) -iterate(space.n, 3, 2, 4, box.index.LT) -iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996') -iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996', 'a') -iterate(space.n, 3, 2, 4, box.index.EQ, 'tid_996', 'z') -iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996') -iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996', 'a') -iterate(space.n, 3, 2, 4, box.index.REQ, 'tid_996', '0') -iterate(space.n, 3, 2, 4, box.index.GE, 'tid_997') -iterate(space.n, 3, 2, 4, box.index.GT, 'tid_997') -iterate(space.n, 3, 2, 4, box.index.GE, 'tid_998') -iterate(space.n, 3, 2, 4, box.index.GT, 'tid_998') -iterate(space.n, 3, 2, 4, box.index.LE, 'tid_997') -iterate(space.n, 3, 2, 4, box.index.LT, 'tid_997') -iterate(space.n, 3, 2, 4, box.index.LE, 'tid_000') -iterate(space.n, 3, 2, 4, box.index.LT, 'tid_000') -iterate(space.n, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys') +iterate('tweedledum', 'i3', 2, 4, box.index.ALL) +iterate('tweedledum', 'i3', 2, 4, box.index.EQ) +iterate('tweedledum', 'i3', 2, 4, box.index.REQ) +iterate('tweedledum', 'i3', 2, 4, box.index.GE) +iterate('tweedledum', 'i3', 2, 4, box.index.GT) +iterate('tweedledum', 'i3', 2, 4, box.index.LE) +iterate('tweedledum', 'i3', 2, 4, box.index.LT) +iterate('tweedledum', 'i3', 2, 4, box.index.EQ, 'tid_996') +iterate('tweedledum', 'i3', 2, 4, box.index.EQ, 'tid_996', 'a') +iterate('tweedledum', 'i3', 2, 4, box.index.EQ, 'tid_996', 'z') +iterate('tweedledum', 'i3', 2, 4, box.index.REQ, 'tid_996') +iterate('tweedledum', 'i3', 2, 4, box.index.REQ, 'tid_996', 'a') +iterate('tweedledum', 'i3', 2, 4, box.index.REQ, 'tid_996', '0') +iterate('tweedledum', 'i3', 2, 4, box.index.GE, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.GT, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.GE, 'tid_998') +iterate('tweedledum', 'i3', 2, 4, box.index.GT, 'tid_998') +iterate('tweedledum', 'i3', 2, 4, box.index.LE, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.LT, 'tid_997') +iterate('tweedledum', 'i3', 2, 4, box.index.LE, 'tid_000') +iterate('tweedledum', 'i3', 2, 4, box.index.LT, 'tid_000') +iterate('tweedledum', 'i3', 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys') ------------------------------------------------------------------------------- -- Iterator: hash single-part unique ------------------------------------------------------------------------------- -iterate(space.n, 4, 0, 1) -iterate(space.n, 4, 0, 1, box.index.ALL) -iterate(space.n, 4, 0, 1, box.index.EQ) -iterate(space.n, 4, 0, 1, box.index.GE) -iterate(space.n, 4, 0, 1, box.index.EQ, 'pid_003') -iterate(space.n, 4, 0, 1, box.index.EQ, 'pid_666') -iterate(space.n, 4, 0, 1, box.index.GE, 'pid_001') -iterate(space.n, 4, 0, 1, box.index.GE, 'pid_999') +iterate('tweedledum', 'i4', 0, 1) +iterate('tweedledum', 'i4', 0, 1, box.index.ALL) +iterate('tweedledum', 'i4', 0, 1, box.index.EQ) +iterate('tweedledum', 'i4', 0, 1, box.index.GE) +iterate('tweedledum', 'i4', 0, 1, box.index.EQ, 'pid_003') +iterate('tweedledum', 'i4', 0, 1, box.index.EQ, 'pid_666') +iterate('tweedledum', 'i4', 0, 1, box.index.GE, 'pid_001') +iterate('tweedledum', 'i4', 0, 1, box.index.GE, 'pid_999') ------------------------------------------------------------------------------- -- Iterator: hash multi-part unique ------------------------------------------------------------------------------- -iterate(space.n, 5, 1, 3, box.index.ALL) -iterate(space.n, 5, 1, 3, box.index.EQ) -iterate(space.n, 5, 1, 3, box.index.EQ, 'sid_005') -iterate(space.n, 5, 1, 3, box.index.GE) -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') -iterate(space.n, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a') -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') -iterate(space.n, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') +iterate('tweedledum', 'i5', 1, 3, box.index.ALL) +iterate('tweedledum', 'i5', 1, 3, box.index.EQ) +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005') +iterate('tweedledum', 'i5', 1, 3, box.index.GE) +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005', 'tid_995') +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005', 'tid_999') +iterate('tweedledum', 'i5', 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a') +iterate('tweedledum', 'i5', 1, 3, box.index.GE, 'sid_005', 'tid_995') +iterate('tweedledum', 'i5', 1, 3, box.index.GE, 'sid_005', 'tid_999') ------------------------------------------------------------------------------- -- Iterator: various ------------------------------------------------------------------------------- -space.index[0]:iterator(-666) +space.index['primary']:iterator(-666) -- Test cases for #123: box.index.count does not check arguments properly -space.index[0]:iterator(box.index.EQ, function() end) +space.index['primary']:iterator(box.index.EQ, function() end) space:drop() diff --git a/test/big/lua.result b/test/big/lua.result index e296e755daa8c3d2ab7469260a734691777f1c67..9ee7552e6fc2e1d7593cb20f4d41b2f38bc5f05c 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -1,38 +1,32 @@ -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') +space:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) --- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'str'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'minmax', 'tree', 1, 2, 1, 'str', 2, 'str') ---- -- [0, 1, 'minmax', 'tree', 1, 2, 1, 'str', 2, 'str'] -... -space = box.space[0] +space:create_index('minmax', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true }) --- ... space:insert('brave', 'new', 'world') --- - ['brave', 'new', 'world'] ... -space.index[1]:min() +space.index['minmax']:min() --- - ['brave', 'new', 'world'] ... -space.index[1]:max() +space.index['minmax']:max() --- - ['brave', 'new', 'world'] ... -space:select(1, 'new', 'world') +space.index['minmax']:select('new', 'world') --- - ['brave', 'new', 'world'] ... -- A test case for Bug #904208 -- "assert failed, when key cardinality is greater than index cardinality" -- https://bugs.launchpad.net/tarantool/+bug/904208 -space:select(1, 'new', 'world', 'order') +space.index['minmax']:select('new', 'world', 'order') --- - error: Invalid key part count (expected [0..2], got 3) ... @@ -47,7 +41,7 @@ space:insert('item 1', 'alabama', 'song') --- - ['item 1', 'alabama', 'song'] ... -space:select(1, 'alabama') +space.index['minmax']:select('alabama') --- - ['item 1', 'alabama', 'song'] ... @@ -63,14 +57,14 @@ space:insert('item 4', 'georgia', 'on my mind') --- - ['item 4', 'georgia', 'on my mind'] ... -iter, tuple = space.index[1]:next('california') +iter, tuple = space.index['minmax']:next('california') --- ... tuple --- - ['item 2', 'california', 'dreaming '] ... -_, tuple = space.index[1]:next(iter) +_, tuple = space.index['minmax']:next(iter) --- ... tuple @@ -113,19 +107,13 @@ space:drop() -- -- Check range scan over multipart keys -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') ---- -- [0, 0, 'tweedledum'] -... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'minmax', 'tree', 0, 2, 1, 'str', 2, 'str') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- -- [0, 1, 'minmax', 'tree', 0, 2, 1, 'str', 2, 'str'] ... -space = box.space[0] +space:create_index('minmax', 'tree', {parts = {1, 'str', 2, 'str'}, unique = false }) --- ... space:insert(1234567, 'new', 'world') @@ -140,12 +128,12 @@ space:insert(00000001ULL, 'of', 'might', 'and', 'magic') --- - [1, 'of', 'might', 'and', 'magic'] ... -space:select_range(1, 2, 'of') +space.index['minmax']:select_range(2, 'of') --- - [1, 'of', 'might', 'and', 'magic'] - [0, 'of', 'puppets'] ... -space:select_reverse_range(1, 2, 'of') +space.index['minmax']:select_reverse_range(2, 'of') --- - [0, 'of', 'puppets'] - [1, 'of', 'might', 'and', 'magic'] @@ -160,7 +148,7 @@ space:insert(2^51, 'hello', 'world') --- - [2251799813685248, 'hello', 'world'] ... -space:select(0, 2^51) +space.index['primary']:select(2^51) --- - [2251799813685248, 'hello', 'world'] ... @@ -170,22 +158,17 @@ space:drop() -- -- Lua 64bit numbers support -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') ---- -- [0, 0, 'tweedledum'] -... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] ... -space = box.space[0] +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) --- ... space:insert(tonumber64('18446744073709551615'), 'magic') --- - [18446744073709551615, 'magic'] ... -tuple = space:select(0, tonumber64('18446744073709551615')) +tuple = space.index['primary']:select(tonumber64('18446744073709551615')) --- ... num = tuple[0] @@ -218,10 +201,10 @@ space:insert(125ULL, 'magic') --- - [125, 'magic'] ... -tuple = space:select(0, 125) +tuple = space.index['primary']:select(125) --- ... -tuple2 = space:select(0, 125LL) +tuple2 = space.index['primary']:select(125LL) --- ... num = tuple[0] @@ -282,19 +265,13 @@ space:drop() -- -- lua select_reverse_range() testing -- https://blueprints.launchpad.net/tarantool/+spec/backward-tree-index-iterator -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'range', 'tree', 1, 2, 1, 'num', 0, 'num') ---- -- [0, 1, 'range', 'tree', 1, 2, 1, 'num', 0, 'num'] -... -space = box.space[0] +space:create_index('range', 'tree', {parts = {1, 'num', 0, 'num'}, unique = true }) --- ... space:insert(0, 0) @@ -337,7 +314,7 @@ space:insert(9, 0) --- - [9, 0] ... -space:select_range(1, 10) +space.index['range']:select_range(10) --- - [0, 0] - [1, 0] @@ -350,7 +327,7 @@ space:select_range(1, 10) - [8, 0] - [9, 0] ... -space:select_reverse_range(1, 10) +space.index['range']:select_reverse_range(10) --- - [9, 0] - [8, 0] @@ -363,7 +340,7 @@ space:select_reverse_range(1, 10) - [1, 0] - [0, 0] ... -space:select_reverse_range(1, 4) +space.index['range']:select_reverse_range(4) --- - [9, 0] - [8, 0] @@ -376,19 +353,13 @@ space:drop() -- -- Tests for box.index iterators -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'str') +space:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'str'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 1, 2, 1, 'str', 2, 'str') ---- -- [0, 1, 'i1', 'tree', 1, 2, 1, 'str', 2, 'str'] -... -space = box.space[0] +space:create_index('i1', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true }) --- ... pid = 1 @@ -408,7 +379,7 @@ end; --- ... --# setopt delimiter '' -index = space.index[1] +index = space.index['i1'] --- ... t = {} @@ -492,6 +463,9 @@ t t = {} --- ... +index = nil +--- +... space:drop() --- ... @@ -499,19 +473,13 @@ space:drop() -- Tests for lua idx:count() -- -- https://blueprints.launchpad.net/tarantool/+spec/lua-builtin-size-of-subtree -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') ---- -- [0, 0, 'tweedledum'] -... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 0, 2, 1, 'num', 2, 'num') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- -- [0, 1, 'i1', 'tree', 0, 2, 1, 'num', 2, 'num'] ... -space = box.space[0] +space:create_index('i1', 'tree', {parts = {1, 'num', 2, 'num'}, unique = false }) --- ... space:insert(1, 1, 1) @@ -538,38 +506,38 @@ space:insert(6, 3, 2) --- - [6, 3, 2] ... -space.index[1]:count(1) +space.index['i1']:count(1) --- - 1 ... -space.index[1]:count(2) +space.index['i1']:count(2) --- - 2 ... -space.index[1]:count(2, 1) +space.index['i1']:count(2, 1) --- - 1 ... -space.index[1]:count(2, 2) +space.index['i1']:count(2, 2) --- - 0 ... -space.index[1]:count(3) +space.index['i1']:count(3) --- - 3 ... -space.index[1]:count(3, 3) +space.index['i1']:count(3, 3) --- - 0 ... -- Returns total number of records -- https://github.com/tarantool/tarantool/issues/46 -space.index[1]:count() +space.index['i1']:count() --- - 6 ... -- Test cases for #123: box.index.count does not check arguments properly -space.index[1]:count(function() end) +space.index['i1']:count(function() end) --- - error: 'msgpack.encode: can not encode Lua type ''function''' ... @@ -579,15 +547,10 @@ space:drop() -- -- Tests for lua tuple:transform() -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') ---- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'str'] -... -space = box.space[0] +space:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) --- ... t = space:insert('1', '2', '3', '4', '5', '6', '7') @@ -761,15 +724,10 @@ space:drop() -- http://bugs.launchpad.net/tarantool/+bug/1038784 -- https://bugs.launchpad.net/tarantool/+bug/1006354 -- lua box.auto_increment() testing -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] -... -space = box.space[0] +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) --- ... dofile('push.lua') @@ -850,19 +808,14 @@ space:drop() -- Truncate hangs when primary key is not in linear or starts at the first field -- https://bugs.launchpad.net/tarantool/+bug/1042798 -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') ---- -- [0, 0, 'tweedledum'] -... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 2, 2, 'num', 1, 'num') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'primary', 'tree', 1, 2, 2, 'num', 1, 'num'] ... -space = box.space[0] +space:create_index('primary', 'tree', {parts = {2, 'num', 1, 'num'}, unique = true }) --- ... -- Print key fields in pk -space.index[0].key_field +space.index['primary'].key_field --- - 0: type: NUM @@ -883,7 +836,7 @@ space:insert(20, 30, 40, 50) --- - [20, 30, 40, 50] ... -space:select(0) +space.index['primary']:select() --- - [1, 2, 3, 4] - [10, 20, 30, 40] @@ -894,7 +847,7 @@ space:truncate() --- ... -- Empty result -space:select(0) +space.index['primary']:select() --- ... space:drop() @@ -906,32 +859,26 @@ space:drop() dofile('index_random_test.lua') --- ... -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') ---- -- [0, 0, 'tweedledum'] -... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'secondary', 'hash', 1, 1, 0, 'num') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) --- -- [0, 1, 'secondary', 'hash', 1, 1, 0, 'num'] ... -space = box.space[0] +space:create_index('secondary', 'hash', {parts = {0, 'num'}, unique = true }) --- ... ------------------------------------------------------------------------------- -- TreeIndex::random() ------------------------------------------------------------------------------- -index_random_test(space, 0) +index_random_test(space, 'primary') --- - true ... ------------------------------------------------------------------------------- -- HashIndex::random() ------------------------------------------------------------------------------- -index_random_test(space, 1) +index_random_test(space, 'secondary') --- - true ... @@ -941,4 +888,4 @@ space:drop() space = nil --- ... --- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua +-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/test/big/lua.test.lua b/test/big/lua.test.lua index cbda742f4b9b926b1447eb8fa66a63bdf75d979e..e2607e9542318cc4dca4768e1b0ca7aca33acc2d 100644 --- a/test/big/lua.test.lua +++ b/test/big/lua.test.lua @@ -1,19 +1,17 @@ - -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') -box.insert(box.schema.INDEX_ID, 0, 1, 'minmax', 'tree', 1, 2, 1, 'str', 2, 'str') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) +space:create_index('minmax', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true }) space:insert('brave', 'new', 'world') -space.index[1]:min() -space.index[1]:max() -space:select(1, 'new', 'world') +space.index['minmax']:min() +space.index['minmax']:max() +space.index['minmax']:select('new', 'world') -- A test case for Bug #904208 -- "assert failed, when key cardinality is greater than index cardinality" -- https://bugs.launchpad.net/tarantool/+bug/904208 -space:select(1, 'new', 'world', 'order') +space.index['minmax']:select('new', 'world', 'order') space:delete('brave') -- A test case for Bug #902091 @@ -21,13 +19,13 @@ space:delete('brave') -- https://bugs.launchpad.net/tarantool/+bug/902091 space:insert('item 1', 'alabama', 'song') -space:select(1, 'alabama') +space.index['minmax']:select('alabama') space:insert('item 2', 'california', 'dreaming ') space:insert('item 3', 'california', 'uber alles') space:insert('item 4', 'georgia', 'on my mind') -iter, tuple = space.index[1]:next('california') +iter, tuple = space.index['minmax']:next('california') tuple -_, tuple = space.index[1]:next(iter) +_, tuple = space.index['minmax']:next(iter) tuple space:delete('item 1') space:delete('item 2') @@ -45,16 +43,15 @@ space:drop() -- -- Check range scan over multipart keys -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') -box.insert(box.schema.INDEX_ID, 0, 1, 'minmax', 'tree', 0, 2, 1, 'str', 2, 'str') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) +space:create_index('minmax', 'tree', {parts = {1, 'str', 2, 'str'}, unique = false }) space:insert(1234567, 'new', 'world') space:insert(0, 'of', 'puppets') space:insert(00000001ULL, 'of', 'might', 'and', 'magic') -space:select_range(1, 2, 'of') -space:select_reverse_range(1, 2, 'of') +space.index['minmax']:select_range(2, 'of') +space.index['minmax']:select_reverse_range(2, 'of') space:truncate() -- @@ -62,18 +59,17 @@ space:truncate() -- space:insert(2^51, 'hello', 'world') -space:select(0, 2^51) +space.index['primary']:select(2^51) space:drop() -- -- Lua 64bit numbers support -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) space:insert(tonumber64('18446744073709551615'), 'magic') -tuple = space:select(0, tonumber64('18446744073709551615')) +tuple = space.index['primary']:select(tonumber64('18446744073709551615')) num = tuple[0] num type(num) == 'cdata' @@ -82,8 +78,8 @@ num = tuple[0] num == tonumber64('18446744073709551615') space:delete(18446744073709551615ULL) space:insert(125ULL, 'magic') -tuple = space:select(0, 125) -tuple2 = space:select(0, 125LL) +tuple = space.index['primary']:select(125) +tuple2 = space.index['primary']:select(125LL) num = tuple[0] num2 = tuple2[0] num, num2 @@ -109,10 +105,9 @@ space:drop() -- -- lua select_reverse_range() testing -- https://blueprints.launchpad.net/tarantool/+spec/backward-tree-index-iterator -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') -box.insert(box.schema.INDEX_ID, 0, 1, 'range', 'tree', 1, 2, 1, 'num', 0, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) +space:create_index('range', 'tree', {parts = {1, 'num', 0, 'num'}, unique = true }) space:insert(0, 0) space:insert(1, 0) @@ -124,18 +119,17 @@ space:insert(6, 0) space:insert(7, 0) space:insert(8, 0) space:insert(9, 0) -space:select_range(1, 10) -space:select_reverse_range(1, 10) -space:select_reverse_range(1, 4) +space.index['range']:select_range(10) +space.index['range']:select_reverse_range(10) +space.index['range']:select_reverse_range(4) space:drop() -- -- Tests for box.index iterators -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'str') -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 1, 2, 1, 'str', 2, 'str') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) +space:create_index('i1', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true }) pid = 1 tid = 999 @@ -149,7 +143,7 @@ for sid = 1, 2 do end; --# setopt delimiter '' -index = space.index[1] +index = space.index['i1'] t = {} for k, v in index.next, index, 'sid_1' do table.insert(t, v) end @@ -170,42 +164,40 @@ t = {} for k, v in index.prev_equal, index, 'sid_2' do table.insert(t, v) end t t = {} +index = nil space:drop() -- -- Tests for lua idx:count() -- -- https://blueprints.launchpad.net/tarantool/+spec/lua-builtin-size-of-subtree -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 0, 2, 1, 'num', 2, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) +space:create_index('i1', 'tree', {parts = {1, 'num', 2, 'num'}, unique = false }) space:insert(1, 1, 1) space:insert(2, 2, 0) space:insert(3, 2, 1) space:insert(4, 3, 0) space:insert(5, 3, 1) space:insert(6, 3, 2) -space.index[1]:count(1) -space.index[1]:count(2) -space.index[1]:count(2, 1) -space.index[1]:count(2, 2) -space.index[1]:count(3) -space.index[1]:count(3, 3) +space.index['i1']:count(1) +space.index['i1']:count(2) +space.index['i1']:count(2, 1) +space.index['i1']:count(2, 2) +space.index['i1']:count(3) +space.index['i1']:count(3, 3) -- Returns total number of records -- https://github.com/tarantool/tarantool/issues/46 -space.index[1]:count() +space.index['i1']:count() -- Test cases for #123: box.index.count does not check arguments properly -space.index[1]:count(function() end) +space.index['i1']:count(function() end) space:drop() -- -- Tests for lua tuple:transform() -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') -space = box.space[0] - +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) t = space:insert('1', '2', '3', '4', '5', '6', '7') t:transform(7, 0, '8', '9', '100') t:transform(0, 1) @@ -270,9 +262,8 @@ space:drop() -- https://bugs.launchpad.net/tarantool/+bug/1006354 -- lua box.auto_increment() testing -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) dofile('push.lua') push_collection(space, 0, 1038784, 'hello') @@ -305,45 +296,43 @@ space:drop() -- Truncate hangs when primary key is not in linear or starts at the first field -- https://bugs.launchpad.net/tarantool/+bug/1042798 -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 2, 2, 'num', 1, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {2, 'num', 1, 'num'}, unique = true }) -- Print key fields in pk -space.index[0].key_field +space.index['primary'].key_field space:insert(1, 2, 3, 4) space:insert(10, 20, 30, 40) space:insert(20, 30, 40, 50) -space:select(0) +space.index['primary']:select() -- Truncate must not hang space:truncate() -- Empty result -space:select(0) +space.index['primary']:select() space:drop() -- -- index:random test -- dofile('index_random_test.lua') -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') -box.insert(box.schema.INDEX_ID, 0, 1, 'secondary', 'hash', 1, 1, 0, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) +space:create_index('secondary', 'hash', {parts = {0, 'num'}, unique = true }) ------------------------------------------------------------------------------- -- TreeIndex::random() ------------------------------------------------------------------------------- -index_random_test(space, 0) +index_random_test(space, 'primary') ------------------------------------------------------------------------------- -- HashIndex::random() ------------------------------------------------------------------------------- -index_random_test(space, 1) +index_random_test(space, 'secondary') space:drop() space = nil --- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua +-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/test/big/lua/bitset.lua b/test/big/lua/bitset.lua index 6adf5b173ad4658464ffd6ea7b58df7b339d9ee4..fd3ac9e19c58f87ccbbc871998fca6750258ea0b 100644 --- a/test/big/lua/bitset.lua +++ b/test/big/lua/bitset.lua @@ -2,37 +2,39 @@ local SPACE_NO = 0 local INDEX_NO = 1 function create_space() - box.insert(box.schema.SPACE_ID, SPACE_NO, 0, 'tweedledum') - box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') - box.insert(box.schema.INDEX_ID, 0, INDEX_NO, 'bitset', 'bitset', 0, 1, 1, 'num') + local space = box.schema.create_space('tweedledum') + space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) + space:create_index('bitset', 'bitset', {parts = {1, 'num'}, unique = false }) end function fill(...) + local space = box.space['tweedledum'] local nums = table.generate(arithmetic(...)); table.shuffle(nums); for _k, v in ipairs(nums) do - box.insert(SPACE_NO, v, v); + space:insert(v, v); end end function delete(...) + local space = box.space['tweedledum'] local nums = table.generate(arithmetic(...)); table.shuffle(nums); for _k, v in ipairs(nums) do - box.delete(SPACE_NO, v); + space:delete(v); end end function clear() - box.space[SPACE_NO]:truncate() + box.space['tweedledum']:truncate() end function drop_space() - box.space[SPACE_NO]:drop() + box.space['tweedledum']:drop() end function dump(...) - return iterate(SPACE_NO, INDEX_NO, 1, 2, ...); + return iterate('tweedledum', 'bitset', 1, 2, ...); end function test_insert_delete(n) diff --git a/test/big/tree_pk.result b/test/big/tree_pk.result index 2ac36fd3aef2a1a916d4ae3e35255c507a0aa14b..8c0d614c1520c1aec43bf8ca07be44d8fa004eb3 100644 --- a/test/big/tree_pk.result +++ b/test/big/tree_pk.result @@ -1,15 +1,10 @@ dofile('utils.lua') --- ... -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +s0 = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] -... -s0 = box.space[0] +s0:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) --- ... -- integer keys @@ -33,15 +28,15 @@ s0:insert(3, 'tuple 3') --- - [3, 'tuple 3'] ... -s0:select(0, 1) +s0.index['primary']:select(1) --- - [1, 'tuple'] ... -s0:select(0, 2) +s0.index['primary']:select(2) --- - [2, 'tuple 2'] ... -s0:select(0, 3) +s0.index['primary']:select(3) --- - [3, 'tuple 3'] ... @@ -72,26 +67,16 @@ s0:insert('12') --- - error: 'Tuple field 0 type does not match one required by operation: expected NUM' ... -box.insert(box.schema.SPACE_ID, 1, 0, 'tweedledee') ---- -- [1, 0, 'tweedledee'] -... -box.insert(box.schema.INDEX_ID, 1, 0, 'primary', 'tree', 1, 1, 0, 'str') +s1 = box.schema.create_space('tweedledee') --- -- [1, 0, 'primary', 'tree', 1, 1, 0, 'str'] ... -box.insert(box.schema.SPACE_ID, 2, 0, 'alice') +s1:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) --- -- [2, 0, 'alice'] ... -box.insert(box.schema.INDEX_ID, 2, 0, 'primary', 'tree', 1, 1, 0, 'str') +s2 = box.schema.create_space('alice') --- -- [2, 0, 'primary', 'tree', 1, 1, 0, 'str'] ... -s1 = box.space[1] ---- -... -s2 = box.space[1] +s2:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) --- ... -- string keys @@ -111,11 +96,11 @@ box.snapshot() --- - ok ... -s1:select_range(0, '100', 'second') +s1.index['primary']:select_range(100, 'second') --- - ['second', 'tuple 2'] ... -s1:select_range(0, '100', 'identifier') +s1.index['primary']:select_range(100, 'identifier') --- - ['identifier', 'tuple'] - ['second', 'tuple 2'] @@ -124,15 +109,15 @@ s1:insert('third', 'tuple 3') --- - ['third', 'tuple 3'] ... -s1:select(0, 'identifier') +s1.index['primary']:select('identifier') --- - ['identifier', 'tuple'] ... -s1:select(0, 'second') +s1.index['primary']:select('second') --- - ['second', 'tuple 2'] ... -s1:select(0, 'third') +s1.index['primary']:select('third') --- - ['third', 'tuple 3'] ... @@ -176,7 +161,7 @@ s2:insert('1', 'tuple') ... s1:insert('1', 'tuple') --- -- error: Duplicate key exists in unique index 0 +- ['1', 'tuple'] ... s1:insert('2', 'tuple') --- @@ -203,9 +188,7 @@ crossjoin(s1, s1, 10000) crossjoin(s1, s2, 10000) --- - - ['1', 'tuple', '1', 'tuple'] - - ['1', 'tuple', '2', 'tuple'] - ['2', 'tuple', '1', 'tuple'] - - ['2', 'tuple', '2', 'tuple'] ... s1:truncate() --- @@ -218,14 +201,14 @@ s0:insert(200, 'select me!') --- - [200, 'select me!'] ... -s0:select(0, 200) +s0.index['primary']:select(200) --- - [200, 'select me!'] ... -s0:select(0, 199) +s0.index['primary']:select(199) --- ... -s0:select(0, 201) +s0.index['primary']:select(201) --- ... -- Test partially specified keys in TREE indexes @@ -265,7 +248,7 @@ s1:insert('abcdc_') --- - ['abcdc_'] ... -box.sort({s1.index[0]:select_range(3, 'abcdb')}) +box.sort({s1.index['primary']:select_range(3, 'abcdb')}) --- - - ['abcdb'] - ['abcdb_'] @@ -277,23 +260,26 @@ s1:drop() s1 = nil --- ... +s2:drop() +--- +... +s2 = nil +--- +... -- -- tree::replace tests -- s0:truncate() --- ... -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 1, 1, 1, 'num') +s0:create_index('i1', 'tree', {parts = {1, 'num'}, unique = true }) --- -- [0, 1, 'i1', 'tree', 1, 1, 1, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 2, 'i2', 'tree', 0, 1, 2, 'num') +s0:create_index('i2', 'tree', {parts = {2, 'num'}, unique = false }) --- -- [0, 2, 'i2', 'tree', 0, 1, 2, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 3, 'i3', 'tree', 1, 1, 3, 'num') +s0:create_index('i3', 'tree', {parts = {3, 'num'}, unique = true }) --- -- [0, 3, 'i3', 'tree', 1, 1, 3, 'num'] ... s0:insert(0, 0, 0, 0) --- @@ -320,31 +306,31 @@ s0:replace_if_exists(1, 1, 1, 1) --- - [1, 1, 1, 1] ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -s0:select(0, 1) +s0.index['primary']:select(1) --- - [1, 1, 1, 1] ... -s0:select(1, 1) +s0.index['i1']:select(1) --- - [1, 1, 1, 1] ... -s0:select(2, 1) +s0.index['i2']:select(1) --- - [1, 1, 1, 1] ... -s0:select(3, 1) +s0.index['i3']:select(1) --- - [1, 1, 1, 1] ... @@ -357,16 +343,16 @@ s0:delete(10) --- - [10, 10, 10, 10] ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -- TupleFound (primary key) @@ -374,19 +360,19 @@ s0:insert(1, 10, 10, 10) --- - error: Duplicate key exists in unique index 0 ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -s0:select(0, 1) +s0.index['primary']:select(1) --- - [1, 1, 1, 1] ... @@ -395,16 +381,16 @@ s0:replace_if_exists(10, 10, 10, 10) --- - error: Tuple doesn't exist in index 0 ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -- TupleFound (key #1) @@ -412,19 +398,19 @@ s0:insert(10, 0, 10, 10) --- - error: Duplicate key exists in unique index 1 ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -s0:select(1, 0) +s0.index['i1']:select(0) --- - [0, 0, 0, 0] ... @@ -433,19 +419,19 @@ s0:replace_if_exists(2, 0, 10, 10) --- - error: Duplicate key exists in unique index 1 ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -s0:select(1, 0) +s0.index['i1']:select(0) --- - [0, 0, 0, 0] ... @@ -454,19 +440,19 @@ s0:insert(10, 10, 10, 0) --- - error: Duplicate key exists in unique index 3 ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -s0:select(3, 0) +s0.index['i3']:select(0) --- - [0, 0, 0, 0] ... @@ -475,19 +461,19 @@ s0:replace_if_exists(2, 10, 10, 0) --- - error: Duplicate key exists in unique index 3 ... -s0:select(0, 10) +s0.index['primary']:select(10) --- ... -s0:select(1, 10) +s0.index['i1']:select(10) --- ... -s0:select(2, 10) +s0.index['i2']:select(10) --- ... -s0:select(3, 10) +s0.index['i3']:select(10) --- ... -s0:select(3, 0) +s0.index['i3']:select(0) --- - [0, 0, 0, 0] ... @@ -508,7 +494,7 @@ s0:replace_if_exists(5, 5, 0, 5) --- - [5, 5, 0, 5] ... -box.sort({s0:select(2, 0)}) +box.sort({s0.index['i2']:select(0)}) --- - - [0, 0, 0, 0] - [4, 4, 0, 4] @@ -519,7 +505,7 @@ s0:delete(5) --- - [5, 5, 0, 5] ... -box.sort({s0:select(2, 0)}) +box.sort({s0.index['i2']:select(0)}) --- - - [0, 0, 0, 0] - [4, 4, 0, 4] diff --git a/test/big/tree_pk.test.lua b/test/big/tree_pk.test.lua index 5dc66461c91a3837a87f5d86ff624ba6e585ab19..349faa6a186175f34db427347b256063371e27a7 100644 --- a/test/big/tree_pk.test.lua +++ b/test/big/tree_pk.test.lua @@ -1,9 +1,7 @@ dofile('utils.lua') -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') - -s0 = box.space[0] +s0 = box.schema.create_space('tweedledum') +s0:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) -- integer keys s0:insert(1, 'tuple') @@ -12,9 +10,9 @@ s0:insert(2, 'tuple 2') box.snapshot() s0:insert(3, 'tuple 3') -s0:select(0, 1) -s0:select(0, 2) -s0:select(0, 3) +s0.index['primary']:select(1) +s0.index['primary']:select(2) +s0.index['primary']:select(3) -- Cleanup s0:delete(1) @@ -27,27 +25,24 @@ s0:insert('xxxxxxx') s0:insert('') s0:insert('12') -box.insert(box.schema.SPACE_ID, 1, 0, 'tweedledee') -box.insert(box.schema.INDEX_ID, 1, 0, 'primary', 'tree', 1, 1, 0, 'str') - -box.insert(box.schema.SPACE_ID, 2, 0, 'alice') -box.insert(box.schema.INDEX_ID, 2, 0, 'primary', 'tree', 1, 1, 0, 'str') +s1 = box.schema.create_space('tweedledee') +s1:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) -s1 = box.space[1] -s2 = box.space[1] +s2 = box.schema.create_space('alice') +s2:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) -- string keys s1:insert('identifier', 'tuple') box.snapshot() s1:insert('second', 'tuple 2') box.snapshot() -s1:select_range(0, '100', 'second') -s1:select_range(0, '100', 'identifier') +s1.index['primary']:select_range(100, 'second') +s1.index['primary']:select_range(100, 'identifier') s1:insert('third', 'tuple 3') -s1:select(0, 'identifier') -s1:select(0, 'second') -s1:select(0, 'third') +s1.index['primary']:select('identifier') +s1.index['primary']:select('second') +s1.index['primary']:select('third') -- Cleanup s1:delete('identifier') @@ -87,9 +82,9 @@ s2:truncate() -- Bug #922520 - select missing keys s0:insert(200, 'select me!') -s0:select(0, 200) -s0:select(0, 199) -s0:select(0, 201) +s0.index['primary']:select(200) +s0.index['primary']:select(199) +s0.index['primary']:select(201) -- Test partially specified keys in TREE indexes s1:insert('abcd') @@ -101,17 +96,20 @@ s1:insert('abcdb__') s1:insert('abcdb___') s1:insert('abcdc') s1:insert('abcdc_') -box.sort({s1.index[0]:select_range(3, 'abcdb')}) +box.sort({s1.index['primary']:select_range(3, 'abcdb')}) s1:drop() s1 = nil +s2:drop() +s2 = nil -- -- tree::replace tests -- s0:truncate() -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 1, 1, 1, 'num') -box.insert(box.schema.INDEX_ID, 0, 2, 'i2', 'tree', 0, 1, 2, 'num') -box.insert(box.schema.INDEX_ID, 0, 3, 'i3', 'tree', 1, 1, 3, 'num') + +s0:create_index('i1', 'tree', {parts = {1, 'num'}, unique = true }) +s0:create_index('i2', 'tree', {parts = {2, 'num'}, unique = false }) +s0:create_index('i3', 'tree', {parts = {3, 'num'}, unique = true }) s0:insert(0, 0, 0, 0) s0:insert(1, 1, 1, 1) @@ -121,79 +119,79 @@ s0:insert(2, 2, 2, 2) s0:replace_if_exists(1, 1, 1, 1) s0:replace_if_exists(1, 10, 10, 10) s0:replace_if_exists(1, 1, 1, 1) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) -s0:select(0, 1) -s0:select(1, 1) -s0:select(2, 1) -s0:select(3, 1) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) +s0.index['primary']:select(1) +s0.index['i1']:select(1) +s0.index['i2']:select(1) +s0.index['i3']:select(1) -- OK s0:insert(10, 10, 10, 10) s0:delete(10) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) -- TupleFound (primary key) s0:insert(1, 10, 10, 10) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) -s0:select(0, 1) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) +s0.index['primary']:select(1) -- TupleNotFound (primary key) s0:replace_if_exists(10, 10, 10, 10) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) -- TupleFound (key #1) s0:insert(10, 0, 10, 10) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) -s0:select(1, 0) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) +s0.index['i1']:select(0) -- TupleFound (key #1) s0:replace_if_exists(2, 0, 10, 10) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) -s0:select(1, 0) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) +s0.index['i1']:select(0) -- TupleFound (key #3) s0:insert(10, 10, 10, 0) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) -s0:select(3, 0) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) +s0.index['i3']:select(0) -- TupleFound (key #3) s0:replace_if_exists(2, 10, 10, 0) -s0:select(0, 10) -s0:select(1, 10) -s0:select(2, 10) -s0:select(3, 10) -s0:select(3, 0) +s0.index['primary']:select(10) +s0.index['i1']:select(10) +s0.index['i2']:select(10) +s0.index['i3']:select(10) +s0.index['i3']:select(0) -- Non-Uniq test (key #2) s0:insert(4, 4, 0, 4) s0:insert(5, 5, 0, 5) s0:insert(6, 6, 0, 6) s0:replace_if_exists(5, 5, 0, 5) -box.sort({s0:select(2, 0)}) +box.sort({s0.index['i2']:select(0)}) s0:delete(5) -box.sort({s0:select(2, 0)}) +box.sort({s0.index['i2']:select(0)}) s0:drop() s0 = nil diff --git a/test/big/tree_pk_multipart.result b/test/big/tree_pk_multipart.result index 9c0c8c76afd9f8ca203f5f20081bda1c6c1c8905..84ddf1dddc7afa526fec8f1c2cfc5a7612f0c168 100644 --- a/test/big/tree_pk_multipart.result +++ b/test/big/tree_pk_multipart.result @@ -1,16 +1,11 @@ -- -- Insert test -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -- Multipart primary key (sender nickname, receiver nickname, message id) -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 3, 0, 'str', 1, 'str', 2, 'num') ---- -- [0, 0, 'primary', 'tree', 1, 3, 0, 'str', 1, 'str', 2, 'num'] -... -space = box.space[0] +space:create_index('primary', 'tree', {parts = {0, 'str', 1, 'str', 2, 'num'}, unique = true }) --- ... space:insert('Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?') @@ -105,96 +100,96 @@ space:insert('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time -- Select test -- -- Select by one entry -space:select(0, 'Vincent', 'Jules', 0) +space.index['primary']:select('Vincent', 'Jules', 0) --- - ['Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'] ... -space:select(0, 'Jules', 'Vincent', 0) +space.index['primary']:select('Jules', 'Vincent', 0) --- - ['Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?'] ... -space:select(0, 'Vincent', 'Jules', 1) +space.index['primary']:select('Vincent', 'Jules', 1) --- - ['Vincent', 'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.'] ... -space:select(0, 'Jules', 'Vincent', 1) +space.index['primary']:select('Jules', 'Vincent', 1) --- - ['Jules', 'Vincent', 1, 'Then what do they call it?'] ... -space:select(0, 'Vincent', 'Jules', 2) +space.index['primary']:select('Vincent', 'Jules', 2) --- - ['Vincent', 'Jules', 2, 'They call it a `Royale` with cheese.'] ... -space:select(0, 'Jules', 'Vincent', 2) +space.index['primary']:select('Jules', 'Vincent', 2) --- - ['Jules', 'Vincent', 2, 'A `Royale` with cheese!'] ... -space:select(0, 'Vincent', 'Jules', 3) +space.index['primary']:select('Vincent', 'Jules', 3) --- - ['Vincent', 'Jules', 3, 'That`s right.'] ... -space:select(0, 'Jules', 'Vincent', 3) +space.index['primary']:select('Jules', 'Vincent', 3) --- - ['Jules', 'Vincent', 3, 'What do they call a Big Mac?'] ... -space:select(0, 'Vincent', 'Jules', 4) +space.index['primary']:select('Vincent', 'Jules', 4) --- - ['Vincent', 'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`'] ... -space:select(0, 'Jules', 'Vincent', 4) +space.index['primary']:select('Jules', 'Vincent', 4) --- - ['Jules', 'Vincent', 4, '`Le Big Mac!`'] ... -space:select(0, 'Vincent', 'Jules', 5) +space.index['primary']:select('Vincent', 'Jules', 5) --- - ['Vincent', 'Jules', 5, 'Ha, ha, ha.'] ... -space:select(0, 'Jules', 'Vincent', 5) +space.index['primary']:select('Jules', 'Vincent', 5) --- - ['Jules', 'Vincent', 5, 'What do they call a `Whopper`?'] ... -space:select(0, 'Vincent', 'Jules', 6) +space.index['primary']:select('Vincent', 'Jules', 6) --- - ['Vincent', 'Jules', 6, 'I dunno, I didn`t go into Burger King.'] ... -space:select(0, 'The Wolf!', 'Vincent', 0) +space.index['primary']:select('The Wolf!', 'Vincent', 0) --- - ['The Wolf!', 'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'] ... -space:select(0, 'Vincent', 'The Wolf!', 0) +space.index['primary']:select('Vincent', 'The Wolf!', 0) --- - ['Vincent', 'The Wolf!', 0, 'A please would be nice.'] ... -space:select(0, 'The Wolf!', 'Vincent', 1) +space.index['primary']:select('The Wolf!', 'Vincent', 1) --- - ['The Wolf!', 'Vincent', 1, 'Come again?'] ... -space:select(0, 'Vincent', 'The Wolf!', 1) +space.index['primary']:select('Vincent', 'The Wolf!', 1) --- - ['Vincent', 'The Wolf!', 1, 'I said a please would be nice.'] ... -space:select(0, 'The Wolf!', 'Vincent', 2) +space.index['primary']:select('The Wolf!', 'Vincent', 2) --- - ['The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'] ... -space:select(0, 'The Wolf!', 'Vincent', 3) +space.index['primary']:select('The Wolf!', 'Vincent', 3) --- - ['The Wolf!', 'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.'] ... -space:select(0, 'Vincent', 'The Wolf!', 2) +space.index['primary']:select('Vincent', 'The Wolf!', 2) --- - ['Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'] ... -- Select all messages from Vincent to Jules -space:select(0, 'Vincent', 'Jules') +space.index['primary']:select('Vincent', 'Jules') --- - ['Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'] @@ -207,7 +202,7 @@ space:select(0, 'Vincent', 'Jules') - ['Vincent', 'Jules', 6, 'I dunno, I didn`t go into Burger King.'] ... -- Select all messages from Jules to Vincent -space:select(0, 'Jules', 'Vincent') +space.index['primary']:select('Jules', 'Vincent') --- - ['Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?'] - ['Jules', 'Vincent', 1, 'Then what do they call it?'] @@ -217,7 +212,7 @@ space:select(0, 'Jules', 'Vincent') - ['Jules', 'Vincent', 5, 'What do they call a `Whopper`?'] ... -- Select all messages from Vincent to The Wolf -space:select(0, 'Vincent', 'The Wolf!') +space.index['primary']:select('Vincent', 'The Wolf!') --- - ['Vincent', 'The Wolf!', 0, 'A please would be nice.'] - ['Vincent', 'The Wolf!', 1, 'I said a please would be nice.'] @@ -226,7 +221,7 @@ space:select(0, 'Vincent', 'The Wolf!') of this. So, pretty please... with sugar on top. Clean the fucking car.'] ... -- Select all messages from The Wolf to Vincent -space:select(0, 'The Wolf!', 'Vincent') +space.index['primary']:select('The Wolf!', 'Vincent') --- - ['The Wolf!', 'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'] - ['The Wolf!', 'Vincent', 1, 'Come again?'] @@ -238,7 +233,7 @@ space:select(0, 'The Wolf!', 'Vincent') barking orders at me.'] ... -- Select all Vincent messages -space:select(0, 'Vincent') +space.index['primary']:select('Vincent') --- - ['Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'] @@ -281,7 +276,7 @@ space:update({'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, 1) - ['Vincent', 'The Wolf!', 1, 'I said a please would be nice.'] ... -- Checking Vincent's last messages -space:select(0, 'Vincent', 'The Wolf!') +space.index['primary']:select('Vincent', 'The Wolf!') --- - ['Vincent', 'The Wolf!', 1, 'I said a please would be nice.'] - ['Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. @@ -289,7 +284,7 @@ space:select(0, 'Vincent', 'The Wolf!') of this. So, pretty please... with sugar on top. Clean the fucking car.'] ... -- Checking The Wolf's last messages -space:select(0, 'The Wolf!', 'Vincent') +space.index['primary']:select('The Wolf!', 'Vincent') --- - ['The Wolf!', 'Vincent', 1, 'Come again?'] - ['The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, @@ -323,7 +318,7 @@ space:update({'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>') - ['Vincent', 'The Wolf!', 1, '<ooops>'] ... -- Checking Vincent's last messages -space:select(0, 'Vincent', 'The Wolf!') +space.index['primary']:select('Vincent', 'The Wolf!') --- - ['Vincent', 'The Wolf!', 1, '<ooops>'] - ['Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. @@ -331,7 +326,7 @@ space:select(0, 'Vincent', 'The Wolf!') of this. So, pretty please... with sugar on top. Clean the fucking car.'] ... -- Checking The Wolf's last messages -space:select(0, 'The Wolf!', 'Vincent') +space.index['primary']:select('The Wolf!', 'Vincent') --- - ['The Wolf!', 'Vincent', 1, '<ooops>'] - ['The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, @@ -367,15 +362,13 @@ space:len() -- A test case for Bug#1051006 Tree iterators return garbage --if an index is modified between calls -- -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'str') +space.index['primary']:drop() --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'str'] ... -box.replace(box.schema.INDEX_ID, 0, 1, 'second', 'tree', 1, 2, 1, 'str', 2, 'str') +space:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) --- -- [0, 1, 'second', 'tree', 1, 2, 1, 'str', 2, 'str'] ... -space = box.space[0] +space:create_index('second', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true }) --- ... space:insert('a', 'a', 'a') @@ -403,7 +396,7 @@ t = {} ... --# setopt delimiter ';' for i = 1, 2 do - k,v = space.index[1]:next(k) + k,v = space.index['second']:next(k) table.insert(t, v) end; --- @@ -449,7 +442,7 @@ t = {} ... --# setopt delimiter ';' for i = 1, 3 do - k,v = space.index[1]:next(k) + k,v = space.index['second']:next(k) table.insert(t, v) end; --- @@ -462,18 +455,16 @@ t space:drop() --- ... +space = nil +--- +... -- Bug #1082356 -- Space #19, https://bugs.launchpad.net/tarantool/+bug/1082356 -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -- Multipart primary key (sender nickname, receiver nickname, message id) -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 2, 0, 'num', 2, 'num') ---- -- [0, 0, 'primary', 'tree', 1, 2, 0, 'num', 2, 'num'] -... -space = box.space[0] +space:create_index('primary', 'tree', {parts = {0, 'num', 2, 'num'}, unique = true }) --- ... space:insert(1, 1) diff --git a/test/big/tree_pk_multipart.test.lua b/test/big/tree_pk_multipart.test.lua index 59e697c5c42d34d1e312552836938dcf57fa532e..b33cc0dff6aae1fec8741890b5fd08d243624bea 100644 --- a/test/big/tree_pk_multipart.test.lua +++ b/test/big/tree_pk_multipart.test.lua @@ -1,11 +1,9 @@ -- -- Insert test -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') -- Multipart primary key (sender nickname, receiver nickname, message id) -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 3, 0, 'str', 1, 'str', 2, 'num') - -space = box.space[0] +space:create_index('primary', 'tree', {parts = {0, 'str', 1, 'str', 2, 'num'}, unique = true }) space:insert('Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?') space:insert('Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?') @@ -34,42 +32,42 @@ space:insert('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time -- -- Select by one entry -space:select(0, 'Vincent', 'Jules', 0) -space:select(0, 'Jules', 'Vincent', 0) -space:select(0, 'Vincent', 'Jules', 1) -space:select(0, 'Jules', 'Vincent', 1) -space:select(0, 'Vincent', 'Jules', 2) -space:select(0, 'Jules', 'Vincent', 2) -space:select(0, 'Vincent', 'Jules', 3) -space:select(0, 'Jules', 'Vincent', 3) -space:select(0, 'Vincent', 'Jules', 4) -space:select(0, 'Jules', 'Vincent', 4) -space:select(0, 'Vincent', 'Jules', 5) -space:select(0, 'Jules', 'Vincent', 5) -space:select(0, 'Vincent', 'Jules', 6) - -space:select(0, 'The Wolf!', 'Vincent', 0) -space:select(0, 'Vincent', 'The Wolf!', 0) -space:select(0, 'The Wolf!', 'Vincent', 1) -space:select(0, 'Vincent', 'The Wolf!', 1) -space:select(0, 'The Wolf!', 'Vincent', 2) -space:select(0, 'The Wolf!', 'Vincent', 3) -space:select(0, 'Vincent', 'The Wolf!', 2) +space.index['primary']:select('Vincent', 'Jules', 0) +space.index['primary']:select('Jules', 'Vincent', 0) +space.index['primary']:select('Vincent', 'Jules', 1) +space.index['primary']:select('Jules', 'Vincent', 1) +space.index['primary']:select('Vincent', 'Jules', 2) +space.index['primary']:select('Jules', 'Vincent', 2) +space.index['primary']:select('Vincent', 'Jules', 3) +space.index['primary']:select('Jules', 'Vincent', 3) +space.index['primary']:select('Vincent', 'Jules', 4) +space.index['primary']:select('Jules', 'Vincent', 4) +space.index['primary']:select('Vincent', 'Jules', 5) +space.index['primary']:select('Jules', 'Vincent', 5) +space.index['primary']:select('Vincent', 'Jules', 6) + +space.index['primary']:select('The Wolf!', 'Vincent', 0) +space.index['primary']:select('Vincent', 'The Wolf!', 0) +space.index['primary']:select('The Wolf!', 'Vincent', 1) +space.index['primary']:select('Vincent', 'The Wolf!', 1) +space.index['primary']:select('The Wolf!', 'Vincent', 2) +space.index['primary']:select('The Wolf!', 'Vincent', 3) +space.index['primary']:select('Vincent', 'The Wolf!', 2) -- Select all messages from Vincent to Jules -space:select(0, 'Vincent', 'Jules') +space.index['primary']:select('Vincent', 'Jules') -- Select all messages from Jules to Vincent -space:select(0, 'Jules', 'Vincent') +space.index['primary']:select('Jules', 'Vincent') -- Select all messages from Vincent to The Wolf -space:select(0, 'Vincent', 'The Wolf!') +space.index['primary']:select('Vincent', 'The Wolf!') -- Select all messages from The Wolf to Vincent -space:select(0, 'The Wolf!', 'Vincent') +space.index['primary']:select('The Wolf!', 'Vincent') -- Select all Vincent messages -space:select(0, 'Vincent') +space.index['primary']:select('Vincent') -- -- Delete test @@ -83,9 +81,9 @@ space:delete('Vincent', 'The Wolf!', 0) space:update({'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New') space:update({'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, 1) -- Checking Vincent's last messages -space:select(0, 'Vincent', 'The Wolf!') +space.index['primary']:select('Vincent', 'The Wolf!') -- Checking The Wolf's last messages -space:select(0, 'The Wolf!', 'Vincent') +space.index['primary']:select('The Wolf!', 'Vincent') -- try to delete nonexistent message space:delete('Vincent', 'The Wolf!', 3) @@ -101,9 +99,9 @@ space:update({'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>') space:update({'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>') -- Checking Vincent's last messages -space:select(0, 'Vincent', 'The Wolf!') +space.index['primary']:select('Vincent', 'The Wolf!') -- Checking The Wolf's last messages -space:select(0, 'The Wolf!', 'Vincent') +space.index['primary']:select('The Wolf!', 'Vincent') -- try to update a nonexistent message space:update({'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>') @@ -118,9 +116,9 @@ space:len() -- A test case for Bug#1051006 Tree iterators return garbage --if an index is modified between calls -- -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'str') -box.replace(box.schema.INDEX_ID, 0, 1, 'second', 'tree', 1, 2, 1, 'str', 2, 'str') -space = box.space[0] +space.index['primary']:drop() +space:create_index('primary', 'tree', {parts = {0, 'str'}, unique = true }) +space:create_index('second', 'tree', {parts = {1, 'str', 2, 'str'}, unique = true }) space:insert('a', 'a', 'a') space:insert('d', 'd', 'd') @@ -131,7 +129,7 @@ space:insert('c', 'c', 'c') t = {} --# setopt delimiter ';' for i = 1, 2 do - k,v = space.index[1]:next(k) + k,v = space.index['second']:next(k) table.insert(t, v) end; --# setopt delimiter '' @@ -150,21 +148,19 @@ v t = {} --# setopt delimiter ';' for i = 1, 3 do - k,v = space.index[1]:next(k) + k,v = space.index['second']:next(k) table.insert(t, v) end; --# setopt delimiter '' t space:drop() - +space = nil -- Bug #1082356 -- Space #19, https://bugs.launchpad.net/tarantool/+bug/1082356 -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') -- Multipart primary key (sender nickname, receiver nickname, message id) -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 2, 0, 'num', 2, 'num') - -space = box.space[0] +space:create_index('primary', 'tree', {parts = {0, 'num', 2, 'num'}, unique = true }) space:insert(1, 1) space:replace_if_exists(1, 1) diff --git a/test/big/tree_variants.result b/test/big/tree_variants.result index 542ec21cc3ca16c320b559e71726055c63b88c7a..55ef4213aa63a43f355e7429d41bef4c63e424b1 100644 --- a/test/big/tree_variants.result +++ b/test/big/tree_variants.result @@ -1,36 +1,25 @@ -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) --- -- [0, 0, 'primary', 'tree', 1, 1, 0, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 1, 1, 1, 'num') +space:create_index('i1', 'tree', {parts = {1, 'num'}, unique = false }) --- -- [0, 1, 'i1', 'tree', 1, 1, 1, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 2, 'i2', 'tree', 0, 1, 2, 'num') +space:create_index('i2', 'tree', {parts = {2, 'num'}, unique = false }) --- -- [0, 2, 'i2', 'tree', 0, 1, 2, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 3, 'i3', 'tree', 0, 2, 3, 'str', 4, 'str') +space:create_index('i3', 'tree', {parts = {3, 'str', 4, 'str'}, unique = false }) --- -- [0, 3, 'i3', 'tree', 0, 2, 3, 'str', 4, 'str'] ... -box.insert(box.schema.INDEX_ID, 0, 4, 'i4', 'tree', 0, 2, 6, 'str', 5, 'str') +space:create_index('i4', 'tree', {parts = {6, 'str', 5, 'str'}, unique = false }) --- -- [0, 4, 'i4', 'tree', 0, 2, 6, 'str', 5, 'str'] ... -box.insert(box.schema.INDEX_ID, 0, 5, 'i5', 'tree', 0, 1, 8, 'num') +space:create_index('i5', 'tree', {parts = {8, 'num'}, unique = false }) --- -- [0, 5, 'i5', 'tree', 0, 1, 8, 'num'] ... -box.insert(box.schema.INDEX_ID, 0, 6, 'i6', 'tree', 1, 5, 6, 'str', 5, 'str', 3, 'str', 4, 'str', 8, 'num') ---- -- [0, 6, 'i6', 'tree', 1, 5, 6, 'str', 5, 'str', 3, 'str', 4, 'str', 8, 'num'] -... -space = box.space[0] +space:create_index('i6', 'tree', {parts = {6, 'str', 5, 'str', 3, 'str', 4, 'str', 8, 'num'}, unique = true }) --- ... space:insert(0, 0, 100, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000) @@ -73,11 +62,11 @@ space:insert(9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009) --- - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... -space:select(0, 1) +space.index['primary']:select(1) --- - [1, 1, 200, 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001] ... -space:select(1, 2) +space.index['i1']:select(2) --- - [2, 2, 200, 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002] ... @@ -87,23 +76,23 @@ space:select(1, 2) - [4, 4, 300, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004] - [5, 5, 300, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005] ... -#{space:select(3, 'Joe', 'Sixpack')} +#{space.index['i3']:select('Joe', 'Sixpack')} --- - 6 ... -#{space:select(3, 'John')} +#{space.index['i3']:select('John')} --- - 4 ... -#{space:select(4, 'A Pipe')} +#{space.index['i4']:select('A Pipe')} --- - 1 ... -{space:select(4, 'Miller Genuine Draft', 'Drinks')} +{space.index['i4']:select('Miller Genuine Draft', 'Drinks')} --- - - [5, 5, 300, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005] ... -space:select(5, 2007) +space.index['i5']:select(2007) --- - [7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007] ... @@ -143,22 +132,22 @@ space:insert(9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009) --- - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... -space:select(1, 6ULL) +space.index['i1']:select(6ULL) --- - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] ... -space:select(1, 6) +space.index['i1']:select(6) --- - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] ... -{space:select(2, 400ULL)} +{space.index['i2']:select(400ULL)} --- - - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] - [7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007] - [8, 8, 400, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008] - [9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009] ... -{space:select(2, 400)} +{space.index['i2']:select(400)} --- - - [6, 6, 400, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006] - [7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007] diff --git a/test/big/tree_variants.test.lua b/test/big/tree_variants.test.lua index 3757b742321915f20769777bc1dc0456ea78e708..408f730e54d6bb83a5c80a177f2f30dd94839e75 100644 --- a/test/big/tree_variants.test.lua +++ b/test/big/tree_variants.test.lua @@ -1,13 +1,11 @@ -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'tree', 1, 1, 0, 'num') -box.insert(box.schema.INDEX_ID, 0, 1, 'i1', 'tree', 1, 1, 1, 'num') -box.insert(box.schema.INDEX_ID, 0, 2, 'i2', 'tree', 0, 1, 2, 'num') -box.insert(box.schema.INDEX_ID, 0, 3, 'i3', 'tree', 0, 2, 3, 'str', 4, 'str') -box.insert(box.schema.INDEX_ID, 0, 4, 'i4', 'tree', 0, 2, 6, 'str', 5, 'str') -box.insert(box.schema.INDEX_ID, 0, 5, 'i5', 'tree', 0, 1, 8, 'num') -box.insert(box.schema.INDEX_ID, 0, 6, 'i6', 'tree', 1, 5, 6, 'str', 5, 'str', 3, 'str', 4, 'str', 8, 'num') - -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'tree', {parts = {0, 'num'}, unique = true }) +space:create_index('i1', 'tree', {parts = {1, 'num'}, unique = false }) +space:create_index('i2', 'tree', {parts = {2, 'num'}, unique = false }) +space:create_index('i3', 'tree', {parts = {3, 'str', 4, 'str'}, unique = false }) +space:create_index('i4', 'tree', {parts = {6, 'str', 5, 'str'}, unique = false }) +space:create_index('i5', 'tree', {parts = {8, 'num'}, unique = false }) +space:create_index('i6', 'tree', {parts = {6, 'str', 5, 'str', 3, 'str', 4, 'str', 8, 'num'}, unique = true }) space:insert(0, 0, 100, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000) space:insert(1, 1, 200, 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001) @@ -20,14 +18,14 @@ space:insert(7, 7, 400, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007) space:insert(8, 8, 400, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008) space:insert(9, 9, 400, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009) -space:select(0, 1) -space:select(1, 2) +space.index['primary']:select(1) +space.index['i1']:select(2) {space:select(2,300)} -#{space:select(3, 'Joe', 'Sixpack')} -#{space:select(3, 'John')} -#{space:select(4, 'A Pipe')} -{space:select(4, 'Miller Genuine Draft', 'Drinks')} -space:select(5, 2007) +#{space.index['i3']:select('Joe', 'Sixpack')} +#{space.index['i3']:select('John')} +#{space.index['i4']:select('A Pipe')} +{space.index['i4']:select('Miller Genuine Draft', 'Drinks')} +space.index['i5']:select(2007) space:select(6, 'Miller Genuine Draft', 'Drinks') space:delete(6) @@ -40,10 +38,10 @@ space:insert(7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007) space:insert(8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008) space:insert(9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009) -space:select(1, 6ULL) -space:select(1, 6) -{space:select(2, 400ULL)} -{space:select(2, 400)} +space.index['i1']:select(6ULL) +space.index['i1']:select(6) +{space.index['i2']:select(400ULL)} +{space.index['i2']:select(400)} {space:select(0)} diff --git a/test/wal/lua.result b/test/wal/lua.result index 523764f796d3ef05a034b0f42abb56642f90d134..20222ac7022f82ec7c44e6ca82b509f6e9732ba7 100644 --- a/test/wal/lua.result +++ b/test/wal/lua.result @@ -1,16 +1,10 @@ -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') +space:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) --- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'str'] ... -box.insert(box.schema.INDEX_ID, 0, 1, 'secondary', 'tree', 0, 1, 1, 'num') ---- -- [0, 1, 'secondary', 'tree', 0, 1, 1, 'num'] -... -space = box.space[0] +space:create_index('secondary', 'tree', {parts = {1, 'num'}, unique = false }) --- ... -- A test case for Bug#1042738 @@ -43,7 +37,7 @@ space:truncate() for i = 1, 100000, 1 do space:insert(tostring(i),i) end --- ... -local t1 = {space:select(1)} +local t1 = {space.index['secondary']:select()} --- - error: stack overflow ... @@ -54,13 +48,11 @@ space:drop() -- A test case for https://github.com/tarantool/tarantool/issues/65 -- Space does not exist error on repetitive access to space 0 in Lua -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum', {id=0}) --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] ... --# setopt delimiter ';' function mktuple(n) @@ -72,8 +64,7 @@ function mktuple(n) assert(t[0] == 1, "tuple check") assert(t[n-1] == n, "tuple check") return string.format("count %u len %u", #t, t:bsize()) -end -; +end; --- ... --# setopt delimiter '' @@ -85,3 +76,6 @@ mktuple(100000) --- - count 100000 len 368553 ... +space:drop() +--- +... diff --git a/test/wal/lua.test.lua b/test/wal/lua.test.lua index 4244957cf1f7cb270b3e18eb713ca7982b2699b2..2e33d9627f9548540eacc64e477f0bd0741235ff 100644 --- a/test/wal/lua.test.lua +++ b/test/wal/lua.test.lua @@ -1,7 +1,6 @@ -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'str') -box.insert(box.schema.INDEX_ID, 0, 1, 'secondary', 'tree', 0, 1, 1, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'str'}, unique = true }) +space:create_index('secondary', 'tree', {parts = {1, 'num'}, unique = false }) -- A test case for Bug#1042738 -- https://bugs.launchpad.net/tarantool/+bug/1042738 -- Iteration over a non-unique TREE index @@ -28,19 +27,17 @@ space:truncate() -- 5.4 -- for i = 1, 100000, 1 do space:insert(tostring(i),i) end -local t1 = {space:select(1)} +local t1 = {space.index['secondary']:select()} space:drop() - -- -- A test case for https://github.com/tarantool/tarantool/issues/65 -- Space does not exist error on repetitive access to space 0 in Lua -- -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +space = box.schema.create_space('tweedledum', {id=0}) +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --# setopt delimiter ';' - function mktuple(n) local fields = { [n] = n } for i = 1,n do @@ -50,10 +47,9 @@ function mktuple(n) assert(t[0] == 1, "tuple check") assert(t[n-1] == n, "tuple check") return string.format("count %u len %u", #t, t:bsize()) -end -; - +end; --# setopt delimiter '' mktuple(5000) mktuple(100000) +space:drop() diff --git a/test/wal/oom.result b/test/wal/oom.result index 76edb87795f063f7956875f31612e03c3b87a176..3aa6c08e1339b8891f0a7d3dcfde7330cc0cd565 100644 --- a/test/wal/oom.result +++ b/test/wal/oom.result @@ -1,14 +1,9 @@ --# stop server default --# start server default -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] -... -space = box.space[0] +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- ... --# setopt delimiter ';' @@ -55,23 +50,23 @@ space:len() --- - 6378 ... -space:select(0, 0) +space.index['primary']:select(0) --- - [0, 'test'] ... -space:select(0, 5) +space.index['primary']:select(5) --- - [5, 'testtesttesttesttesttest'] ... -space:select(0, 9) +space.index['primary']:select(9) --- - [9, 'testtesttesttesttesttesttesttesttesttest'] ... -space:select(0, 11) +space.index['primary']:select(11) --- - [11, 'testtesttesttesttesttesttesttesttesttesttesttest'] ... -space:select(0, 15) +space.index['primary']:select(15) --- - [15, 'testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest'] ... @@ -153,7 +148,7 @@ space:insert(0, 'test') --- - [0, 'test'] ... -space:select(0, 0) +space.index['primary']:select(0) --- - [0, 'test'] ... diff --git a/test/wal/oom.test.lua b/test/wal/oom.test.lua index 9092ff979baddfae771a4e0f0c25a5ee12413caa..24c1ca21b68e8b7d72784aecabd474c5d57e16d0 100644 --- a/test/wal/oom.test.lua +++ b/test/wal/oom.test.lua @@ -1,8 +1,7 @@ --# stop server default --# start server default -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --# setopt delimiter ';' i = 1; while true do @@ -23,11 +22,11 @@ while true do end; --# setopt delimiter '' space:len() -space:select(0, 0) -space:select(0, 5) -space:select(0, 9) -space:select(0, 11) -space:select(0, 15) +space.index['primary']:select(0) +space.index['primary']:select(5) +space.index['primary']:select(9) +space.index['primary']:select(11) +space.index['primary']:select(15) -- check that iterators work i = 0 t = {} @@ -43,5 +42,5 @@ end; t space:truncate() space:insert(0, 'test') -space:select(0, 0) +space.index['primary']:select(0) space:drop() diff --git a/test/wal/wal_mode.result b/test/wal/wal_mode.result index 3ebe04cc9783c3506c5761d344260d6f12b3b03c..9b1bb2887c3510a33d341e0083554aa1f83a8cb7 100644 --- a/test/wal/wal_mode.result +++ b/test/wal/wal_mode.result @@ -2,15 +2,10 @@ box.cfg.wal_mode --- - none ... -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +space = box.schema.create_space('tweedledum') --- -- [0, 0, 'tweedledum'] ... -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 'hash', 1, 1, 0, 'num'] -... -space = box.space[0] +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) --- ... space:insert(1) @@ -25,19 +20,19 @@ space:insert(3) --- - [3] ... -space:select(0, 1) +space.index['primary']:select(1) --- - [1] ... -space:select(0, 2) +space.index['primary']:select(2) --- - [2] ... -space:select(0, 3) +space.index['primary']:select(3) --- - [3] ... -space:select(0, 4) +space.index['primary']:select(4) --- ... box.snapshot() diff --git a/test/wal/wal_mode.test.lua b/test/wal/wal_mode.test.lua index dc95ed519eb1e17b9777f32a41dccfc19c77437a..e677adac1a3a4c4ab7a7e8cd001a3377ae87deff 100644 --- a/test/wal/wal_mode.test.lua +++ b/test/wal/wal_mode.test.lua @@ -1,14 +1,13 @@ box.cfg.wal_mode -box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') -space = box.space[0] +space = box.schema.create_space('tweedledum') +space:create_index('primary', 'hash', {parts = {0, 'num'}, unique = true }) space:insert(1) space:insert(2) space:insert(3) -space:select(0, 1) -space:select(0, 2) -space:select(0, 3) -space:select(0, 4) +space.index['primary']:select(1) +space.index['primary']:select(2) +space.index['primary']:select(3) +space.index['primary']:select(4) box.snapshot() box.snapshot() space:truncate()