forestdb: Update forestdb api.

Fix opening snapshots -- use -1 as parameter.
db4
Doug Coleman 2014-11-12 17:54:47 -08:00
parent 0826d8468c
commit df1b9dffe0
3 changed files with 42 additions and 45 deletions

View File

@ -14,9 +14,10 @@ LIBRARY: forestdb
CONSTANT: FDB_MAX_KEYLEN 3840 CONSTANT: FDB_MAX_KEYLEN 3840
CONSTANT: FDB_MAX_METALEN 65535 CONSTANT: FDB_MAX_METALEN 65535
CONSTANT: FDB_MAX_BODYLEN 4294967295 CONSTANT: FDB_MAX_BODYLEN 4294967295
TYPEDEF: uint64_t fdb_seqnum_t
CONSTANT: FDB_SNAPSHOT_INMEM -1 CONSTANT: FDB_SNAPSHOT_INMEM -1
TYPEDEF: uint64_t fdb_seqnum_t
TYPEDEF: void* fdb_custom_cmp_fixed TYPEDEF: void* fdb_custom_cmp_fixed
TYPEDEF: void* fdb_custom_cmp_variable TYPEDEF: void* fdb_custom_cmp_variable
TYPEDEF: void* fdb_log_callback TYPEDEF: void* fdb_log_callback
@ -135,7 +136,7 @@ STRUCT: fdb_doc
! filename is a pointer to the handle's filename ! filename is a pointer to the handle's filename
! new_filename is a pointer to the handle's new_file ! new_filename is a pointer to the handle's new_file
STRUCT: fdb_info STRUCT: fdb_file_info
{ filename char* } { filename char* }
{ new_filename char* } { new_filename char* }
{ doc_count uint64_t } { doc_count uint64_t }
@ -144,7 +145,14 @@ STRUCT: fdb_info
STRUCT: fdb_kvs_info STRUCT: fdb_kvs_info
{ name char* } { name char* }
{ last_seqnum fdb_seqnum_t } ; { last_seqnum fdb_seqnum_t }
{ doc_count uint64_t }
{ space_used uint64_t }
{ file fdb_file_handle* } ;
STRUCT: fdb_kvs_name_list
{ num_kvs_names size_t }
{ kvs_names char** } ;
FUNCTION: fdb_status fdb_init ( fdb_config* config ) ; FUNCTION: fdb_status fdb_init ( fdb_config* config ) ;
FUNCTION: fdb_config fdb_get_default_config ( ) ; FUNCTION: fdb_config fdb_get_default_config ( ) ;
@ -188,11 +196,14 @@ FUNCTION: fdb_status fdb_iterator_close ( fdb_iterator* iterator ) ;
FUNCTION: fdb_status fdb_compact ( fdb_file_handle* handle, c-string new_filename ) ; FUNCTION: fdb_status fdb_compact ( fdb_file_handle* handle, c-string new_filename ) ;
FUNCTION: size_t fdb_estimate_space_used ( fdb_file_handle* fhandle ) ; FUNCTION: size_t fdb_estimate_space_used ( fdb_file_handle* fhandle ) ;
FUNCTION: fdb_status fdb_get_dbinfo ( fdb_file_handle* handle, fdb_info* info ) ; FUNCTION: fdb_status fdb_get_file_info ( fdb_file_handle* handle, fdb_file_info* info ) ;
FUNCTION: fdb_status fdb_get_kvs_info ( fdb_handle* handle, fdb_kvs_info* info ) ; FUNCTION: fdb_status fdb_get_kvs_info ( fdb_handle* handle, fdb_kvs_info* info ) ;
FUNCTION: fdb_status fdb_get_seqnum ( fdb_handle* handle, fdb_seqnum_t* seqnum ) ; FUNCTION: fdb_status fdb_get_kvs_seqnum ( fdb_handle* handle, fdb_seqnum_t* seqnum ) ;
FUNCTION: fdb_status fdb_switch_compaction_mode ( fdb_file_handle* fhandle, fdb_compaction_mode_t mode, size_t new_threshold ) ; FUNCTION: fdb_status fdb_switch_compaction_mode ( fdb_file_handle* fhandle, fdb_compaction_mode_t mode, size_t new_threshold ) ;
FUNCTION: fdb_status fdb_get_kvs_name_list ( fdb_file_handle *fhandle, fdb_kvs_name_list *kvs_name_list ) ;
FUNCTION: fdb_status fdb_free_kvs_name_list ( fdb_kvs_name_list *kvs_name_list ) ;
FUNCTION: fdb_status fdb_close ( fdb_file_handle* fhandle ) ; FUNCTION: fdb_status fdb_close ( fdb_file_handle* fhandle ) ;
FUNCTION: fdb_status fdb_destroy ( c-string filename, fdb_config* fconfig ) ; FUNCTION: fdb_status fdb_destroy ( c-string filename, fdb_config* fconfig ) ;
FUNCTION: fdb_status fdb_shutdown ( ) ; FUNCTION: fdb_status fdb_shutdown ( ) ;
@ -213,3 +224,4 @@ FUNCTION: fdb_status fdb_kvs_open_default ( fdb_file_handle* fhandle,
FUNCTION: fdb_status fdb_kvs_close ( fdb_handle* handle ) ; FUNCTION: fdb_status fdb_kvs_close ( fdb_handle* handle ) ;
FUNCTION: fdb_status fdb_kvs_remove ( fdb_file_handle* fhandle, char* kvs_name ) ; FUNCTION: fdb_status fdb_kvs_remove ( fdb_file_handle* fhandle, char* kvs_name ) ;
FUNCTION: char* fdb_error_msg ( fdb_status err_code ) ;

View File

@ -117,8 +117,7 @@ IN: forestdb.lib
test-db-1 [ test-db-1 [
1 set-kv-n 1 set-kv-n
fdb-commit-normal fdb-commit-normal
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
fdb-get-info doc_count>>
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test
@ -128,8 +127,7 @@ IN: forestdb.lib
5 set-kv-n 5 set-kv-n
5 set-kv-nth 5 set-kv-nth
fdb-commit-normal fdb-commit-normal
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
fdb-get-info doc_count>>
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test
@ -138,8 +136,7 @@ IN: forestdb.lib
test-db-1 [ test-db-1 [
5 set-kv-n 5 set-kv-n
fdb-commit-normal fdb-commit-normal
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
fdb-get-info doc_count>>
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test
@ -149,9 +146,8 @@ IN: forestdb.lib
test-db-1 [ test-db-1 [
5 set-kv-n 5 set-kv-n
fdb-commit-normal fdb-commit-normal
5 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
fdb-get-info doc_count>>
] with-forestdb-snapshot ] with-forestdb-snapshot
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test
@ -166,9 +162,8 @@ IN: forestdb.lib
test-db-1 [ test-db-1 [
5 set-kv-n 5 set-kv-n
fdb-commit-normal fdb-commit-normal
2 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi
fdb-get-info doc_count>>
] with-forestdb-snapshot ] with-forestdb-snapshot
] with-forestdb-path ] with-forestdb-path
] [ ] [
@ -179,7 +174,7 @@ IN: forestdb.lib
! Test that we take two snapshots and their seqnums/doc counts are right. ! Test that we take two snapshots and their seqnums/doc counts are right.
! XXX: Buggy, want to see the first snapshot's document count at 5 too ! XXX: Buggy, want to see the first snapshot's document count at 5 too
{ {
{ 5 7 } { 7 7 }
{ 7 7 } { 7 7 }
} [ } [
delete-test-db-1 delete-test-db-1
@ -190,21 +185,19 @@ IN: forestdb.lib
6 7 set-kv-range 6 7 set-kv-range
fdb-commit-normal fdb-commit-normal
5 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi 2array
fdb-get-info doc_count>> 2array
] with-forestdb-snapshot ] with-forestdb-snapshot
7 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi 2array
fdb-get-info doc_count>> 2array
] with-forestdb-snapshot ] with-forestdb-snapshot
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test
! Same test as above, but with buggy behavior for now so it passes ! Same test as above, but with buggy behavior for now so it passes
{ {
5 7
7 7
} [ } [
delete-test-db-1 delete-test-db-1
@ -215,12 +208,12 @@ IN: forestdb.lib
6 7 set-kv-range 6 7 set-kv-range
fdb-commit-normal fdb-commit-normal
5 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info last_seqnum>>
] with-forestdb-snapshot ] with-forestdb-snapshot
7 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info last_seqnum>>
] with-forestdb-snapshot ] with-forestdb-snapshot
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test
@ -228,11 +221,9 @@ IN: forestdb.lib
! Rollback test ! Rollback test
! Make sure the doc_count is correct after a rollback ! Make sure the doc_count is correct after a rollback
! XXX: doc_count is wrong after rollback
{ {
7 7
{ 5 12 } { 5 5 }
! { 5 5 } ! expected
} [ } [
delete-test-db-1 delete-test-db-1
test-db-1 [ test-db-1 [
@ -242,15 +233,14 @@ IN: forestdb.lib
6 7 set-kv-range 6 7 set-kv-range
fdb-commit-normal fdb-commit-normal
7 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info last_seqnum>>
] with-forestdb-snapshot ] with-forestdb-snapshot
5 fdb-rollback 5 fdb-rollback
5 [ FDB_SNAPSHOT_INMEM [
fdb-get-seqnum fdb-get-kvs-info [ last_seqnum>> ] [ doc_count>> ] bi 2array
fdb-get-info doc_count>> 2array
] with-forestdb-snapshot ] with-forestdb-snapshot
] with-forestdb-path ] with-forestdb-path
] unit-test ] unit-test

View File

@ -151,14 +151,9 @@ SYMBOL: current-fdb-handle
: with-create-doc ( key meta body quot: ( doc -- ) -- ) : with-create-doc ( key meta body quot: ( doc -- ) -- )
[ fdb-doc-create ] dip with-doc ; inline [ fdb-doc-create ] dip with-doc ; inline
: fdb-get-info ( -- fdb_info ) : fdb-get-info ( -- fdb_file_info )
get-file-handle get-file-handle
fdb_info <struct> [ fdb_get_dbinfo fdb-check-error ] keep ; fdb_file_info <struct> [ fdb_get_file_info fdb-check-error ] keep ;
: fdb-get-seqnum ( -- fdb_info )
get-handle
1020 fdb_seqnum_t <ref> [ fdb_get_seqnum fdb-check-error ] keep
fdb_seqnum_t deref ;
: fdb-get-kvs-info ( -- fdb_kvs_info ) : fdb-get-kvs-info ( -- fdb_kvs_info )
get-handle get-handle
@ -301,7 +296,7 @@ T{ doc
[ size_ondisk>> ] [ size_ondisk>> ]
} cleave <fdb-doc> ; } cleave <fdb-doc> ;
: fdb_info>info ( fdb_doc -- doc ) : fdb_file_info>info ( fdb_doc -- doc )
{ {
[ filename>> alien>native-string ] [ filename>> alien>native-string ]
[ new_filename>> alien>native-string ] [ new_filename>> alien>native-string ]