[
https://issues.apache.org/jira/browse/TINKERPOP-2050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16672413#comment-16672413
]
stephen mallette edited comment on TINKERPOP-2050 at 11/6/18 8:00 PM:
----------------------------------------------------------------------
Some quick experimentation yielded:
{code}
gremlin> :bytecode from g.V().out('knows')
==>{"@type":"g:Bytecode","@value":{"step":[["V"],["out","knows"]]}}
gremlin> :bytecode translate g
{"@type":"g:Bytecode","@value":{"step":[["V"],["out","knows"]]}}
==>g.V().out("knows")
{code}
Going to ask on the dev list if folks find it useful....
was (Author: spmallette):
Some quick experimentation yielded:
{code}
gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> :bytecode from g.V().out('knows')
==>{"@type":"g:Bytecode","@value":{"step":[["V"],["out","knows"]]}}
gremlin> :bytecode translate g
{"@type":"g:Bytecode","@value":{"step":[["V"],["out","knows"]]}}
==>g.V().out("knows")
gremlin> :bytecode eval g
{"@type":"g:Bytecode","@value":{"step":[["V"],["out","knows"]]}}
==>v[2]
==>v[4]
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :bytecode submit g
{"@type":"g:Bytecode","@value":{"step":[["V"],["out","knows"]]}}
==>v[2]
==>v[4]
{code}
Going to ask on the dev list if folks find it useful....
> Add a :bytecode command to Gremlin Console
> ------------------------------------------
>
> Key: TINKERPOP-2050
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2050
> Project: TinkerPop
> Issue Type: Improvement
> Components: console
> Affects Versions: 3.2.9
> Reporter: Jim Hatcher
> Assignee: stephen mallette
> Priority: Minor
>
> I am working on a project where there is Java code being written to
> dynamically generate a Traversal based on a request coming in to an API. You
> can think of this as a "Traversal Builder."
> The code looks something like this:
> {code:java}
> Traversal<Vertex, Vertex> traversal = g.V();
> if (request.searchByAddress == true) {
> traversal.hasLabel("address");
> if (request.address.addressLine1 != null){
> traversal.has("address_line_1", request.address.addressLine1)
> }
> }
> etc.
> {code}
> When that code is being debugged, a traversal.toString() is run on the
> traversal to see the ouptut. This output is Gremlin bytecode.
> It would be nice to have a way to easily see the Gremlin Groovy that was
> built so that you could take the Groovy, drop it into Studio, make sure it
> runs, run a profile() on it, and make sure it's efficient.
> I figured out that you can do this by running this code:
> {code:java}
> private String toGremlinGroovyString(Traversal traversal){
> if (traversal == null){
> return null;
> }
> Bytecode bc = traversal.asAdmin().getBytecode();
> return GroovyTranslator.of("g").translate(bc);
> }
> {code}
> I think it would be nice to add that as a method on the Traversal class so
> that it could be used by driver users more easily.
> See comment below for information on the approach taken to help provide
> support in this area.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)