在创建新的边并返回下一个结果时,gremlin-go中存在潜在错误.在为以下内容创建JIRA错误罚单之前,我只想确保这不是用户错误/我的错.

用于连接JanusGraph并与JanusGraph(0.6.2)交互的ApacheTinkerop gremlin-go版本:githorb.com/apache/tinkerop/gremlin-go/v3 v3.6.1.

不带事务的示例:

g := gremlingo.Traversal_().WithRemote(gremlingo.NewDriverRemoteConnection(source))
rv, err := g.AddV("v").Next()
fmt.Println(err)
fmt.Println(rv)
v, err := rv.GetVertex()
fmt.Println(err)
fmt.Println(v)
fmt.Println(v.Id)
re, err := g.AddE("e").Property("some_property", "some-property").From(__.V(v.Id)).To(__.V(v.Id)).Next()
fmt.Println(err)
fmt.Println(re)

返回:

<nil>
result{object=v[%!s(int64=24776)] class=*gremlingo.Vertex}
<nil>
v[%!s(int64=24776)]
24776
E0903: there are no results left
<nil>

交易示例:

g := gremlingo.Traversal_().WithRemote(gremlingo.NewDriverRemoteConnection(source))
tx := g.Tx()
gtx, err := tx.Begin()
if err != nil {
    tx.Close()
}
rv, err = gtx.AddV("v").Next()
if err != nil {
    fmt.Println(err)
    tx.Rollback()
}
fmt.Println(rv)
v, err = rv.GetVertex()
if err != nil {
    fmt.Println(err)
    tx.Rollback()
}
fmt.Println(v)
fmt.Println(v.Id)
re, err = gtx.AddE("e").Property("some_property", "some-property").From(__.V(v.Id)).To(__.V(v.Id)).Next()
if err != nil {
    fmt.Println(err)
    tx.Rollback()
}
fmt.Println(re)
err = txx.Commit()
if err != nil {
    tx.Rollback()
}

返回:

Creating Session based connection
Connecting.
result{object=v[%!s(int64=28872)] class=*gremlingo.Vertex}
v[%!s(int64=28872)]
28872
panic: runtime error: slice bounds out of range [:7623] with capacity 512
goroutine 133 [running]:
github.com/apache/tinkerpop/gremlin-go/v3/driver.readString(0xc00000ec60, 0xc0003b2fa0)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:912 +0x145
github.com/apache/tinkerpop/gremlin-go/v3/driver.readUnqualified(0xc00000ec60, 0xc0003b2fa0, 0x3, 0x0?)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1308 +0x362
github.com/apache/tinkerpop/gremlin-go/v3/driver.edgeReader(0xc4e860?, 0xc0003b2fa0)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1079 +0x7d
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0xe0?)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.traverserReader(0xc00000ec60, 0xc0003b2fa0)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1159 +0xdc
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0x0?)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.readList(0xc00000ec60, 0xc0003b2fa0)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:953 +0x133
github.com/apache/tinkerpop/gremlin-go/v3/driver.readFullyQualifiedNullable(0xc00000ec60, 0xc0003b2fa0, 0xc0?)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/graphBinary.go:1327 +0x3f1
github.com/apache/tinkerpop/gremlin-go/v3/driver.graphBinarySerializer.deserializeMessage({0xc00051ec00?}, {0xc0005b2200, 0xc5, 0x200})
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/serializer.go:214 +0x3fa
github.com/apache/tinkerpop/gremlin-go/v3/driver.(*gremlinServerWSProtocol).readLoop(0xc00051ec00, 0x5456ea?, 0x1c?)
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/protocol.go:75 +0x1e2
created by github.com/apache/tinkerpop/gremlin-go/v3/driver.newGremlinServerWSProtocol
    /go/pkg/mod/github.com/apache/tinkerpop/gremlin-go/v3@v3.6.1/driver/protocol.go:200 +0x250

添加.ElementMap()时:

gtx.AddE("e").Property("some_property", "some-property").From(__.V(v.Id)).To(__.V(v.Id)).ElementMap().Next()

返回:

Creating Session based connection
Connecting.
result{object=v[%!s(int64=16576)] class=*gremlingo.Vertex}
v[%!s(int64=16576)]
16576
2023/01/10 11:49:46 Error occurred during operation gremlinServerWSProtocol.readLoop(): 'E0408: unknown data type to deserialize 0x0'
2023/01/10 11:49:46 Read loop error 'E0408: unknown data type to deserialize 0x0', closing read loop.
2023/01/10 11:49:46 Connection error callback invoked, closing protocol.
2023/01/10 11:49:46 Connecting.
E0903: there are no results left
2023/01/10 11:49:47 Closing DriverRemoteConnection with url 'ws://janusgraph:8182/gremlin' with session '3071a486-6649-4f05-8baa-9603163936a3'
2023/01/10 11:49:47 Closing Client with url 'ws://janusgraph:8182/gremlin'
2023/01/10 11:49:47 Closing the connection.

通过gremlin-控制台获得预期结果:

gremlin> g.addE("e").property("some_property", "some-property").from(__.V(24776)).to(__.V(24776)).next()
==>e[8bd-j48-q39-j48][24776-e->24776]
gremlin> g.addE("e").property("some_property", "some-property").from(__.V(24776)).to(__.V(24776)).elementMap().next()
==>id=8pl-j48-q39-j48
==>label=e
==>IN={id=24776, label=v}
==>OUT={id=24776, label=v}
==>some_property=some-property

推荐答案

添加Edge将返回Edge,而JanusGraph使用特殊类型的RelationIdentifier作为Edge ID,这是Gremlin围棋驱动程序不支持的.这会导致E0408:未知数据类型反序列化0x0. 如果您只想在图形中创建一条边,一种解决方法是不在带有g.addE().from([...]).to([...]).none()的驱动程序中返回它. 更多细节将在https://issues.apache.org/jira/browse/TINKERPOP-2828分钟内公布.

Go相关问答推荐

如何在AWS SDK Go v2 STS上正确使用重试

golang 的通用 map 功能

如何存储来自异步Goroutine的返回值列表?

使用Digitorus/pdfsign在GO(Golang)中签署pdf文件

GO:如何指定类型约束,使S方法的参数类型与接收方的参数类型相同

如何模拟go的Elastic search SDK?

无法使用exec从管道中读取.Go中的命令

关于如何使用 Service Weaver 设置多个不同侦听器的问题

运行 Docker 容器 - X11 无法打开显示:0

无法使用带有 422 的 go-github 创建提交 - 更新不是快进

使用 unsafe.Pointer 将 struct point直接转换为另一个 struct 是否安全?

如果值为 false,gRPC 不返回布尔值

Go 的垃圾收集器在使用时删除 ZeroMQ 套接字

无法使用 gocsv 读取引用字段

Golang 构建多平台问题

Golang:隐式 struct 匹配

Golang:每个键具有多个值的映射

为什么 go-cmp Equal() 说 struct 不是完全相等的,即使所有字段都非常相等?

try 执行`go test ./... -v`时,Golang中有没有办法设置标志

Go http标准库中的内存泄漏?