非常基本的问题,
我刚刚将我的Titan从0.54升级到Titan 1.0 Hadoop 1/TP3 3.01版本.
我遇到删除值的问题
Property key: Cardinality.LIST/SET
Run Code Online (Sandbox Code Playgroud)
也许这是由于升级过程或仅仅是我的TP3误解.
// ----- CODE ------:
tg = TitanFactory.open(c);
TitanManagement mg = tg.openManagement();
//create KEY (Cardinality.LIST) and commit changes
tm.makePropertyKey("myList").dataType(String.class).cardinality( Cardinality.LIST).make();
mg.commit();
//add vertex with multi properties
Vertex v = tg.addVertex();
v.property("myList", "role1");
v.property("myList", "role2");
v.property("myList", "role3");
v.property("myList", "role4");
v.property("myList", "role4");
Run Code Online (Sandbox Code Playgroud)
现在,我想删除所有值"role1,role2 ...."
// iterate over all values and try to remove the values
List<String> values = IteratorUtils.toList(v.values("myList"));
for (String val : values) {
v.property("myList", val).remove();
}
tg.tx().commit();
Run Code Online (Sandbox Code Playgroud)
// …
我有一个带有以下细节的顶点:
{
"requestId": "6ce01f3b-f623-41f6-bb03-dd56014e0701",
"status":
{
"message": "",
"code": ?200,
"attributes": { }
},
"result":
{
"data":
[
{
"id": ?4192,
"label": "person",
"type": "vertex",
"properties":
{
"name":
[
{
"id": "170-38g-sl",
"value": "marko2"
}
],
"age":
[
{
"id": "1l8-38g-28lh",
"value": ?29
}
]
}
}
],
"meta": { }
}
}
Run Code Online (Sandbox Code Playgroud)
我想更新顶点的名称:
我试过以下查询:
GV(4192).setProperty( '名', '威廉')
但它没有更新,它给出了错误
{
"message": "Error encountered evaluating script: g.V(4192).setProperty('name','William')"
}
Run Code Online (Sandbox Code Playgroud) 刚开始使用 Tinkerpop 和 Janusgraph,我正试图根据文档弄清楚这一点。
但首先我需要一种将数据导入 Janusgraph 的方法。
可能存在用于此的脚本。但除此之外,它是否可能用python编写,打开一个csv文件,获取变量X的每一行,并将其添加为顶点/边/等。……?还是我完全误解了 Janusgraph/Tinkerpop?
提前感谢您的任何帮助。
编辑:
假设我有几个文件,每个文件包含几百万行,代表人,还有几个变量,代表不同的指标。第一个示例可能如下所示:
metric_1 metric_2 metric_3 ..
person_1 a e i
person_2 b f j
person_3 c g k
person_4 d h l
..
Run Code Online (Sandbox Code Playgroud)
我是否应该将其转换为具有首先仅由值 [a,..., l] 组成的节点的文件。(以及后来可能更精细的属性集)
然后 [a,..., l] 被索引了吗?
在“现代”图形这里似乎有一个索引(号码1,...,12对所有的节点和边,独立于它们的重叠标签/类别的),例如应在每次测量单独索引,然后连接至一个给定的person_x他们属于哪个?
为这些可能直截了当的问题道歉,但我对此很陌生。
我将 JanusGraph 与标准 python gremlin 绑定一起使用,我想float[]在顶点/边上设置一个属性。但是,Python的Tinkerpop 驱动程序似乎无法做到这一点。
例如,下面是一个直接在 Groovy 中运行的脚本示例:
val = [1.2, 3.4, 5.6]
_client.submit("g.V(4200).property('a', %s as float[])" % val).all().result()
Run Code Online (Sandbox Code Playgroud)
这是使用 gremlin python 库时失败的代码:
val = [1.2, 3.4, 5.6]
g.V(4200).property('a', val).next()
Run Code Online (Sandbox Code Playgroud)
错误在哪里:
GremlinServerError: 500: Property value [[1.2, 3.4, 5.6]] is of type class java.util.ArrayList is not supported
Run Code Online (Sandbox Code Playgroud)
该错误可能是因为请求是由 python 驱动程序在 GraphSON 中序列化的 - 并且 GraphSON 支持具有不同类型元素的数组,因此场景背后的 Java 代码将值读取为 a java.util.ArrayList,而实际上无法转换为float[].
问题是 - 除了编写显式查询字符串之外,是否有任何理智的方法可以做到这一点?
从 java 客户端检索边时,JanusGraph v0.5.3 服务器日志中显示以下错误
12277786 [gremlin-server-exec-7] WARN org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor - The result [[e[ofncw-iyo-4avp-374][24576-hasTag->4144]]] in the request 098dc551-6558-497a-a066-b293edd29833 could not be serialized and returned.
org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.io.IOException: Serializer for type org.janusgraph.graphdb.relations.RelationIdentifier not found
at org.apache.tinkerpop.gremlin.driver.ser.binary.ResponseMessageSerializer.writeValue(ResponseMessageSerializer.java:86)
at org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1.serializeResponseAsBinary(GraphBinaryMessageSerializerV1.java:143)
at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.makeFrame(AbstractOpProcessor.java:335)
at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.handleIterator(TraversalOpProcessor.java:580)
at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.lambda$iterateBytecodeTraversal$4(TraversalOpProcessor.java:411)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Serializer for type org.janusgraph.graphdb.relations.RelationIdentifier not found
at org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry.validateInstance(TypeSerializerRegistry.java:392)
at org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry.getSerializer(TypeSerializerRegistry.java:361)
at org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter.write(GraphBinaryWriter.java:90)
at org.apache.tinkerpop.gremlin.structure.io.binary.types.EdgeSerializer.writeValue(EdgeSerializer.java:63)
at org.apache.tinkerpop.gremlin.structure.io.binary.types.EdgeSerializer.writeValue(EdgeSerializer.java:34)
at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.writeValue(SimpleTypeSerializer.java:91)
at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.write(SimpleTypeSerializer.java:73)
at org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter.write(GraphBinaryWriter.java:112)
at org.apache.tinkerpop.gremlin.structure.io.binary.types.TraverserSerializer.writeValue(TraverserSerializer.java:49) …Run Code Online (Sandbox Code Playgroud) 我已阅读有关匿名遍历的文档。我知道它们可以开始使用__,并且可以在步进调制器内使用。虽然我从概念上不理解它。为什么我们不能使用从步骤调制器内的图遍历源生成的正常遍历?例如,在下面的 gremlin 代码中创建一条边
this.g
.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) // check incoming edge of label given
.where( // conditional check to check if edge exists
outV() // get destination vertex of the edge to check …Run Code Online (Sandbox Code Playgroud) 我正在从事一个涉及在 Java 中使用知识表示的项目,我的印象是某种语义网络是实现它的方法。
Gremlin/Tinkerpop 似乎有非常好的图形生成和遍历语法,但我只能让它在独立的 shell 中工作。它是一种 JVM 语言,所以大概它有某种 Java API?我尝试将源文件夹添加到 Eclipse 项目中,但它充满了错误并且拒绝工作。
有更好的方法吗?也许是一个编译库,类似于我用来处理用户输入的斯坦福 CoreNLP 库?
我目前正在使用 TinkerPop 3.1.0 Console Incubating,每次都有一个选项
Display stack trace? [yN]
我无法输入“y”或“N”来显示或不显示堆栈跟踪。它只是换一个新行,让您没有机会输入 yN 答案。这意味着我无法对我的 gremlin 脚本、命令等进行任何调试。
您可以在下图中看到一个示例:Gremlin Console Stack Trace Message
我在运行 TinkerPop 3.1.0 Console Incubating 的两台独立机器上遇到了这个问题,并且我之前测试的 gremlin-2.6.0 Console 版本没有遇到同样的问题。
其他人遇到过这个问题吗?有没有快速修复的可能?或者我是否需要等待新版本并查看是否可以解决问题?
提前致谢。- 男
我们有顶点来存储各种作业及其类型,并算作属性。我必须按状态和数量进行分组。我尝试了以下查询,该查询适用于一个属性(receiveCount)
g.V().hasLabel("Jobs").has("Type",within("A","B","C")).group().by("Type").by(fold().match(__.as("p").unfold().values("receiveCount").sum().as("totalRec")).select("totalRec")).next()
Run Code Online (Sandbox Code Playgroud)
我想提供 10 个以上的属性,例如 successCount、FailedCount 等。有没有更好的方法来提供呢?
我有 Gremlin 和 Amazon Neptune 的后端服务。我想提供一个 GraphQL 端点来在 Neptune 中执行查询。我发现了一个可能有效的旧黑客马拉松项目。但是,我想知道是否有更好的方法来实现它。
gremlin ×10
tinkerpop3 ×10
tinkerpop ×5
janusgraph ×4
graph ×2
python ×2
titan ×2
graphql ×1
java ×1
stack-trace ×1