Created
November 12, 2014 16:54
-
-
Save erasmas/eaff8ee6f9feb7700622 to your computer and use it in GitHub Desktop.
Using aggregations in Cascalog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def test-tap [["a" "x1" 0 1 0] | |
["a" "x2" 1 0 1] | |
["b" "bar" 0 1 0] | |
["b" "foo" 1 1 0]]) | |
(defaggregatefn dosum | |
([] 0) | |
([state val] (+ state val)) | |
([state] [state])) | |
(defaggregatefn agg-strings | |
([] "") | |
([state val] (str val "|" state)) | |
([state] [state])) | |
(??<- [?id ?s-out ?a-out ?b-out ?c-out] | |
(test-tap :> ?id ?s ?a ?b ?c) | |
(dosum ?a :> ?a-out) | |
(dosum ?b :> ?b-out) | |
(dosum ?c :> ?c-out) | |
(agg-strings ?s :> ?s-out)) | |
;;=> (["a" "x1|x2|" 1 1 1] ["b" "bar|foo|" 1 2 0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment