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

Method decodeEntry

value.go:151–172  ·  view source on GitHub ↗
(buf []byte, offset uint32)

Source from the content-addressed store, hash-verified

149}
150
151func (lf *logFile) decodeEntry(buf []byte, offset uint32) (*Entry, error) {
152 var h header
153 hlen := h.Decode(buf)
154 kv := buf[hlen:]
155 if lf.encryptionEnabled() {
156 var err error
157 // No need to worry about mmap. because, XORBlock allocates a byte array to do the
158 // xor. So, the given slice is not being mutated.
159 if kv, err = lf.decryptKV(kv, offset); err != nil {
160 return nil, err
161 }
162 }
163 e := &Entry{
164 meta: h.meta,
165 UserMeta: h.userMeta,
166 ExpiresAt: h.expiresAt,
167 offset: offset,
168 Key: kv[:h.klen],
169 Value: kv[h.klen : h.klen+h.vlen],
170 }
171 return e, nil
172}
173
174func (lf *logFile) decryptKV(buf []byte, offset uint32) ([]byte, error) {
175 return y.XORBlock(buf, lf.dataKey.Data, lf.generateIV(offset))

Callers 3

doRunGCMethod · 0.80
TestValueBasicFunction · 0.80
BenchmarkReadWriteFunction · 0.80

Calls 3

DecodeMethod · 0.95
encryptionEnabledMethod · 0.95
decryptKVMethod · 0.95

Tested by 2

TestValueBasicFunction · 0.64
BenchmarkReadWriteFunction · 0.64