readMapInt64Int64 reads map[int64]int64 using chunk protocol
(ctx *ReadContext)
| 683 | |
| 684 | // readMapInt64Int64 reads map[int64]int64 using chunk protocol |
| 685 | func readMapInt64Int64(ctx *ReadContext) map[int64]int64 { |
| 686 | err := ctx.Err() |
| 687 | buf := ctx.Buffer() |
| 688 | size, ok := readTypedMapSize(ctx) |
| 689 | result := make(map[int64]int64) |
| 690 | if !ok { |
| 691 | return result |
| 692 | } |
| 693 | result = make(map[int64]int64, size) |
| 694 | |
| 695 | for size > 0 { |
| 696 | chunkHeader := buf.ReadUint8(err) |
| 697 | if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 { |
| 698 | ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks")) |
| 699 | return result |
| 700 | } |
| 701 | |
| 702 | chunkSize := int(buf.ReadUint8(err)) |
| 703 | if ctx.HasError() { |
| 704 | return result |
| 705 | } |
| 706 | if chunkSize == 0 || chunkSize > size { |
| 707 | ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size)) |
| 708 | return result |
| 709 | } |
| 710 | if (chunkHeader & KEY_DECL_TYPE) == 0 { |
| 711 | if !ctx.readExpectedTypeID(VARINT64) { |
| 712 | return result |
| 713 | } |
| 714 | } |
| 715 | if (chunkHeader & VALUE_DECL_TYPE) == 0 { |
| 716 | if !ctx.readExpectedTypeID(VARINT64) { |
| 717 | return result |
| 718 | } |
| 719 | } |
| 720 | for i := 0; i < chunkSize; i++ { |
| 721 | k := buf.ReadVarint64(err) |
| 722 | v := buf.ReadVarint64(err) |
| 723 | result[k] = v |
| 724 | size-- |
| 725 | } |
| 726 | } |
| 727 | return result |
| 728 | } |
| 729 | |
| 730 | // writeMapIntInt writes map[int]int using chunk protocol |
| 731 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
no test coverage detected