MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / convertValue

Function convertValue

worker/task.go:171–184  ·  view source on GitHub ↗

convertValue converts the data to the schema.State() type of predicate.

(attr, data string)

Source from the content-addressed store, hash-verified

169
170// convertValue converts the data to the schema.State() type of predicate.
171func convertValue(attr, data string) (types.Val, error) {
172 // Parse given value and get token. There should be only one token.
173 t, err := schema.State().TypeOf(attr)
174 if err != nil {
175 return types.Val{}, err
176 }
177 if !t.IsScalar() {
178 return types.Val{}, errors.Errorf("Attribute %s is not valid scalar type",
179 x.ParseAttr(attr))
180 }
181 src := types.Val{Tid: types.StringID, Value: []byte(data)}
182 dst, err := types.Convert(src, t)
183 return dst, err
184}
185
186// Returns nil byte on error
187func convertToType(v types.Val, typ types.TypeID) (*pb.TaskValue, error) {

Callers 1

parseSrcFnFunction · 0.85

Calls 6

StateFunction · 0.92
ParseAttrFunction · 0.92
ConvertFunction · 0.92
TypeOfMethod · 0.80
IsScalarMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected