MCPcopy Create free account
hub / github.com/apache/fory / writeMapStringFloat64

Function writeMapStringFloat64

go/fory/map_primitive.go:388–423  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
388func 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
426func readMapStringFloat64(ctx *ReadContext) map[string]float64 {

Callers 4

SerializeFunction · 0.85
WriteDataMethod · 0.85
WriteMethod · 0.85
WriteStringFloat64MapMethod · 0.85

Calls 6

writeStringFunction · 0.85
WriteUint8Method · 0.80
uint32Function · 0.50
uint8Function · 0.50
WriteVarUint32Method · 0.45
WriteFloat64Method · 0.45

Tested by

no test coverage detected