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

Function writeMapStringInt64

go/fory/map_primitive.go:133–168  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

131// writeMapStringInt64 writes map[string]int64 using chunk protocol
132// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info
133func writeMapStringInt64(buf *ByteBuffer, m map[string]int64, hasGenerics bool) {
134 length := len(m)
135 buf.WriteVarUint32(uint32(length))
136 if length == 0 {
137 return
138 }
139
140 remaining := length
141 for remaining > 0 {
142 chunkSize := remaining
143 if chunkSize > MAX_CHUNK_SIZE {
144 chunkSize = MAX_CHUNK_SIZE
145 }
146
147 if hasGenerics {
148 buf.WriteUint8(KEY_DECL_TYPE | VALUE_DECL_TYPE)
149 buf.WriteUint8(uint8(chunkSize))
150 } else {
151 buf.WriteUint8(0)
152 buf.WriteUint8(uint8(chunkSize))
153 buf.WriteUint8(uint8(STRING)) // key type
154 buf.WriteUint8(uint8(VARINT64)) // value type
155 }
156
157 count := 0
158 for k, v := range m {
159 writeString(buf, k)
160 buf.WriteVarint64(v)
161 count++
162 if count >= chunkSize {
163 break
164 }
165 }
166 remaining -= chunkSize
167 }
168}
169
170// readMapStringInt64 reads map[string]int64 using chunk protocol
171func readMapStringInt64(ctx *ReadContext) map[string]int64 {

Callers 4

SerializeFunction · 0.85
WriteDataMethod · 0.85
WriteMethod · 0.85
WriteStringInt64MapMethod · 0.85

Calls 6

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

Tested by

no test coverage detected