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

Function writeMapInt32Int32

go/fory/map_primitive.go:562–597  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

560// writeMapInt32Int32 writes map[int32]int32 using chunk protocol
561// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
562func writeMapInt32Int32(buf *ByteBuffer, m map[int32]int32, hasGenerics bool) {
563 length := len(m)
564 buf.WriteVarUint32(uint32(length))
565 if length == 0 {
566 return
567 }
568
569 remaining := length
570 for remaining > 0 {
571 chunkSize := remaining
572 if chunkSize > MAX_CHUNK_SIZE {
573 chunkSize = MAX_CHUNK_SIZE
574 }
575
576 if hasGenerics {
577 buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE)
578 buf.WriteUint8(uint8(chunkSize))
579 } else {
580 buf.WriteUint8(0)
581 buf.WriteUint8(uint8(chunkSize))
582 buf.WriteUint8(uint8(VARINT32)) // key type
583 buf.WriteUint8(uint8(VARINT32)) // value type
584 }
585
586 count := 0
587 for k, v := range m {
588 buf.WriteVarint32(k)
589 buf.WriteVarint32(v)
590 count++
591 if count >= chunkSize {
592 break
593 }
594 }
595 remaining -= chunkSize
596 }
597}
598
599// readMapInt32Int32 reads map[int32]int32 using chunk protocol
600func readMapInt32Int32(ctx *ReadContext) map[int32]int32 {

Callers 4

SerializeFunction · 0.85
WriteDataMethod · 0.85
WriteMethod · 0.85
WriteInt32Int32MapMethod · 0.85

Calls 5

WriteUint8Method · 0.80
uint32Function · 0.50
uint8Function · 0.50
WriteVarUint32Method · 0.45
WriteVarint32Method · 0.45

Tested by

no test coverage detected