MCPcopy
hub / github.com/dgraph-io/badger / Encode

Method Encode

structs.go:85–92  ·  view source on GitHub ↗

Encode encodes the header into []byte. The provided []byte should be atleast 5 bytes. The function will panic if out []byte isn't large enough to hold all the values. The encoded header looks like +------+----------+------------+--------------+-----------+ | Meta | UserMeta | Key Length | Value Leng

(out []byte)

Source from the content-addressed store, hash-verified

83// | Meta | UserMeta | Key Length | Value Length | ExpiresAt |
84// +------+----------+------------+--------------+-----------+
85func (h header) Encode(out []byte) int {
86 out[0], out[1] = h.meta, h.userMeta
87 index := 2
88 index += binary.PutUvarint(out[index:], uint64(h.klen))
89 index += binary.PutUvarint(out[index:], uint64(h.vlen))
90 index += binary.PutUvarint(out[index:], h.expiresAt)
91 return index
92}
93
94// Decode decodes the given header from the provided byte slice.
95// Returns the number of bytes read.

Callers 7

encodeEntryMethod · 0.95
replayFunctionMethod · 0.45
writeToLSMMethod · 0.45
handleFlushTaskMethod · 0.45
FlushMethod · 0.45
handleRequestsMethod · 0.45
putValMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected