1 ! Copyright (C) 2014 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs continuations forestdb.lib fry io.directories
4 io.files.temp kernel math.parser math.ranges sequences ;
7 : test-db-0 ( -- path ) "0.forestdb.0" temp-file ;
8 : test-db-1 ( -- path ) "1.forestdb.0" temp-file ;
10 : with-forestdb-tester ( path quot -- )
13 ] with-forestdb ; inline
15 : delete-test-db-0 ( -- ) [ test-db-0 delete-file ] ignore-errors ;
16 : delete-test-db-1 ( -- ) [ test-db-1 delete-file ] ignore-errors ;
18 : make-kv-nth ( n -- key val )
19 number>string [ "key" prepend ] [ "val" prepend ] bi ;
21 : make-kv-n ( n -- seq )
22 [1,b] [ make-kv-nth ] { } map>assoc ;
24 : make-kv-range ( a b -- seq )
25 [a,b] [ make-kv-nth ] { } map>assoc ;
28 make-kv-n [ fdb-set-kv ] assoc-each ;
31 make-kv-n keys [ fdb-del-kv ] each ;
34 make-kv-nth fdb-set-kv ;
36 : set-kv-range ( a b -- )
37 make-kv-range [ fdb-set-kv ] assoc-each ;