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

Function MarshalPostingList

posting/list.go:1520–1542  ·  view source on GitHub ↗

MarshalPostingList returns a KV with the marshalled posting list. The caller SHOULD SET the Key and Version for the returned KV.

(plist *pb.PostingList, alloc *z.Allocator)

Source from the content-addressed store, hash-verified

1518// MarshalPostingList returns a KV with the marshalled posting list. The caller
1519// SHOULD SET the Key and Version for the returned KV.
1520func MarshalPostingList(plist *pb.PostingList, alloc *z.Allocator) *bpb.KV {
1521 x.VerifyPack(plist)
1522 kv := y.NewKV(alloc)
1523 if isPlistEmpty(plist) {
1524 kv.Value = nil
1525 kv.UserMeta = alloc.Copy([]byte{BitEmptyPosting})
1526 return kv
1527 }
1528 ref := plist.Pack.GetAllocRef()
1529 if plist.Pack != nil {
1530 // Set allocator to zero for marshal.
1531 plist.Pack.AllocRef = 0
1532 }
1533
1534 out, err := x.MarshalToSizedBuffer(alloc.Allocate(proto.Size(plist)), plist)
1535 x.Check(err)
1536 if plist.Pack != nil {
1537 plist.Pack.AllocRef = ref
1538 }
1539 kv.Value = out
1540 kv.UserMeta = alloc.Copy([]byte{BitCompletePosting})
1541 return kv
1542}
1543
1544const blockSize int = 256
1545

Callers 5

toListMethod · 0.92
writeIndexMethod · 0.92
processReqChMethod · 0.92
RollupMethod · 0.85

Calls 6

VerifyPackFunction · 0.92
MarshalToSizedBufferFunction · 0.92
CheckFunction · 0.92
isPlistEmptyFunction · 0.85
GetAllocRefMethod · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected