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

Function populateKeyValues

worker/predicate_move.go:41–58  ·  view source on GitHub ↗

size of kvs won't be too big, we would take care before proposing.

(ctx context.Context, kvs []*bpb.KV)

Source from the content-addressed store, hash-verified

39
40// size of kvs won't be too big, we would take care before proposing.
41func populateKeyValues(ctx context.Context, kvs []*bpb.KV) error {
42 glog.Infof("Writing %d keys\n", len(kvs))
43 if len(kvs) == 0 {
44 return nil
45 }
46 writer := posting.NewTxnWriter(pstore)
47 if err := writer.Write(&bpb.KVList{Kv: kvs}); err != nil {
48 return err
49 }
50 if err := writer.Flush(); err != nil {
51 return err
52 }
53 pk, err := x.Parse(kvs[0].Key)
54 if err != nil {
55 return errors.Errorf("while parsing KV: %+v, got error: %v", kvs[0], err)
56 }
57 return schema.Load(pk.Attr)
58}
59
60func batchAndProposeKeyValues(ctx context.Context, kvs chan *pb.KVS) error {
61 glog.Infoln("Receiving predicate. Batching and proposing key values")

Callers 1

applyCommittedMethod · 0.85

Calls 7

WriteMethod · 0.95
FlushMethod · 0.95
NewTxnWriterFunction · 0.92
ParseFunction · 0.92
LoadFunction · 0.92
InfofMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected