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

Function readMapStringFloat64

go/fory/map_primitive.go:426–469  ·  view source on GitHub ↗

readMapStringFloat64 reads map[string]float64 using chunk protocol

(ctx *ReadContext)

Source from the content-addressed store, hash-verified

424
425// readMapStringFloat64 reads map[string]float64 using chunk protocol
426func readMapStringFloat64(ctx *ReadContext) map[string]float64 {
427 err := ctx.Err()
428 buf := ctx.Buffer()
429 size, ok := readTypedMapSize(ctx)
430 result := make(map[string]float64)
431 if !ok {
432 return result
433 }
434 result = make(map[string]float64, size)
435
436 for size > 0 {
437 chunkHeader := buf.ReadUint8(err)
438 if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 {
439 ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks"))
440 return result
441 }
442
443 chunkSize := int(buf.ReadUint8(err))
444 if ctx.HasError() {
445 return result
446 }
447 if chunkSize == 0 || chunkSize > size {
448 ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size))
449 return result
450 }
451 if (chunkHeader & KEY_DECL_TYPE) == 0 {
452 if !ctx.readExpectedTypeID(STRING) {
453 return result
454 }
455 }
456 if (chunkHeader & VALUE_DECL_TYPE) == 0 {
457 if !ctx.readExpectedTypeID(FLOAT64) {
458 return result
459 }
460 }
461 for i := 0; i < chunkSize; i++ {
462 k := readString(buf, err)
463 v := buf.ReadFloat64(err)
464 result[k] = v
465 size--
466 }
467 }
468 return result
469}
470
471// writeMapStringBool writes map[string]bool using chunk protocol
472// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info

Callers 2

ReadStringFloat64MapMethod · 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
ReadFloat64Method · 0.45

Tested by

no test coverage detected