ToDeletePredEdge takes an NQuad of the form '* p *' and returns the equivalent directed edge. Returns an error if the NQuad does not have the expected form.
()
| 144 | // ToDeletePredEdge takes an NQuad of the form '* p *' and returns the equivalent |
| 145 | // directed edge. Returns an error if the NQuad does not have the expected form. |
| 146 | func (nq NQuad) ToDeletePredEdge() (*pb.DirectedEdge, error) { |
| 147 | if nq.Subject != x.Star && nq.ObjectValue.String() != x.Star { |
| 148 | return &emptyEdge, errors.Errorf("Subject and object both should be *. Got: %+v", nq) |
| 149 | } |
| 150 | |
| 151 | out := &pb.DirectedEdge{ |
| 152 | // This along with edge.ObjectValue == x.Star would indicate |
| 153 | // that we want to delete the predicate. |
| 154 | Entity: 0, |
| 155 | Attr: nq.Predicate, |
| 156 | Namespace: nq.Namespace, |
| 157 | Lang: nq.Lang, |
| 158 | Facets: nq.Facets, |
| 159 | Op: pb.DirectedEdge_DEL, |
| 160 | } |
| 161 | |
| 162 | if err := copyValue(out, nq); err != nil { |
| 163 | return &emptyEdge, err |
| 164 | } |
| 165 | return out, nil |
| 166 | } |
| 167 | |
| 168 | // ToEdgeUsing determines the UIDs for the provided XIDs and populates the |
| 169 | // xidToUid map. |