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

Function readMapStringInt64

go/fory/map_primitive.go:171–214  ·  view source on GitHub ↗

readMapStringInt64 reads map[string]int64 using chunk protocol

(ctx *ReadContext)

Source from the content-addressed store, hash-verified

169
170// readMapStringInt64 reads map[string]int64 using chunk protocol
171func readMapStringInt64(ctx *ReadContext) map[string]int64 {
172 err := ctx.Err()
173 buf := ctx.Buffer()
174 size, ok := readTypedMapSize(ctx)
175 result := make(map[string]int64)
176 if !ok {
177 return result
178 }
179 result = make(map[string]int64, size)
180
181 for size > 0 {
182 chunkHeader := buf.ReadUint8(err)
183 if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 {
184 ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks"))
185 return result
186 }
187
188 chunkSize := int(buf.ReadUint8(err))
189 if ctx.HasError() {
190 return result
191 }
192 if chunkSize == 0 || chunkSize > size {
193 ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size))
194 return result
195 }
196 if (chunkHeader & KEY_DECL_TYPE) == 0 {
197 if !ctx.readExpectedTypeID(STRING) {
198 return result
199 }
200 }
201 if (chunkHeader & VALUE_DECL_TYPE) == 0 {
202 if !ctx.readExpectedTypeID(VARINT64) {
203 return result
204 }
205 }
206 for i := 0; i < chunkSize; i++ {
207 k := readString(buf, err)
208 v := buf.ReadVarint64(err)
209 result[k] = v
210 size--
211 }
212 }
213 return result
214}
215
216// writeMapStringInt32 writes map[string]int32 using chunk protocol
217// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info

Callers 2

ReadStringInt64MapMethod · 0.85
ReadDataMethod · 0.85

Calls 11

readTypedMapSizeFunction · 0.85
DeserializationErrorFunction · 0.85
DeserializationErrorfFunction · 0.85
readStringFunction · 0.85
ReadUint8Method · 0.80
readExpectedTypeIDMethod · 0.80
ErrMethod · 0.45
BufferMethod · 0.45
SetErrorMethod · 0.45
HasErrorMethod · 0.45
ReadVarint64Method · 0.45

Tested by

no test coverage detected