readMapStringInt64 reads map[string]int64 using chunk protocol
(ctx *ReadContext)
| 169 | |
| 170 | // readMapStringInt64 reads map[string]int64 using chunk protocol |
| 171 | func 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 |
no test coverage detected