-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to use the gremlin statement to trigger oltp query #2544
Comments
To trigger an OLTP query in HugeGraph using a Gremlin statement, you can use the public GremlinResult executeQuery(int connId, GremlinQuery query) {
HugeClient client = this.getClient(connId);
log.debug("The original gremlin ==> {}", query.getContent());
String gremlin = this.optimize(query.getContent());
log.debug("The optimized gremlin ==> {}", gremlin);
// Execute gremlin query
ResultSet resultSet = this.executeGremlin(gremlin, client);
// Scan data, vote the result type
TypedResult typedResult = this.parseResults(resultSet);
// Build json view
JsonView jsonView = new JsonView(typedResult.getData());
// Build table view
TableView tableView = this.buildTableView(typedResult);
// Build graph view
GraphView graphView = this.buildGraphView(typedResult, client);
return GremlinResult.builder()
.type(typedResult.getType())
.jsonView(jsonView)
.tableView(tableView)
.graphView(graphView)
.build();
} To use this method, create an instance of Additionally, you can use the REST API to execute Gremlin queries in HugeGraph. Here is an example of how to post a Gremlin query using the REST API: @Test
public void testPost() {
String body = "{" +
"\"gremlin\":\"g.V()\"," +
"\"bindings\":{}," +
"\"language\":\"gremlin-groovy\"," +
"\"aliases\":{\"g\":\"__g_hugegraph\"}}";
assertResponseStatus(200, client().post(path, body));
} In this example, the
|
@dosu 在源代码中没有找到 GremlinQueryService这个类 |
The Here is an example of how you can use the import org.apache.hugegraph.controller.query.GremlinQueryController;
import org.apache.hugegraph.entity.query.GremlinQuery;
import org.apache.hugegraph.entity.query.GremlinResult;
import org.apache.hugegraph.service.query.GremlinQueryService;
import org.springframework.beans.factory.annotation.Autowired;
public class GremlinQueryExecutor {
@Autowired
private GremlinQueryService queryService;
public GremlinResult executeGremlinQuery(int connId, String gremlinQueryContent) {
GremlinQuery query = new GremlinQuery();
query.setContent(gremlinQueryContent);
GremlinResult result = queryService.executeQuery(connId, query);
// Process the result as needed
return result;
}
} In this example, you need to create a
|
Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label |
Problem Type (问题类型)
gremlin (结果不合预期)
Before submit
Environment (环境信息)
Server Version: 1.0.0 (Apache Release Version)
Backend: Hbase
Your Question (问题描述)
如下是从官方文档找到功能对应的PR,能提供一个gremlin触发的示例?
#1289
Vertex/Edge example (问题点 / 边数据举例)
No response
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
No response
The text was updated successfully, but these errors were encountered: