in gremlin-go/driver/graphBinary.go [683:779]
func (serializer *graphBinaryTypeSerializer) getType(val interface{}) (dataType, error) {
switch val.(type) {
case *Bytecode, Bytecode, *GraphTraversal:
return bytecodeType, nil
case string:
return stringType, nil
case uint, uint64, *big.Int:
return bigIntegerType, nil
case int64, int, uint32:
return longType, nil
case int32, uint16:
return intType, nil
case int8, int16: // GraphBinary doesn't have a type for signed 8-bit integer, serializing int8 as Short instead.
return shortType, nil
case uint8:
return byteType, nil
case bool:
return booleanType, nil
case uuid.UUID:
return uuidType, nil
case float32:
return floatType, nil
case float64:
return doubleType, nil
case *Vertex:
return vertexType, nil
case *Edge:
return edgeType, nil
case *Property:
return propertyType, nil
case *VertexProperty:
return vertexPropertyType, nil
case *Lambda:
return lambdaType, nil
case *traversalStrategy:
return traversalStrategyType, nil
case *Path:
return pathType, nil
case Set:
return setType, nil
case time.Time:
return offsetDateTimeType, nil // default serialization of Time will become OffsetDateTime
case time.Duration:
return durationType, nil
case cardinality:
return cardinalityType, nil
case column:
return columnType, nil
case direction:
return directionType, nil
case operator:
return operatorType, nil
case order:
return orderType, nil
case pick:
return pickType, nil
case pop:
return popType, nil
case t:
return tType, nil
case barrier:
return barrierType, nil
case scope:
return scopeType, nil
case merge:
return mergeType, nil
case dt:
return dtType, nil
case p, Predicate:
return pType, nil
case textP, TextPredicate:
return textPType, nil
case *Binding, Binding:
return bindingType, nil
case *BigDecimal, BigDecimal:
return bigDecimalType, nil
case *GremlinType, GremlinType:
return classType, nil
case *Metrics, Metrics:
return metricsType, nil
case *TraversalMetrics, TraversalMetrics:
return traversalMetricsType, nil
case *ByteBuffer, ByteBuffer:
return byteBuffer, nil
default:
switch reflect.TypeOf(val).Kind() {
case reflect.Map:
return mapType, nil
case reflect.Array, reflect.Slice:
// We can write an array or slice into the list dataType.
return listType, nil
default:
serializer.logHandler.logf(Error, serializeDataTypeError, reflect.TypeOf(val).Name())
return intType, newError(err0407GetSerializerToWriteUnknownTypeError, reflect.TypeOf(val).Name())
}
}
}