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)
| 1518 | // MarshalPostingList returns a KV with the marshalled posting list. The caller |
| 1519 | // SHOULD SET the Key and Version for the returned KV. |
| 1520 | func 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 | |
| 1544 | const blockSize int = 256 |
| 1545 |
no test coverage detected