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

Function readMapStringBool

go/fory/map_primitive.go:511–558  ·  view source on GitHub ↗

readMapStringBool reads map[string]bool using chunk protocol

(ctx *ReadContext)

Source from the content-addressed store, hash-verified

509
510// readMapStringBool reads map[string]bool using chunk protocol
511func readMapStringBool(ctx *ReadContext) map[string]bool {
512 err := ctx.Err()
513 buf := ctx.Buffer()
514 size, ok := readTypedMapSize(ctx)
515 result := make(map[string]bool)
516 if !ok {
517 return result
518 }
519 result = make(map[string]bool, size)
520
521 for size > 0 {
522 chunkHeader := buf.ReadUint8(err)
523 if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 {
524 ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks"))
525 return result
526 }
527
528 chunkSize := int(buf.ReadUint8(err))
529 if ctx.HasError() {
530 return result
531 }
532 if chunkSize == 0 || chunkSize > size {
533 ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size))
534 return result
535 }
536
537 keyDeclType := (chunkHeader & KEY_DECL_TYPE) != 0
538 valDeclType := (chunkHeader & VALUE_DECL_TYPE) != 0
539 if !keyDeclType {
540 if !ctx.readExpectedTypeID(STRING) {
541 return result
542 }
543 }
544 if !valDeclType {
545 if !ctx.readExpectedTypeID(BOOL) {
546 return result
547 }
548 }
549
550 for i := 0; i < chunkSize; i++ {
551 k := readString(buf, err)
552 v := buf.ReadBool(err)
553 result[k] = v
554 size--
555 }
556 }
557 return result
558}
559
560// writeMapInt32Int32 writes map[int32]int32 using chunk protocol
561// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info

Callers 2

ReadStringBoolMapMethod · 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
ReadBoolMethod · 0.45

Tested by

no test coverage detected