in() not recognized but out() is fine?

317 views
Skip to first unread message

Adolfo Onasontisi

unread,
Jun 24, 2016, 5:08:13 PM6/24/16
to gremli...@googlegroups.com
out() works but not in(). It is weird! This is Gremlin 3.1, on Titan.

I am running a simple query to get degree (out, then in):

gremlin> g.V().group().by('name').by(out().count())
14:06:19 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>[Bob:[20]...

However, when I run in() I get an error. Out works, In doesn't. What gives?

gremlin> g.V().group().by('name').by(in().count())
groovysh_parse: 2: unexpected token: in @ line 2, column 31.
   g.V().group().by('name').by(in().count())
                                 ^

1 error
Display stack trace? [yN] y
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
groovysh_parse: 2: unexpected token: in @ line 2, column 31.
   g.V().group().by('name').by(in().count())
                                 ^

1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:106)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:148)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:119)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:131)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:359)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:142)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.tools.shell.RigidParser.parse(Parser.groovy:157)
at org.codehaus.groovy.tools.shell.Parser.parse(Parser.groovy:73)
at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:172)
at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:119)
at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:94)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:123)
at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:58)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150)
at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:82)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:144)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:215)
at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:303)

Marko Rodriguez

unread,
Jun 24, 2016, 7:57:10 PM6/24/16
to gremli...@googlegroups.com
Read the docs — _.in(). Likewise, in Groovy, when as() is a start, its _.as().

Marko.
--
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/CACRvbzMFt4-VzbMrJtYMXsLxPkJuHuCY%3DW6eCn1aJdaWkz%2Bfig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Kuppitz

unread,
Jun 25, 2016, 7:01:39 AM6/25/16
to gremli...@googlegroups.com
Hey Marko, read the docs! It's __, not just _ :)

The relevant note in the docs is right here: http://tinkerpop.apache.org/docs/current/reference/#graph-traversal-steps (first NOTE box).

Cheers,
Daniel


Gregory Zhukovsky

unread,
Jun 12, 2017, 4:43:18 AM6/12/17
to Gremlin-users
Hi Marko and Daniel,

It seem to work when .in is preceded by a dot; but, for example, in case of recursive query, like this one (rephrased example by Daniel from another thread), it doesn't:
g.V("some V").repeat(in("child").simplePath().dedup()).times(depth).tree().next()

In the above case, I get the same
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovysh_parse: 2: unexpected token: in @
exception.

How can it be worked around?

Thanks!
Gregory

Gregory Zhukovsky

unread,
Jun 12, 2017, 4:43:18 AM6/12/17
to Gremlin-users
Oh sorry...

when I write it like
g.V("some V").repeat(__in("child").simplePath().dedup()).times(depth).tree().next()


I get an error says
No signature of method: groovysh_evaluate.__in() is applicable for argument types: (java.lang.String) values: [child]

The same query for out() works perfectly..
:(


On Saturday, June 25, 2016 at 2:01:39 PM UTC+3, Daniel Kuppitz wrote:

Stephen Mallette

unread,
Jun 12, 2017, 6:46:16 AM6/12/17
to Gremlin-users
Daniel's link explains it:

To reduce the verbosity of the expression, it is good to import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*. This way, instead of doing __.inE() for an anonymous traversal, it is possible to simply write inE(). Be aware of language-specific reserved keywords when using anonymous traversals. For example, in and as are reserved keywords in Groovy, therefore you must use the verbose syntax __.in() and __.as() to avoid collisions.



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/0e32afe5-75a7-41f3-8ff8-873884e8a455%40googlegroups.com.

Gregory Zhukovsky

unread,
Jun 12, 2017, 1:25:49 PM6/12/17
to Gremlin-users
Hi Stephen,

Thank you.
Can you please see the query from my last post that I get an error with and tell what's wrong with it?


g.V("some V").repeat(__in("child").simplePath().dedup()).times(depth).tree().next()

The same query with "out" works just fine, but this one gives "No signature of method: groovysh_evaluate.__in() is applicable for argument types: (java.lang.String) values: [child]" error.

Sorry if it's a noob question, but I really fail to figure it out by myself :(

Marko Rodriguez

unread,
Jun 12, 2017, 1:26:51 PM6/12/17
to gremli...@googlegroups.com
__.in()

NOT

__in()

Note the . (“dot”)

Marko.


Gregory Zhukovsky

unread,
Jun 12, 2017, 1:42:20 PM6/12/17
to Gremlin-users
Hi Marko,

I've tried it before, and it gave me no result - but now it just works.. looks like some ID typo. Thank you so much!
Reply all
Reply to author
Forward
0 new messages