MCPcopy Create free account
hub / github.com/apache/thrift / ReadMapBegin

Method ReadMapBegin

lib/go/thrift/json_protocol.go:287–328  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

285}
286
287func (p *TJSONProtocol) ReadMapBegin(ctx context.Context) (keyType TType, valueType TType, size int, e error) {
288 if isNull, e := p.ParseListBegin(); isNull || e != nil {
289 return VOID, VOID, 0, e
290 }
291
292 // read keyType
293 sKeyType, e := p.ReadString(ctx)
294 if e != nil {
295 return keyType, valueType, size, e
296 }
297 keyType, e = p.StringToTypeId(sKeyType)
298 if e != nil {
299 return keyType, valueType, size, e
300 }
301
302 // read valueType
303 sValueType, e := p.ReadString(ctx)
304 if e != nil {
305 return keyType, valueType, size, e
306 }
307 valueType, e = p.StringToTypeId(sValueType)
308 if e != nil {
309 return keyType, valueType, size, e
310 }
311
312 // read size
313 iSize, err := p.ReadI64(ctx)
314 if err != nil {
315 return keyType, valueType, size, err
316 }
317 size = int(iSize)
318
319 minElemSize := p.getMinSerializedSize(keyType) + p.getMinSerializedSize(valueType)
320 totalMinSize := int32(iSize) * minElemSize
321 err = checkSizeForProtocol(totalMinSize, p.cfg)
322 if err != nil {
323 return keyType, valueType, 0, err
324 }
325
326 _, e = p.ParseObjectStart()
327 return keyType, valueType, size, e
328}
329
330func (p *TJSONProtocol) ReadMapEnd(ctx context.Context) error {
331 e := p.ParseObjectEnd()

Callers 1

TestWriteJSONProtocolMapFunction · 0.95

Calls 7

ReadStringMethod · 0.95
StringToTypeIdMethod · 0.95
ReadI64Method · 0.95
getMinSerializedSizeMethod · 0.95
checkSizeForProtocolFunction · 0.85
ParseListBeginMethod · 0.80
ParseObjectStartMethod · 0.80

Tested by 1

TestWriteJSONProtocolMapFunction · 0.76