writeMapStringInt32 writes map[string]int32 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]int32, hasGenerics bool)
| 216 | // writeMapStringInt32 writes map[string]int32 using chunk protocol |
| 217 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
| 218 | func writeMapStringInt32(buf *ByteBuffer, m map[string]int32, hasGenerics bool) { |
| 219 | length := len(m) |
| 220 | buf.WriteVarUint32(uint32(length)) |
| 221 | if length == 0 { |
| 222 | return |
| 223 | } |
| 224 | |
| 225 | remaining := length |
| 226 | for remaining > 0 { |
| 227 | chunkSize := remaining |
| 228 | if chunkSize > MAX_CHUNK_SIZE { |
| 229 | chunkSize = MAX_CHUNK_SIZE |
| 230 | } |
| 231 | |
| 232 | if hasGenerics { |
| 233 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 234 | buf.WriteUint8(uint8(chunkSize)) |
| 235 | } else { |
| 236 | buf.WriteUint8(0) |
| 237 | buf.WriteUint8(uint8(chunkSize)) |
| 238 | buf.WriteUint8(uint8(STRING)) // key type |
| 239 | buf.WriteUint8(uint8(VARINT32)) // value type |
| 240 | } |
| 241 | |
| 242 | count := 0 |
| 243 | for k, v := range m { |
| 244 | writeString(buf, k) |
| 245 | buf.WriteVarint32(v) |
| 246 | count++ |
| 247 | if count >= chunkSize { |
| 248 | break |
| 249 | } |
| 250 | } |
| 251 | remaining -= chunkSize |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // readMapStringInt32 reads map[string]int32 using chunk protocol |
| 256 | func readMapStringInt32(ctx *ReadContext) map[string]int32 { |
no test coverage detected