github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/convert/pprof/streaming/vt_label.go (about) 1 package streaming 2 3 import ( 4 "fmt" 5 "io" 6 ) 7 8 // revive:disable-next-line:cognitive-complexity,cyclomatic necessary complexity 9 func UnmarshalVTLabel(dAtA []byte) (uint64, error) { 10 k := int64(0) 11 v := int64(0) 12 13 l := len(dAtA) 14 iNdEx := 0 15 for iNdEx < l { 16 //preIndex := iNdEx 17 var wire uint64 18 for shift := uint(0); ; shift += 7 { 19 if shift >= 64 { 20 return 0, ErrIntOverflow 21 } 22 if iNdEx >= l { 23 return 0, io.ErrUnexpectedEOF 24 } 25 b := dAtA[iNdEx] 26 iNdEx++ 27 wire |= uint64(b&0x7F) << shift 28 if b < 0x80 { 29 break 30 } 31 } 32 fieldNum := int32(wire >> 3) 33 wireType := int(wire & 0x7) 34 if wireType == 4 { 35 return 0, fmt.Errorf("proto: Label: wiretype end group for non-group") 36 } 37 if fieldNum <= 0 { 38 return 0, fmt.Errorf("proto: Label: illegal tag %d (wire type %d)", fieldNum, wire) 39 } 40 switch fieldNum { 41 case 1: 42 if wireType != 0 { 43 return 0, fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) 44 } 45 k = 0 46 for shift := uint(0); ; shift += 7 { 47 if shift >= 64 { 48 return 0, ErrIntOverflow 49 } 50 if iNdEx >= l { 51 return 0, io.ErrUnexpectedEOF 52 } 53 b := dAtA[iNdEx] 54 iNdEx++ 55 k |= int64(b&0x7F) << shift 56 if b < 0x80 { 57 break 58 } 59 } 60 case 2: 61 if wireType != 0 { 62 return 0, fmt.Errorf("proto: wrong wireType = %d for field Str", wireType) 63 } 64 v = 0 65 for shift := uint(0); ; shift += 7 { 66 if shift >= 64 { 67 return 0, ErrIntOverflow 68 } 69 if iNdEx >= l { 70 return 0, io.ErrUnexpectedEOF 71 } 72 b := dAtA[iNdEx] 73 iNdEx++ 74 v |= int64(b&0x7F) << shift 75 if b < 0x80 { 76 break 77 } 78 } 79 case 3: 80 if wireType != 0 { 81 return 0, fmt.Errorf("proto: wrong wireType = %d for field Num", wireType) 82 } 83 //m.Num = 0 84 for shift := uint(0); ; shift += 7 { 85 if shift >= 64 { 86 return 0, ErrIntOverflow 87 } 88 if iNdEx >= l { 89 return 0, io.ErrUnexpectedEOF 90 } 91 b := dAtA[iNdEx] 92 iNdEx++ 93 //m.Num |= int64(b&0x7F) << shift 94 if b < 0x80 { 95 break 96 } 97 } 98 case 4: 99 if wireType != 0 { 100 return 0, fmt.Errorf("proto: wrong wireType = %d for field NumUnit", wireType) 101 } 102 //m.NumUnit = 0 103 for shift := uint(0); ; shift += 7 { 104 if shift >= 64 { 105 return 0, ErrIntOverflow 106 } 107 if iNdEx >= l { 108 return 0, io.ErrUnexpectedEOF 109 } 110 b := dAtA[iNdEx] 111 iNdEx++ 112 //m.NumUnit |= int64(b&0x7F) << shift 113 if b < 0x80 { 114 break 115 } 116 } 117 default: 118 return 0, ErrUnknownField 119 } 120 } 121 122 if iNdEx > l { 123 return 0, io.ErrUnexpectedEOF 124 } 125 return uint64(k<<32 | v), nil 126 }