Permalink
Browse files

Reduce to build the pipe and with more info

  • Loading branch information...
1 parent 88ca87b commit ca9cd9fd381e269fb62b9767ee40936345fbdcef Darrick Wiebe committed Aug 26, 2012
View
Binary file not shown.
Binary file not shown.
View
@@ -1,6 +1,7 @@
(ns pacer
(:import
- (com.tinkerpop.blueprints.impls.tg TinkerGraph)))
+ (com.tinkerpop.blueprints.impls.tg TinkerGraph))
+ (:use [clojure.pprint :only [pprint]]))
(defn simple-encoder [] { :encode nil :decode nil })
(defn tg []
@@ -23,26 +24,24 @@
[{ :source-type :graph
:type :vertex
:name "GraphV"
- :iterator (fn [source] (.. (:raw-graph source) getVertices iterator)) }])
+ :iterator (fn v [source] (.. (:raw-graph source) getVertices iterator)) }])
([graph]
(conj [graph] (first (v)))))
-(defn- pipe-from-step [source step]
+(defn- pipe-from-step [in step]
(cond
(:pipe step) (doto (:pipe step)
- (.setStarts source))
- (:build-pipe step) (throw (Exception. "Not Implemented"))
- (:iterator step) ((:iterator step) source)
+ (.setStarts (:pipe in (:source in))))
+ (:iterator step) ((:iterator step) (:pipe in (:source in)))
:else (throw (Exception. "Don't know how to build step"))))
(defn pipe
"Build a pipe from a route definition"
- ([[source step & route]]
- (if route
- (pipe (pipe-from-step source step) route)
- (pipe-from-step source step)))
- ([iter [step & route]]
- (if route
- (recur (pipe-from-step iter step) route)
- (pipe-from-step iter step))))
-
+ [[source & route]]
+ (reduce (fn [in step]
+ (pprint in)
+ { :pipe (pipe-from-step in step)
+ :type (:type step (:type in))
+ :route (conj (:route in) step)})
+ { :source source :route [] }
+ route))
View
@@ -1 +1 @@
-58812
+59581
@@ -1 +1 @@
-([:dependencies [[org.clojure/clojure "1.4.0"] [com.tinkerpop.blueprints/blueprints-core "2.1.0"] [com.tinkerpop/pipes "2.1.0"] [com.tinkerpop.gremlin/gremlin-java "2.1.0"] [swank-clojure "1.4.0"]]])
+([:dependencies [[org.clojure/tools.nrepl "0.2.0-beta9" :exclusions [org.clojure/clojure]] [clojure-complete "0.2.1" :exclusions [org.clojure/clojure]] [org.thnetos/cd-client "0.3.4" :exclusions [org.clojure/clojure]] [org.clojure/clojure "1.4.0"] [com.tinkerpop.blueprints/blueprints-core "2.1.0"] [com.tinkerpop/pipes "2.1.0"] [com.tinkerpop.gremlin/gremlin-java "2.1.0"]]])

0 comments on commit ca9cd9f

Please sign in to comment.