writeMapStringFloat64 writes map[string]float64 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]float64, hasGenerics bool)
| 386 | // writeMapStringFloat64 writes map[string]float64 using chunk protocol |
| 387 | // When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info |
| 388 | func writeMapStringFloat64(buf *ByteBuffer, m map[string]float64, hasGenerics bool) { |
| 389 | length := len(m) |
| 390 | buf.WriteVarUint32(uint32(length)) |
| 391 | if length == 0 { |
| 392 | return |
| 393 | } |
| 394 | |
| 395 | remaining := length |
| 396 | for remaining > 0 { |
| 397 | chunkSize := remaining |
| 398 | if chunkSize > MAX_CHUNK_SIZE { |
| 399 | chunkSize = MAX_CHUNK_SIZE |
| 400 | } |
| 401 | |
| 402 | if hasGenerics { |
| 403 | buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE) |
| 404 | buf.WriteUint8(uint8(chunkSize)) |
| 405 | } else { |
| 406 | buf.WriteUint8(0) |
| 407 | buf.WriteUint8(uint8(chunkSize)) |
| 408 | buf.WriteUint8(uint8(STRING)) // key type |
| 409 | buf.WriteUint8(uint8(FLOAT64)) // value type |
| 410 | } |
| 411 | |
| 412 | count := 0 |
| 413 | for k, v := range m { |
| 414 | writeString(buf, k) |
| 415 | buf.WriteFloat64(v) |
| 416 | count++ |
| 417 | if count >= chunkSize { |
| 418 | break |
| 419 | } |
| 420 | } |
| 421 | remaining -= chunkSize |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | // readMapStringFloat64 reads map[string]float64 using chunk protocol |
| 426 | func readMapStringFloat64(ctx *ReadContext) map[string]float64 { |
no test coverage detected