forestdb.lib: Relax our expectations of ALIEN: slots and save other slots to doc tuple.
parent
ef743f3b90
commit
9348cb48ef
|
@ -8,37 +8,12 @@ math multiline namespaces sequences ;
|
||||||
IN: forestdb.lib
|
IN: forestdb.lib
|
||||||
|
|
||||||
/*
|
/*
|
||||||
! Possible bugs in foresdtb:
|
! Issues
|
||||||
|
! 1) bug - snapshot has doc_count of entire file, not just that snapshot's doc_count
|
||||||
! 1) why is meta set but metalen is 0?
|
! 2) build on macosx doesn't search /usr/local for libsnappy
|
||||||
! also, there is no meta info in these docs
|
! 3) build on macosx doesn't include -L/usr/local/lib when it finds snappy
|
||||||
delete-test-db-1
|
|
||||||
test-db-1 [
|
|
||||||
5 set-kv-n
|
|
||||||
fdb-commit-normal
|
|
||||||
"key1" "key5" [
|
|
||||||
.
|
|
||||||
] with-fdb-normal-meta-iterator
|
|
||||||
] with-forestdb-path
|
|
||||||
|
|
||||||
...
|
|
||||||
S{ fdb_doc
|
|
||||||
{ keylen 4 }
|
|
||||||
{ metalen 0 }
|
|
||||||
{ bodylen 4 }
|
|
||||||
{ size_ondisk 0 }
|
|
||||||
{ key ALIEN: 12721e3f0 }
|
|
||||||
{ seqnum 5 }
|
|
||||||
{ offset 4256 }
|
|
||||||
{ meta ALIEN: 1272308d0 }
|
|
||||||
{ body f }
|
|
||||||
{ deleted f }
|
|
||||||
}
|
|
||||||
! 2) same for with-fdb-byseq-iterator, body and meta are messed up
|
|
||||||
! 3) snapshot has doc_count of entire file, not in that snapshot
|
|
||||||
! 4) build on macosx doesn't search /usr/local for libsnappy
|
|
||||||
! 5) build on macosx doesn't include -L/usr/local/lib when it finds snappy
|
|
||||||
! - link_directories(/usr/local/lib) or some other fix
|
! - link_directories(/usr/local/lib) or some other fix
|
||||||
|
! 4) byseq iteration doesn't have bodies, weird.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ERROR: fdb-error error ;
|
ERROR: fdb-error error ;
|
||||||
|
@ -214,41 +189,42 @@ M: fdb-iterator dispose*
|
||||||
|
|
||||||
! fdb_doc key, meta, body only valid inside with-forestdb
|
! fdb_doc key, meta, body only valid inside with-forestdb
|
||||||
! so make a helper word to preserve them outside
|
! so make a helper word to preserve them outside
|
||||||
TUPLE: doc seqnum key meta body deleted? offset size-ondisk ;
|
TUPLE: doc seqnum keylen key metalen meta bodylen body deleted? offset size-ondisk ;
|
||||||
|
|
||||||
CONSTRUCTOR: <doc> doc ( seqnum key meta body deleted? offset size-ondisk -- obj ) ;
|
CONSTRUCTOR: <doc> doc ( seqnum keylen key metalen meta bodylen body deleted? offset size-ondisk -- obj ) ;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
! Example fdb_doc and converted doc
|
! Example fdb_doc and converted doc
|
||||||
S{ fdb_doc
|
S{ fdb_doc
|
||||||
{ keylen 4 }
|
{ keylen 4 } { metalen 0 } { bodylen 4 } { size_ondisk 0 }
|
||||||
{ metalen 0 }
|
{ key ALIEN: 1002f2f10 } { seqnum 5 } { offset 4256 }
|
||||||
{ bodylen 4 }
|
{ meta ALIEN: 1002dc790 } { body f } { deleted f }
|
||||||
{ size_ondisk 0 }
|
|
||||||
{ key ALIEN: 111e003b0 }
|
|
||||||
{ seqnum 5 }
|
|
||||||
{ offset 4256 }
|
|
||||||
{ meta f }
|
|
||||||
{ body ALIEN: 111d11740 }
|
|
||||||
{ deleted f }
|
|
||||||
}
|
}
|
||||||
T{ doc
|
T{ doc
|
||||||
{ seqnum 5 }
|
{ seqnum 5 }
|
||||||
{ key "key5" }
|
{ keylen 4 } { key "key5" }
|
||||||
{ body "val5" }
|
{ metalen 0 } { bodylen 4 }
|
||||||
{ offset 4256 }
|
{ offset 4256 } { size-ondisk 0 }
|
||||||
{ size-ondisk 0 }
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
: alien/length>string ( alien n -- string/f )
|
: alien/length>string ( alien n -- string/f )
|
||||||
[ drop f ] [ memory>byte-array utf8 decode ] if-zero ;
|
[ drop f ] [
|
||||||
|
over [
|
||||||
|
memory>byte-array utf8 decode
|
||||||
|
] [
|
||||||
|
2drop f
|
||||||
|
] if
|
||||||
|
] if-zero ;
|
||||||
|
|
||||||
: fdb_doc>doc ( fdb_doc -- doc )
|
: fdb_doc>doc ( fdb_doc -- doc )
|
||||||
{
|
{
|
||||||
[ seqnum>> ]
|
[ seqnum>> ]
|
||||||
|
[ keylen>> ]
|
||||||
[ [ key>> ] [ keylen>> ] bi alien/length>string ]
|
[ [ key>> ] [ keylen>> ] bi alien/length>string ]
|
||||||
|
[ metalen>> ]
|
||||||
[ [ meta>> ] [ metalen>> ] bi alien/length>string ]
|
[ [ meta>> ] [ metalen>> ] bi alien/length>string ]
|
||||||
|
[ bodylen>> ]
|
||||||
[ [ body>> ] [ bodylen>> ] bi alien/length>string ]
|
[ [ body>> ] [ bodylen>> ] bi alien/length>string ]
|
||||||
[ deleted>> >boolean ]
|
[ deleted>> >boolean ]
|
||||||
[ offset>> ]
|
[ offset>> ]
|
||||||
|
@ -271,17 +247,14 @@ T{ doc
|
||||||
[ FDB_ITR_NONE \ fdb-iterator-init \ fdb-iterator-next ] dip
|
[ FDB_ITR_NONE \ fdb-iterator-init \ fdb-iterator-next ] dip
|
||||||
with-fdb-iterator ; inline
|
with-fdb-iterator ; inline
|
||||||
|
|
||||||
! XXX: broken?
|
|
||||||
: with-fdb-normal-meta-iterator ( start-key end-key quot -- )
|
: with-fdb-normal-meta-iterator ( start-key end-key quot -- )
|
||||||
[ FDB_ITR_NONE \ fdb-iterator-init \ fdb-iterator-next-meta-only ] dip
|
[ FDB_ITR_NONE \ fdb-iterator-init \ fdb-iterator-next-meta-only ] dip
|
||||||
with-fdb-iterator ; inline
|
with-fdb-iterator ; inline
|
||||||
|
|
||||||
! XXX: broken? -- body and meta slots are wrong
|
|
||||||
: with-fdb-byseq-iterator ( start-seq end-seq quot -- )
|
: with-fdb-byseq-iterator ( start-seq end-seq quot -- )
|
||||||
[ FDB_ITR_NONE \ fdb-iterator-byseq-init \ fdb-iterator-next-meta-only ] dip
|
[ FDB_ITR_NONE \ fdb-iterator-byseq-init \ fdb-iterator-next-meta-only ] dip
|
||||||
with-fdb-iterator ; inline
|
with-fdb-iterator ; inline
|
||||||
|
|
||||||
|
|
||||||
! Do not try to commit here, as it will fail with FDB_RESULT_RONLY_VIOLATION
|
! Do not try to commit here, as it will fail with FDB_RESULT_RONLY_VIOLATION
|
||||||
! fdb-current is weird, it gets replaced if you call fdb-rollback
|
! fdb-current is weird, it gets replaced if you call fdb-rollback
|
||||||
! Therefore, only clean up fdb-current once, and clean it up at the end
|
! Therefore, only clean up fdb-current once, and clean it up at the end
|
||||||
|
|
Loading…
Reference in New Issue