Gremlin-Go: 树步骤不可序列化

huangapple go评论70阅读模式
英文:

Gremlin-Go: Tree Step Is Not Serializable

问题

我正在运行一个查询,以遍历所有特定标签的“in”边,并且稍后我将执行类似的查询来获取“out”边。我希望将其作为一棵树返回,因为可能有一个顶点有多条边需要遍历,并且需要在我的客户端中反映出来,所以我不能只使用 ToList()

我目前正在使用Gremlin-Go SDK,但是在调用 Tree() 步骤时,我遇到了反序列化错误。这是我客户端代码的一部分:

	res, err := g.V(id).
		Emit().
		Repeat(__.In(label)).
		Tree().
		Next() // 其他终端步骤产生相同的问题

这会在数据类型 0x2b 上产生反序列化错误,它是一个GraphBinary核心数据类型“Tree”

2023/02/28 12:23:05 在操作gremlinServerWSProtocol.readLoop()期间发生错误:'E0408: unknown data type to deserialize 0x2b'
2023/02/28 12:23:05 读取循环错误'E0408: unknown data type to deserialize 0x2b',关闭读取循环
2023/02/28 12:23:05 调用连接错误回调关闭协议

Gremlin-Go参考文档似乎没有提到具体的序列化支持。根据 gremlin-goREADME,它支持所有核心的GraphBinary数据类型。我已经在Gremlin Console中测试了我的查询,以验证查询和服务器:
g.V(<ID>).emit().repeat(__.in(<LABEL>)).tree().next()


为了提供一些背景信息,我正在开发针对本地的 gremlin-server:3.5.3 进行实验,以便与AWS Neptune的支持最终确定查询。我知道它们并不完全可互换,并且将遵循Neptune-Gremlin参考。Neptune的最新版本指定了支持的最新Gremlin版本为3.5.3。

英文:

I am running a query to traverse all the "in" edges following a specific label, and I will be doing a similar query later for the "out" edges later. I want to get this as a tree as there may be a vertex with multiple edges to traverse and need to reflect that in my client, so I can't just use a ToList() here.

I'm currently using Gremlin-Go SDK, but when calling the Tree() step I get a deserialization error. Here's a snippet from my client code:

	res, err := g.V(id).
		Emit().
		Repeat(__.In(label)).
		Tree().
		Next() // Other terminal steps produce same issue

This produces the deserialization error on the data type 0x2b, which is a GraphBinary core data type "Tree"

2023/02/28 12:23:05 Error occurred during operation gremlinServerWSProtocol.readLoop(): &#39;E0408: unknown data type to deserialize 0x2b&#39;
2023/02/28 12:23:05 Read loop error &#39;E0408: unknown data type to deserialize 0x2b&#39;, closing read loop.
2023/02/28 12:23:05 Connection error callback invoked, closing protocol.

The Gremlin-Go reference docs don't seem to mention anything on specific serialization support. According to the gremlin-go README, it supports all core GraphBinary data types. I have tested my query in Gremlin Console to verify the query and server:
g.V(&lt;ID&gt;).emit().repeat(__.in(&lt;LABEL&gt;)).tree().next().


For some added context, I am developing this against gremlin-server:3.5.3 locally for experimentation with the intention of finalizing queries with support for AWS Neptune. I'm aware these aren't fully interchangeable and will follow the Neptune-Gremlin reference. The latest version of Neptune specifies the latest supported version of Gremlin is 3.5.3.

答案1

得分: 1

一般来说,只有Java(和其他基于JVM的客户端)能够反序列化像SubGraph或Tree这样的结构。这是因为这些是目前唯一具有这些数据结构的本地实现的Gremlin客户端(例如JVM客户端具有TinkerGraph可用)。

TinkerPop社区非常清楚这一点,并且已将其列入需要改进的事项之一。

一个可能的解决方法(并不是很好的解决方法)是使用HTTP端点(将查询作为文本发送),并在返回的GraphSON中处理这种类型的数据结构,如果必须获取此类型的数据结构。

英文:

In general, only the Java (and other JVM based clients) are able to de-serialize structures like a SubGraph or a Tree. This is because those are the only Gremlin clients that have native implementations of those data structures currently available (for example the JVM clients have TinkerGraph available).

This is an item that the TinkerPop community is very aware of and it is on the list of things that it makes sense to improve.

A possible workaround (not a great one) is to use the HTTP endpoint (sending queries as text) and processing the GraphSON returned if getting this type of data structure back is essential.

huangapple
  • 本文由 发表于 2023年3月1日 03:24:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75596457.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定