在创建新的边并返回下一个结果时,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