|
|
@ -53,8 +53,9 @@ int main(int argc,char * argv[]) |
|
|
|
E(mdb_env_set_mapsize(env, 10485760)); |
|
|
|
E(mdb_env_set_mapsize(env, 10485760)); |
|
|
|
E(mdb_env_set_maxdbs(env, 4)); |
|
|
|
E(mdb_env_set_maxdbs(env, 4)); |
|
|
|
E(mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664)); |
|
|
|
E(mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664)); |
|
|
|
|
|
|
|
|
|
|
|
E(mdb_txn_begin(env, NULL, 0, &txn)); |
|
|
|
E(mdb_txn_begin(env, NULL, 0, &txn)); |
|
|
|
E(mdb_open(txn, "id2", MDB_CREATE|MDB_DUPSORT, &dbi)); |
|
|
|
E(mdb_dbi_open(txn, "id2", MDB_CREATE|MDB_DUPSORT, &dbi)); |
|
|
|
E(mdb_cursor_open(txn, dbi, &cursor)); |
|
|
|
E(mdb_cursor_open(txn, dbi, &cursor)); |
|
|
|
|
|
|
|
|
|
|
|
key.mv_size = sizeof(int); |
|
|
|
key.mv_size = sizeof(int); |
|
|
@ -75,7 +76,7 @@ int main(int argc,char * argv[]) |
|
|
|
E(mdb_txn_commit(txn)); |
|
|
|
E(mdb_txn_commit(txn)); |
|
|
|
E(mdb_env_stat(env, &mst)); |
|
|
|
E(mdb_env_stat(env, &mst)); |
|
|
|
|
|
|
|
|
|
|
|
E(mdb_txn_begin(env, NULL, 1, &txn)); |
|
|
|
E(mdb_txn_begin(env, NULL, MDB_RDONLY, &txn)); |
|
|
|
E(mdb_cursor_open(txn, dbi, &cursor)); |
|
|
|
E(mdb_cursor_open(txn, dbi, &cursor)); |
|
|
|
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { |
|
|
|
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { |
|
|
|
printf("key: %p %.*s, data: %p %.*s\n", |
|
|
|
printf("key: %p %.*s, data: %p %.*s\n", |
|
|
@ -109,7 +110,7 @@ int main(int argc,char * argv[]) |
|
|
|
printf("Deleted %d values\n", j); |
|
|
|
printf("Deleted %d values\n", j); |
|
|
|
|
|
|
|
|
|
|
|
E(mdb_env_stat(env, &mst)); |
|
|
|
E(mdb_env_stat(env, &mst)); |
|
|
|
E(mdb_txn_begin(env, NULL, 1, &txn)); |
|
|
|
E(mdb_txn_begin(env, NULL, MDB_RDONLY, &txn)); |
|
|
|
E(mdb_cursor_open(txn, dbi, &cursor)); |
|
|
|
E(mdb_cursor_open(txn, dbi, &cursor)); |
|
|
|
printf("Cursor next\n"); |
|
|
|
printf("Cursor next\n"); |
|
|
|
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { |
|
|
|
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { |
|
|
@ -126,10 +127,9 @@ int main(int argc,char * argv[]) |
|
|
|
} |
|
|
|
} |
|
|
|
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get"); |
|
|
|
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get"); |
|
|
|
mdb_cursor_close(cursor); |
|
|
|
mdb_cursor_close(cursor); |
|
|
|
mdb_close(env, dbi); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mdb_txn_abort(txn); |
|
|
|
mdb_txn_abort(txn); |
|
|
|
mdb_env_close(env); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mdb_dbi_close(env, dbi); |
|
|
|
|
|
|
|
mdb_env_close(env); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|