Guest User

Shared State in (map-reduce) > Clojure

a guest
Apr 1st, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn get-accounts [uname]
  2.  
  3.   (let [m (str "function(){
  4.              if( (this.content[1].content != null) && (this.owner == '"uname"') ) {
  5.                this.content[1].content.forEach(                   function(x) {
  6.                    emit( this.owner , x );
  7.                  }
  8.                );
  9.              }
  10.            };")
  11.         r   "function(k,vals) { return { result : vals } ; }"
  12.         result (map-reduce :bookkeeping m r :result-collection)]
  13.          
  14.     (println (str "-- commands.get-accounts[" (first result) "]"))
  15.     (vec (map bkell.domain/keywordize-tags
  16.       (-> result first :value :result)))  ;; dig in and get the currency list
  17.        
  18.   )
  19. )
  20.  
  21.  
  22. (defn get-entries [uname]
  23.  
  24.   (let [m (str "function(){
  25.              if( (this.content[2].content[0].content[0].content != null) && (this.owner == '"uname"') ) {
  26.                this.content[2].content[0].content[0].content.forEach(
  27.                                    function(x) {                     emit( this.owner , x );                   }
  28.                );
  29.              }
  30.            };" )
  31.         r   "function(k,vals) { return { result : vals } ; }"
  32.         result (map-reduce :bookkeeping m r :result-collection)]
  33.  
  34.     (println (str "-- commands.get-entries[" (first result) "]"))
  35.     (vec (map bkell.domain/keywordize-tags
  36.       (-> result first :value :result)))  ;; dig in and get the currency list
  37.  
  38.   )
  39. )
Advertisement
Add Comment
Please, Sign In to add comment