Skip to content
Snippets Groups Projects
Commit 07b817fd authored by Dmitry Simonenko's avatar Dmitry Simonenko
Browse files

sophia-gh-577: make profiler information available in tarantool

parent cc61c3ba
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,22 @@ void sophia_raise(void *env)
tnt_raise(ClientError, ER_SOPHIA, error);
}
void sophia_info(void (*callback)(const char*, const char*, void*), void *arg)
{
SophiaFactory *factory = (SophiaFactory*)engine_find("sophia");
void *env = factory->env;
void *c = sp_ctl(env);
void *o, *cur = sp_cursor(c, ">=", NULL);
if (cur == NULL)
sophia_raise(env);
while ((o = sp_get(cur))) {
const char *k = (const char *)sp_get(o, "key", NULL);
const char *v = (const char *)sp_get(o, "value", NULL);
callback(k, v, arg);
}
sp_destroy(cur);
}
struct Sophia: public Engine {
Sophia(EngineFactory*);
};
......
......@@ -47,6 +47,7 @@ struct SophiaFactory: public EngineFactory {
void *tx_db;
};
void sophia_info(void (*)(const char*, const char*, void*), void*);
void sophia_raise(void*);
#endif /* TARANTOOL_BOX_ENGINE_SOPHIA_H_INCLUDED */
......@@ -118,6 +118,27 @@ lbox_info_logger_pid(struct lua_State *L)
return 1;
}
void sophia_info(void (*)(const char*, const char*, void*), void*);
static void
lbox_info_sophia_cb(const char *key, const char *value, void *arg)
{
struct lua_State *L;
L = (struct lua_State*)arg;
if (value == NULL)
return;
lua_pushstring(L, key);
lua_pushstring(L, value);
lua_settable(L, -3);
}
static int
lbox_info_sophia(struct lua_State *L)
{
lua_newtable(L);
sophia_info(lbox_info_sophia_cb, (void*)L);
return 1;
}
static const struct luaL_reg
lbox_info_dynamic_meta [] =
......@@ -130,6 +151,7 @@ lbox_info_dynamic_meta [] =
{"uptime", lbox_info_uptime},
{"snapshot_pid", lbox_info_snapshot_pid},
{"logger_pid", lbox_info_logger_pid},
{"sophia", lbox_info_sophia},
{NULL, NULL}
};
......
sophia_rmdir()
---
...
box.info().sophia['sophia.version']
---
- '1.2'
...
space = box.schema.create_space('test', { engine = 'sophia', id = 100 })
---
...
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
---
...
for key = 1, 10 do space:insert({key}) end
---
...
box.info().sophia['db.100.profiler.index_count']
---
- '10'
...
space:drop()
---
...
sophia_rmdir()
---
...
sophia_rmdir()
box.info().sophia['sophia.version']
space = box.schema.create_space('test', { engine = 'sophia', id = 100 })
index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} })
for key = 1, 10 do space:insert({key}) end
box.info().sophia['db.100.profiler.index_count']
space:drop()
sophia_rmdir()
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