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

Function marshalMapEntry

dgraph/cmd/bulk/mapper.go:86–105  ·  view source on GitHub ↗
(dst []byte, uid uint64, key []byte, p *pb.Posting)

Source from the content-addressed store, hash-verified

84}
85
86func marshalMapEntry(dst []byte, uid uint64, key []byte, p *pb.Posting) {
87 if p != nil {
88 uid = p.Uid
89 }
90 binary.BigEndian.PutUint64(dst[0:8], uid)
91 binary.BigEndian.PutUint32(dst[8:12], uint32(len(key)))
92
93 psz := proto.Size(p)
94 binary.BigEndian.PutUint32(dst[12:16], uint32(psz))
95
96 n := copy(dst[16:], key)
97
98 if psz > 0 {
99 pbuf := dst[16+n:]
100 _, err := x.MarshalToSizedBuffer(pbuf, p)
101 x.Check(err)
102 }
103
104 x.AssertTrue(len(dst) == 16+n+psz)
105}
106
107func (me MapEntry) Size() int {
108 return len(me)

Callers 1

addMapEntryMethod · 0.85

Calls 5

MarshalToSizedBufferFunction · 0.92
CheckFunction · 0.92
AssertTrueFunction · 0.92
copyFunction · 0.85
SizeMethod · 0.45

Tested by

no test coverage detected