• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ sp_env函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sp_env函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_env函数的具体用法?C++ sp_env怎么用?C++ sp_env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sp_env函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: multi_process

static void
multi_process(void) {
	void *env = sp_env();
	t( env != NULL );
	t( sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0 );
	void *db = sp_open(env);
	t( db != NULL );
	int pid = fork();
	t( pid != -1 );
	if (pid == 0) {
		/* new process */
		void *env2 = sp_env();
		t( env2 != NULL );
		t( sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0 );
		void *db2 = sp_open(env2);
		t( db2 == NULL );
		t( sp_destroy(env2) == 0 );
		/* valgrind: parent db and env are unfreed here, and that
		 *           is correct otherwise destroy would
		 *           corrupt the database.
		*/
		exit(0);
	} else {
		int status = 0;
		t( waitpid(pid, &status, 0) == pid );
		t( status == 0 );
	}
	t( sp_destroy(db) == 0 );
	t( sp_destroy(env) == 0 );
	rmrf(dbrep1);
}
开发者ID:FromPointer,项目名称:sophia,代码行数:31,代码来源:concurrent.c


示例2: repository_test4

static void
repository_test4(void)
{
	rmrf("./sophia");
	rmrf("./logdir");
	rmrf("./dir");
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", "sophia", 0) == 0 );
	t( sp_setint(env, "sophia.path_create", 0) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_open(env) == -1 );
	t( sp_destroy(env) == 0 );

	t( exists("sophia", "") == 0 );

	mkdir("sophia", 0755);
	env = sp_env();
	t( env != NULL );

	t( sp_setstring(env, "sophia.path", "sophia", 0) == 0 );
	t( sp_setint(env, "sophia.path_create", 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_open(env) == 0 );
	t( exists("sophia", "test") == 1 );
	t( sp_destroy(env) == 0 );
}
开发者ID:mneumann,项目名称:sophia,代码行数:31,代码来源:repository.test.c


示例3: 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


示例4: repository_test4

static void
repository_test4(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.path_create", 0) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_open(env) == -1 );
	t( sp_destroy(env) == 0 );

	t( exists(st_r.conf->sophia_dir, "") == 0 );

	mkdir(st_r.conf->sophia_dir, 0755);
	env = sp_env();
	t( env != NULL );

	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "sophia.path_create", 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_open(env) == 0 );
	t( exists(st_r.conf->sophia_dir, "test") == 1 );
	t( sp_destroy(env) == 0 );
}
开发者ID:Alexey-Ivanensky,项目名称:sophia,代码行数:28,代码来源:repository.test.c


示例5: workflow_test

void
workflow_test(char *injection)
{
	workflow_upsert_n = 0;

	int i = 0;
	int j = 0;
	for (;; i++) {
		st_scene_rmrf(NULL);
		fprintf(st_r.output, " %d", i);
		fflush(NULL);
		/* open */
		void *env = sp_env();
		t( env != NULL );
		t( sp_setint(env, injection, i) == 0 );
		void *db = workflow_open(env);
		if (db == NULL) {
			sp_destroy(env); /* close(2) might fail */
			continue;
		}
		/* write, transaction, read, get, cursor */
		int rc = workflow_write_read(env, db);
		if (rc == -1) {
			sp_destroy(env);
			continue;
		}
		/* upsert */
		rc = workflow_upsert(env, db);
		if (rc == -1) {
			sp_destroy(env);
			continue;
		}
		/* branch + compaction */
		rc = workflow_compaction(env, db);
		if (rc == -1) {
			sp_destroy(env);
			continue;
		}
		/* snapshot */
		rc = workflow_snapshot(env, db);
		if (rc == -1) {
			sp_destroy(env);
			continue;
		}
		sp_destroy(env);
		/* recover */
		env = sp_env();
		t( env != NULL );
		t( sp_setint(env, injection, j) == 0 );
		db = workflow_open(env);
		if (db == NULL) {
			j++;
			sp_destroy(env);
			continue;
		}
		sp_destroy(env);
		break;
	}
}
开发者ID:Alexey-Ivanensky,项目名称:sophia,代码行数:59,代码来源:workflow.test.c


示例6: 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 );
}
开发者ID:muthhus,项目名称:sophia,代码行数:58,代码来源:scheme.test.c


示例7: meta_scheduler

static void
meta_scheduler(void)
{
	void *env = sp_env();
	t( env != NULL );

	t( sp_setint(env, "scheduler.threads", 2) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_getstring(env, "scheduler.0.trace", NULL) == NULL );
	t( sp_open(env) == 0 );

	char *v = sp_getstring(env, "scheduler.0.trace", NULL);
	t( v != NULL );
	t( strcmp(v, "malfunction") != 0 );
	free(v);

	v = sp_getstring(env, "scheduler.1.trace", NULL);
	t( v != NULL );
	t( strcmp(v, "malfunction") != 0 );
	free(v);

	v = sp_getstring(env, "scheduler.2.trace", NULL);
	t( v == NULL );

	t( sp_destroy(env) == 0 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:27,代码来源:meta.test.c


示例8: 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 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:29,代码来源:meta.test.c


示例9: meta_cursor

static void
meta_cursor(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.sync", 0) == 0 );
	t( sp_open(env) == 0 );
	t( sp_setstring(env, "snapshot", "test_snapshot0", 0) == 0 );

	fprintf(st_r.output, "\n");

	void *cur = sp_getobject(env, NULL);
	t( cur != NULL );
	fprintf(st_r.output, "\n");
	void *o = NULL;
	while ((o = sp_get(cur, o))) {
		char *key = sp_getstring(o, "key", 0);
		char *value = sp_getstring(o, "value", 0);
		fprintf(st_r.output, "%s", key);
		if (value)
			fprintf(st_r.output, " = %s\n", value);
		else
			fprintf(st_r.output, " = \n");
	}
	fprintf(st_r.output, "\n");

	t( sp_destroy(cur) == 0 );
	t( sp_destroy(env) == 0 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:34,代码来源:meta.test.c


示例10: 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


示例11: meta_empty_key

static void
meta_empty_key(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(env) == 0 );

	void *o = sp_object(db);
	t( sp_setstring(o, "key", "", 0) == 0 );
	t( sp_set(db, o) == 0 );

	o = sp_object(db);
	t( sp_setstring(o, "key", "", 0) == 0 );
	o = sp_get(db, o);
	t( o != NULL );

	int key_size;
	void *key = sp_getstring(o, "key", &key_size);
	t( key_size == 0 );
	t( key != NULL );
	sp_destroy(o);

	t( sp_destroy(env) == 0 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:30,代码来源:meta.test.c


示例12: mt_quota_checkpoint

static void
mt_quota_checkpoint(stc *cx)
{
	cx->env = sp_env();
	t( cx->env != NULL );
	void *c = sp_ctl(cx->env);
	t( c != NULL );
	t( sp_set(c, "sophia.path", cx->suite->sophiadir) == 0 );
	t( sp_set(c, "memory.limit", "524288") == 0 ); /* 512k */
	/* use default settings */
	t( sp_set(c, "scheduler.threads", "5") == 0 );
	t( sp_set(c, "log.path", cx->suite->logdir) == 0 );
	t( sp_set(c, "log.sync", "0") == 0 );
	t( sp_set(c, "log.rotate_sync", "0") == 0 );
	t( sp_set(c, "db", "test") == 0 );
	t( sp_set(c, "db.test.path", cx->suite->dir) == 0 );
	t( sp_set(c, "db.test.sync", "0") == 0 );
	t( sp_set(c, "db.test.index.cmp", "u32", NULL) == 0 );
	cx->db = sp_get(c, "db.test");
	t( cx->db != NULL );
	t( sp_open(cx->env) == 0 );
	char value[1000];
	memset(value, 0, sizeof(value));
	int i = 0;
	while (i < 20000) { /* ~ 20Mb */
		void *o = sp_object(cx->db);
		assert(o != NULL);
		sp_set(o, "key", &i, sizeof(i));
		sp_set(o, "value", value, sizeof(value));
		int rc = sp_set(cx->db, o);
		t( rc == 0 );
		i++;
	}
	t( sp_destroy(cx->env) == 0 );
}
开发者ID:bhdz,项目名称:sophia,代码行数:35,代码来源:mt.test.c


示例13: gh_29

static void
gh_29(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 );
	int i;
	for (i = 1; i <= 10; i++)  {
		char key[4];
		int len = snprintf(key, sizeof(key), "%d", i);
		t( sp_set(db, key, len, key, len) == 0 );
	}
	for (i = 1; i <= 10; i++) {
		char key[4];
		int len = snprintf(key, sizeof(key), "%d", i);
		size_t vsize = 0;
		void *vp = NULL;
		t( sp_get(db, key, len, &vp, &vsize) == 1 );
		t( vsize == len );
		t( memcmp(key, vp, len) == 0 );
		free(vp);
	}
	t( sp_destroy(db) == 0 );
	t( sp_destroy(env) == 0 );
	t( rmrf(dbrep) == 0 );
}
开发者ID:FromPointer,项目名称:sophia,代码行数:27,代码来源:issues.c


示例14: 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


示例15: 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_open(env) == 0 );

	t( exists("./", "abc") == 1 );
	t( exists("./", "abc_log") == 1 );

	void *db = sp_getobject(env, "db.test");
	t( db != NULL );

	t( sp_destroy(env) == 0 );

	rmrf("./abc");
	rmrf("./abc_log");
}
开发者ID:ConfusedReality,项目名称:sophia,代码行数:29,代码来源:github.test.c


示例16: 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 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:25,代码来源:snapshot.test.c


示例17: checkpoint_test2

static void
checkpoint_test2(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.sync", 0) == 0 );
	t( sp_open(env) == 0 );

	t( sp_getint(env, "db.test.scheduler.checkpoint") == 0 );
	t( sp_getint(env, "db.test.scheduler.checkpoint_lsn") == 0 );
	t( sp_getint(env, "db.test.scheduler.checkpoint_lsn_last") == 0 );

	t( sp_setint(env, "db.test.compaction.checkpoint", 0) == 0 );

	t( sp_getint(env, "db.test.scheduler.checkpoint") == 1 );
	t( sp_getint(env, "db.test.scheduler.checkpoint_lsn") == 0 );
	t( sp_getint(env, "db.test.scheduler.checkpoint_lsn_last") == 0 );

	t( sp_setint(env, "scheduler.run", 0) == 0 );
	t( sp_setint(env, "scheduler.run", 0) == 0 );

	t( sp_getint(env, "db.test.scheduler.checkpoint") == 0 );
	t( sp_getint(env, "db.test.scheduler.checkpoint_lsn") == 0 );
	t( sp_getint(env, "db.test.scheduler.checkpoint_lsn_last") == 0 );

	t( sp_destroy(env) == 0 );
}
开发者ID:ConfusedReality,项目名称:sophia,代码行数:33,代码来源:checkpoint.test.c


示例18: todo_db_new

todo_db_t *
todo_db_new (char *path) {
  int rc;
  void *env;
  todo_db_t *db = malloc(sizeof(todo_db_t));

  // bail if failed to allocate memoery
  if (NULL == db) return NULL;

  env = sp_env();

  // error in memoery allocation
  if (NULL == env) return NULL;

  // create if not exists in read-write mode
  rc = sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, path);

  // turn on garbage collection
  sp_ctl(env, SPGC, 1);

  if (-1 == rc) {
    todo_ferror("%s\n", sp_error(env));
    sp_destroy(env);
    return NULL;
  }

  db->env = env;
  db->path = path;

  return db;
}
开发者ID:jwerle,项目名称:todo.c,代码行数:31,代码来源:db.c


示例19: object_readonly1

static void
object_readonly1(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 );

	int key = 7;
	void *o = sp_object(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 );
	o = sp_object(db);
	t( o != NULL );
	t( sp_setstring(o, "order", ">", 0) == 0 );
	void *c = sp_cursor(db, o);
	o = sp_get(c, NULL);
	t( o != NULL );
	t( sp_setstring(o, "key", &key, sizeof(key)) == -1 );
	sp_destroy(o);
	sp_destroy(c);

	sp_destroy(env);
}
开发者ID:mneumann,项目名称:sophia,代码行数:35,代码来源:object.test.c


示例20: 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 );
}
开发者ID:mladinox,项目名称:sophia,代码行数:26,代码来源:multithread.test.c



注:本文中的sp_env函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sp_error_message函数代码示例发布时间:2022-05-30
下一篇:
C++ sp_document函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap