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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]