g.getVertices('foo.key','foo1')._().inE('links').outV().inE('connects').outV()
GremlinPipeline<Iterable<Vertex>, Vertex> pipe = new GremlinPipeline<>();
pipe.start(g.getVertices("foo.key", "foo1")).inE("links").outV().inE("connects").outV();
for (Vertex v : pipe) { LOGGER.info("result = {}", v); }
new GremlinGroovyPipeline( g.getVertices("foo.key", "foo1") ).inE('links').outV().inE('connects').outV().each( { println it } )
Gremlin.defineStep( 'bars', [Vertex, Pipe], { _().has('keytype','foo').inE('links').outV().has('keytype','bar') } )Gremlin.defineStep( 'bazs', [Vertex, Pipe], { _().has('keytype','bar').inE('connects').outV().has('keytype','baz') } )
g.getVertices('foo.key','foo1')._().bars.bazs
Gremlin.defineStep( 'bars', [Vertex, Pipe], { _().has('keytype','foo').inE('links').outV().has('keytype','bar') } )Gremlin.defineStep( 'bazs', [Vertex, Pipe], { _().has('keytype','bar').inE('connects').outV().has('keytype','baz') } )new GremlinGroovyPipeline( g.getVertices("foo.key", "foo1") ).bars.bazs.each( { println it } )
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: com.example.test.GroovyTest$_mfv2_closure1._() is applicable for argument types: () values: []
Possible solutions: is(java.lang.Object), is(java.lang.Object), any(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:379)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:723)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:72)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:137)
at com.verisign.test.GroovyTest$_mfv2_closure1.doCall(GroovyTest.groovy:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.verisign.test.GroovyTest$_mfv2_closure1.doCall(GroovyTest.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at com.tinkerpop.gremlin.groovy.Gremlin$_defineStep_closure2_closure5.doCall(Gremlin.groovy:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80)
at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:816)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1128)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1081)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1106)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:781)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:772)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:164)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:185)
at com.tinkerpop.gremlin.groovy.loaders.PipeLoader$_load_closure1.doCall(PipeLoader.groovy:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80)
at groovy.lang.MetaClassImpl.invokeMissingProperty(MetaClassImpl.java:771)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1621)
at groovy.lang.ExpandoMetaClass.getProperty(ExpandoMetaClass.java:1136)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3343)
at groovy.lang.ExpandoMetaClass.getProperty(ExpandoMetaClass.java:1148)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:161)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassGetPropertySite.getProperty(PojoMetaClassGetPropertySite.java:33)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at com.example.test.GroovyTest.test1(GroovyTest.groovy:29)
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/749dff36-a579-409b-9b89-9c498eedced4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0e64d7ef-803f-47d4-b8c3-a77805968daf%40googlegroups.com.
My final solution was to create a class to hold my DSL bits. The class has a static "load" method which checks a static "loaded" flag. If it's already been loaded, it does nothing, otherwise it calls Gremlin.load() and then initializes an instance of the DSL class, which does all of the defineStep() calls, along with my other metaClass work.
I can call DSL.load() from a static method, go figure.
I think that since the defineStep calls shouldn't be repeated (and are somewhat slow due to all of the initialization overhead) that this pattern should be described in the wiki page about custom steps.
- Craig -
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CAA-H43_YrMvWVR%3DJ_QA9rLi3nEN3gJGd-8VFGNjW7DZZJzP5ng%40mail.gmail.com.
package com.example.utilimport com.tinkerpop.blueprints.Graphimport com.tinkerpop.blueprints.Verteximport com.tinkerpop.gremlin.groovy.Gremlinimport com.tinkerpop.pipes.Pipeclass DSL {
private static boolean loaded = false/*** This loads and initializes Gremlin, and defines the DSL extensions for Groovy and Gremlin*/public static void load() {
if (!loaded) {Gremlin.load()DSL dsl = new DSL()loaded = true}
}private DSL() {
// Extend the Graph classGraph.metaClass.start_vertex = { String classname, String key ->
delegate.getVertices( classname+".key", key )._()
}// Add custom Gremlin stepsGremlin.defineStep( 'bars', [Vertex, Pipe ]) {
_().has('keytype','foo').inE('links').outV().has('keytype','bar')
}Gremlin.defineStep( 'bazs', [Vertex, Pipe ]) {
_().has('keytype','bar').inE('links').outV().has('keytype','baz')
}
}
}
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0e64d7ef-803f-47d4-b8c3-a77805968daf%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.