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

Function ApplyMutations

query/mutation.go:28–49  ·  view source on GitHub ↗

ApplyMutations performs the required edge expansions and forwards the results to the worker to perform the mutations.

(ctx context.Context, m *pb.Mutations)

Source from the content-addressed store, hash-verified

26// ApplyMutations performs the required edge expansions and forwards the results to the
27// worker to perform the mutations.
28func ApplyMutations(ctx context.Context, m *pb.Mutations) (*api.TxnContext, error) {
29 // In expandEdges, for non * type prredicates, we prepend the namespace directly and for
30 // * type predicates, we fetch the predicates and prepend the namespace.
31 edges, err := ExpandEdges(ctx, m)
32 if err != nil {
33 return nil, errors.Wrapf(err, "While adding pb.edges")
34 }
35 m.Edges = edges
36
37 err = checkIfDeletingAclOperation(ctx, m.Edges)
38 if err != nil {
39 return nil, err
40 }
41 tctx, err := worker.MutateOverNetwork(ctx, m)
42 if err != nil {
43 span := trace.SpanFromContext(ctx)
44 span.AddEvent("MutateOverNetwork Error", trace.WithAttributes(
45 attribute.String("error", err.Error()),
46 attribute.String("mutation", m.String())))
47 }
48 return tctx, err
49}
50
51func ExpandEdges(ctx context.Context, m *pb.Mutations) ([]*pb.DirectedEdge, error) {
52 edges := make([]*pb.DirectedEdge, 0, 2*len(m.Edges))

Callers 3

alterMethod · 0.92
doMutateMethod · 0.92

Calls 5

MutateOverNetworkFunction · 0.92
ExpandEdgesFunction · 0.85
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected