MCPcopy Create free account
hub / github.com/IBM/sarama / decode

Method decode

offset_fetch_request.go:167–272  ·  view source on GitHub ↗
(pd packetDecoder, version int16)

Source from the content-addressed store, hash-verified

165}
166
167func (r *OffsetFetchRequest) decode(pd packetDecoder, version int16) (err error) {
168 r.Version = version
169
170 if r.Version >= 8 {
171 groupCount, err := pd.getArrayLength()
172 if err != nil {
173 return err
174 }
175 if groupCount < 0 {
176 return errInvalidArrayLength
177 }
178 if groupCount > 0 {
179 r.Groups = make([]OffsetFetchRequestGroup, groupCount)
180 }
181 for i := range groupCount {
182 groupID, err := pd.getString()
183 if err != nil {
184 return err
185 }
186 r.Groups[i].GroupId = groupID
187
188 // peek first byte to distinguish null (0x00) from empty (0x01)
189 topicCountMarker, err := pd.peekInt8(0)
190 if err != nil {
191 return err
192 }
193 topicCount, err := pd.getArrayLength()
194 if err != nil {
195 return err
196 }
197 if topicCountMarker != 0 {
198 partitions := make(map[string][]int32, topicCount)
199 for range topicCount {
200 topic, err := pd.getString()
201 if err != nil {
202 return err
203 }
204 ps, err := pd.getInt32Array()
205 if err != nil {
206 return err
207 }
208 if _, err := pd.getEmptyTaggedFieldArray(); err != nil {
209 return err
210 }
211 partitions[topic] = ps
212 }
213 r.Groups[i].Partitions = partitions
214 }
215
216 if _, err := pd.getEmptyTaggedFieldArray(); err != nil {
217 return err
218 }
219 }
220
221 r.RequireStable, err = pd.getBool()
222 if err != nil {
223 return err
224 }

Callers

nothing calls this directly

Calls 6

getArrayLengthMethod · 0.65
getStringMethod · 0.65
peekInt8Method · 0.65
getInt32ArrayMethod · 0.65
getBoolMethod · 0.65

Tested by

no test coverage detected