本文整理汇总了C++中sp_document函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_document函数的具体用法?C++ sp_document怎么用?C++ sp_document使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_document函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conf_empty_key
static void
conf_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_setint(env, "log.rotate_wm", 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
t( sp_setstring(env, "db", "test", 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 *o = sp_document(db);
t( sp_setstring(o, "key", "", 0) == 0 );
t( sp_set(db, o) == 0 );
o = sp_document(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 );
}
示例2: workflow_upsert
static inline int
workflow_upsert(void *env, void *db)
{
void *o = sp_document(db);
if (o == NULL)
return -1;
int up = 777;
int i = 0;
sp_setstring(o, "key", &i, sizeof(i));
sp_setstring(o, "value", &up, sizeof(up));
int rc = sp_upsert(db, o);
if (rc == -1)
return -1;
o = sp_document(db);
if (o == NULL)
return -1;
up = 778;
sp_setstring(o, "key", &i, sizeof(i));
sp_setstring(o, "value", &up, sizeof(up));
rc = sp_upsert(db, o);
if (rc == -1)
return -1;
o = sp_document(db);
if (o == NULL)
return -1;
sp_setstring(o, "key", &i, sizeof(i));
o = sp_get(db, o);
if (o == NULL)
return -1;
t( *(int*)sp_getstring(o, "value", NULL) == 778 );
sp_destroy(o);
return 0;
}
示例3: 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 );
}
示例4: 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 );
}
示例5: mt_setget
static void
mt_setget(void)
{
char value[100];
memset(value, 0, sizeof(value));
uint32_t n = 300000;
uint32_t i, k;
srand(82351);
for (i = 0; i < n; i++) {
k = rand();
*(uint32_t*)value = k;
void *o = sp_document(st_r.db);
t( o != NULL );
t( sp_setstring(o, "key", &k, sizeof(k)) == 0 );
t( sp_setstring(o, "value", value, sizeof(value)) == 0 );
t( sp_set(st_r.db, o) == 0 );
print_current(i);
}
srand(82351);
for (i = 0; i < n; i++) {
k = rand();
void *o = sp_document(st_r.db);
t( o != NULL );
t( sp_setstring(o, "key", &k, sizeof(k)) == 0 );
o = sp_get(st_r.db, o);
t( o != NULL );
t( *(uint32_t*)sp_getstring(o, "value", NULL) == k );
sp_destroy(o);
print_current(i);
}
}
示例6: 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;
}
示例7: compact_directio
static void
compact_directio(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_setint(env, "db.test.compaction.branch_wm", 1) == 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 );
t( sp_setint(env, "db.test.direct_io", 1) == 0 );
t( sp_setint(env, "log.sync", 0) == 0 );
t( sp_setint(env, "log.rotate_sync", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
char value[100];
memset(value, 0, sizeof(value));
int key = 0;
while (key < 300000) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_setstring(o, "value", value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
if ((key % 10000) == 0 && key > 0) {
if (sp_setint(env, "db.test.compaction.branch", 0) == -1) {
char *e = sp_getstring(env, "sophia.error", NULL);
printf("%s, %d\n", (e) ? e: "null", errno);
t( 0 );
}
/*t( sp_setint(env, "db.test.compaction.branch", 0) == 0 );*/
}
key++;
}
t( sp_setint(env, "db.test.compaction.compact", 0) == 0 );
key = 0;
while (key < 1000) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
o = sp_get(db, o);
t( o != NULL );
t( *(int*)sp_getstring(o, "key", NULL) == key );
sp_destroy(o);
key++;
}
t( sp_destroy(env) == 0 );
}
示例8: compact_delete1
static void
compact_delete1(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.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 );
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 );
key = 0;
while (key < 20) {
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
t( sp_delete(db, o) == 0 );
key++;
}
t( sp_setint(env, "db.test.branch", 0) == 0 );
t( sp_setint(env, "db.test.compact", 0) == 0 );
void *o = sp_document(db);
t( o != NULL );
void *cur = sp_cursor(env);
t( o != NULL );
int i = 0;
while ((o = sp_get(cur, o))) {
t( *(int*)sp_getstring(o, "key", NULL) == i );
i++;
}
t( i == 0 );
t( sp_destroy(env) == 0 );
}
示例9: mt_async_read
static void
mt_async_read(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", 5) == 0 );
t( sp_setint(env, "compaction.0.async", 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_setint(env, "db.test.sync", 0) == 0 );
t( sp_setstring(env, "db.test.format", "kv", 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_open(env) == 0 );
int i = 0;
while (i < 100000) {
void *o = sp_document(db);
assert(o != NULL);
sp_setstring(o, "key", &i, sizeof(i));
int rc = sp_set(db, o);
t( rc == 0 );
print_current(i);
i++;
}
fprintf(st_r.output, " (insert done..iterate) ");
/* trigger iteration */
void *o = sp_document(db);
sp_setint(o, "async", 1);
sp_setstring(o, "order", ">=", 0);
o = sp_get(db, o);
t( o != NULL );
sp_destroy(o);
i = 0;
while (i < 100000) {
o = sp_poll(env);
if (o == NULL)
continue;
t( strcmp(sp_getstring(o, "type", 0), "on_read") == 0 );
t( sp_getint(o, "status") == 1 );
t( *(int*)sp_getstring(o, "key", NULL) == i );
o = sp_get(db, o);
t( o != NULL );
sp_destroy(o);
print_current(i);
i++;
}
t( i == 100000 );
fprintf(st_r.output, "(complete)");
t( sp_destroy(env) == 0 );
}
示例10: github_120
static void
github_120(void)
{
/* open or create environment and database */
void *env = sp_env();
sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0);
sp_setstring(env, "db", "test", 0);
void *db = sp_getobject(env, "db.test");
int rc = sp_open(env);
if (rc == -1)
goto error;
/* set */
void *o = sp_document(db);
sp_setstring(o, "key", "hello", 0);
sp_setstring(o, "value", "world", 0);
rc = sp_set(db, o);
if (rc == -1)
goto error;
/* get */
o = sp_document(db);
sp_setstring(o, "key", "hello", 0);
o = sp_get(db, o);
if (o) {
/* ensure key and value are correct */
int size;
char *ptr = sp_getstring(o, "key", &size);
t( size == 5 );
t( strncmp(ptr, "hello", 5) == 0 );
ptr = sp_getstring(o, "value", &size);
t( size == 5 );
t( strncmp(ptr, "world", 5) == 0 );
sp_destroy(o);
}
/* delete */
o = sp_document(db);
sp_setstring(o, "key", "hello", 0);
rc = sp_delete(db, o);
if (rc == -1)
goto error;
/* finish work */
sp_destroy(env);
return;
error:;
int size;
char *error = sp_getstring(env, "sophia.error", &size);
printf("error: %s\n", error);
free(error);
sp_destroy(env);
}
示例11: 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 );
}
示例12: 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);
}
示例13: 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 );
}
示例14: mt_set_delete_get
static void
mt_set_delete_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", 5) == 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 );
char value[100];
memset(value, 0, sizeof(value));
uint32_t n = 700000;
uint32_t i, k;
srand(82351);
for (i = 0; i < n; i++) {
k = rand();
*(uint32_t*)value = k;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &k, sizeof(k)) == 0 );
t( sp_setstring(o, "value", value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
print_current(i);
}
srand(82351);
for (i = 0; i < n; i++) {
k = rand();
*(uint32_t*)value = k;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &k, sizeof(k)) == 0 );
t( sp_setstring(o, "value", value, sizeof(value)) == 0 );
t( sp_delete(db, o) == 0 );
print_current(i);
}
srand(82351);
for (i = 0; i < n; i++) {
k = rand();
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", &k, sizeof(k)) == 0 );
o = sp_get(db, o);
t( o == NULL );
print_current(i);
}
t( sp_destroy(env) == 0 );
}
示例15: mt_set_get_kv_multipart
static void
mt_set_get_kv_multipart(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", 5) == 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_setint(env, "db.test.compression_key", 1) == 0 );
t( sp_setint(env, "db.test.sync", 0) == 0 );
t( sp_setstring(env, "db.test.index.key", "string", 0) == 0 );
t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
t( sp_setstring(env, "db.test.index.key_b", "u32", 0) == 0 );
void *db = sp_getobject(env, "db.test");
t( db != NULL );
t( sp_open(env) == 0 );
uint32_t n = 500000;
uint32_t i;
char key_a[] = "very_long_long_key_part";
srand(82351);
for (i = 0; i < n; i++) {
uint32_t key_b = rand();
uint32_t value = key_b;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", key_a, sizeof(key_a)) == 0 );
t( sp_setstring(o, "key_b", &key_b, sizeof(key_b)) == 0 );
t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
t( sp_set(db, o) == 0 );
print_current(i);
}
srand(82351);
for (i = 0; i < n; i++) {
uint32_t key_b = rand();
uint32_t value = key_b;
void *o = sp_document(db);
t( o != NULL );
t( sp_setstring(o, "key", key_a, sizeof(key_a)) == 0 );
t( sp_setstring(o, "key_b", &key_b, sizeof(key_b)) == 0 );
o = sp_get(db, o);
t( o != NULL );
int size = 0;
t( memcmp(sp_getstring(o, "key", &size), key_a, sizeof(key_a)) == 0 );
t( *(uint32_t*)sp_getstring(o, "key_b", &size) == key_b );
t( *(uint32_t*)sp_getstring(o, "value", &size) == value );
sp_destroy(o);
print_current(i);
}
t( sp_destroy(env) == 0 );
}