Skip to content
Snippets Groups Projects
Commit 9bc7d2b9 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Merge remote-tracking branch 'origin/sophia-integration'

Conflicts:
	src/box/sophia_engine.cc
parents 19e9498f f82a40b5
No related branches found
No related tags found
No related merge requests found
Showing
with 242 additions and 197 deletions
...@@ -152,6 +152,7 @@ execute_select(struct request *request, struct port *port) ...@@ -152,6 +152,7 @@ execute_select(struct request *request, struct port *port)
struct tuple *tuple; struct tuple *tuple;
while ((tuple = it->next(it)) != NULL) { while ((tuple = it->next(it)) != NULL) {
TupleGuard tuple_gc(tuple);
if (offset > 0) { if (offset > 0) {
offset--; offset--;
continue; continue;
......
...@@ -176,41 +176,26 @@ SophiaEngine::createIndex(struct key_def *key_def) ...@@ -176,41 +176,26 @@ SophiaEngine::createIndex(struct key_def *key_def)
} }
} }
static inline int
drop_repository(char *path)
{
DIR *dir = opendir(path);
if (dir == NULL)
return -1;
char file[1024];
struct dirent *de;
while ((de = readdir(dir))) {
if (de->d_name[0] == '.')
continue;
snprintf(file, sizeof(file), "%s/%s", path, de->d_name);
int rc = unlink(file);
if (rc == -1) {
closedir(dir);
return -1;
}
}
closedir(dir);
return rmdir(path);
}
void void
SophiaEngine::dropIndex(Index *index) SophiaEngine::dropIndex(Index *index)
{ {
SophiaIndex *i = (SophiaIndex*)index; SophiaIndex *i = (SophiaIndex*)index;
int rc = sp_destroy(i->db); /* schedule asynchronous drop */
int rc = sp_drop(i->db);
if (rc == -1)
sophia_raise(env);
/* unref db object */
rc = sp_destroy(i->db);
if (rc == -1)
sophia_raise(env);
/* maybe start asynchronous database
* shutdown: last snapshot might hold a
* db pointer. */
rc = sp_destroy(i->db);
if (rc == -1) if (rc == -1)
sophia_raise(env); sophia_raise(env);
i->db = NULL; i->db = NULL;
i->env = NULL; i->env = NULL;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s/%" PRIu32,
cfg_gets("sophia_dir"), index->key_def->space_id);
drop_repository(path);
} }
void void
...@@ -279,7 +264,8 @@ SophiaEngine::commit(struct txn *txn) ...@@ -279,7 +264,8 @@ SophiaEngine::commit(struct txn *txn)
rlist_foreach_entry(stmt, &txn->stmts, next) { rlist_foreach_entry(stmt, &txn->stmts, next) {
if (! stmt->new_tuple) if (! stmt->new_tuple)
continue; continue;
assert(stmt->new_tuple->refs >= 2); assert(stmt->new_tuple->refs >= 1 &&
stmt->new_tuple->refs < UINT8_MAX);
tuple_unref(stmt->new_tuple); tuple_unref(stmt->new_tuple);
} }
auto scoped_guard = make_scoped_guard([=] { auto scoped_guard = make_scoped_guard([=] {
...@@ -303,7 +289,7 @@ SophiaEngine::rollback(struct txn *txn) ...@@ -303,7 +289,7 @@ SophiaEngine::rollback(struct txn *txn)
{ {
if (txn->engine_tx == NULL) if (txn->engine_tx == NULL)
return; return;
sp_rollback(txn->engine_tx); sp_destroy(txn->engine_tx);
txn->engine_tx = NULL; txn->engine_tx = NULL;
} }
...@@ -436,3 +422,11 @@ SophiaEngine::abort_checkpoint() ...@@ -436,3 +422,11 @@ SophiaEngine::abort_checkpoint()
m_checkpoint_lsn = -1; m_checkpoint_lsn = -1;
} }
} }
int sophia_schedule(void)
{
SophiaEngine *engine = (SophiaEngine *)engine_find("sophia");
assert(engine->env != NULL);
void *c = sp_ctl(engine->env);
return sp_set(c, "scheduler.run");
}
...@@ -56,4 +56,8 @@ struct SophiaEngine: public Engine { ...@@ -56,4 +56,8 @@ struct SophiaEngine: public Engine {
void sophia_info(void (*)(const char*, const char*, void*), void*); void sophia_info(void (*)(const char*, const char*, void*), void*);
void sophia_raise(void*); void sophia_raise(void*);
extern "C" {
int sophia_schedule(void);
}
#endif /* TARANTOOL_BOX_SOPHIA_ENGINE_H_INCLUDED */ #endif /* TARANTOOL_BOX_SOPHIA_ENGINE_H_INCLUDED */
...@@ -214,11 +214,8 @@ SophiaIndex::random(uint32_t rnd) const ...@@ -214,11 +214,8 @@ SophiaIndex::random(uint32_t rnd) const
struct space *space = space_cache_find(key_def->space_id); struct space *space = space_cache_find(key_def->space_id);
int valuesize; int valuesize;
void *value = sp_get(o, "value", &valuesize); void *value = sp_get(o, "value", &valuesize);
struct tuple *ret = return tuple_new(space->format, (char*)value,
tuple_new(space->format, (char*)value, (char*)value + valuesize);
(char*)value + valuesize);
tuple_ref(ret);
return ret;
} }
size_t size_t
...@@ -376,10 +373,7 @@ sophia_iterator_next(struct iterator *ptr) ...@@ -376,10 +373,7 @@ sophia_iterator_next(struct iterator *ptr)
return NULL; return NULL;
int valuesize = 0; int valuesize = 0;
const char *value = (const char*)sp_get(o, "value", &valuesize); const char *value = (const char*)sp_get(o, "value", &valuesize);
struct tuple *ret = return tuple_new(it->space->format, value, value + valuesize);
tuple_new(it->space->format, value, value + valuesize);
tuple_ref(ret);
return ret;
} }
struct tuple * struct tuple *
...@@ -394,12 +388,8 @@ sophia_iterator_eq(struct iterator *ptr) ...@@ -394,12 +388,8 @@ sophia_iterator_eq(struct iterator *ptr)
ptr->next = sophia_iterator_last; ptr->next = sophia_iterator_last;
struct sophia_iterator *it = (struct sophia_iterator *) ptr; struct sophia_iterator *it = (struct sophia_iterator *) ptr;
assert(it->cursor == NULL); assert(it->cursor == NULL);
struct tuple *tuple = return sophia_index_get(it->env, it->db, it->tx, it->key, it->keysize,
sophia_index_get(it->env, it->db, it->tx, it->key, it->keysize, it->space->format);
it->space->format);
if (tuple)
tuple_ref(tuple);
return tuple;
} }
struct iterator * struct iterator *
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <box/lua/index.h> #include <box/lua/index.h>
#include <box/lua/tuple.h> #include <box/lua/tuple.h>
#include <box/lua/call.h> #include <box/lua/call.h>
#include <box/sophia_engine.h>
#include <lua/init.h> #include <lua/init.h>
#include <tarantool.h> #include <tarantool.h>
#include "lua/bsdsocket.h" #include "lua/bsdsocket.h"
...@@ -60,5 +61,6 @@ void *ffi_symbols[] = { ...@@ -60,5 +61,6 @@ void *ffi_symbols[] = {
(void *) guava, (void *) guava,
(void *) random_bytes, (void *) random_bytes,
(void *) fiber_time, (void *) fiber_time,
(void *) fiber_time64 (void *) fiber_time64,
(void *) sophia_schedule
}; };
#!/usr/bin/env tarantool #!/usr/bin/env tarantool
os = require('os')
function sophia_printdir() require('suite')
f = io.popen("ls -1 sophia_test")
ls = f:read("*all")
unused = f:close()
return ls
end
function sophia_mkdir(dir)
os.execute("mkdir sophia_test")
end
function sophia_rmdir(dir)
os.execute("rm -rf sophia_test")
end
function file_exists(name) if not file_exists('lock') then
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
if not file_exists("lock") then
sophia_rmdir() sophia_rmdir()
sophia_mkdir() sophia_mkdir()
end end
local sophia = { local sophia = {
threads = 3 -- test case threads = 0
} }
if file_exists('mt') then
sophia.threads = 3
end
box.cfg { box.cfg {
listen = os.getenv("LISTEN"), listen = os.getenv("LISTEN"),
slab_alloc_arena = 0.1, slab_alloc_arena = 0.1,
pid_file = "tarantool.pid", pid_file = "tarantool.pid",
rows_per_wal = 50, rows_per_wal = 50,
sophia_dir = "./sophia_test", sophia_dir = "./sophia_test",
sophia = sophia sophia = sophia,
custom_proc_title = "default"
} }
require('console').listen(os.getenv('ADMIN')) require('console').listen(os.getenv('ADMIN'))
-- insert -- insert
space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
--- ---
... ...
sophia_dir()[1]
---
- 1
...
for key = 1, 132 do space:insert({key}) end for key = 1, 132 do space:insert({key}) end
--- ---
... ...
...@@ -1162,14 +1166,14 @@ index:select(7, {iterator = box.index.LT}) ...@@ -1162,14 +1166,14 @@ index:select(7, {iterator = box.index.LT})
- [2] - [2]
- [1] - [1]
... ...
-- random space:drop()
dofile('index_random_test.lua')
--- ---
... ...
index_random_test(space, 'primary') sophia_schedule()
--- ---
- true - 1
... ...
space:drop() sophia_dir()[1]
--- ---
- 0
... ...
-- insert -- insert
space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
sophia_dir()[1]
for key = 1, 132 do space:insert({key}) end for key = 1, 132 do space:insert({key}) end
t = {} t = {}
for key = 1, 132 do table.insert(t, space:get({key})) end for key = 1, 132 do table.insert(t, space:get({key})) end
...@@ -44,9 +45,6 @@ index:select(7, {iterator = box.index.LE}) ...@@ -44,9 +45,6 @@ index:select(7, {iterator = box.index.LE})
index:select({}, {iterator = box.index.LT}) index:select({}, {iterator = box.index.LT})
index:select(7, {iterator = box.index.LT}) index:select(7, {iterator = box.index.LT})
-- random
dofile('index_random_test.lua')
index_random_test(space, 'primary')
space:drop() space:drop()
sophia_schedule()
sophia_dir()[1]
-- space create/drop -- space create/drop
space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
sophia_printdir() sophia_dir()[1]
--- ---
- - 0
... ...
space:drop() space:drop()
--- ---
... ...
sophia_printdir() sophia_schedule()
--- ---
- - 0
...
sophia_dir()[1]
---
- 0
... ...
-- index create/drop -- index create/drop
space = box.schema.create_space('test', { id = 101, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary') index = space:create_index('primary')
--- ---
... ...
sophia_printdir() sophia_dir()[1]
--- ---
- '101 - 1
'
... ...
space:drop() space:drop()
--- ---
... ...
sophia_printdir() sophia_schedule()
--- ---
- - 1
...
sophia_dir()[1]
---
- 0
... ...
-- index create/drop alter -- index create/drop alter
space = box.schema.create_space('test', { id = 102, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary') index = space:create_index('primary')
--- ---
... ...
sophia_printdir() sophia_dir()[1]
--- ---
- '102 - 1
'
... ...
_index = box.space[box.schema.INDEX_ID] _index = box.space[box.schema.INDEX_ID]
--- ---
... ...
_index:delete{102, 0} _index:delete{102, 0}
--- ---
- [102, 0, 'primary', 'tree', 1, 1, 0, 'num']
... ...
sophia_printdir() space:drop()
--- ---
-
... ...
space:drop() sophia_schedule()
---
- 1
...
sophia_dir()[1]
--- ---
- 0
... ...
-- index create/drop tree string -- index create/drop tree string
space = box.schema.create_space('test', { id = 103, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}}) index = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}})
...@@ -71,17 +78,19 @@ space:insert({'test'}) ...@@ -71,17 +78,19 @@ space:insert({'test'})
--- ---
- ['test'] - ['test']
... ...
sophia_printdir() space:drop()
--- ---
- '103
'
... ...
space:drop() sophia_schedule()
---
- 1
...
sophia_dir()[1]
--- ---
- 0
... ...
-- index create/drop tree num -- index create/drop tree num
space = box.schema.create_space('test', { id = 104, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary', {type = 'tree', parts = {1, 'num'}}) index = space:create_index('primary', {type = 'tree', parts = {1, 'num'}})
...@@ -91,17 +100,19 @@ space:insert({13}) ...@@ -91,17 +100,19 @@ space:insert({13})
--- ---
- [13] - [13]
... ...
sophia_printdir() space:drop()
--- ---
- '104
'
... ...
space:drop() sophia_schedule()
--- ---
- 1
...
sophia_dir()[1]
---
- 0
... ...
-- index create hash -- index create hash
space = box.schema.create_space('test', { id = 105, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary', {type = 'hash'}) index = space:create_index('primary', {type = 'hash'})
...@@ -111,8 +122,16 @@ index = space:create_index('primary', {type = 'hash'}) ...@@ -111,8 +122,16 @@ index = space:create_index('primary', {type = 'hash'})
space:drop() space:drop()
--- ---
... ...
sophia_schedule()
---
- 0
...
sophia_dir()[1]
---
- 0
...
-- secondary index create -- secondary index create
space = box.schema.create_space('test', { id = 106, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index1 = space:create_index('primary') index1 = space:create_index('primary')
...@@ -126,12 +145,16 @@ index2 = space:create_index('secondary') ...@@ -126,12 +145,16 @@ index2 = space:create_index('secondary')
space:drop() space:drop()
--- ---
... ...
sophia_printdir() sophia_schedule()
---
- 1
...
sophia_dir()[1]
--- ---
- - 0
... ...
-- index size -- index size
space = box.schema.create_space('test', { id = 107, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary') index = space:create_index('primary')
...@@ -163,3 +186,7 @@ primary:len() ...@@ -163,3 +186,7 @@ primary:len()
space:drop() space:drop()
--- ---
... ...
sophia_schedule()
---
- 1
...
-- space create/drop -- space create/drop
space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
sophia_printdir() sophia_dir()[1]
space:drop() space:drop()
sophia_printdir() sophia_schedule()
sophia_dir()[1]
-- index create/drop -- index create/drop
space = box.schema.create_space('test', { id = 101, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary') index = space:create_index('primary')
sophia_printdir() sophia_dir()[1]
space:drop() space:drop()
sophia_printdir() sophia_schedule()
sophia_dir()[1]
-- index create/drop alter -- index create/drop alter
space = box.schema.create_space('test', { id = 102, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary') index = space:create_index('primary')
sophia_printdir() sophia_dir()[1]
_index = box.space[box.schema.INDEX_ID] _index = box.space[box.schema.INDEX_ID]
_index:delete{102, 0} _index:delete{102, 0}
sophia_printdir()
space:drop() space:drop()
sophia_schedule()
sophia_dir()[1]
-- index create/drop tree string -- index create/drop tree string
space = box.schema.create_space('test', { id = 103, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}}) index = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}})
space:insert({'test'}) space:insert({'test'})
sophia_printdir()
space:drop() space:drop()
sophia_schedule()
sophia_dir()[1]
-- index create/drop tree num -- index create/drop tree num
space = box.schema.create_space('test', { id = 104, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary', {type = 'tree', parts = {1, 'num'}}) index = space:create_index('primary', {type = 'tree', parts = {1, 'num'}})
space:insert({13}) space:insert({13})
sophia_printdir()
space:drop() space:drop()
sophia_schedule()
sophia_dir()[1]
-- index create hash -- index create hash
space = box.schema.create_space('test', { id = 105, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary', {type = 'hash'}) index = space:create_index('primary', {type = 'hash'})
space:drop() space:drop()
sophia_schedule()
sophia_dir()[1]
-- secondary index create -- secondary index create
space = box.schema.create_space('test', { id = 106, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index1 = space:create_index('primary') index1 = space:create_index('primary')
index2 = space:create_index('secondary') index2 = space:create_index('secondary')
space:drop() space:drop()
sophia_printdir() sophia_schedule()
sophia_dir()[1]
-- index size -- index size
space = box.schema.create_space('test', { id = 107, engine = 'sophia' }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary') index = space:create_index('primary')
primary = space.index[0] primary = space.index[0]
primary:len() primary:len()
...@@ -65,3 +73,4 @@ space:insert({14}) ...@@ -65,3 +73,4 @@ space:insert({14})
space:insert({15}) space:insert({15})
primary:len() primary:len()
space:drop() space:drop()
sophia_schedule()
-- gh-283: Sophia: hang after three creates and drops -- gh-283: Sophia: hang after three creates and drops
s = box.schema.create_space('space0', {id = 33, engine='sophia'}) s = box.schema.create_space('space0', {engine='sophia'})
--- ---
... ...
i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}})
...@@ -12,7 +12,11 @@ s:insert{'a', 'b', 'c'} ...@@ -12,7 +12,11 @@ s:insert{'a', 'b', 'c'}
s:drop() s:drop()
--- ---
... ...
s = box.schema.create_space('space0', {id = 33, engine='sophia'}) sophia_schedule()
---
- 1
...
s = box.schema.create_space('space0', {engine='sophia'})
--- ---
... ...
i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}})
...@@ -32,7 +36,11 @@ t ...@@ -32,7 +36,11 @@ t
s:drop() s:drop()
--- ---
... ...
s = box.schema.create_space('space0', {id = 33, engine='sophia'}) sophia_schedule()
---
- 1
...
s = box.schema.create_space('space0', {engine='sophia'})
--- ---
... ...
i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}})
...@@ -52,6 +60,10 @@ t ...@@ -52,6 +60,10 @@ t
s:drop() s:drop()
--- ---
... ...
sophia_schedule()
---
- 1
...
-- gh-280: Sophia: crash if insert without index -- gh-280: Sophia: crash if insert without index
s = box.schema.create_space('test', {engine='sophia'}) s = box.schema.create_space('test', {engine='sophia'})
--- ---
...@@ -63,13 +75,17 @@ s:insert{'a'} ...@@ -63,13 +75,17 @@ s:insert{'a'}
s:drop() s:drop()
--- ---
... ...
sophia_schedule()
---
- 0
...
-- gh-436: No error when creating temporary sophia space -- gh-436: No error when creating temporary sophia space
s = box.schema.create_space('tester',{engine='sophia', temporary=true}) s = box.schema.create_space('tester',{engine='sophia', temporary=true})
--- ---
- error: 'Can''t modify space ''tester'': space does not support temporary flag' - error: 'Can''t modify space ''tester'': space does not support temporary flag'
... ...
-- gh-432: Sophia: ignored limit -- gh-432: Sophia: ignored limit
s = box.schema.create_space('tester',{id = 89, engine='sophia'}) s = box.schema.create_space('tester',{engine='sophia'})
--- ---
... ...
i = s:create_index('sophia_index', {}) i = s:create_index('sophia_index', {})
...@@ -96,7 +112,11 @@ t ...@@ -96,7 +112,11 @@ t
s:drop() s:drop()
--- ---
... ...
s = box.schema.create_space('tester', {id = 90, engine='sophia'}) sophia_schedule()
---
- 1
...
s = box.schema.create_space('tester', {engine='sophia'})
--- ---
... ...
i = s:create_index('sophia_index', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('sophia_index', {type = 'tree', parts = {1, 'STR'}})
...@@ -122,30 +142,9 @@ t ...@@ -122,30 +142,9 @@ t
s:drop() s:drop()
--- ---
... ...
-- gh-282: Sophia: truncate() does nothing sophia_schedule()
s = box.schema.create_space('name_of_space', {id = 33, engine='sophia'})
---
...
i = s:create_index('name_of_index', {type = 'tree', parts = {1, 'STR'}})
---
...
s:insert{'a', 'b', 'c'}
---
- ['a', 'b', 'c']
...
box.space['name_of_space']:select{'a'}
---
- - ['a', 'b', 'c']
...
box.space['name_of_space']:truncate()
---
...
box.space['name_of_space']:select{'a'}
---
- []
...
s:drop()
--- ---
- 1
... ...
-- gh-680: Sophia: assertion on update -- gh-680: Sophia: assertion on update
s = box.schema.space.create('tester', {engine='sophia'}) s = box.schema.space.create('tester', {engine='sophia'})
...@@ -185,3 +184,7 @@ s:select{'Y'} ...@@ -185,3 +184,7 @@ s:select{'Y'}
s:drop() s:drop()
--- ---
... ...
sophia_schedule()
---
- 1
...
-- gh-283: Sophia: hang after three creates and drops -- gh-283: Sophia: hang after three creates and drops
s = box.schema.create_space('space0', {id = 33, engine='sophia'}) s = box.schema.create_space('space0', {engine='sophia'})
i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}})
s:insert{'a', 'b', 'c'} s:insert{'a', 'b', 'c'}
s:drop() s:drop()
sophia_schedule()
s = box.schema.create_space('space0', {id = 33, engine='sophia'}) s = box.schema.create_space('space0', {engine='sophia'})
i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}})
s:insert{'a', 'b', 'c'} s:insert{'a', 'b', 'c'}
t = s.index[0]:select({}, {iterator = box.index.ALL}) t = s.index[0]:select({}, {iterator = box.index.ALL})
t t
s:drop() s:drop()
sophia_schedule()
s = box.schema.create_space('space0', {id = 33, engine='sophia'}) s = box.schema.create_space('space0', {engine='sophia'})
i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}})
s:insert{'a', 'b', 'c'} s:insert{'a', 'b', 'c'}
t = s.index[0]:select({}, {iterator = box.index.ALL}) t = s.index[0]:select({}, {iterator = box.index.ALL})
t t
s:drop() s:drop()
sophia_schedule()
-- gh-280: Sophia: crash if insert without index -- gh-280: Sophia: crash if insert without index
s = box.schema.create_space('test', {engine='sophia'}) s = box.schema.create_space('test', {engine='sophia'})
s:insert{'a'} s:insert{'a'}
s:drop() s:drop()
sophia_schedule()
-- gh-436: No error when creating temporary sophia space -- gh-436: No error when creating temporary sophia space
...@@ -32,7 +36,7 @@ s = box.schema.create_space('tester',{engine='sophia', temporary=true}) ...@@ -32,7 +36,7 @@ s = box.schema.create_space('tester',{engine='sophia', temporary=true})
-- gh-432: Sophia: ignored limit -- gh-432: Sophia: ignored limit
s = box.schema.create_space('tester',{id = 89, engine='sophia'}) s = box.schema.create_space('tester',{engine='sophia'})
i = s:create_index('sophia_index', {}) i = s:create_index('sophia_index', {})
for v=1, 100 do s:insert({v}) end for v=1, 100 do s:insert({v}) end
t = s:select({''},{iterator='GT', limit =1}) t = s:select({''},{iterator='GT', limit =1})
...@@ -40,8 +44,9 @@ t ...@@ -40,8 +44,9 @@ t
t = s:select({},{iterator='GT', limit =1}) t = s:select({},{iterator='GT', limit =1})
t t
s:drop() s:drop()
sophia_schedule()
s = box.schema.create_space('tester', {id = 90, engine='sophia'}) s = box.schema.create_space('tester', {engine='sophia'})
i = s:create_index('sophia_index', {type = 'tree', parts = {1, 'STR'}}) i = s:create_index('sophia_index', {type = 'tree', parts = {1, 'STR'}})
for v=1, 100 do s:insert({tostring(v)}) end for v=1, 100 do s:insert({tostring(v)}) end
t = s:select({''},{iterator='GT', limit =1}) t = s:select({''},{iterator='GT', limit =1})
...@@ -49,16 +54,7 @@ t ...@@ -49,16 +54,7 @@ t
t = s:select({},{iterator='GT', limit =1}) t = s:select({},{iterator='GT', limit =1})
t t
s:drop() s:drop()
sophia_schedule()
-- gh-282: Sophia: truncate() does nothing
s = box.schema.create_space('name_of_space', {id = 33, engine='sophia'})
i = s:create_index('name_of_index', {type = 'tree', parts = {1, 'STR'}})
s:insert{'a', 'b', 'c'}
box.space['name_of_space']:select{'a'}
box.space['name_of_space']:truncate()
box.space['name_of_space']:select{'a'}
s:drop()
-- gh-680: Sophia: assertion on update -- gh-680: Sophia: assertion on update
s = box.schema.space.create('tester', {engine='sophia'}) s = box.schema.space.create('tester', {engine='sophia'})
...@@ -71,3 +67,4 @@ s:update({'X'}, {{'=', 3, 'Z'}}) ...@@ -71,3 +67,4 @@ s:update({'X'}, {{'=', 3, 'Z'}})
s:select{'X'} s:select{'X'}
s:select{'Y'} s:select{'Y'}
s:drop() s:drop()
sophia_schedule()
function index_random_test(space, index_no) function index_random_test(space, index_no)
local COUNT = 1028 local COUNT = 1028
-- clear the space
space:truncate()
-- randomize -- randomize
math.randomseed(os.time()) math.randomseed(os.time())
-- insert values into the index -- insert values into the index
......
-- box.info().sophia['sophia.version'] -- box.info().sophia['sophia.version']
space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) space = box.schema.create_space('test', { engine = 'sophia' })
--- ---
... ...
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
......
-- box.info().sophia['sophia.version'] -- box.info().sophia['sophia.version']
space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
for key = 1, 10 do space:insert({key}) end for key = 1, 10 do space:insert({key}) end
......
box.cfg.sophia box.cfg.sophia
--- ---
- page_size: 131072 - page_size: 131072
threads: 3 threads: 0
node_size: 134217728 node_size: 134217728
memory_limit: 0 memory_limit: 0
... ...
......
-- random
space = box.schema.create_space('test', { engine = 'sophia'})
---
...
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
---
...
dofile('index_random_test.lua')
---
...
index_random_test(space, 'primary')
---
- true
...
space:drop()
---
...
sophia_schedule()
---
- 1
...
-- random
space = box.schema.create_space('test', { engine = 'sophia'})
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
dofile('index_random_test.lua')
index_random_test(space, 'primary')
space:drop()
sophia_schedule()
-- snapshot -- snapshot
space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) os.execute("touch mt")
--# stop server default
--# start server default
space = box.schema.create_space('test', { engine = 'sophia' })
index = space:create_index('primary') index = space:create_index('primary')
sophia_printdir()
for key = 1, 351 do space:insert({key}) end for key = 1, 351 do space:insert({key}) end
box.snapshot() box.snapshot()
os.execute("rm -f mt")
os.execute("touch lock") os.execute("touch lock")
--# stop server default --# stop server default
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
core = tarantool core = tarantool
description = sophia integration tests description = sophia integration tests
script = box.lua script = box.lua
disabled = disabled = info.test.lua truncate.test.lua snapshot.test.lua
valgrind_disabled = valgrind_disabled =
release_disabled = release_disabled =
lua_libs = index_random_test.lua lua_libs = suite.lua index_random_test.lua
use_unix_sockets = True use_unix_sockets = True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment