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

Function writeMapStringBool

go/fory/map_primitive.go:473–508  ·  view source on GitHub ↗

writeMapStringBool writes map[string]bool 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]bool, hasGenerics bool)

Source from the content-addressed store, hash-verified

471// writeMapStringBool writes map[string]bool using chunk protocol
472// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
473func writeMapStringBool(buf *ByteBuffer, m map[string]bool, hasGenerics bool) {
474 length := len(m)
475 buf.WriteVarUint32(uint32(length))
476 if length == 0 {
477 return
478 }
479
480 remaining := length
481 for remaining > 0 {
482 chunkSize := remaining
483 if chunkSize > MAX_CHUNK_SIZE {
484 chunkSize = MAX_CHUNK_SIZE
485 }
486
487 if hasGenerics {
488 buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE)
489 buf.WriteUint8(uint8(chunkSize))
490 } else {
491 buf.WriteUint8(0)
492 buf.WriteUint8(uint8(chunkSize))
493 buf.WriteUint8(uint8(STRING)) // key type
494 buf.WriteUint8(uint8(BOOL)) // value type
495 }
496
497 count := 0
498 for k, v := range m {
499 writeString(buf, k)
500 buf.WriteBool(v)
501 count++
502 if count >= chunkSize {
503 break
504 }
505 }
506 remaining -= chunkSize
507 }
508}
509
510// readMapStringBool reads map[string]bool using chunk protocol
511func readMapStringBool(ctx *ReadContext) map[string]bool {

Callers 4

SerializeFunction · 0.85
WriteDataMethod · 0.85
WriteMethod · 0.85
WriteStringBoolMapMethod · 0.85

Calls 6

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

Tested by

no test coverage detected