MCPcopy Create free account
hub / github.com/HDT3213/rdb / readListPack

Method readListPack

core/listpack.go:11–32  ·  view source on GitHub ↗

readListPack returns: list of entry, list of entry size, error

()

Source from the content-addressed store, hash-verified

9
10// readListPack returns: list of entry, list of entry size, error
11func (dec *Decoder) readListPack() ([][]byte, []uint32, error) {
12 buf, err := dec.readString()
13 if err != nil {
14 return nil, nil, err
15 }
16 cursor := 0
17 size := readListPackLength(buf, &cursor)
18 entries := make([][]byte, 0, size)
19 entrySizes := make([]uint32, 0, size)
20 for i := 0; i < size; i++ {
21 str, intval, length, err := dec.readListPackEntry(buf, &cursor)
22 if err != nil {
23 return nil, nil, err
24 }
25 if str == nil {
26 str = []byte(strconv.FormatInt(intval, 10))
27 }
28 entries = append(entries, str)
29 entrySizes = append(entrySizes, length)
30 }
31 return entries, entrySizes, nil
32}
33
34func readListPackLength(buf []byte, cursor *int) int {
35 start := *cursor + 4

Callers 1

readQuickList2Method · 0.95

Calls 3

readStringMethod · 0.95
readListPackEntryMethod · 0.95
readListPackLengthFunction · 0.85

Tested by

no test coverage detected