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

Method ToEdgeUsing

dql/mutation.go:170–200  ·  view source on GitHub ↗

ToEdgeUsing determines the UIDs for the provided XIDs and populates the xidToUid map.

(newToUid map[string]uint64)

Source from the content-addressed store, hash-verified

168// ToEdgeUsing determines the UIDs for the provided XIDs and populates the
169// xidToUid map.
170func (nq NQuad) ToEdgeUsing(newToUid map[string]uint64) (*pb.DirectedEdge, error) {
171 var edge *pb.DirectedEdge
172 sUid, err := toUid(nq.Subject, newToUid)
173 if err != nil {
174 return nil, err
175 }
176
177 if sUid == 0 {
178 return nil, errors.Errorf("Subject should be > 0 for nquad: %+v", nq)
179 }
180
181 switch nq.valueType() {
182 case x.ValueUid:
183 oUid, err := toUid(nq.ObjectId, newToUid)
184 if err != nil {
185 return nil, err
186 }
187 if oUid == 0 {
188 return nil, errors.Errorf("ObjectId should be > 0 for nquad: %+v", nq)
189 }
190 edge = nq.CreateUidEdge(sUid, oUid)
191 case x.ValuePlain, x.ValueMulti:
192 edge, err = nq.CreateValueEdge(sUid)
193 default:
194 return &emptyEdge, errors.Errorf("Unknown value type for nquad: %+v", nq)
195 }
196 if err != nil {
197 return nil, err
198 }
199 return edge, nil
200}
201
202func copyValue(out *pb.DirectedEdge, nq NQuad) error {
203 var err error

Callers 2

populateGraphExportFunction · 0.95
ToDirectedEdgesFunction · 0.95

Calls 5

valueTypeMethod · 0.95
CreateUidEdgeMethod · 0.95
CreateValueEdgeMethod · 0.95
toUidFunction · 0.85
ErrorfMethod · 0.45

Tested by 1

populateGraphExportFunction · 0.76