本文整理汇总了C++中sp_getobject函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_getobject函数的具体用法?C++ sp_getobject怎么用?C++ sp_getobject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_getobject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snapshot_create_delete
static void
snapshot_create_delete(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
t( sp_setstring(env, "snapshot", "test_snapshot", 0) == 0 );
void *snapshot = sp_getobject(env, "snapshot.test_snapshot");
t( snapshot != NULL );
t( sp_destroy(snapshot) == 0 );
snapshot = sp_getobject(env, "snapshot.test_snapshot");
t( snapshot == NULL );
t( sp_destroy(env) == 0 );
}
示例2: shutdown_transaction1
static void
shutdown_transaction1(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_open(env) == 0 );
void *txn = sp_begin(env);
t( txn != NULL );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_setint(env, "db.test.sync", 0) == 0 );
t( sp_open(db) == 0 );
sp_destroy(db); /* unref */
sp_destroy(db); /* schedule shutdown, unlink */
void *dbp = sp_getobject(env, "db.test");
t( dbp == NULL );
/* process shutdown, txn not binded */
t( sp_setint(env, "scheduler.run", 0) == 1 );
t( sp_destroy(txn) == 0 );
t( sp_destroy(env) == 0 );
}
示例3: github_123
static void
github_123(void)
{
rmrf("./abc");
rmrf("./abc_log");
void *env = sp_env();
t( env != NULL );
char path[] = { '.', '/', 'a', 'b', 'c' };
char path_log[] = { '.', '/', 'a', 'b', 'c', '_', 'l', 'o', 'g' };
char name[] = { 't', 'e', 's', 't' };
t( sp_setstring(env, "sophia.path", path, sizeof(path)) == 0 );
t( sp_setstring(env, "db", name, sizeof(name)) == 0 );
t( sp_setstring(env, "log.path", path_log, sizeof(path_log)) == 0 );
t( sp_setstring(env, "view", name, sizeof(name)) == 0 );
t( sp_open(env) == 0 );
t( exists("./", "abc") == 1 );
t( exists("./", "abc_log") == 1 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
void *view = sp_getobject(env, "view.test");
t( view != NULL );
t( sp_destroy(env) == 0 );
rmrf("./abc");
rmrf("./abc_log");
}
示例4: drop_test
static void
drop_test(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(db) == 0 );
void *txn = sp_begin(env);
t( txn != NULL );
sp_destroy(db); /* unref */
t( sp_drop(db) == 0); /* scheduler drop */
void *dbp = sp_getobject(env, "db.test");
t( dbp == NULL );
t( sp_setint(env, "scheduler.run", 0) == 0 );
t( sp_destroy(txn) == 0 );
t( exists(st_r.conf->db_dir, "") == 1 );
t( sp_setint(env, "scheduler.run", 0) == 1 ); /* proceed drop */
t( exists(st_r.conf->db_dir, "") == 0 );
t( sp_destroy(env) == 0 );
}
示例5: scheme_test0
static void
scheme_test0(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.compression_cold", "zstd", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
t( sp_setstring(env, "db.test.scheme.key", "u32,key(0)", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "key_b", 0) == 0 );
t( sp_setstring(env, "db.test.scheme.key_b", "string,key(1)", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "value", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
t( sp_destroy(env) == 0 );
env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.sync", 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
char *v = sp_getstring(env, "db.test.compression_cold", 0);
t( v != NULL );
t( strcmp(v, "zstd") == 0 );
free(v);
v = sp_getstring(env, "db.test.scheme.key", 0);
t( v != NULL );
t( strcmp(v, "u32,key(0)") == 0 );
free(v);
v = sp_getstring(env, "db.test.scheme.key_b", 0);
t( v != NULL );
t( strcmp(v, "string,key(1)") == 0 );
free(v);
v = sp_getstring(env, "db.test.scheme.value", 0);
t( v != NULL );
t( strcmp(v, "string") == 0 );
free(v);
t( sp_destroy(env) == 0 );
}
示例6: secondary_index_test0
static void
secondary_index_test0(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
/* unique */
t( sp_setstring(env, "db", "primary", 0) == 0 );
t( sp_setstring(env, "db.primary.scheme", "a", 0) == 0 );
t( sp_setstring(env, "db.primary.scheme.a", "u32,key(0)", 0) == 0 );
t( sp_setstring(env, "db.primary.scheme", "b", 0) == 0 );
t( sp_setstring(env, "db.primary.scheme.b", "u32", 0) == 0 );
t( sp_setint(env, "db.primary.sync", 0) == 0 );
/* non-unique */
t( sp_setstring(env, "db", "secondary", 0) == 0 );
t( sp_setstring(env, "db.secondary.scheme", "a", 0) == 0 );
t( sp_setstring(env, "db.secondary.scheme.a", "u32,key(1)", 0) == 0 );
t( sp_setstring(env, "db.secondary.scheme", "b", 0) == 0 );
t( sp_setstring(env, "db.secondary.scheme.b", "u32,key(0)", 0) == 0 );
t( sp_setint(env, "db.secondary.sync", 0) == 0 );
void *primary = sp_getobject(env, "db.primary");
void *secondary = sp_getobject(env, "db.secondary");
t( primary != NULL );
t( secondary != NULL );
t( sp_open(env) == 0 );
void *tx = sp_begin(env);
uint32_t a = 0;
uint32_t b = 0;
void *po = sp_document(primary);
sp_setstring(po, "a", &a, sizeof(a));
sp_setstring(po, "b", &b, sizeof(b));
t( sp_open(po) == 0 );
t( sp_set(tx, po) == 0 );
void *so = sp_document(secondary);
t( sp_setobject(so, "reuse", po) == 0 );
t( sp_set(tx, so) == 0 );
t( sp_commit(tx) == 0 );
sp_destroy(po);
t( sp_getint(env, "performance.documents") == 1 );
t( sp_setint(env, "db.primary.branch", 0) == 0 );
t( sp_setint(env, "db.secondary.branch", 0) == 0 );
sp_destroy(env);
}
示例7: ddl_open_online0
static void
ddl_open_online0(void)
{
rmrf("./logdir");
rmrf("./dir0");
rmrf("./dir1");
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "s0", 0) == 0 );
t( sp_setstring(env, "db.s0.path", "dir0", 0) == 0 );
t( sp_setstring(env, "db.s0.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.s0.sync", 0) == 0 );
void *s0 = sp_getobject(env, "db.s0");
t( s0 != NULL );
t( sp_open(s0) == 0 );
int key = 7;
void *o = sp_object(s0);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s0, o) == 0 );
key = 8;
o = sp_object(s0);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s0, o) == 0 );
key = 9;
o = sp_object(s0);
sp_setstring(o, "key", &key, sizeof(key));
t( sp_set(s0, o) == 0 );
t( sp_destroy(s0) == 0 );
t( sp_destroy(s0) == 0 ); /* shutdown */
t( sp_setstring(env, "db", "s0", 0) == 0 );
t( sp_setstring(env, "db.s0.path", "dir0", 0) == 0 );
t( sp_setstring(env, "db.s0.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.s0.sync", 0) == 0 );
/* ban open existing databases */
s0 = sp_getobject(env, "db.s0");
t( s0 != NULL );
t( sp_open(s0) == -1 );
t( sp_destroy(env) == 0 );
rmrf("./logdir");
rmrf("./dir0");
rmrf("./dir1");
}
示例8: snapshot_get
static void
snapshot_get(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
int i = 0;
while ( i < 100 ) {
void *o = sp_object(db);
t( sp_setstring(o, "key", &i, sizeof(i)) == 0 );
t( sp_setstring(o, "value", &i, sizeof(i)) == 0 );
t( sp_set(db, o) == 0 );
i++;
}
t( sp_setstring(env, "snapshot", "test_snapshot", 0) == 0 );
void *snapshot = sp_getobject(env, "snapshot.test_snapshot");
t( snapshot != NULL );
i = 0;
while ( i < 100 ) {
void *o = sp_object(db);
int value = i + 1;
t( sp_setstring(o, "key", &i, sizeof(i)) == 0 );
t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
i++;
}
i = 0;
while ( i < 100 ) {
void *o = sp_object(db);
t( sp_setstring(o, "key", &i, sizeof(i)) == 0 );
o = sp_get(snapshot, o);
t( *(int*)sp_getstring(o, "value", NULL) == i );
t( sp_destroy(o) == 0 );
i++;
}
t( sp_destroy(env) == 0 );
}
示例9: npr_test0
static void
npr_test0(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "sophia.recover", 3) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.enable", 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_open(env) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
t( sp_setstring(env, "db.test.scheme.key", "u32,key(0)", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "value", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(db) == 0 );
char *v = sp_getstring(env, "db.test.status", NULL);
t( strcmp(v, "online") == 0 );
free(v);
t( sp_open(env) == 0 ); /* 2nd state */
/* recover */
t( sp_setstring(env, "db", "test2", 0) == 0 );
t( sp_setint(env, "db.test2.sync", 0) == 0 );
db = sp_getobject(env, "db.test2");
t( db != NULL );
t( sp_open(db) == 0 );
v = sp_getstring(env, "db.test2.status", NULL);
t( strcmp(v, "online") == 0 );
free(v);
t( sp_open(env) == 0 ); /* 3nd state */
/* online */
t( sp_open(env) == 0 ); /* N states */
/* recover */
t( sp_open(env) == 0 ); /* ... */
/* online */
t( sp_destroy(db) == 0 );
t( sp_destroy(env) == 0 );
}
示例10: mt_single_stmt
static void
mt_single_stmt(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 3) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_setint(env, "log.sync", 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
ssthreadpool p;
ss_threadpool_init(&p);
t( ss_threadpool_new(&p, &st_r.a, 5, single_stmt_thread, db) == 0 );
t( ss_threadpool_shutdown(&p, &st_r.a) == 0 );
t (sp_getint(env, "db.test.index.count") == 100000 );
t( sp_destroy(env) == 0 );
}
示例11: mt_multi_stmt_conflict0
static void
mt_multi_stmt_conflict0(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 3) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_setint(env, "log.sync", 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
/* conflict source */
t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
t( sp_setstring(env, "db.test.scheme.key", "u32,key", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "value", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
ssthreadpool p;
ss_threadpool_init(&p);
void *ptr[2] = { env, db };
t( ss_threadpool_new(&p, &st_r.a, 5, multi_stmt_conflict_thread0, ptr) == 0 );
t( ss_threadpool_shutdown(&p, &st_r.a) == 0 );
t( sp_destroy(env) == 0 );
}
示例12: meta_db
static void
meta_db(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
t( sp_setint(env, "db.test.id", 777) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
t( sp_open(env) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
char *s = sp_getstring(db, "name", NULL);
t( strcmp(s, "test") == 0 );
free(s);
t( sp_getint(db, "id") == 777 );
t( sp_getint(db, "key-count") == 2 );
s = sp_getstring(env, "db.test.index.key", 0);
t( s != NULL );
t( strcmp(s, "string") == 0 );
free(s);
s = sp_getstring(env, "db.test.index.key_b", 0);
t( s != NULL );
t( strcmp(s, "string") == 0 );
free(s);
t( sp_destroy(env) == 0 );
}
示例13: transaction_batch_test1
static void
transaction_batch_test1(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
t( sp_setstring(env, "db.test.scheme.key", "u32,key(0)", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
void *tx = sp_begin(env);
t( tx != NULL );
uint32_t a = 7;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &a, sizeof(a)) == 0 );
t( sp_set(tx, o) == 0 );
t( sp_setstring(tx, "isolation", "batch", 0) == -1 );
t( sp_destroy(tx) == 0 );
t( sp_destroy(env) == 0 );
}
示例14: github_118
static void
github_118(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_open(env) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
unsigned key = 123456;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
o = sp_get(db, o);
t( o != NULL );
sp_destroy(o);
t( sp_getint(env, "db.test.index.count") == 1 );
char *sz = sp_getstring(env, "db.test.index.temperature_histogram", NULL);
t( strcmp(sz, "[0]:1-1 ") == 0 );
free(sz);
t( sp_destroy(db) == 0 );
t( sp_destroy(env) == 0 );
}
示例15: batch_set_commit
static void
batch_set_commit(void)
{
void *env = sp_env();
t( env != NULL );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
void *batch = sp_batch(db);
t( batch != NULL );
int key = 123;
void *o = sp_object(db);
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(batch, o) == 0 );
t( sp_commit(batch) == 0 );
t( sp_destroy(env) == 0 );
}