Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:michaelklishin/welle

  • Loading branch information...
commit d9768394b487da82e78c9e24f9a925edb1e2d421 2 parents 229b5c4 + e9a4c02
@michaelklishin authored
Showing with 18 additions and 3 deletions.
  1. +18 −3 test/clojurewerkz/welle/test/mr_test.clj
View
21 test/clojurewerkz/welle/test/mr_test.clj
@@ -12,9 +12,11 @@
(deftest ^{:mr true} test-basic-map-reduce-with-erlang-builtins
(let [bucket-name "clojurewerkz.welle.mr1"
- bucket (wb/update bucket-name)]
- (doseq [l (range 0 200)]
- (kv/store bucket-name (str "java_" l) (str l) :content-type "text/plain"))
+ bucket (wb/update bucket-name :last-write-wins true)
+ store-fn #(kv/store bucket-name (str "java_" %) (str %) :content-type "text/plain")]
+ ;; Make sure we supply unordered values
+ (doseq [l (range 100 200)] (store-fn l))
+ (doseq [l (range 0 100)] (store-fn l))
(let [result (mr/map-reduce {:inputs bucket-name
:query [{:map {:language "erlang"
:module "riak_kv_mapreduce"
@@ -83,3 +85,16 @@
(is (= bucket-name (-> result first :bucket)))
(is (= "5" (-> result first :key))))
(kv/delete-all bucket-name ["1" "2" "3" "4" "5" "6"])))
+
+(deftest ^{:mr true} test-map-reduce-with-reduce-slice
+ (let [bucket-name "clojurewerkz.welle.mr5"
+ bucket (wb/update bucket-name :last-write-wins true)]
+ (dotimes [i 20]
+ (kv/store bucket-name (str i) {:field i} :content-type Constants/CTYPE_JSON))
+ (let [result (mr/map-reduce {:inputs bucket-name
+ :query [
+ {:map {:language "javascript" :name "Riak.mapValuesJson"}}
+ {:reduce {:language "javascript" :name "Riak.reduceSort" :arg "function (a,b) {return parseInt(a.field) > parseInt(b.field)}"}}
+ {:reduce {:language "javascript", :name "Riak.reduceSlice", :arg [0, 2]}}]})]
+ (is (= [{:field 0} {:field 1}] result)))
+ (drain bucket-name)))
Please sign in to comment.
Something went wrong with that request. Please try again.