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

Function writeMapInt64Int64

go/fory/map_primitive.go:647–682  ·  view source on GitHub ↗

writeMapInt64Int64 writes map[int64]int64 using chunk protocol When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info

(buf *ByteBuffer, m map[int64]int64, hasGenerics bool)

Source from the content-addressed store, hash-verified

645// writeMapInt64Int64 writes map[int64]int64 using chunk protocol
646// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
647func writeMapInt64Int64(buf *ByteBuffer, m map[int64]int64, hasGenerics bool) {
648 length := len(m)
649 buf.WriteVarUint32(uint32(length))
650 if length == 0 {
651 return
652 }
653
654 remaining := length
655 for remaining > 0 {
656 chunkSize := remaining
657 if chunkSize > MAX_CHUNK_SIZE {
658 chunkSize = MAX_CHUNK_SIZE
659 }
660
661 if hasGenerics {
662 buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE)
663 buf.WriteUint8(uint8(chunkSize))
664 } else {
665 buf.WriteUint8(0)
666 buf.WriteUint8(uint8(chunkSize))
667 buf.WriteUint8(uint8(VARINT64)) // key type
668 buf.WriteUint8(uint8(VARINT64)) // value type
669 }
670
671 count := 0
672 for k, v := range m {
673 buf.WriteVarint64(k)
674 buf.WriteVarint64(v)
675 count++
676 if count >= chunkSize {
677 break
678 }
679 }
680 remaining -= chunkSize
681 }
682}
683
684// readMapInt64Int64 reads map[int64]int64 using chunk protocol
685func readMapInt64Int64(ctx *ReadContext) map[int64]int64 {

Callers 4

SerializeFunction · 0.85
WriteDataMethod · 0.85
WriteMethod · 0.85
WriteInt64Int64MapMethod · 0.85

Calls 5

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

Tested by

no test coverage detected