Permalink
Browse files

Almost all tests passing. Multigroup remains.

  • Loading branch information...
1 parent c2d7806 commit 0506e456a069d4d1f693ca34799bb2d843c26616 @sritchie sritchie committed Jun 5, 2012
Showing with 45 additions and 55 deletions.
  1. +4 −1 test/cascalog/api_secondary_test.clj
  2. +7 −5 test/cascalog/api_test.clj
  3. +34 −49 test/cascalog/jcascalog_test.clj
View
5 test/cascalog/api_secondary_test.clj
@@ -258,8 +258,11 @@
(multigroup [?key]
[?count ?sum]
count-sum gen1 gen2))
+
(test?- [["a" 2 2 0] ["a" 9 9 9]
["b" 1 1 2] ["b" 9 9 9]
["c" 0 0 2] ["c" 9 9 9]]
- (multigroup [?key] [?v1 ?v2 ?v3] [count-arg [9]]
+ (multigroup [?key]
+ [?v1 ?v2 ?v3]
+ [count-arg [9]]
gen1 gen1 gen2))))
View
12 test/cascalog/api_test.clj
@@ -31,12 +31,12 @@
(test?<- [["j"] ["n"]]
[?p]
(age ?p ?a)
- (< ?a 25))
+ (< ?a 25)
+ (:distinct true))
(test?<- [["j"] ["n"] ["n"]]
[?p]
(age ?p ?a)
- (< ?a 25)
- (:distinct false))))
+ (< ?a 25))))
(deftest test-larger-tuples
(let [stats [["n" 6 190 nil] ["n" 6 195 nil]
@@ -102,7 +102,8 @@
(friends !p _)
(age !p !age)
(interest !p !interest)
- (gender !p !gender))))
+ (gender !p !gender)
+ (:distinct true))))
(defmapcatop split [^String words]
(seq (.split words "\\s+")))
@@ -308,7 +309,8 @@
[?p ?s]
(person ?p)
(follows ?p !!p2)
- (existence2str !!p2 :> ?s))))
+ (existence2str !!p2 :> ?s)
+ (:distinct true))))
(deftest test-outer-join-complex
(let [age [["a" 20] ["b" 30]
View
83 test/cascalog/jcascalog_test.clj
@@ -1,43 +1,37 @@
(ns cascalog.jcascalog-test
- (:use [clojure test]
+ (:use clojure.test
[cascalog api testing])
- (:import [cascalog.test MultiplyAgg RangeOp DoubleOp])
- (:import [jcascalog Api Fields Option Predicate
- PredicateMacro Subquery Api$FirstNArgs])
- (:import [jcascalog.op Avg Count Div Limit Sum Plus Multiply Equals])
- )
+ (:import [cascalog.test MultiplyAgg RangeOp DoubleOp]
+ [jcascalog Api Fields Option Predicate
+ PredicateMacro Subquery Api$FirstNArgs]
+ [jcascalog.op Avg Count Div Limit Sum Plus Multiply Equals]))
(deftest test-vanilla
(let [value [["a" 1] ["a" 2] ["b" 10]
["c" 3] ["b" 2] ["a" 6]]]
(test?- [["a" 18] ["b" 24] ["c" 6]]
- (Subquery. (Fields. ["?letter" "?doublesum"])
- [(Predicate. value (Fields. ["?letter" "?v"]))
- (Predicate. (Multiply.) (Fields. ["?v" 2]) (Fields. ["?double"]))
- (Predicate. (Sum.) (Fields. ["?double"]) (Fields. ["?doublesum"]))
- ]))
+ (Subquery. (Fields. ["?letter" "?doublesum"])
+ [(Predicate. value (Fields. ["?letter" "?v"]))
+ (Predicate. (Multiply.) (Fields. ["?v" 2]) (Fields. ["?double"]))
+ (Predicate. (Sum.) (Fields. ["?double"]) (Fields. ["?doublesum"])) ]))
(test?- [["a"] ["a"] ["a"]]
- (Subquery. (Fields. ["?letter"])
- [(Predicate. value (Fields. ["?letter" "_"]))
- (Predicate. (Equals.) (Fields. ["?letter" "a"]))
- (Option/distinct false)
- ]))
+ (Subquery. (Fields. ["?letter"])
+ [(Predicate. value (Fields. ["?letter" "_"]))
+ (Predicate. (Equals.) (Fields. ["?letter" "a"]))]))
(test?- [["a"]]
- (Subquery. (Fields. ["?letter"])
- [(Predicate. value (Fields. ["?letter" "_"]))
- (Predicate. #'= (Fields. ["?letter" "a"]))
- ]))
+ (Subquery. (Fields. ["?letter"])
+ [(Predicate. value (Fields. ["?letter" "_"]))
+ (Predicate. #'= (Fields. ["?letter" "a"]))
+ (Option/distinct true)]))
(test?- [[(* 1 2 3628800 6 2 720) 24]]
- (Subquery. (Fields. ["?result" "?count"])
- [(Predicate. value (Fields. ["_" "?v"]))
- (Predicate. (RangeOp.) (Fields. ["?v"]) (Fields. ["?v2"]))
- (Predicate. (MultiplyAgg.) (Fields. ["?v2"]) (Fields. ["?result"]))
- (Predicate. (Count.) (Fields. ["?count"]))
- ]))
- ))
+ (Subquery. (Fields. ["?result" "?count"])
+ [(Predicate. value (Fields. ["_" "?v"]))
+ (Predicate. (RangeOp.) (Fields. ["?v"]) (Fields. ["?v2"]))
+ (Predicate. (MultiplyAgg.) (Fields. ["?v2"]) (Fields. ["?result"]))
+ (Predicate. (Count.) (Fields. ["?count"])) ]))))
(def my-avg
(reify PredicateMacro
@@ -46,39 +40,30 @@
sum-var (Api/genNullableVar)]
[(Predicate. (Count.) (Fields. [count-var]))
(Predicate. (Sum.) (Fields. [val]) (Fields. [sum-var]))
- (Predicate. (Div.) (Fields. [sum-var count-var]) (Fields. [avg]))
- ]
- ))))
+ (Predicate. (Div.) (Fields. [sum-var count-var]) (Fields. [avg]))]))))
(deftest test-java-predicate-macro
(let [nums [[1] [2] [3] [4] [5]]]
(test?- [[3]]
- (Subquery. (Fields. ["?avg"])
- [(Predicate. nums (Fields. ["?v"]))
- (Predicate. my-avg (Fields. ["?v"]) (Fields. ["?avg"]))
- ]))
- ))
+ (Subquery. (Fields. ["?avg"])
+ [(Predicate. nums (Fields. ["?v"]))
+ (Predicate. my-avg (Fields. ["?v"]) (Fields. ["?avg"]))]))))
(deftest test-first-n
(let [data [["a" 1] ["a" 1] ["b" 1] ["c" 1] ["c" 1] ["a" 1]
["d" 1]]
sq (Subquery. (Fields. ["?l" "?count"])
- [(Predicate. data (Fields. ["?l" "_"]))
- (Predicate. (Count.) (Fields. ["?count"]))
- ])
- firstn (Api/firstN sq 2 (-> (Api$FirstNArgs.) (.sort "?count") (.reverse true)))
- ]
+ [(Predicate. data (Fields. ["?l" "_"]))
+ (Predicate. (Count.) (Fields. ["?count"]))
+ ])
+ firstn (Api/firstN sq 2 (-> (Api$FirstNArgs.) (.sort "?count") (.reverse true)))]
(test?- [["c"]]
- (Subquery. (Fields. ["?l"])
- [(Predicate. firstn (Fields. ["?l" 2]))
- ]))
- ))
+ (Subquery. (Fields. ["?l"])
+ [(Predicate. firstn (Fields. ["?l" 2]))]))))
(deftest test-java-each
(let [data [[1 2 3] [4 5 6]]]
(test?- [[2 4 6] [8 10 12]]
- (Subquery. (Fields. ["?x" "?y" "?z"])
- [(Predicate. data (Fields. ["?a" "?b" "?c"]))
- (Predicate. (Api/each (DoubleOp.)) (Fields. ["?a" "?b" "?c"]) (Fields. ["?x" "?y" "?z"]))
- ]))
- ))
+ (Subquery. (Fields. ["?x" "?y" "?z"])
+ [(Predicate. data (Fields. ["?a" "?b" "?c"]))
+ (Predicate. (Api/each (DoubleOp.)) (Fields. ["?a" "?b" "?c"]) (Fields. ["?x" "?y" "?z"]))]))))

0 comments on commit 0506e45

Please sign in to comment.