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

Function readMapInt64Int64

go/fory/map_primitive.go:685–728  ·  view source on GitHub ↗

readMapInt64Int64 reads map[int64]int64 using chunk protocol

(ctx *ReadContext)

Source from the content-addressed store, hash-verified

683
684// readMapInt64Int64 reads map[int64]int64 using chunk protocol
685func readMapInt64Int64(ctx *ReadContext) map[int64]int64 {
686 err := ctx.Err()
687 buf := ctx.Buffer()
688 size, ok := readTypedMapSize(ctx)
689 result := make(map[int64]int64)
690 if !ok {
691 return result
692 }
693 result = make(map[int64]int64, size)
694
695 for size > 0 {
696 chunkHeader := buf.ReadUint8(err)
697 if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 {
698 ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks"))
699 return result
700 }
701
702 chunkSize := int(buf.ReadUint8(err))
703 if ctx.HasError() {
704 return result
705 }
706 if chunkSize == 0 || chunkSize > size {
707 ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size))
708 return result
709 }
710 if (chunkHeader & KEY_DECL_TYPE) == 0 {
711 if !ctx.readExpectedTypeID(VARINT64) {
712 return result
713 }
714 }
715 if (chunkHeader & VALUE_DECL_TYPE) == 0 {
716 if !ctx.readExpectedTypeID(VARINT64) {
717 return result
718 }
719 }
720 for i := 0; i < chunkSize; i++ {
721 k := buf.ReadVarint64(err)
722 v := buf.ReadVarint64(err)
723 result[k] = v
724 size--
725 }
726 }
727 return result
728}
729
730// writeMapIntInt writes map[int]int using chunk protocol
731// When hasGenerics=true, element types are known so we set DECL_TYPE flags and skip type info

Callers 2

ReadInt64Int64MapMethod · 0.85
ReadDataMethod · 0.85

Calls 10

readTypedMapSizeFunction · 0.85
DeserializationErrorFunction · 0.85
DeserializationErrorfFunction · 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