-
Notifications
You must be signed in to change notification settings - Fork 239
Using Gremlin through Groovy
okram edited this page Jan 14, 2011
·
36 revisions
Gremlin works by using the metaprogramming facilities provided by Groovy. There is single Groovy class called Gremlin.groovy
. If that class is constructed, then it appends particular properties and methods to various MetaClass
objects. Thus, to use Gremlin while in Groovy, simply do Gremlin.load()
(be sure Gremlin is in the classpath).
Gremlin shell (gremlin.sh
) is basically the Groovy shell wrapped to have the Gremlin look and feel. For example, do \h
at the gremlin>
prompt.
marko:~$ groovysh
Groovy Shell (1.7.2, JVM: 1.6.0_22)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> com.tinkerpop.gremlin.Gremlin.load()
If you are using Groovy classes, its easy to use Gremlin. In this way, your Java code and your Gremlin/Groovy code seamless interact through standard class mechanisms.
class CountPipeTest extends TestCase {
public void testCountingObjects() {
Gremlin.load()
Graph g = TinkerGraphFactory.createTinkerGraph()
def results = []
g.v(1).outE.inV >> results
}
}