本文整理汇总了C++中sp_set函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_set函数的具体用法?C++ sp_set怎么用?C++ sp_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: while
static inline void *multi_stmt_conflict_thread(void *arg)
{
soworker *self = arg;
void *env = ((void**)self->arg)[0];
void *db = ((void**)self->arg)[1];
int i = 0;
while (i < 2000) {
int rc;
void *tx = sp_begin(env);
assert( tx != NULL );
int j = 0;
while (j < 10) {
void *o = sp_object(db);
int key = i + j;
assert(o != NULL);
sp_set(o, "key", &key, sizeof(key));
rc = sp_set(tx, o);
assert(rc != -1);
j++;
}
rc = sp_commit(tx);
assert(rc != -1);
if (rc == 2)
sp_destroy(tx);
i++;
}
return NULL;
}
开发者ID:bhdz,项目名称:sophia,代码行数:28,代码来源:mt.test.c
示例2: gh_5
static void
gh_5(void) {
void *env = sp_env();
t( env != NULL );
t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0 );
void *db = sp_open(env);
t( db != NULL );
char k1[] = "key-1";
char v1[] = "val-1";
t( sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0);
char k2[] = "key-10";
char v2[] = "val-10";
t( sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0);
size_t ressize = 0;
void *res = NULL;
t( sp_get(db, k1, sizeof(k1), &res, &ressize) == 1 );
t( ressize == sizeof(v1) );
t( strcmp(v1, res) == 0 );
free(res);
t( sp_destroy(db) == 0 );
t( sp_destroy(env) == 0 );
t( rmrf(dbrep) == 0 );
}
开发者ID:FromPointer,项目名称:sophia,代码行数:29,代码来源:issues.c
示例3: switch
jint JNICALL Java_eu_unicredit_sophia_SophiaInterface_sp_1set
(JNIEnv * env, jobject obj, jlongArray args)
{
jlong* array = (*env)->GetLongArrayElements(env, args,JNI_FALSE);
jint size = (*env)->GetArrayLength(env, args);
int ret = -1;
switch(size) {
case 0:
printf("Not supported\n");
break;
case 1:
printf("Not supported\n");
break;
case 2:
ret = sp_set((void*)array[0],
(void*)array[1]);
break;
case 3:
ret = sp_set((void*)array[0],
(void*)array[1],
(void*)array[2]);
break;
case 4:
ret = sp_set((void*)array[0],
(void*)array[1],
(void*)array[2],
(void*)array[3]);
break;
default:
printf("Not supported\n");
break;
};
return (jint)ret;
}
开发者ID:muthhus,项目名称:sophia-java,代码行数:34,代码来源:SophiaInterface.c
示例4: meta_db
static void
meta_db(void)
{
void *env = sp_env();
t( env != NULL );
void *c = sp_ctl(env);
t( c != NULL );
t( sp_set(c, "sophia.path", cx->suite->sophiadir) == 0 );
t( sp_set(c, "scheduler.threads", "0") == 0 );
t( sp_set(c, "db", "test") == 0 );
t( sp_set(c, "db.test.sync", "0") == 0 );
t( sp_open(env) == 0 );
void *db = sp_get(c, "db.test");
t( db != NULL );
void *dbctl = sp_ctl(db);
t( dbctl != NULL );
void *o = sp_get(dbctl, "name");
t( o != NULL );
t( strcmp(sp_get(o, "value", NULL), "test") == 0 );
sp_destroy(o);
o = sp_get(dbctl, "id");
t( o != NULL );
t( strcmp(sp_get(o, "value", NULL), "1") == 0 );
sp_destroy(o);
t( sp_destroy(env) == 0 );
}
开发者ID:v09-software,项目名称:sophia,代码行数:31,代码来源:meta.test.c
示例5: leak_set
static void
leak_set(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_setint(env, "compaction.0.branch_wm", 1) == 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 key = 123;
void *o = sp_document(db);
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
key = 124;
o = sp_document(db);
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
t( sp_getint(env, "performance.documents") == 2 );
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_getint(env, "performance.documents") == 0 );
t( sp_destroy(env) == 0 );
}
开发者ID:ifzz,项目名称:sophia,代码行数:33,代码来源:leak.test.c
示例6: single_process_2
static void
single_process_2(void) {
void *env = sp_env();
t( env != NULL );
t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0 );
t( sp_ctl(env, SPCMP, cmp, NULL) == 0 );
void *db = sp_open(env);
t( db != NULL );
void *env2 = sp_env();
t( env != NULL );
t( sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0 );
t( sp_ctl(env2, SPCMP, cmp, NULL) == 0 );
void *db2 = sp_open(env2);
t( db2 != NULL );
uint32_t k = 1;
t( sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0 );
size_t vsize = 0;
void *vp = NULL;
t( sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1 );
t( vsize == sizeof(k) );
t( *(uint32_t*)vp == k );
free(vp);
k = 3;
t( sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0 );
t( sp_get(db, &k, sizeof(k), &vp, &vsize) == 1 );
t( vsize == sizeof(k) );
t( *(uint32_t*)vp == k );
free(vp);
t( sp_destroy(db) == 0 );
t( sp_destroy(env) == 0 );
t( sp_destroy(db2) == 0 );
t( sp_destroy(env2) == 0 );
t( rmrf(dbrep1) == 0 );
t( rmrf(dbrep2) == 0 );
}
开发者ID:FromPointer,项目名称:sophia,代码行数:35,代码来源:concurrent.c
示例7: workflow_compaction
static inline int
workflow_compaction(void *env, void *db)
{
/* branch oom */
int rc = sp_setint(env, "db.test.branch", 0);
if (rc == -1)
return -1;
uint32_t key = 123;
int count = 0;
while (count < 10) {
void *o = sp_document(db);
if (o == NULL)
return -1;
rc = sp_setstring(o, "key", &key, sizeof(key));
if (rc == -1) {
sp_destroy(o);
return -1;
}
rc = sp_setstring(o, "value", &key, sizeof(key));
if (rc == -1) {
sp_destroy(o);
return -1;
}
rc = sp_set(db, o);
if (rc == -1)
return -1;
key++;
count++;
}
rc = sp_setint(env, "db.test.branch", 0);
if (rc == -1)
return -1;
/* put some statements in log */
while (count < 15) {
void *o = sp_document(db);
if (o == NULL)
return -1;
rc = sp_setstring(o, "key", &key, sizeof(key));
if (rc == -1) {
sp_destroy(o);
return -1;
}
rc = sp_setstring(o, "value", &key, sizeof(key));
if (rc == -1) {
sp_destroy(o);
return -1;
}
rc = sp_set(db, o);
if (rc == -1)
return -1;
key++;
count++;
}
/* compaction oom */
rc = sp_setint(env, "db.test.compact", 0);
if (rc == -1)
return -1;
return 0;
}
开发者ID:Alexey-Ivanensky,项目名称:sophia,代码行数:59,代码来源:workflow.test.c
示例8: amqf_test3
static void
amqf_test3(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.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 );
t( sp_setint(env, "db.test.amqf", 1) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_open(env) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
int i = 0;
while (i < 100) {
void *o = sp_document(db);
t( o != NULL );
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_setint(env, "db.test.branch", 0) == 0 );
i = 300;
while (i < 500) {
void *o = sp_document(db);
t( o != NULL );
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_setint(env, "db.test.branch", 0) == 0 );
t( sp_setint(env, "db.test.compact", 0) == 0 );
i = 0;
while (i < 400) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &i, sizeof(i)) == 0 );
o = sp_get(db, o);
if (o) {
sp_destroy(o);
}
i++;
}
t( sp_getint(env, "db.test.index.read_disk") == 232 );
t( sp_destroy(env) == 0 );
}
开发者ID:mladinox,项目名称:sophia,代码行数:56,代码来源:amqf.test.c
示例9: 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);
}
开发者ID:dongxu-pc,项目名称:sophia,代码行数:55,代码来源:secondary_index.test.c
示例10: st_phase_commit
static inline void
st_phase_commit(stc *cx)
{
switch (cx->phase_scene) {
case 0:
break;
case 1:
t( sp_set(sp_ctl(cx->env), "db.test.branch") == 0 );
break;
case 2:
t( sp_set(sp_ctl(cx->env), "db.test.branch") == 0 );
t( sp_set(sp_ctl(cx->env), "db.test.compact") == 0 );
break;
case 3:
t( sp_set(sp_ctl(cx->env), "log.rotate") == 0 );
t( sp_set(sp_ctl(cx->env), "log.gc") == 0 );
break;
case 4:
if (cx->phase == 0) {
t( sp_set(sp_ctl(cx->env), "db.test.branch") == 0 );
t( sp_set(sp_ctl(cx->env), "log.rotate") == 0 );
t( sp_set(sp_ctl(cx->env), "log.gc") == 0 );
cx->phase = 1;
} else if (cx->phase == 1) {
t( sp_set(sp_ctl(cx->env), "db.test.compact") == 0 );
cx->phase = 0;
}
break;
default:
t(0);
}
}
开发者ID:venkatarajasekhar,项目名称:bee,代码行数:32,代码来源:st_scene.c
示例11: checkpoint_test1
static void
checkpoint_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_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_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(env) == 0 );
int key = 0;
while (key < 20) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
key++;
}
t( sp_setint(env, "log.rotate", 0) == 0 );
t( sp_getint(env, "log.files") == 2 );
key = 40;
while (key < 80) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
key++;
}
t( sp_setint(env, "log.rotate", 0) == 0 );
t( sp_getint(env, "log.files") == 3 );
t( sp_setint(env, "db.test.compaction.checkpoint", 0) == 0 );
t( sp_setint(env, "scheduler.run", 0) == 1 );
t( sp_setint(env, "scheduler.run", 0) == 1 );
t( sp_getint(env, "log.files") == 1 );
t( sp_destroy(env) == 0 );
}
开发者ID:ConfusedReality,项目名称:sophia,代码行数:55,代码来源:checkpoint.test.c
示例12: github_104
static void
github_104(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.scheme", "key", 0) == 0 );
t( sp_setstring(env, "db.test.scheme.key", "string,key(0)", 0) == 0 );
t( sp_setstring(env, "db.test.scheme", "value", 0) == 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 key_a[] = "aa";
char key_b[] = "bb";
char key_c[] = "cc";
char key_d[] = "dd";
void *o = sp_document(db);
t( sp_setstring(o, "key", key_a, sizeof(key_a)) == 0 );
t( sp_set(db, o) == 0 );
o = sp_document(db);
t( sp_setstring(o, "key", key_b, sizeof(key_b)) == 0 );
t( sp_set(db, o) == 0 );
o = sp_document(db);
t( sp_setstring(o, "key", key_c, sizeof(key_c)) == 0 );
t( sp_set(db, o) == 0 );
o = sp_document(db);
t( sp_setstring(o, "key", key_d, sizeof(key_d)) == 0 );
t( sp_set(db, o) == 0 );
void *cur = sp_cursor(env);
t( cur != NULL );
o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", key_b, sizeof(key_b)) == 0 );
t( sp_setstring(o, "order", "<=", 0) == 0 );
int i = 0;
while ((o = sp_get(cur, o))) {
printf(" %s", (char*)sp_getstring(o, "key", 0));
i++;
}
fflush(NULL);
t( i == 2 );
sp_destroy(cur);
t( sp_destroy(env) == 0 );
}
开发者ID:ConfusedReality,项目名称:sophia,代码行数:53,代码来源:github.test.c
示例13: hc_prepare_rollback1
static void
hc_prepare_rollback1(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 );
t( sp_open(env) == 0 );
void *db = sp_getobject(env, "db.test");
int rc;
void *tx = sp_begin(env);
t( tx != NULL );
int key = 7;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(tx, o) == 0 );
o = sp_document(db);
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
o = sp_get(tx, o);
t( o != NULL );
t( *(int*)sp_getstring(o, "value", NULL) == key );
sp_destroy(o);
t( sp_setint(tx, "half_commit", 1) == 0 );
rc = sp_commit(tx);
t( rc == 0 );
rc = sp_destroy(tx);
t( rc == 0 );
tx = sp_begin(env);
t( tx != NULL );
o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(tx, o) == 0 );
t( sp_setint(tx, "half_commit", 1) == 0 );
rc = sp_commit(tx);
t( rc == 0 );
rc = sp_commit(tx);
t( rc == 0 );
t( sp_destroy(env) == 0 );
}
开发者ID:Alexey-Ivanensky,项目名称:sophia,代码行数:53,代码来源:half_commit.test.c
示例14: 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");
}
开发者ID:egmkang,项目名称:green_turtle,代码行数:52,代码来源:ddl.test.c
示例15: cache_test1
static void
cache_test1(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_setint(env, "db.test.sync", 0) == 0 );
t( sp_setint(env, "scheduler.threads", 0) == 0 );
t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_open(env) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
int i = 0;
while (i < 185) {
void *o = sp_object(db);
t( o != NULL );
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_setint(env, "db.test.branch", 0) == 0 );
i = 185;
while (i < 370) {
void *o = sp_object(db);
t( o != NULL );
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( i == 370 );
t( sp_setint(env, "db.test.branch", 0) == 0 );
void *cur = sp_cursor(env);
t( cur != NULL );
void *o = sp_object(db);
i = 0;
while ((o = sp_get(cur, o))) {
t( *(int*)sp_getstring(o, "key", NULL) == i );
i++;
}
t( sp_destroy(cur) == 0 );
t( sp_getint(env, "db.test.index.read_disk") == 2 );
t( sp_getint(env, "db.test.index.read_cache") == 553 );
t( sp_destroy(env) == 0 );
}
开发者ID:egmkang,项目名称:green_turtle,代码行数:52,代码来源:cache.test.c
示例16: transaction_batch_test0
static void
transaction_batch_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.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 );
t( sp_setstring(tx, "isolation", "batch", 0) == 0 );
t( sp_setstring(tx, "isolation", "batch", 0) == -1 );
t( sp_setstring(tx, "isolation", "serializable", 0) == -1 );
uint32_t a = 7;
uint32_t b = 8;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &a, sizeof(a)) == 0 );
t( sp_set(tx, o) == 0 );
o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &b, sizeof(a)) == 0 );
t( sp_set(tx, o) == 0 );
o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &a, sizeof(a)) == 0 );
o = sp_get(tx, o); /* error */
t( sp_commit(tx) == 0 );
o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &a, sizeof(a)) == 0 );
o = sp_get(db, o);
t( o != NULL );
sp_destroy(o);
t( sp_destroy(env) == 0 );
}
开发者ID:muthhus,项目名称:sophia,代码行数:51,代码来源:transaction_batch.test.c
示例17: profiler_count
static void
profiler_count(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, "log.sync", 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_setstring(env, "db", "test", 0) == 0 );
t( sp_setint(env, "db.test.compaction.cache", 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 );
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 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
t( sp_getint(env, "db.test.index.node_count") == 1 );
int i = 0;
while ( i < 100 ) {
void *o = sp_document(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_setint(env, "db.test.compaction.compact", 0) == 0 );
t( sp_getint(env, "db.test.index.count") == 100 );
i = 0;
while ( i < 10 ) {
void *o = sp_document(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_getint(env, "db.test.index.count") == 110 );
t( sp_setint(env, "db.test.compaction.compact", 0) == 0 );
t( sp_getint(env, "db.test.index.count") == 100 );
t( sp_destroy(env) == 0 );
}
开发者ID:dioptre,项目名称:sophia,代码行数:51,代码来源:profiler.test.c
示例18: 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 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:51,代码来源:snapshot.test.c
示例19: memset
static inline
void *spr_worker(void *arg)
{
char value[100];
memset(value, 0, sizeof(value));
while (spr_start)
{
if (spr_pause) {
sleep(1);
continue;
}
uint32_t key = rand() % 100000000;
void *o = sp_document(spr_db);
sp_setstring(o, "key", &key, sizeof(key));
sp_setstring(o, "value", &key, sizeof(key));
int rc = sp_set(spr_db, o);
if (rc == -1) {
}
/*
o = sp_document(spr_db);
sp_setstring(o, "key", &key, sizeof(key));
o = sp_get(spr_db, o);
if (o) {
sp_destroy(o);
}
*/
}
return NULL;
}
开发者ID:jason-xxl,项目名称:sophia,代码行数:29,代码来源:sophia-prof.c
示例20: compact_temperature
static void
compact_temperature(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_setint(env, "compaction.0.branch_wm", 1) == 0 );
t( sp_setint(env, "compaction.0.compact_mode", 1) == 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.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.temperature", 1) == 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 key = 0;
while (key < 20) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
t( sp_set(db, o) == 0 );
key++;
}
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_setint(env, "db.test.compact", 0) == 0 );
t( sp_destroy(env) == 0 );
}
开发者ID:mladinox,项目名称:sophia,代码行数:35,代码来源:compact.test.c
注:本文中的sp_set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论