作为容量和性能测试的一部分,我尝试使用 java 线程并行执行多个 gremlin 请求(图形遍历)。它在较少数量的线程中工作得很好。
当我增加线程数(例如 500)时,出现以下错误
线程“Thread-34”中出现异常 java.lang.RuntimeException:java.lang.RuntimeException:java.util.concurrent.TimeoutException:等待可用主机超时。在 org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:146) 在 com.tests.java.titan.Vertices.exists(Vertices.java:37) 在 com.tests.java.titan.Complex com.tests.java.perfTests.TitanThread.run(ParallelGraphTraversal.java:112) 处的.searchNodesRelatedByRelation(Complex.java:110) 引起:java.lang.RuntimeException: java.util.concurrent.TimeoutException: 等待超时可用的主机。在 org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:194) 在 org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:174) 在 org.apache.tinkerpop.gremlin .driver.Client.submit(Client.java:144) ... 3 个以上
我尝试将 threadPoolWorker 的值从 1 增加到 2,将 gremlinPool 从 8 增加到 16(在文件 gremlin-server.yaml 中)。但我没有注意到任何区别。
有人遇到过这个问题吗?您能否告诉我最大同时连接数是否有限制?
我们的环境:CDH 5.7.1、Titan 1.1.0-SNAPSHOT、Solr 4.10.3、HBase 1.2.0、titan-tp3-driver,用于创建与 gremlin 服务器的远程连接并进行查询
请问如何使用 gremlin javascript 编写下面的 3 个 gremlin 查询?
gremlin> g.V.filter{it.name.matches(".*ark.*")}.name
g.V().filter({ it.getProperty("name").contains("ark") })
g.V().filter(label().is('person'))
Run Code Online (Sandbox Code Playgroud) 我正在使用 Gremlin 使用以下内容更新插入边缘。我正在遵循这里提到的食谱。这是我正在使用的代码。该代码在 lambda 中运行,该 lambda 与 Amazon Neptune 中托管的集群进行通信
public void createEdge(final String id, final String label, final String fromId, final String toId, final Map<String, String> properties) {
this.graphTraversalSource
.V(fromId) // get vertex of id given for the source
.as("fromVertex") // label as fromVertex to be accessed later
.V(toId) // get vertex of id given for destination
.coalesce( // evaluates the provided traversals in order and returns the first traversal that emits at least one element
inE(label) …Run Code Online (Sandbox Code Playgroud) 我知道图形笔记本项目允许使用魔法命令提交 Gremlin 查询。但是,有时我需要在常规 Jupyter 笔记本单元中使用 Python 进行编码并使用代码连接到服务器。如果使用 Gremlin Python 3.5.2 客户端,我尝试执行以下操作:
server = '<your server endpoint goes here>'
port = 8182
endpoint = f'wss://{server}:{port}/gremlin'
connection = DriverRemoteConnection(endpoint,'g')
g = traversal().withRemote(connection)
Run Code Online (Sandbox Code Playgroud)
由于 Jupyter 事件循环已在运行,因此会引发错误。
有没有解决的办法?
gremlin tinkerpop amazon-neptune gremlinpython graph-notebook
我想要一个在某个边缘类型上向下遍历的查询,直到它到达具有给定属性的顶点或者它到达起始顶点的给定距离.
当它碰到某个顶点类型时,我可以让这个遍历停止,但我不能让它停在给定的深度/距离.我使用"simplePath"和"count"步骤的方式一定有问题,但我不确定它是什么.
这是Java代码:
GraphTraversal<Vertex, TinkerGraph> traversal = g.V(start)
.repeat(__.outE("type").subgraph("subGraph").inV())
.until(
__.or(
//this line works just fine
__.has("type", "one"),
//this line doesn't seem to do what I expect,
//stop when the size of the path from "start" gets too long
__.simplePath().count().is(P.gt(3))
)
)
.cap("subGraph");
Run Code Online (Sandbox Code Playgroud)
那么当从"开始"顶点到当前顶点的路径大小大于3时,我需要做些什么来使这个遍历停止?
我试图使用下面的代码将Titan图数据导出到JSON文件
TitanGraph titanGraph = TitanFactory.open("D:/Dev/Titan/titan-1.0.0-hadoop1/conf/titan-cassandra.properties");
FileOutputStream outJSON = new FileOutputStream("D:/titan-graph.json");
GraphSONWriter.build().create().writeGraph(outJSON, titanGraph);
Run Code Online (Sandbox Code Playgroud)
运行此代码获取异常时:
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.IllegalStateException) (through reference chain: com.thinkaurelius.titan.graphdb.relations.RelationIdentifier["inVertexId"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:210)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:177)
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:187)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:647)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil.writeWithType(GraphSONUtil.java:49)
at org.apache.tinkerpop.gremlin.structure.util.star.StarGraphGraphSONSerializer.ser(StarGraphGraphSONSerializer.java:100)
at org.apache.tinkerpop.gremlin.structure.util.star.StarGraphGraphSONSerializer.serialize(StarGraphGraphSONSerializer.java:64)
at org.apache.tinkerpop.gremlin.structure.util.star.StarGraphGraphSONSerializer.serialize(StarGraphGraphSONSerializer.java:54)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:128)
at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:2881)
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:2304)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter.writeVertex(GraphSONWriter.java:76)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter.writeVertices(GraphSONWriter.java:104)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter.writeGraph(GraphSONWriter.java:65)
at com.mimos.titan.TitanGraphTest.main(TitanGraphTest.java:29)
Caused by: java.lang.IllegalStateException
at com.google.common.base.Preconditions.checkState(Preconditions.java:158)
at com.thinkaurelius.titan.graphdb.relations.RelationIdentifier.getInVertexId(RelationIdentifier.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:466)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:639)
... …Run Code Online (Sandbox Code Playgroud) 我的数据结构如下:
{
number: Integer
letter: String
}
Run Code Online (Sandbox Code Playgroud)
我想按以下两个属性进行组计数:
g.V().values('number', 'letter').groupCount();
Run Code Online (Sandbox Code Playgroud)
并查看显示的数据,如下所示:
[[1,A]:16, [1,B]:64, [2,A]:78, [2,B]:987]
Run Code Online (Sandbox Code Playgroud)
在tinkerpop中有什么方法可以做到这一点?
在发现你必须使用from_而不是from使用gremlin javascript 之前,我挣扎了好几个小时.
在深入挖掘源代码后,我终于发现代码正在使用from_而不是代码from(参见代码).因为我是新手,所以这很奇怪,因为它的对应物to仍然是to(而不是to_,请参阅此处的代码)
我用谷歌搜索到了,但无法找到这种方式的原因,并且对使用下划线版本感到不安,因为大多数时候下划线表示用户不应该真正信任的私有方法.
另外,是否有一个我错过的gremlin javascript官方文档页面?我担心将来我可能会遇到这些问题,而且JavaScript版本并没有真正的官方文档,我可能需要经历同样的困难.我喜欢gremlin,但如果JavaScript版本不稳定且不应该使用,我不妨考虑除Tinkerpop套件之外的其他选择.
我用打TinkerGraph和gremlin-scala,我看到它是能够坚持复杂的对象:
case class InnerObj(a: Int, b: String)
case class ComplexObj(a: Int, b: InnerObj)
case class SuperComplexObj(a : String, b: ComplexObj)
class GremlinQueriesSpec extends FlatSpec
with ScalaFutures with MustMatchers {
behavior of "Gremlin queries"
it must "be able to persist complex objects containing collections" taggedAs Integration in {
val g = TinkerGraph.open()
implicit val graph = g.asScala
val user = RandomData.randomUserDataAggregate
graph + user
graph.V().toCC[UserDataAggregate].toList() must be eq List(user)
}
}
Run Code Online (Sandbox Code Playgroud)
使用gremlin-javascript,我正在使用以下方法连接到远程服务器:
const gremlin = require('gremlin')
const Graph = gremlin.structure.Graph
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection
const graph = new Graph()
const g = graph
.traversal()
.withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'))
Run Code Online (Sandbox Code Playgroud)
从小鬼CLI,我可以设置一个TinkerGraph使用
gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal()
Run Code Online (Sandbox Code Playgroud)
但是,我想通过连接到我的图表localhost:8182。这并不能完全解决问题:
gremlin> graph = RemoteGraph.open('ws://localhost:8182/gremlin')
Run Code Online (Sandbox Code Playgroud)
而且也不是这样:
gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'))
Run Code Online (Sandbox Code Playgroud)
如何从CLI连接到该服务器?