MCPcopy
hub / github.com/dgraph-io/dgraph / TypeValFrom

Function TypeValFrom

dql/mutation.go:52–82  ·  view source on GitHub ↗
(val *api.Value)

Source from the content-addressed store, hash-verified

50}
51
52func TypeValFrom(val *api.Value) types.Val {
53 switch val.Val.(type) {
54 case *api.Value_BytesVal:
55 return types.Val{Tid: types.BinaryID, Value: val.GetBytesVal()}
56 case *api.Value_IntVal:
57 return types.Val{Tid: types.IntID, Value: val.GetIntVal()}
58 case *api.Value_StrVal:
59 return types.Val{Tid: types.StringID, Value: val.GetStrVal()}
60 case *api.Value_BoolVal:
61 return types.Val{Tid: types.BoolID, Value: val.GetBoolVal()}
62 case *api.Value_DoubleVal:
63 return types.Val{Tid: types.FloatID, Value: val.GetDoubleVal()}
64 case *api.Value_GeoVal:
65 return types.Val{Tid: types.GeoID, Value: val.GetGeoVal()}
66 case *api.Value_BigfloatVal:
67 return types.Val{Tid: types.BigFloatID, Value: val.GetBigfloatVal()}
68 case *api.Value_DatetimeVal:
69 return types.Val{Tid: types.DateTimeID, Value: val.GetDatetimeVal()}
70 case *api.Value_PasswordVal:
71 return types.Val{Tid: types.PasswordID, Value: val.GetPasswordVal()}
72 case *api.Value_Vfloat32Val:
73 return types.Val{
74 Tid: types.VFloatID,
75 Value: types.BytesAsFloatArray(val.GetVfloat32Val()),
76 }
77 case *api.Value_DefaultVal:
78 return types.Val{Tid: types.DefaultID, Value: val.GetDefaultVal()}
79 }
80
81 return types.Val{Tid: types.StringID, Value: ""}
82}
83
84func byteVal(nq NQuad) ([]byte, types.TypeID, error) {
85 // We infer object type from type of value. We set appropriate type in parse

Callers 5

verifyUniqueFunction · 0.92
addQueryIfUniqueFunction · 0.92
getTypeValFunction · 0.92
byteValFunction · 0.85

Calls 1

BytesAsFloatArrayFunction · 0.92

Tested by

no test coverage detected