[
https://issues.apache.org/jira/browse/TINKERPOP-2802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17748686#comment-17748686
]
ASF GitHub Bot commented on TINKERPOP-2802:
-------------------------------------------
vkagamlyk commented on code in PR #2174:
URL: https://github.com/apache/tinkerpop/pull/2174#discussion_r1277785633
##########
gremlin-go/driver/graphBinary.go:
##########
@@ -1282,6 +1284,78 @@ func metricsReader(data *[]byte, i *int) (interface{},
error) {
return metrics, nil
}
+type JanusgraphRelationIdentifier struct {
+ OutVertexIdLong int64
+ OutVertexIdString string
+ TypeId int64
+ RelationId int64
+ InVertexIdLong int64
+ InVertexIdString string
+}
+
+func janusgraphRelationIdentifierReader(data *[]byte, i *int) (interface{},
error) {
+ const (
+ relationIdentifierType uint32 = 0x1001
+ longMarker byte = 0
+ stringMarker byte = 1
+ )
+
+ r := new(JanusgraphRelationIdentifier)
+
+ // expect type code
+ customDataTyp := readUint32Safe(data, i)
+ if customDataTyp != relationIdentifierType {
+ return nil,
newError(err0408GetSerializerToReadUnknownTypeError, customDataTyp)
+ }
+
+ // value flag, expect this to be non-nullable
+ if readByteSafe(data, i) != valueFlagNone {
+ return nil, newError(err0405ReadValueInvalidNullInputError)
+ }
+
+ // outvertexid
+ if readByteSafe(data, i) == longMarker {
+ r.OutVertexIdLong = readLongSafe(data, i)
+ } else {
+ vertexId, err := readString(data, i)
+ if err != nil {
+ return nil, err
+ }
+ r.OutVertexIdString = vertexId.(string)
+ }
+
+ r.TypeId = readLongSafe(data, i)
+ r.RelationId = readLongSafe(data, i)
+
+ // invertexid
+ if readByteSafe(data, i) == longMarker {
+ r.InVertexIdLong = readLongSafe(data, i)
+ } else {
+ vertexId, err := readString(data, i)
+ if err != nil {
+ return nil, err
+ }
+ r.InVertexIdString = vertexId.(string)
+ }
+
+ return r, nil
+}
+
+// {name}{type specific payload}
+func customTypeReader(data *[]byte, i *int) (interface{}, error) {
+ // type name
+ *i = *i - 1
+ customTypeName, err := readString(data, i)
+ if err != nil {
+ return nil, err
+ }
+ deserializer, ok := customDeserializers[customTypeName.(string)]
Review Comment:
there is example of implementation of custom serializer for Java, looks like
a good starting point
https://github.com/apache/tinkerpop/blob/master/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/types/sample/SamplePersonSerializer.java
> Support Adding Custom Serializer for Gremlin Go
> -----------------------------------------------
>
> Key: TINKERPOP-2802
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2802
> Project: TinkerPop
> Issue Type: Improvement
> Components: go
> Affects Versions: 3.6.2
> Reporter: Yang Xia
> Priority: Major
>
> To enable mechanisms to add custom serializers in the Go driver, for
> compatibility with database specific types outside of TinkerPop, such as the
> JanusGraph RelationIdentifier.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)