writeMapStringInt64 writes map[string]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[string]int64, hasGenerics bool)
| 131 | // writeMapStringInt64 writes map[string]int64 using chunk protocol |
| 132 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
| 133 | func writeMapStringInt64(buf *ByteBuffer, m map[string]int64, hasGenerics bool) { |
| 134 | length := len(m) |
| 135 | buf.WriteVarUint32(uint32(length)) |
| 136 | if length == 0 { |
| 137 | return |
| 138 | } |
| 139 | |
| 140 | remaining := length |
| 141 | for remaining > 0 { |
| 142 | chunkSize := remaining |
| 143 | if chunkSize > MAX_CHUNK_SIZE { |
| 144 | chunkSize = MAX_CHUNK_SIZE |
| 145 | } |
| 146 | |
| 147 | if hasGenerics { |
| 148 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 149 | buf.WriteUint8(uint8(chunkSize)) |
| 150 | } else { |
| 151 | buf.WriteUint8(0) |
| 152 | buf.WriteUint8(uint8(chunkSize)) |
| 153 | buf.WriteUint8(uint8(STRING)) // key type |
| 154 | buf.WriteUint8(uint8(VARINT64)) // value type |
| 155 | } |
| 156 | |
| 157 | count := 0 |
| 158 | for k, v := range m { |
| 159 | writeString(buf, k) |
| 160 | buf.WriteVarint64(v) |
| 161 | count++ |
| 162 | if count >= chunkSize { |
| 163 | break |
| 164 | } |
| 165 | } |
| 166 | remaining -= chunkSize |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // readMapStringInt64 reads map[string]int64 using chunk protocol |
| 171 | func readMapStringInt64(ctx *ReadContext) map[string]int64 { |
no test coverage detected