github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/kitex_gen/base/k-base.go (about)

     1  // Code generated by Kitex v0.0.3. DO NOT EDIT.
     2  
     3  package base
     4  
     5  import (
     6  	"bytes"
     7  	"fmt"
     8  	"reflect"
     9  	"strings"
    10  
    11  	"github.com/apache/thrift/lib/go/thrift"
    12  
    13  	"github.com/cloudwego/kitex/pkg/protocol/bthrift"
    14  )
    15  
    16  // unused protection
    17  var (
    18  	_ = fmt.Formatter(nil)
    19  	_ = (*bytes.Buffer)(nil)
    20  	_ = (*strings.Builder)(nil)
    21  	_ = reflect.Type(nil)
    22  	_ = thrift.TProtocol(nil)
    23  	_ = bthrift.BinaryWriter(nil)
    24  )
    25  
    26  func (p *TrafficEnv) FastRead(buf []byte) (int, error) {
    27  	var err error
    28  	var offset int
    29  	var l int
    30  	var fieldTypeId thrift.TType
    31  	var fieldId int16
    32  	_, l, err = bthrift.Binary.ReadStructBegin(buf)
    33  	offset += l
    34  	if err != nil {
    35  		goto ReadStructBeginError
    36  	}
    37  
    38  	for {
    39  		_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
    40  		offset += l
    41  		if err != nil {
    42  			goto ReadFieldBeginError
    43  		}
    44  		if fieldTypeId == thrift.STOP {
    45  			break
    46  		}
    47  		switch fieldId {
    48  		case 1:
    49  			if fieldTypeId == thrift.BOOL {
    50  				l, err = p.FastReadField1(buf[offset:])
    51  				offset += l
    52  				if err != nil {
    53  					goto ReadFieldError
    54  				}
    55  			} else {
    56  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
    57  				offset += l
    58  				if err != nil {
    59  					goto SkipFieldError
    60  				}
    61  			}
    62  		case 2:
    63  			if fieldTypeId == thrift.STRING {
    64  				l, err = p.FastReadField2(buf[offset:])
    65  				offset += l
    66  				if err != nil {
    67  					goto ReadFieldError
    68  				}
    69  			} else {
    70  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
    71  				offset += l
    72  				if err != nil {
    73  					goto SkipFieldError
    74  				}
    75  			}
    76  		default:
    77  			l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
    78  			offset += l
    79  			if err != nil {
    80  				goto SkipFieldError
    81  			}
    82  		}
    83  
    84  		l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
    85  		offset += l
    86  		if err != nil {
    87  			goto ReadFieldEndError
    88  		}
    89  	}
    90  	l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
    91  	offset += l
    92  	if err != nil {
    93  		goto ReadStructEndError
    94  	}
    95  
    96  	return offset, nil
    97  ReadStructBeginError:
    98  	return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
    99  ReadFieldBeginError:
   100  	return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   101  ReadFieldError:
   102  	return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_TrafficEnv[fieldId]), err)
   103  SkipFieldError:
   104  	return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   105  ReadFieldEndError:
   106  	return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   107  ReadStructEndError:
   108  	return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   109  }
   110  
   111  func (p *TrafficEnv) FastReadField1(buf []byte) (int, error) {
   112  	offset := 0
   113  
   114  	if v, l, err := bthrift.Binary.ReadBool(buf[offset:]); err != nil {
   115  		return offset, err
   116  	} else {
   117  		offset += l
   118  
   119  		p.Open = v
   120  
   121  	}
   122  	return offset, nil
   123  }
   124  
   125  func (p *TrafficEnv) FastReadField2(buf []byte) (int, error) {
   126  	offset := 0
   127  
   128  	if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   129  		return offset, err
   130  	} else {
   131  		offset += l
   132  
   133  		p.Env = v
   134  
   135  	}
   136  	return offset, nil
   137  }
   138  
   139  // for compatibility
   140  func (p *TrafficEnv) FastWrite(buf []byte) int {
   141  	return 0
   142  }
   143  
   144  func (p *TrafficEnv) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   145  	offset := 0
   146  	offset += bthrift.Binary.WriteStructBegin(buf[offset:], "TrafficEnv")
   147  	if p != nil {
   148  		offset += p.fastWriteField1(buf[offset:], binaryWriter)
   149  		offset += p.fastWriteField2(buf[offset:], binaryWriter)
   150  	}
   151  	offset += bthrift.Binary.WriteFieldStop(buf[offset:])
   152  	offset += bthrift.Binary.WriteStructEnd(buf[offset:])
   153  	return offset
   154  }
   155  
   156  func (p *TrafficEnv) BLength() int {
   157  	l := 0
   158  	l += bthrift.Binary.StructBeginLength("TrafficEnv")
   159  	if p != nil {
   160  		l += p.field1Length()
   161  		l += p.field2Length()
   162  	}
   163  	l += bthrift.Binary.FieldStopLength()
   164  	l += bthrift.Binary.StructEndLength()
   165  	return l
   166  }
   167  
   168  func (p *TrafficEnv) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   169  	offset := 0
   170  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Open", thrift.BOOL, 1)
   171  	offset += bthrift.Binary.WriteBool(buf[offset:], p.Open)
   172  
   173  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   174  	return offset
   175  }
   176  
   177  func (p *TrafficEnv) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   178  	offset := 0
   179  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Env", thrift.STRING, 2)
   180  	offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Env)
   181  
   182  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   183  	return offset
   184  }
   185  
   186  func (p *TrafficEnv) field1Length() int {
   187  	l := 0
   188  	l += bthrift.Binary.FieldBeginLength("Open", thrift.BOOL, 1)
   189  	l += bthrift.Binary.BoolLength(p.Open)
   190  
   191  	l += bthrift.Binary.FieldEndLength()
   192  	return l
   193  }
   194  
   195  func (p *TrafficEnv) field2Length() int {
   196  	l := 0
   197  	l += bthrift.Binary.FieldBeginLength("Env", thrift.STRING, 2)
   198  	l += bthrift.Binary.StringLengthNocopy(p.Env)
   199  
   200  	l += bthrift.Binary.FieldEndLength()
   201  	return l
   202  }
   203  
   204  func (p *Base) FastRead(buf []byte) (int, error) {
   205  	var err error
   206  	var offset int
   207  	var l int
   208  	var fieldTypeId thrift.TType
   209  	var fieldId int16
   210  	_, l, err = bthrift.Binary.ReadStructBegin(buf)
   211  	offset += l
   212  	if err != nil {
   213  		goto ReadStructBeginError
   214  	}
   215  
   216  	for {
   217  		_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
   218  		offset += l
   219  		if err != nil {
   220  			goto ReadFieldBeginError
   221  		}
   222  		if fieldTypeId == thrift.STOP {
   223  			break
   224  		}
   225  		switch fieldId {
   226  		case 1:
   227  			if fieldTypeId == thrift.STRING {
   228  				l, err = p.FastReadField1(buf[offset:])
   229  				offset += l
   230  				if err != nil {
   231  					goto ReadFieldError
   232  				}
   233  			} else {
   234  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   235  				offset += l
   236  				if err != nil {
   237  					goto SkipFieldError
   238  				}
   239  			}
   240  		case 2:
   241  			if fieldTypeId == thrift.STRING {
   242  				l, err = p.FastReadField2(buf[offset:])
   243  				offset += l
   244  				if err != nil {
   245  					goto ReadFieldError
   246  				}
   247  			} else {
   248  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   249  				offset += l
   250  				if err != nil {
   251  					goto SkipFieldError
   252  				}
   253  			}
   254  		case 3:
   255  			if fieldTypeId == thrift.STRING {
   256  				l, err = p.FastReadField3(buf[offset:])
   257  				offset += l
   258  				if err != nil {
   259  					goto ReadFieldError
   260  				}
   261  			} else {
   262  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   263  				offset += l
   264  				if err != nil {
   265  					goto SkipFieldError
   266  				}
   267  			}
   268  		case 4:
   269  			if fieldTypeId == thrift.STRING {
   270  				l, err = p.FastReadField4(buf[offset:])
   271  				offset += l
   272  				if err != nil {
   273  					goto ReadFieldError
   274  				}
   275  			} else {
   276  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   277  				offset += l
   278  				if err != nil {
   279  					goto SkipFieldError
   280  				}
   281  			}
   282  		case 5:
   283  			if fieldTypeId == thrift.STRUCT {
   284  				l, err = p.FastReadField5(buf[offset:])
   285  				offset += l
   286  				if err != nil {
   287  					goto ReadFieldError
   288  				}
   289  			} else {
   290  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   291  				offset += l
   292  				if err != nil {
   293  					goto SkipFieldError
   294  				}
   295  			}
   296  		case 6:
   297  			if fieldTypeId == thrift.MAP {
   298  				l, err = p.FastReadField6(buf[offset:])
   299  				offset += l
   300  				if err != nil {
   301  					goto ReadFieldError
   302  				}
   303  			} else {
   304  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   305  				offset += l
   306  				if err != nil {
   307  					goto SkipFieldError
   308  				}
   309  			}
   310  		default:
   311  			l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   312  			offset += l
   313  			if err != nil {
   314  				goto SkipFieldError
   315  			}
   316  		}
   317  
   318  		l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
   319  		offset += l
   320  		if err != nil {
   321  			goto ReadFieldEndError
   322  		}
   323  	}
   324  	l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
   325  	offset += l
   326  	if err != nil {
   327  		goto ReadStructEndError
   328  	}
   329  
   330  	return offset, nil
   331  ReadStructBeginError:
   332  	return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   333  ReadFieldBeginError:
   334  	return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   335  ReadFieldError:
   336  	return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Base[fieldId]), err)
   337  SkipFieldError:
   338  	return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   339  ReadFieldEndError:
   340  	return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   341  ReadStructEndError:
   342  	return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   343  }
   344  
   345  func (p *Base) FastReadField1(buf []byte) (int, error) {
   346  	offset := 0
   347  
   348  	if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   349  		return offset, err
   350  	} else {
   351  		offset += l
   352  
   353  		p.LogID = v
   354  
   355  	}
   356  	return offset, nil
   357  }
   358  
   359  func (p *Base) FastReadField2(buf []byte) (int, error) {
   360  	offset := 0
   361  
   362  	if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   363  		return offset, err
   364  	} else {
   365  		offset += l
   366  
   367  		p.Caller = v
   368  
   369  	}
   370  	return offset, nil
   371  }
   372  
   373  func (p *Base) FastReadField3(buf []byte) (int, error) {
   374  	offset := 0
   375  
   376  	if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   377  		return offset, err
   378  	} else {
   379  		offset += l
   380  
   381  		p.Addr = v
   382  
   383  	}
   384  	return offset, nil
   385  }
   386  
   387  func (p *Base) FastReadField4(buf []byte) (int, error) {
   388  	offset := 0
   389  
   390  	if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   391  		return offset, err
   392  	} else {
   393  		offset += l
   394  
   395  		p.Client = v
   396  
   397  	}
   398  	return offset, nil
   399  }
   400  
   401  func (p *Base) FastReadField5(buf []byte) (int, error) {
   402  	offset := 0
   403  	p.TrafficEnv = NewTrafficEnv()
   404  	if l, err := p.TrafficEnv.FastRead(buf[offset:]); err != nil {
   405  		return offset, err
   406  	} else {
   407  		offset += l
   408  	}
   409  	return offset, nil
   410  }
   411  
   412  func (p *Base) FastReadField6(buf []byte) (int, error) {
   413  	offset := 0
   414  
   415  	_, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:])
   416  	offset += l
   417  	if err != nil {
   418  		return offset, err
   419  	}
   420  	p.Extra = make(map[string]string, size)
   421  	for i := 0; i < size; i++ {
   422  		var _key string
   423  		if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   424  			return offset, err
   425  		} else {
   426  			offset += l
   427  
   428  			_key = v
   429  
   430  		}
   431  
   432  		var _val string
   433  		if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   434  			return offset, err
   435  		} else {
   436  			offset += l
   437  
   438  			_val = v
   439  
   440  		}
   441  
   442  		p.Extra[_key] = _val
   443  	}
   444  	if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil {
   445  		return offset, err
   446  	} else {
   447  		offset += l
   448  	}
   449  	return offset, nil
   450  }
   451  
   452  // for compatibility
   453  func (p *Base) FastWrite(buf []byte) int {
   454  	return 0
   455  }
   456  
   457  func (p *Base) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   458  	offset := 0
   459  	offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Base")
   460  	if p != nil {
   461  		offset += p.fastWriteField1(buf[offset:], binaryWriter)
   462  		offset += p.fastWriteField2(buf[offset:], binaryWriter)
   463  		offset += p.fastWriteField3(buf[offset:], binaryWriter)
   464  		offset += p.fastWriteField4(buf[offset:], binaryWriter)
   465  		offset += p.fastWriteField5(buf[offset:], binaryWriter)
   466  		offset += p.fastWriteField6(buf[offset:], binaryWriter)
   467  	}
   468  	offset += bthrift.Binary.WriteFieldStop(buf[offset:])
   469  	offset += bthrift.Binary.WriteStructEnd(buf[offset:])
   470  	return offset
   471  }
   472  
   473  func (p *Base) BLength() int {
   474  	l := 0
   475  	l += bthrift.Binary.StructBeginLength("Base")
   476  	if p != nil {
   477  		l += p.field1Length()
   478  		l += p.field2Length()
   479  		l += p.field3Length()
   480  		l += p.field4Length()
   481  		l += p.field5Length()
   482  		l += p.field6Length()
   483  	}
   484  	l += bthrift.Binary.FieldStopLength()
   485  	l += bthrift.Binary.StructEndLength()
   486  	return l
   487  }
   488  
   489  func (p *Base) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   490  	offset := 0
   491  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "LogID", thrift.STRING, 1)
   492  	offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.LogID)
   493  
   494  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   495  	return offset
   496  }
   497  
   498  func (p *Base) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   499  	offset := 0
   500  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Caller", thrift.STRING, 2)
   501  	offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Caller)
   502  
   503  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   504  	return offset
   505  }
   506  
   507  func (p *Base) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   508  	offset := 0
   509  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Addr", thrift.STRING, 3)
   510  	offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Addr)
   511  
   512  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   513  	return offset
   514  }
   515  
   516  func (p *Base) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   517  	offset := 0
   518  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Client", thrift.STRING, 4)
   519  	offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Client)
   520  
   521  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   522  	return offset
   523  }
   524  
   525  func (p *Base) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   526  	offset := 0
   527  	if p.IsSetTrafficEnv() {
   528  		offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "TrafficEnv", thrift.STRUCT, 5)
   529  		offset += p.TrafficEnv.FastWriteNocopy(buf[offset:], binaryWriter)
   530  		offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   531  	}
   532  	return offset
   533  }
   534  
   535  func (p *Base) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   536  	offset := 0
   537  	if p.IsSetExtra() {
   538  		offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Extra", thrift.MAP, 6)
   539  		offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Extra))
   540  		for k, v := range p.Extra {
   541  
   542  			offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k)
   543  
   544  			offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v)
   545  
   546  		}
   547  		offset += bthrift.Binary.WriteMapEnd(buf[offset:])
   548  		offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   549  	}
   550  	return offset
   551  }
   552  
   553  func (p *Base) field1Length() int {
   554  	l := 0
   555  	l += bthrift.Binary.FieldBeginLength("LogID", thrift.STRING, 1)
   556  	l += bthrift.Binary.StringLengthNocopy(p.LogID)
   557  
   558  	l += bthrift.Binary.FieldEndLength()
   559  	return l
   560  }
   561  
   562  func (p *Base) field2Length() int {
   563  	l := 0
   564  	l += bthrift.Binary.FieldBeginLength("Caller", thrift.STRING, 2)
   565  	l += bthrift.Binary.StringLengthNocopy(p.Caller)
   566  
   567  	l += bthrift.Binary.FieldEndLength()
   568  	return l
   569  }
   570  
   571  func (p *Base) field3Length() int {
   572  	l := 0
   573  	l += bthrift.Binary.FieldBeginLength("Addr", thrift.STRING, 3)
   574  	l += bthrift.Binary.StringLengthNocopy(p.Addr)
   575  
   576  	l += bthrift.Binary.FieldEndLength()
   577  	return l
   578  }
   579  
   580  func (p *Base) field4Length() int {
   581  	l := 0
   582  	l += bthrift.Binary.FieldBeginLength("Client", thrift.STRING, 4)
   583  	l += bthrift.Binary.StringLengthNocopy(p.Client)
   584  
   585  	l += bthrift.Binary.FieldEndLength()
   586  	return l
   587  }
   588  
   589  func (p *Base) field5Length() int {
   590  	l := 0
   591  	if p.IsSetTrafficEnv() {
   592  		l += bthrift.Binary.FieldBeginLength("TrafficEnv", thrift.STRUCT, 5)
   593  		l += p.TrafficEnv.BLength()
   594  		l += bthrift.Binary.FieldEndLength()
   595  	}
   596  	return l
   597  }
   598  
   599  func (p *Base) field6Length() int {
   600  	l := 0
   601  	if p.IsSetExtra() {
   602  		l += bthrift.Binary.FieldBeginLength("Extra", thrift.MAP, 6)
   603  		l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Extra))
   604  		for k, v := range p.Extra {
   605  
   606  			l += bthrift.Binary.StringLengthNocopy(k)
   607  
   608  			l += bthrift.Binary.StringLengthNocopy(v)
   609  
   610  		}
   611  		l += bthrift.Binary.MapEndLength()
   612  		l += bthrift.Binary.FieldEndLength()
   613  	}
   614  	return l
   615  }
   616  
   617  func (p *BaseResp) FastRead(buf []byte) (int, error) {
   618  	var err error
   619  	var offset int
   620  	var l int
   621  	var fieldTypeId thrift.TType
   622  	var fieldId int16
   623  	_, l, err = bthrift.Binary.ReadStructBegin(buf)
   624  	offset += l
   625  	if err != nil {
   626  		goto ReadStructBeginError
   627  	}
   628  
   629  	for {
   630  		_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
   631  		offset += l
   632  		if err != nil {
   633  			goto ReadFieldBeginError
   634  		}
   635  		if fieldTypeId == thrift.STOP {
   636  			break
   637  		}
   638  		switch fieldId {
   639  		case 1:
   640  			if fieldTypeId == thrift.STRING {
   641  				l, err = p.FastReadField1(buf[offset:])
   642  				offset += l
   643  				if err != nil {
   644  					goto ReadFieldError
   645  				}
   646  			} else {
   647  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   648  				offset += l
   649  				if err != nil {
   650  					goto SkipFieldError
   651  				}
   652  			}
   653  		case 2:
   654  			if fieldTypeId == thrift.I32 {
   655  				l, err = p.FastReadField2(buf[offset:])
   656  				offset += l
   657  				if err != nil {
   658  					goto ReadFieldError
   659  				}
   660  			} else {
   661  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   662  				offset += l
   663  				if err != nil {
   664  					goto SkipFieldError
   665  				}
   666  			}
   667  		case 3:
   668  			if fieldTypeId == thrift.MAP {
   669  				l, err = p.FastReadField3(buf[offset:])
   670  				offset += l
   671  				if err != nil {
   672  					goto ReadFieldError
   673  				}
   674  			} else {
   675  				l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   676  				offset += l
   677  				if err != nil {
   678  					goto SkipFieldError
   679  				}
   680  			}
   681  		default:
   682  			l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
   683  			offset += l
   684  			if err != nil {
   685  				goto SkipFieldError
   686  			}
   687  		}
   688  
   689  		l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
   690  		offset += l
   691  		if err != nil {
   692  			goto ReadFieldEndError
   693  		}
   694  	}
   695  	l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
   696  	offset += l
   697  	if err != nil {
   698  		goto ReadStructEndError
   699  	}
   700  
   701  	return offset, nil
   702  ReadStructBeginError:
   703  	return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   704  ReadFieldBeginError:
   705  	return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   706  ReadFieldError:
   707  	return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaseResp[fieldId]), err)
   708  SkipFieldError:
   709  	return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   710  ReadFieldEndError:
   711  	return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   712  ReadStructEndError:
   713  	return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   714  }
   715  
   716  func (p *BaseResp) FastReadField1(buf []byte) (int, error) {
   717  	offset := 0
   718  
   719  	if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   720  		return offset, err
   721  	} else {
   722  		offset += l
   723  
   724  		p.StatusMessage = v
   725  
   726  	}
   727  	return offset, nil
   728  }
   729  
   730  func (p *BaseResp) FastReadField2(buf []byte) (int, error) {
   731  	offset := 0
   732  
   733  	if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil {
   734  		return offset, err
   735  	} else {
   736  		offset += l
   737  
   738  		p.StatusCode = v
   739  
   740  	}
   741  	return offset, nil
   742  }
   743  
   744  func (p *BaseResp) FastReadField3(buf []byte) (int, error) {
   745  	offset := 0
   746  
   747  	_, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:])
   748  	offset += l
   749  	if err != nil {
   750  		return offset, err
   751  	}
   752  	p.Extra = make(map[string]string, size)
   753  	for i := 0; i < size; i++ {
   754  		var _key string
   755  		if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   756  			return offset, err
   757  		} else {
   758  			offset += l
   759  
   760  			_key = v
   761  
   762  		}
   763  
   764  		var _val string
   765  		if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
   766  			return offset, err
   767  		} else {
   768  			offset += l
   769  
   770  			_val = v
   771  
   772  		}
   773  
   774  		p.Extra[_key] = _val
   775  	}
   776  	if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil {
   777  		return offset, err
   778  	} else {
   779  		offset += l
   780  	}
   781  	return offset, nil
   782  }
   783  
   784  // for compatibility
   785  func (p *BaseResp) FastWrite(buf []byte) int {
   786  	return 0
   787  }
   788  
   789  func (p *BaseResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   790  	offset := 0
   791  	offset += bthrift.Binary.WriteStructBegin(buf[offset:], "BaseResp")
   792  	if p != nil {
   793  		offset += p.fastWriteField2(buf[offset:], binaryWriter)
   794  		offset += p.fastWriteField1(buf[offset:], binaryWriter)
   795  		offset += p.fastWriteField3(buf[offset:], binaryWriter)
   796  	}
   797  	offset += bthrift.Binary.WriteFieldStop(buf[offset:])
   798  	offset += bthrift.Binary.WriteStructEnd(buf[offset:])
   799  	return offset
   800  }
   801  
   802  func (p *BaseResp) BLength() int {
   803  	l := 0
   804  	l += bthrift.Binary.StructBeginLength("BaseResp")
   805  	if p != nil {
   806  		l += p.field1Length()
   807  		l += p.field2Length()
   808  		l += p.field3Length()
   809  	}
   810  	l += bthrift.Binary.FieldStopLength()
   811  	l += bthrift.Binary.StructEndLength()
   812  	return l
   813  }
   814  
   815  func (p *BaseResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   816  	offset := 0
   817  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StatusMessage", thrift.STRING, 1)
   818  	offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.StatusMessage)
   819  
   820  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   821  	return offset
   822  }
   823  
   824  func (p *BaseResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   825  	offset := 0
   826  	offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StatusCode", thrift.I32, 2)
   827  	offset += bthrift.Binary.WriteI32(buf[offset:], p.StatusCode)
   828  
   829  	offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   830  	return offset
   831  }
   832  
   833  func (p *BaseResp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int {
   834  	offset := 0
   835  	if p.IsSetExtra() {
   836  		offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Extra", thrift.MAP, 3)
   837  		offset += bthrift.Binary.WriteMapBegin(buf[offset:], thrift.STRING, thrift.STRING, len(p.Extra))
   838  		for k, v := range p.Extra {
   839  
   840  			offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k)
   841  
   842  			offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v)
   843  
   844  		}
   845  		offset += bthrift.Binary.WriteMapEnd(buf[offset:])
   846  		offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
   847  	}
   848  	return offset
   849  }
   850  
   851  func (p *BaseResp) field1Length() int {
   852  	l := 0
   853  	l += bthrift.Binary.FieldBeginLength("StatusMessage", thrift.STRING, 1)
   854  	l += bthrift.Binary.StringLengthNocopy(p.StatusMessage)
   855  
   856  	l += bthrift.Binary.FieldEndLength()
   857  	return l
   858  }
   859  
   860  func (p *BaseResp) field2Length() int {
   861  	l := 0
   862  	l += bthrift.Binary.FieldBeginLength("StatusCode", thrift.I32, 2)
   863  	l += bthrift.Binary.I32Length(p.StatusCode)
   864  
   865  	l += bthrift.Binary.FieldEndLength()
   866  	return l
   867  }
   868  
   869  func (p *BaseResp) field3Length() int {
   870  	l := 0
   871  	if p.IsSetExtra() {
   872  		l += bthrift.Binary.FieldBeginLength("Extra", thrift.MAP, 3)
   873  		l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.Extra))
   874  		for k, v := range p.Extra {
   875  
   876  			l += bthrift.Binary.StringLengthNocopy(k)
   877  
   878  			l += bthrift.Binary.StringLengthNocopy(v)
   879  
   880  		}
   881  		l += bthrift.Binary.MapEndLength()
   882  		l += bthrift.Binary.FieldEndLength()
   883  	}
   884  	return l
   885  }