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

Function convertWithBestEffort

query/query.go:425–439  ·  view source on GitHub ↗

convert from task.Val to types.Value, based on schema appropriate type is already set in api.Value

(tv *pb.TaskValue, attr string)

Source from the content-addressed store, hash-verified

423// convert from task.Val to types.Value, based on schema appropriate type
424// is already set in api.Value
425func convertWithBestEffort(tv *pb.TaskValue, attr string) (types.Val, error) {
426 // value would be in binary format with appropriate type
427 tid := types.TypeID(tv.ValType)
428 if !tid.IsScalar() {
429 return types.Val{}, errors.Errorf("Leaf predicate:'%v' must be a scalar.", attr)
430 }
431
432 // creates appropriate type from binary format
433 sv, err := types.Convert(types.Val{Tid: types.BinaryID, Value: tv.Val}, tid)
434 if err != nil {
435 // This can happen when a mutation ingests corrupt data into the database.
436 return types.Val{}, errors.Wrapf(err, "error interpreting appropriate type for %v", attr)
437 }
438 return sv, nil
439}
440
441func mathCopy(dst *mathTree, src *dql.MathTree) error {
442 // Either we'll have an operation specified, or the function specified.

Callers 4

populateUidValVarMethod · 0.85
aggregateGroupFunction · 0.85
preTraverseMethod · 0.85
rdfForValueListMethod · 0.85

Calls 4

TypeIDTypeAlias · 0.92
ConvertFunction · 0.92
IsScalarMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected