本文介绍了Java GraphTraversal输出Gremlin查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

如何从Java GraphTraversal对象输出Gremlin查询?默认输出(graphTraversal.toString())看起来像[HasStep([~label.eq(brand), name.eq(Nike), status.within([VALID])])],不容易阅读.

How to output Gremlin query from a Java GraphTraversal object? The default output (graphTraversal.toString()) looks like [HasStep([~label.eq(brand), name.eq(Nike), status.within([VALID])])] which is not easy to read.

推荐答案

克里姆林宫提供了GroovyTranslator类来帮助解决这一问题.这是一个例子.

Gremlin provides the GroovyTranslator class to help with that. Here is an example.

// Simple traversal we can use for testing a few things
Traversal t =
  g.V().has("airport","region","US-TX").
        local(values("code","city").
        fold());


// Generate the text form of the query from a Traversal
String query;
query = GroovyTranslator.of("g").
        translate(t.asAdmin().getBytecode());

System.out.println("\nResults from GroovyTranslator on a traversal");
System.out.println(query);

这是从位于此处的一组示例中获取的: https ://github.com/krlawrence/graph/blob/master/sample-code/RemoteWriteText.java

This is taken from a set of examples located here: https://github.com/krlawrence/graph/blob/master/sample-code/RemoteWriteText.java

这篇关于Java GraphTraversal输出Gremlin查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 10:54