writeMapInt64Int64 writes map[int64]int64 using chunk protocol When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
(buf *ByteBuffer, m map[int64]int64, hasGenerics bool)
| 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 |
| 647 | func writeMapInt64Int64(buf *ByteBuffer, m map[int64]int64, hasGenerics bool) { |
| 648 | length := len(m) |
| 649 | buf.WriteVarUint32(uint32(length)) |
| 650 | if length == 0 { |
| 651 | return |
| 652 | } |
| 653 | |
| 654 | remaining := length |
| 655 | for remaining > 0 { |
| 656 | chunkSize := remaining |
| 657 | if chunkSize > MAX_CHUNK_SIZE { |
| 658 | chunkSize = MAX_CHUNK_SIZE |
| 659 | } |
| 660 | |
| 661 | if hasGenerics { |
| 662 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 663 | buf.WriteUint8(uint8(chunkSize)) |
| 664 | } else { |
| 665 | buf.WriteUint8(0) |
| 666 | buf.WriteUint8(uint8(chunkSize)) |
| 667 | buf.WriteUint8(uint8(VARINT64)) // key type |
| 668 | buf.WriteUint8(uint8(VARINT64)) // value type |
| 669 | } |
| 670 | |
| 671 | count := 0 |
| 672 | for k, v := range m { |
| 673 | buf.WriteVarint64(k) |
| 674 | buf.WriteVarint64(v) |
| 675 | count++ |
| 676 | if count >= chunkSize { |
| 677 | break |
| 678 | } |
| 679 | } |
| 680 | remaining -= chunkSize |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | // readMapInt64Int64 reads map[int64]int64 using chunk protocol |
| 685 | func readMapInt64Int64(ctx *ReadContext) map[int64]int64 { |
no test coverage detected