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

Function readMapIntInt

go/fory/map_primitive.go:770–813  ·  view source on GitHub ↗

readMapIntInt reads map[int]int using chunk protocol

(ctx *ReadContext)

Source from the content-addressed store, hash-verified

768
769// readMapIntInt reads map[int]int using chunk protocol
770func readMapIntInt(ctx *ReadContext) map[int]int {
771 err := ctx.Err()
772 buf := ctx.Buffer()
773 size, ok := readTypedMapSize(ctx)
774 result := make(map[int]int)
775 if !ok {
776 return result
777 }
778 result = make(map[int]int, size)
779
780 for size > 0 {
781 chunkHeader := buf.ReadUint8(err)
782 if chunkHeader&(TRACKING_KEY_REF|KEY_HAS_NULL|TRACKING_VALUE_REF|VALUE_HAS_NULL) != 0 {
783 ctx.SetError(DeserializationError("typed map reader does not support ref/null chunks"))
784 return result
785 }
786
787 chunkSize := int(buf.ReadUint8(err))
788 if ctx.HasError() {
789 return result
790 }
791 if chunkSize == 0 || chunkSize > size {
792 ctx.SetError(DeserializationErrorf("invalid map chunk size %d for remaining length %d", chunkSize, size))
793 return result
794 }
795 if (chunkHeader & KEY_DECL_TYPE) == 0 {
796 if !ctx.readExpectedTypeID(VARINT64) {
797 return result
798 }
799 }
800 if (chunkHeader & VALUE_DECL_TYPE) == 0 {
801 if !ctx.readExpectedTypeID(VARINT64) {
802 return result
803 }
804 }
805 for i := 0; i < chunkSize; i++ {
806 k := buf.ReadVarint64(err)
807 v := buf.ReadVarint64(err)
808 result[int(k)] = int(v)
809 size--
810 }
811 }
812 return result
813}
814
815// ============================================================================
816// Dedicated map serializers

Callers 2

ReadIntIntMapMethod · 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