带有 Java 驱动程序的 DSE 图形,如何像在 Titan 中那样使用 Tinkerpop/Gremlin API 构建图形?
DSE Graph with Java Driver, how to build a graph using Tinkerpop/Gremlin APIs like in Titan?
我有一个目前依赖 tinkerpop 和 titan 的应用程序。
我想评估 DSE 5.0 提供的 Graph 功能,但我没有找到任何方法来使用 DSE Graph java API.
实例化 tinkerpop Graph
对于 titan,我使用了 tinkerpop GraphFactory class:
- org.apache.tinkerpop.gremlin.structure.Graph g = GraphFactory.open(配置文件);
- 参数中的配置文件引用TitanFactory class,其中return tinkerpop Graph接口的实现
(gremlin.graph=com.thinkaurelius.titan.core.TitanFactory)
DSE Graph API中是否有任何等价物?
2017 年 4 月 28 日更新
现在可以通过此依赖项使用 graph fluent API 功能:
<dependency>
<groupId>com.datastax.dse</groupId>
<artifactId>dse-java-driver-graph</artifactId>
<version>1.2.3</version>
</dependency>
2016 年 10 月 28 日更新
Gremlin fluent API 的第一个实现已经可用,尽管它仍处于测试阶段 (https://datastax-oss.atlassian.net/browse/JAVA-1250?focusedCommentId=35907&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-35907):
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>dse-driver</artifactId>
<version>1.1.1-beta1</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>java-dse-graph</artifactId>
<version>1.0.0-beta1</version>
</dependency>
今天用一个小例子就是这样工作的:
DseCluster dseCluster = DseCluster.builder()
.addContactPoint(HOST_IP)
.build();
DseSession dseSession = dseCluster.connect();
GraphTraversalSource g = DseGraph.traversal(dseSession, new GraphOptions().setGraphName(GRAPH_NAME));
GraphTraversal<Vertex,Vertex> gT = g.addV("User").property("uuid","testuuid");
GraphStatement graphStatement = DseGraph.statementFromTraversal(gT);
GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName(GRAPH_NAME));
System.out.println(grs.one().asVertex());
原版Post
我正在尝试将代码从 Titan 迁移到 Datastax DSE。我正在寻找与您相同的 APIs,我在 java 的 github 存储库中提交了一个问题=] dse 驱动程序:https://github.com/datastax/java-driver-dse/issues/42
由于不同语言平台之间的大量协调和优化正在进行中,目前正在进行中。
We do have plans for a more fluent api. Just as some background, most
of the TinkerPop/gremlin drivers out there do a String based approach
- that is, send the traversal String to the server, the server then optimizes the traversal and executes it. The result is sent back to
the client and is deserialized.
For Titan, what people commonly use is remote server mode which gives
access to a Graph object. This is great from a development perspective
because it offers a fluent api which is compile time checked and can
be code completed. From a practical perspective, it's actually less
efficient because it's a remote server that has to make lots of round
trips to the underlying data store to execute the traversal. So the
current String based method is actually more efficient.
We do see great value in a fluent api though. We're working on a
solution for that right now. It will likely take the form of
RemoteGraph so you'll have a graph object that is similar for
traversals. We're also working in the community on TINKERPOP-1278 to
make traversals much more idiomatic across languages. So the reason
why it's taking a bit of time to get this better experience is that
we're trying to make sure it's 1) done efficiently and 2) that it's
done correctly from the TinkerPop foundation up through DSE Graph.
In conjunction with the RemoteGraph interface for traversals, we'll
have a fluent api to do updates.
您可以在此处查看完整的讨论并跟踪问题:https://github.com/datastax/java-driver-dse/issues/42(已移至 Jira)
https://datastax-oss.atlassian.net/browse/JAVA-1250
不幸的是,您要么需要坚持使用 gremlin qraph 查询所有内容作为字符串,要么继续使用 Titan 直到 Datastax DSE API 准备就绪。
我有一个目前依赖 tinkerpop 和 titan 的应用程序。 我想评估 DSE 5.0 提供的 Graph 功能,但我没有找到任何方法来使用 DSE Graph java API.
实例化 tinkerpop Graph对于 titan,我使用了 tinkerpop GraphFactory class:
- org.apache.tinkerpop.gremlin.structure.Graph g = GraphFactory.open(配置文件);
- 参数中的配置文件引用TitanFactory class,其中return tinkerpop Graph接口的实现 (gremlin.graph=com.thinkaurelius.titan.core.TitanFactory)
DSE Graph API中是否有任何等价物?
2017 年 4 月 28 日更新
现在可以通过此依赖项使用 graph fluent API 功能:
<dependency>
<groupId>com.datastax.dse</groupId>
<artifactId>dse-java-driver-graph</artifactId>
<version>1.2.3</version>
</dependency>
2016 年 10 月 28 日更新
Gremlin fluent API 的第一个实现已经可用,尽管它仍处于测试阶段 (https://datastax-oss.atlassian.net/browse/JAVA-1250?focusedCommentId=35907&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-35907):
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>dse-driver</artifactId>
<version>1.1.1-beta1</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>java-dse-graph</artifactId>
<version>1.0.0-beta1</version>
</dependency>
今天用一个小例子就是这样工作的:
DseCluster dseCluster = DseCluster.builder()
.addContactPoint(HOST_IP)
.build();
DseSession dseSession = dseCluster.connect();
GraphTraversalSource g = DseGraph.traversal(dseSession, new GraphOptions().setGraphName(GRAPH_NAME));
GraphTraversal<Vertex,Vertex> gT = g.addV("User").property("uuid","testuuid");
GraphStatement graphStatement = DseGraph.statementFromTraversal(gT);
GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName(GRAPH_NAME));
System.out.println(grs.one().asVertex());
原版Post
我正在尝试将代码从 Titan 迁移到 Datastax DSE。我正在寻找与您相同的 APIs,我在 java 的 github 存储库中提交了一个问题=] dse 驱动程序:https://github.com/datastax/java-driver-dse/issues/42
由于不同语言平台之间的大量协调和优化正在进行中,目前正在进行中。
We do have plans for a more fluent api. Just as some background, most of the TinkerPop/gremlin drivers out there do a String based approach - that is, send the traversal String to the server, the server then optimizes the traversal and executes it. The result is sent back to the client and is deserialized.
For Titan, what people commonly use is remote server mode which gives access to a Graph object. This is great from a development perspective because it offers a fluent api which is compile time checked and can be code completed. From a practical perspective, it's actually less efficient because it's a remote server that has to make lots of round trips to the underlying data store to execute the traversal. So the current String based method is actually more efficient.
We do see great value in a fluent api though. We're working on a solution for that right now. It will likely take the form of RemoteGraph so you'll have a graph object that is similar for traversals. We're also working in the community on TINKERPOP-1278 to make traversals much more idiomatic across languages. So the reason why it's taking a bit of time to get this better experience is that we're trying to make sure it's 1) done efficiently and 2) that it's done correctly from the TinkerPop foundation up through DSE Graph.
In conjunction with the RemoteGraph interface for traversals, we'll have a fluent api to do updates.
您可以在此处查看完整的讨论并跟踪问题:https://github.com/datastax/java-driver-dse/issues/42(已移至 Jira)
https://datastax-oss.atlassian.net/browse/JAVA-1250
不幸的是,您要么需要坚持使用 gremlin qraph 查询所有内容作为字符串,要么继续使用 Titan 直到 Datastax DSE API 准备就绪。