本文整理匯總了Golang中github.com/dgraph-io/dgraph/posting.List類的典型用法代碼示例。如果您正苦於以下問題:Golang List類的具體用法?Golang List怎麽用?Golang List使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了List類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: assignNew
func assignNew(pl *posting.List, xid string, instanceIdx uint64,
numInstances uint64) (uint64, error) {
entry := lmgr.newOrExisting(xid)
entry.Lock()
entry.ts = time.Now()
defer entry.Unlock()
if pl.Length() > 1 {
glog.Fatalf("We shouldn't have more than 1 uid for xid: %v\n", xid)
} else if pl.Length() > 0 {
var p types.Posting
if ok := pl.Get(&p, 0); !ok {
return 0, errors.New("While retrieving entry from posting list.")
}
return p.Uid(), nil
}
// No current id exists. Create one.
uid, err := allocateUniqueUid(xid, instanceIdx, numInstances)
if err != nil {
return 0, err
}
t := x.DirectedEdge{
ValueId: uid,
Source: "_assigner_",
Timestamp: time.Now(),
}
rerr := pl.AddMutation(t, posting.Set)
return uid, rerr
}
示例2: delEdge
func delEdge(t *testing.T, edge *task.DirectedEdge, l *posting.List) {
require.NoError(t,
l.AddMutationWithIndex(context.Background(), edge, posting.Del))
}
示例3: addEdge
func addEdge(t *testing.T, edge x.DirectedEdge, l *posting.List) {
if err := l.AddMutation(edge, posting.Set); err != nil {
t.Error(err)
}
}