MCPcopy Index your code
hub / github.com/HDT3213/rdb / readString

Method readString

core/string.go:81–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81func (dec *Decoder) readString() ([]byte, error) {
82 length, special, err := dec.readLength()
83 if err != nil {
84 return nil, err
85 }
86
87 if special {
88 switch length {
89 case encodeInt8:
90 b, err := dec.readByte()
91 return []byte(strconv.Itoa(int(int8(b)))), err
92 case encodeInt16:
93 b, err := dec.readInt16()
94 return []byte(strconv.Itoa(int(b))), err
95 case encodeInt32:
96 b, err := dec.readInt32()
97 return []byte(strconv.Itoa(int(b))), err
98 case encodeLZF:
99 return dec.readLZF()
100 default:
101 return []byte{}, errors.New("Unknown string encode type ")
102 }
103 }
104
105 res := make([]byte, length)
106 err = dec.readFull(res)
107 return res, err
108}
109
110func (dec *Decoder) readInt16() (int16, error) {
111 err := dec.readFull(dec.buffer[:2])

Callers 15

readObjectMethod · 0.95
parseMethod · 0.95
readSetMethod · 0.95
readIntSetMethod · 0.95
readListPackSetMethod · 0.95
readHashMapMethod · 0.95
readHashMapExMethod · 0.95
readHashMapExValkeyMethod · 0.95
readZipMapHashMethod · 0.95
readZipListHashMethod · 0.95
readListPackHashMethod · 0.95
readListPackHashExMethod · 0.95

Calls 6

readLengthMethod · 0.95
readByteMethod · 0.95
readInt16Method · 0.95
readInt32Method · 0.95
readLZFMethod · 0.95
readFullMethod · 0.95

Tested by 3

TestStringEncodingFunction · 0.76
TestRandomStringEncodingFunction · 0.76
TestLZFStringFunction · 0.76