<json-post-data> couch get db-url "_temp_view" append couch-post ;
: temp-view-map ( map -- results )
- "map" H{ } clone [ set-at ] keep temp-view ;
+ "map" associate temp-view ;
: save-doc-as ( assoc id -- )
[ dup <json-post-data> ] dip id-url couch-put response-ok
USING: calendar math fry kernel assocs math.ranges bson.reader io.streams.byte-array
sequences formatting combinators namespaces io tools.time prettyprint io.encodings.binary
-accessors words mongodb.driver strings math.parser bson.writer ;
+accessors words mongodb.driver strings math.parser bson.writer
+hashtables ;
FROM: mongodb.driver => find ;
FROM: memory => gc ;
: (check-find-result) ( result -- )
"x" check-for-key ; inline
-
+
: (find) ( cursor -- )
[ find [ (check-find-result) ] each (find) ] when* ; inline recursive
drop
[ trial-size
collection-name
- trial-size 2 / "x" H{ } clone [ set-at ] keep
+ trial-size 2 / "x" associate
'[ _ _ <query> 1 limit (find) ] times ] ;
-
+
: find-all ( quot -- quot: ( -- ) )
drop
collection-name
H{ } clone
'[ _ _ <query> (find) ] ;
-
+
: find-range ( quot -- quot: ( -- ) )
drop
[ trial-size batch-size /i
: batch ( -- )
result [ t >>batch ] change ; inline
-
+
: index ( -- )
result [ t >>index ] change ; inline
"Deserialization Tests" print
print-separator-bold
\ deserialize [bench-quot] '[ _ call( doc-word -- ) ] each ;
-
+
: run-insert-bench ( doc-word-seq feat-seq -- )
"Insert Tests" print
print-separator-bold
print-separator-bold
\ find-range [bench-quot] '[ _ call( doc-word -- ) ] each ;
-
+
: run-benchmarks ( -- )
"db" "db" get* "host" "127.0.0.1" get* "port" 27017 get* ensure-number <mdb>
[ print-header
{ { } { index } } run-find-all-bench
! find-range
{ small-doc medium-doc large-doc }
- { { } { index } } run-find-range-bench
+ { { } { index } } run-find-range-bench
] with-db ;
-
+
MAIN: run-benchmarks
-
USING: accessors arrays assocs bson.constants classes classes.tuple
combinators continuations fry kernel mongodb.driver sequences strings
-vectors words combinators.smart literals memoize slots constructors ;
+vectors words combinators.smart literals memoize slots constructors
+hashtables ;
IN: mongodb.tuple
: user-defined-key-index ( class -- assoc )
mdb-slot-map user-defined-key
[ drop [ "user-defined-key-index" 1 ] dip
- H{ } clone [ set-at ] keep <tuple-index> t >>unique?
- [ ] [ name>> ] bi H{ } clone [ set-at ] keep
+ associate <tuple-index> t >>unique?
+ [ ] [ name>> ] bi associate
] [ 2drop H{ } clone ] if ;
USING: accessors assocs classes.mixin classes.tuple
-classes.tuple.parser compiler.units fry kernel sequences mongodb.driver
+classes.tuple.parser compiler.units fry kernel sequences
+hashtables
+mongodb.driver
mongodb.msg mongodb.tuple.collection
mongodb.tuple.persistent mongodb.tuple.state strings ;
FROM: mongodb.driver => update delete find count ;
GENERIC: id-selector ( object -- selector )
M: toid id-selector
- [ value>> ] [ key>> ] bi H{ } clone [ set-at ] keep ; inline
+ [ value>> ] [ key>> ] bi associate ; inline
M: mdb-persistent id-selector
>toid id-selector ;