Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 18th, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (ns blueprints.test
  2.   (:refer-clojure :exclude [remove])
  3.   (:require [blueprints.core :as b])
  4.   (:require [blueprints.utils :as utils])
  5.   (:import (com.thinkaurelius.titan.core TitanFactory)))
  6.  
  7. (defn open
  8.   [config-or-dir]
  9.   (TitanFactory/open config-or-dir))
  10.  
  11. (defn open-in-memory
  12.   []
  13.   (TitanFactory/openInMemoryGraph))
  14.  
  15. (def g (open-in-memory))
  16. ;;(def g (open "/tmp/titan"))
  17.  
  18. (type g)
  19. ;;==> StandardTitanGraph
  20.  
  21. (def james (b/add-vertex g {:name "James"}))
  22.  
  23. (type james)
  24. ;;==> PersistentStandardTitanVertex
  25.  
  26. (b/get-id james)
  27. ;;==> 4
  28. ;;==> nil (in SLIME)
  29.  
  30. (b/get-id (b/add-vertex g {:name "Julie"}))
  31. ;;==> 36
  32. ;;==> 36 (in SLIME -- it works!)
  33.  
  34. ;; These print properly via the lein command line...
  35.  
  36. (println (.getVertex g (b/get-id james)))
  37. ;;==> #<PersistStandardTitanVertex v[4]>
  38. ;;==> nil (in SLIME)
  39.  
  40. (println (b/get-id (.getVertex g (b/get-id james))))
  41. ;;==> 4
  42. ;;==> nil (in SLIME)
  43.  
  44. (defn -main
  45.   "I don't do a whole lot."
  46.   [& args]
  47.   (println "Hello, World!"))