readMapInt32Int32 reads map[int32]int32 using chunk protocol
(ctx *ReadContext)
| 598 | |
| 599 | // readMapInt32Int32 reads map[int32]int32 using chunk protocol |
| 600 | func readMapInt32Int32(ctx *ReadContext) map[int32]int32 { |
| 601 | err := ctx.Err() |
| 602 | buf := ctx.Buffer() |
| 603 | size, ok := readTypedMapSize(ctx) |
| 604 | result := make(map[int32]int32) |
| 605 | if !ok { |
| 606 | return result |
| 607 | } |
| 608 | result = make(map[int32]int32, size) |
| 609 | |
| 610 | for size > 0 { |
| 611 | chunkHeader := buf.ReadUint8(err) |
| 612 | if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 { |
| 613 | ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks")) |
| 614 | return result |
| 615 | } |
| 616 | |
| 617 | chunkSize := int(buf.ReadUint8(err)) |
| 618 | if ctx.HasError() { |
| 619 | return result |
| 620 | } |
| 621 | if chunkSize == 0 || chunkSize > size { |
| 622 | ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size)) |
| 623 | return result |
| 624 | } |
| 625 | if (chunkHeader & KEY_DECL_TYPE) == 0 { |
| 626 | if !ctx.readExpectedTypeID(VARINT32) { |
| 627 | return result |
| 628 | } |
| 629 | } |
| 630 | if (chunkHeader & VALUE_DECL_TYPE) == 0 { |
| 631 | if !ctx.readExpectedTypeID(VARINT32) { |
| 632 | return result |
| 633 | } |
| 634 | } |
| 635 | for i := 0; i < chunkSize; i++ { |
| 636 | k := buf.ReadVarint32(err) |
| 637 | v := buf.ReadVarint32(err) |
| 638 | result[k] = v |
| 639 | size-- |
| 640 | } |
| 641 | } |
| 642 | return result |
| 643 | } |
| 644 | |
| 645 | // writeMapInt64Int64 writes map[int64]int64 using chunk protocol |
| 646 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
no test coverage detected