我们使用Neo4J作为我们的图形数据库开发了用于路径优化的定制和专有软件.我们还开发了一些Java中的插件和非托管扩展,只要在Graph上进行搜索,就可以实现特定的业务逻辑.由于我们正面临着Neo4J的严重性能问题,我们正在考虑将我们的专有软件从Neo4J迁移到DataStaX DSE 5.0 Graph.但是想最初评估DSE Graph.
关于Neo4J的迁移路径,我们几乎没有具体的问题 - > DataStax Graph DB
我们希望了解将现有的Neo4J Java代码迁移到DataStax DSE Graph代码所需的条件.在我们启动并运行DataStax DSE Graph之前,我们需要确定执行此练习所需的工作量.
在gremlin-console
,当我做一个语法错误,如下面的例子 - 我忘了第二个引号 - 我不知道输入什么让我回到正常的提示gremlin>
.我输入的任何内容Ctrl+C
,Ctrl+U
将继续......2>
如下.
gremlin> g.V("
......1>
......1> "
......2> )
groovysh_parse: 1: expecting anything but ''\n''; got it anyway @ line 1, column 6.
g.V("
^
1 error
Type ':help' or ':h' for help.
Display stack trace? [yN]n
......2>
Run Code Online (Sandbox Code Playgroud)
如何"取消"错误并继续使用gremlin-console而不退出?
这听起来很傻,但是有没有办法在 Gremlin 遍历中创建一个空数组?
对于下面的查询:
g.V().has('person','name', 'marko').project('a', 'b').by().by()
Run Code Online (Sandbox Code Playgroud)
我想投影b
为一个空数组。我试过了:
g.V().has('person','name', 'marko').project('a', 'b').by().by(constant("").fold())
Run Code Online (Sandbox Code Playgroud)
但constant("").fold()
实际上并不是空constant("").fold().count()
返回 1。这也适用于constant(null).fold()
。
如何在单个 gremlin 查询中向相同顶点类型添加边和删除边。
假设我们有两种类型的顶点类型 A --is--> B 现在我有一个顶点连接到 B 的其他顶点。
我想将 A 的顶点更新为 B 的其他顶点。
目前,我正在删除当前的 B 顶点,然后添加新的顶点。
gremlin datastax-enterprise tinkerpop datastax datastax-enterprise-graph
如果架构已满或无架构,我感到困惑DataStax graph
.
我问这个问题,因为 入门教程 告诉创建架构.但我key-value
在边缘属性上插入随机并DSE graph
接受它而没有错误.
如果我在DSE-Graph上插入随机Vertex或edge属性(键值)会有问题吗?
datastax-enterprise datastax-java-driver datastax datastax-startup datastax-enterprise-graph
我想用Datastax Java Driver完全构建一个图形.我设法插入顶点,但我不知道如何将边添加到现有顶点.
当我运行以下代码时
session.executeGraph("parent = g.V().has('businessId','sys-1').next()");
session.executeGraph("child = g.V().has('businessId','sys-2').next()");
session.executeGraph("parent.addEdge('consistsOf', child)");
Run Code Online (Sandbox Code Playgroud)
我得到一个例外
Exception in thread "main" com.datastax.driver.core.exceptions.InvalidQueryException: No such property: parent for class: Script285
at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50)
at com.datastax.driver.dse.DriverThrowables.propagateCause(DriverThrowables.java:29)
at com.datastax.driver.dse.DefaultDseSession.executeGraph(DefaultDseSession.java:77)
at com.datastax.driver.dse.DefaultDseSession.executeGraph(DefaultDseSession.java:64)
at de.pratho.valpro.tools.Main.main(Main.java:41)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: No such property: parent for class: Script285
at com.datastax.driver.core.Responses$Error.asException(Responses.java:136)
at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179)
at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:173)
at com.datastax.driver.core.RequestHandler.access$2500(RequestHandler.java:43)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:788)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:607)
at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1012)
at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:935)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266) …
Run Code Online (Sandbox Code Playgroud) java gremlin datastax-enterprise datastax-java-driver datastax-enterprise-graph
我在 datastax 企业中有 3 个节点,并在这些节点上加载了 6500 万个顶点和边。当我使用 dse studio 或 gremlin 控制台并在我的图表上运行 gremlin 查询时,查询速度太慢。我定义了任何类型的索引并再次测试但没有效果。当我运行查询例如“gv().count()”时,cpu 使用率和 cpu 平均负载没有太大变化,而如果我运行 cql 查询,则分布在所有节点上,所有节点上的 cpu 使用率和 cpu 平均负载是一个重大变化在这种情况下,高效 gremlin 查询的最佳实践或最佳配置是什么?
Java DSE GraphFrame API不完全支持从GraphTraversal
到DataFrame
。
下面GraphTraversal
来DataFrame
是可能的:
gf().E().df()
Run Code Online (Sandbox Code Playgroud)
但是,这不是:
gf().E().hasLabel("foo").df()
Run Code Online (Sandbox Code Playgroud)
这是因为hasLabel()
返回GraphTraversal
而不是com.datastax.bdp.graph.spark.graphframe.DseGraphTraversal
并且GraphTraversal
没有df()
方法。
每个文档应该有可能
若要完成遍历并返回到DataFrame API(而不是list或迭代器),请使用.df()方法:
graph.V()。df()
我使用的是dse-graph-frames:5.1.4
同一起dse-byos_2.11:5.1.4
。
这是预期的吗?我真正想要的只是进行一些图遍历并将其转换为DataFrame。
datastax-enterprise datastax-java-driver datastax-enterprise-graph
我写了一个查询,花了比预期更长的时间.
g.V().hasLabel('Person').has('name','Person1').out('BELONGS').in('HAS').dedup().as('x').in('HAS').filter(__.in('HAS').has('name','App1')).store('y').select('x').dedup().in('HAS').hasLabel('Org').repeat(out()).until(outE().hasLabel('IS')).store('a').cap('y').unfold().in('HAS').hasLabel('Class').repeat(inE('IS').dedup().otherV()).until(inE('HAS')).where(within('a'))
Run Code Online (Sandbox Code Playgroud)
我们可以做一个解释计划,看看是什么让这个查询变慢了吗?
问候
Varun Tahin
gremlin datastax-enterprise tinkerpop3 datastax-enterprise-graph
我写了下面的简单查询来遍历 Person 到 Country,但它没有返回任何结果。
g.V().hasLabel("Person").as("p").out("from").hasLabel("Country").as("c").select("p", "c")
Run Code Online (Sandbox Code Playgroud)
在实际数据中,只Person
存在顶点,不存在Country
顶点或from
边。我预计至少会回来p
- 基本上我想做一个左外连接。但是,如果我有Country
和from
数据,以及,查询返回结果。
我也尝试了另一个查询match
,但除非有实际数据,否则仍然没有结果:
g.V().hasLabel("Person").has("name","bob").match(__.as("p").out("from").hasLabel("Country").as("c")).select("p", "c")
Run Code Online (Sandbox Code Playgroud)
我正在对 Datastax Enterprise Graph 运行这些查询。
知道为什么它没有返回任何结果吗?
请告诉一个简单的解决方案,因为我有数百万个节点,所以需要更少的时间:
for(int i=1100000; i<=1200000;i++){
GraphStatement q1 = new SimpleGraphStatement("g.addV(label, 'Asset','name','Asset"+i+"','type','"+1+"').as('a')").setGraphName("lookingglass");
System.out.println("Added node----"+i);
}
for(int i=1100000;i<=1200000;i++){
//int j=i+1;
Vertex v1 = dseSession.executeGraph("g.V().has('name','Org"+1000+"')").one().asVertex();
Vertex v2 = dseSession.executeGraph("g.V().has('name','Asset"+i+"')").one().asVertex();
SimpleGraphStatement s = new SimpleGraphStatement(
"def v1 = g.V(id1).next()\n" +
"def v2 = g.V(id2).next()\n" +
"v1.addEdge('HAS', v2)")
.set("id1", v1)
.set("id2", v2);
dseSession.executeGraph(s);
System.out.println("Added Edge "+i);
}
System.out.println("Done");
Run Code Online (Sandbox Code Playgroud)
由于我正在进行整个图搜索,这需要更长的时间。我们是否可以有一个简单的单个查询来添加一个 vartex 并将一条边从该查询添加到现有顶点,从而减少延迟?
注意我也尝试过以下方法,但以下方法似乎已被废弃,因此给出错误(Vertex 不支持用户提供的标识符:
g.addV().property(id, "A").as("a").
addV().property(id, "B").property("value", 100).as("b").
addV().property(id, "C").property("value", 200).as("c").
addV().property(id, "D").property("value", 500).as("d").
addV().property(id, "E").property("value", 1000).as("e").
addV().property(id, "Z").property("value", 900).as("z").
addE("link").from("a").to("b").property("weight", 80).
addE("link").from("a").to("c").property("weight", 20).
addE("link").from("b").to("d").property("weight", 50). …
Run Code Online (Sandbox Code Playgroud) cassandra gremlin datastax-enterprise tinkerpop3 datastax-enterprise-graph