Browse files

Created my first pipe: (-> (tg) v pipe)

  • Loading branch information...
1 parent a37a527 commit 88ca87b6cf6c51d4dfd3f69360b008f88712c5d2 Darrick Wiebe committed Aug 26, 2012
Showing with 15 additions and 6 deletions.
  1. BIN src/pacer/.pacer.clj.un~
  2. +15 −6 src/pacer/pacer.clj
View
BIN src/pacer/.pacer.clj.un~
Binary file not shown.
View
21 src/pacer/pacer.clj
@@ -1,26 +1,33 @@
(ns pacer
(:import
- (com.tinkerpop.blueprints Graph Element Vertex Edge TransactionalGraph IndexableGraph Index)
- (com.tinkerpop.blueprints.impls.tg TinkerGraph))
- )
+ (com.tinkerpop.blueprints.impls.tg TinkerGraph)))
(defn simple-encoder [] { :encode nil :decode nil })
(defn tg []
{ :type :graph
+ :name "TinkerGraph"
:raw-graph (com.tinkerpop.blueprints.impls.tg.TinkerGraph.)
:encoder (simple-encoder)})
+(defn describe-step [step]
+ (:name step))
+
+(defn show
+ "Show an easy to read"
+ [route]
+ (->> route
+ (map describe-step)
+ (clojure.string/join " -> ")))
(defn v
([]
[{ :source-type :graph
:type :vertex
:name "GraphV"
- :iterator (fn [source] (doto (:graph source) (.getVertices) (.iterator))) }])
+ :iterator (fn [source] (.. (:raw-graph source) getVertices iterator)) }])
([graph]
- (concat [graph] (v))))
+ (conj [graph] (first (v)))))
(defn- pipe-from-step [source step]
- (prn step)
(cond
(:pipe step) (doto (:pipe step)
(.setStarts source))
@@ -29,6 +36,7 @@
: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)
@@ -37,3 +45,4 @@
(if route
(recur (pipe-from-step iter step) route)
(pipe-from-step iter step))))
+

0 comments on commit 88ca87b

Please sign in to comment.