MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / decodeCompatInt64

Function decodeCompatInt64

hintfile.go:332–351  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

330}
331
332func decodeCompatInt64(buf []byte) (int64, int, error) {
333 if len(buf) == 0 {
334 return 0, 0, ErrHintFileCorrupted
335 }
336 fileID, n := binary.Varint(buf)
337 if n > 0 {
338 var encoded [binary.MaxVarintLen64]byte
339 m := binary.PutVarint(encoded[:], fileID)
340 if n == m && bytes.Equal(buf[:n], encoded[:m]) {
341 return fileID, n, nil
342 }
343 }
344
345 uval, n2 := binary.Uvarint(buf)
346 if n2 > 0 {
347 return int64(uval), n2, nil
348 }
349
350 return 0, 0, ErrHintFileCorrupted
351}
352
353func readCompatInt64(r *bufio.Reader, fieldsRead *int) (int64, error) {
354 var scratch [binary.MaxVarintLen64]byte

Callers 2

DecodeMethod · 0.85
readCompatInt64Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected