Skip to content

Commit

Permalink
Reduce to build the pipe and with more info
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Aug 26, 2012
1 parent 88ca87b commit ca9cd9f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
Binary file modified .project.clj.un~
Binary file not shown.
Binary file modified src/pacer/.pacer.clj.un~
Binary file not shown.
29 changes: 14 additions & 15 deletions src/pacer/pacer.clj
@@ -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 []
Expand All @@ -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))
2 changes: 1 addition & 1 deletion target/repl-port
@@ -1 +1 @@
58812
59581
2 changes: 1 addition & 1 deletion target/stale/dependencies
@@ -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.