From 8ea9cd62a6bd18db8e646294996929ec318c322a Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Fri, 24 Nov 2023 20:41:47 +0800 Subject: [PATCH 01/13] feat: add fieldmask base tests --- .gitignore | 1 + codegen/.gitignore | 2 - codegen/basic_idls/test_fieldmask.thrift | 89 +++++++ codegen/codegen_run.sh | 35 ++- codegen/fieldmask/main_test.go | 287 +++++++++++++++++++++++ codegen/fieldmask/run.sh | 21 ++ codegen/fieldmask/test_fieldmask.thrift | 89 +++++++ 7 files changed, 519 insertions(+), 5 deletions(-) delete mode 100644 codegen/.gitignore create mode 100644 codegen/basic_idls/test_fieldmask.thrift create mode 100644 codegen/fieldmask/main_test.go create mode 100644 codegen/fieldmask/run.sh create mode 100644 codegen/fieldmask/test_fieldmask.thrift diff --git a/.gitignore b/.gitignore index 44aaca1..a20c4c8 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ testdata/ # Files produced by run.sh kitex_gen/ kitex_gen_slim/ +old_gen/ grpc_gen/ go.mod go.sum diff --git a/codegen/.gitignore b/codegen/.gitignore deleted file mode 100644 index f15c7e0..0000000 --- a/codegen/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -errors.txt -kitex_gen/ \ No newline at end of file diff --git a/codegen/basic_idls/test_fieldmask.thrift b/codegen/basic_idls/test_fieldmask.thrift new file mode 100644 index 0000000..1ba3ee0 --- /dev/null +++ b/codegen/basic_idls/test_fieldmask.thrift @@ -0,0 +1,89 @@ +# Copyright 2022 CloudWeGo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +namespace go base + +struct TrafficEnv { + 0: string Name = "", + 1: bool Open = false, + 2: string Env = "", + 256: i64 Code, +} + +struct Base { + 0: string Addr = "", + 1: string LogID = "", + 2: string Caller = "", + 5: optional TrafficEnv TrafficEnv, + 255: optional ExtraInfo Extra, + 256: MetaInfo Meta, +} + +struct ExtraInfo { + 1: map F1 + 2: map F2, + 3: list F3 + 4: set F4, + 5: map F5 + 6: map F6 + 7: map> F7 + 8: map> F8 + 9: map>> F9 + 10: map F10 +} + +struct MetaInfo { + 1: map IntMap, + 2: map StrMap, + 3: list List, + 4: set Set, + 11: map> MapList + 12: list>> ListMapList + 255: Base Base, +} + +typedef Val Key + +struct Val { + 1: string id + 2: string name +} + +typedef double Float + +typedef i64 Int + +typedef string Str + +enum Ex { + A = 1, + B = 2, + C = 3 +} + +struct BaseResp { + 1: string StatusMessage = "", + 2: i32 StatusCode = 0, + 3: optional map Extra, + + 4: map F1 + 5: map F2, + 6: list F3 + 7: set F4, + 8: map F5 + 9: map F6 + 10: map F7 + 11: map> F8 + 12: list>> F9 +} diff --git a/codegen/codegen_run.sh b/codegen/codegen_run.sh index ca752e0..2ef934a 100755 --- a/codegen/codegen_run.sh +++ b/codegen/codegen_run.sh @@ -29,6 +29,7 @@ function check_cmd { "kitex -module codegen-test -thrift template=slim $filename" "kitex -module codegen-test -thrift keep_unknown_fields $filename" "kitex -module codegen-test -thrift template=slim -thrift keep_unknown_fields $filename" + "kitex -module codegen-test -thrift with_field_mask -thrift with_reflection -thrift keep_unknown_fields $filename" ) skip_error_info=( @@ -43,7 +44,8 @@ function check_cmd { if ! grep -q -E "$(printf '%s\n' "${skip_error_info[@]}" | paste -sd '|' -)" "$tmp_file"; then echo "$cmd" >> "errors.txt" cat "$tmp_file" >> "errors.txt" # 将错误输出添加到错误文件中 - echo "Error: $cmd" + echo "Kitex Error: $cmd" + exit 1 fi rm "$tmp_file" # 删除临时文件 continue @@ -52,27 +54,49 @@ function check_cmd { rm "$tmp_file" # 删除临时文件 # go mod 不展示输出,会干扰看结果,如果这一步出问题了,下一步 go build 会报错,所以不用担心 + go get github.com/cloudwego/thriftgo@main 2>&1 go mod tidy > /dev/null 2>&1 + # 验证编译 local tmp_file_2=$(mktemp) # 创建一个临时文件来存储输出 if ! eval "go build ./..." > "$tmp_file_2" 2>&1; then echo "$cmd" >> "errors.txt" cat "$tmp_file_2" >> "errors.txt" # 将错误输出添加到错误文件中 - echo "Error: $cmd" + echo "Go Error: $cmd" + exit 2 fi rm "$tmp_file_2" # 删除临时文件 done } +function run_test { + echo "run test..." + + #run fieldmask tests... + cd fieldmask + sh run.sh + if test $? -nq 0 + then + echo "run fieldmask test failed" + exit 3 + fi + cd .. +} + function main { + mkdir -p testdata + cd testdata + + clean_codegen + if [ -e "errors.txt" ]; then rm errors.txt fi touch errors.txt - basic_file_dir="basic_idls" + basic_file_dir="../basic_idls" basic_files=($(find "$basic_file_dir" -name "*.thrift" -type f -print)) basic_total=${#basic_files[@]} echo "starting test" @@ -92,6 +116,11 @@ function main { cat errors.txt exit 1 fi + + cd .. + + run_test + } main \ No newline at end of file diff --git a/codegen/fieldmask/main_test.go b/codegen/fieldmask/main_test.go new file mode 100644 index 0000000..891cccd --- /dev/null +++ b/codegen/fieldmask/main_test.go @@ -0,0 +1,287 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package test + +import ( + "runtime" + "test/kitex_gen/base" + obase "test/old_gen/base" + "testing" + + "github.com/cloudwego/thriftgo/fieldmask" + "github.com/stretchr/testify/require" +) + +func SampleNewBase() *base.Base { + obj := base.NewBase() + obj.Addr = "abcd" + obj.Caller = "abcd" + obj.LogID = "abcd" + obj.Meta = base.NewMetaInfo() + obj.Meta.StrMap = map[string]*base.Val{ + "abcd": base.NewVal(), + "1234": base.NewVal(), + } + obj.Meta.IntMap = map[int64]*base.Val{ + 1: base.NewVal(), + 2: base.NewVal(), + } + v0 := base.NewVal() + v0.Id = "a" + v0.Name = "a" + v1 := base.NewVal() + v1.Id = "b" + v1.Name = "b" + obj.Meta.List = []*base.Val{v0, v1} + obj.Meta.Set = []*base.Val{v0, v1} + obj.Extra = base.NewExtraInfo() + obj.TrafficEnv = base.NewTrafficEnv() + obj.TrafficEnv.Code = 1 + obj.TrafficEnv.Env = "abcd" + obj.TrafficEnv.Name = "abcd" + obj.TrafficEnv.Open = true + return obj +} + +func SampleOldBase() *obase.Base { + obj := obase.NewBase() + obj.Addr = "abcd" + obj.Caller = "abcd" + obj.LogID = "abcd" + obj.Meta = obase.NewMetaInfo() + obj.Meta.StrMap = map[string]*obase.Val{ + "abcd": obase.NewVal(), + "1234": obase.NewVal(), + } + obj.Meta.IntMap = map[int64]*obase.Val{ + 1: obase.NewVal(), + 2: obase.NewVal(), + } + v0 := obase.NewVal() + v0.Id = "a" + v0.Name = "a" + v1 := obase.NewVal() + v1.Id = "b" + v1.Name = "b" + obj.Meta.List = []*obase.Val{v0, v1} + obj.Meta.Set = []*obase.Val{v0, v1} + obj.Extra = obase.NewExtraInfo() + obj.TrafficEnv = obase.NewTrafficEnv() + obj.TrafficEnv.Code = 1 + obj.TrafficEnv.Env = "abcd" + obj.TrafficEnv.Name = "abcd" + obj.TrafficEnv.Open = true + return obj +} + +func TestFastWrite(t *testing.T) { + var obj = SampleNewBase() + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", + "$.LogID", + "$.TrafficEnv.Code", + "$.Meta.IntMap{1}.id", + "$.Meta.IntMap{2}.name", + "$.Meta.StrMap{\"1234\"}", + "$.Meta.List[1]", + "$.Meta.Set[0].id", + "$.Meta.Set[1].name") + if err != nil { + t.Fatal(err) + } + obj.SetFieldMask(fm) + out := make([]byte, obj.BLength()) + e := obj.FastWriteNocopy(out, nil) + var obj2 = base.NewBase() + n, err := obj2.FastRead(out) + if err != nil { + t.Fatal(err) + } + require.Equal(t, e, n) + require.Equal(t, obj.Addr, obj2.Addr) + require.Equal(t, obj.LogID, obj2.LogID) + require.Equal(t, "", obj2.Caller) + require.Equal(t, "", obj2.TrafficEnv.Name) + require.Equal(t, false, obj2.TrafficEnv.Open) + require.Equal(t, "", obj2.TrafficEnv.Env) + require.Equal(t, obj.TrafficEnv.Code, obj2.TrafficEnv.Code) + require.Equal(t, 2, len(obj2.Meta.IntMap)) + require.Equal(t, obj.Meta.IntMap[1].Id, obj2.Meta.IntMap[1].Id) + require.Equal(t, "", obj2.Meta.IntMap[1].Name) + require.Equal(t, "", obj2.Meta.IntMap[2].Id) + require.Equal(t, obj.Meta.IntMap[2].Name, obj2.Meta.IntMap[2].Name) + require.Equal(t, obj.Meta.StrMap["1234"].Id, obj2.Meta.StrMap["1234"].Id) + require.Equal(t, (*base.Val)(nil), obj2.Meta.StrMap["abcd"]) + require.Equal(t, obj.Meta.List[1].Id, obj2.Meta.List[0].Id) + require.Equal(t, obj.Meta.List[1].Name, obj2.Meta.List[0].Name) + require.Equal(t, 1, len(obj2.Meta.List)) + require.Equal(t, 2, len(obj2.Meta.Set)) + require.Equal(t, obj.Meta.Set[0].Id, obj2.Meta.Set[0].Id) + require.Equal(t, "", obj2.Meta.Set[0].Name) + require.Equal(t, "", obj2.Meta.Set[1].Id) + require.Equal(t, obj.Meta.Set[1].Name, obj2.Meta.Set[1].Name) +} + +func TestFastRead(t *testing.T) { + obj := SampleNewBase() + buf := make([]byte, obj.BLength()) + e := obj.FastWriteNocopy(buf, nil) + obj2 := base.NewBase() + fm, err := fieldmask.NewFieldMask(obj2.GetTypeDescriptor(), "$.Addr", + "$.LogID", + "$.TrafficEnv.Code", + "$.Meta.IntMap{1}.id", + "$.Meta.IntMap{2}.name", + "$.Meta.StrMap{\"1234\"}", + "$.Meta.List[1]", + "$.Meta.Set[0].id", + "$.Meta.Set[1].name") + if err != nil { + t.Fatal(err) + } + obj2.SetFieldMask(fm) + n, err := obj2.FastRead(buf) + if err != nil { + t.Fatal(err) + } + require.Equal(t, e, n) + + require.Equal(t, e, n) + require.Equal(t, obj.Addr, obj2.Addr) + require.Equal(t, obj.LogID, obj2.LogID) + require.Equal(t, "", obj2.Caller) + require.Equal(t, "", obj2.TrafficEnv.Name) + require.Equal(t, false, obj2.TrafficEnv.Open) + require.Equal(t, "", obj2.TrafficEnv.Env) + require.Equal(t, obj.TrafficEnv.Code, obj2.TrafficEnv.Code) + require.Equal(t, 2, len(obj2.Meta.IntMap)) + require.Equal(t, obj.Meta.IntMap[1].Id, obj2.Meta.IntMap[1].Id) + require.Equal(t, "", obj2.Meta.IntMap[1].Name) + require.Equal(t, "", obj2.Meta.IntMap[2].Id) + require.Equal(t, obj.Meta.IntMap[2].Name, obj2.Meta.IntMap[2].Name) + require.Equal(t, obj.Meta.StrMap["1234"].Id, obj2.Meta.StrMap["1234"].Id) + require.Equal(t, (*base.Val)(nil), obj2.Meta.StrMap["abcd"]) + require.Equal(t, obj.Meta.List[1].Id, obj2.Meta.List[0].Id) + require.Equal(t, obj.Meta.List[1].Name, obj2.Meta.List[0].Name) + require.Equal(t, 1, len(obj2.Meta.List)) + require.Equal(t, 2, len(obj2.Meta.Set)) + require.Equal(t, obj.Meta.Set[0].Id, obj2.Meta.Set[0].Id) + require.Equal(t, "", obj2.Meta.Set[0].Name) + require.Equal(t, "", obj2.Meta.Set[1].Id) + require.Equal(t, obj.Meta.Set[1].Name, obj2.Meta.Set[1].Name) +} + +func BenchmarkFastWriteWithFieldMask(b *testing.B) { + b.Run("old", func(b *testing.B) { + obj := SampleOldBase() + buf := make([]byte, obj.BLength()) + b.ResetTimer() + for i := 0; i < b.N; i++ { + buf := buf[:obj.BLength()] + if err := obj.FastWriteNocopy(buf, nil); err == 0 { + b.Fatal(err) + } + } + }) + + runtime.GC() + + b.Run("new", func(b *testing.B) { + obj := SampleNewBase() + buf := make([]byte, obj.BLength()) + b.ResetTimer() + for i := 0; i < b.N; i++ { + buf := buf[:obj.BLength()] + if err := obj.FastWriteNocopy(buf, nil); err == 0 { + b.Fatal(err) + } + } + }) + + runtime.GC() + + b.Run("new-mask-half", func(b *testing.B) { + obj := SampleNewBase() + buf := make([]byte, obj.BLength()) + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", "$.Meta.List[1]", "$.Meta.Set[1]") + if err != nil { + b.Fatal(err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + obj.SetFieldMask(fm) + buf := buf[:obj.BLength()] + if err := obj.FastWriteNocopy(buf, nil); err == 0 { + b.Fatal(err) + } + } + }) +} + +func BenchmarkFastReadWithFieldMask(b *testing.B) { + b.Run("old", func(b *testing.B) { + obj := SampleOldBase() + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err == 0 { + b.Fatal(err) + } + obj = obase.NewBase() + b.ResetTimer() + for i := 0; i < b.N; i++ { + if _, err := obj.FastRead(buf); err != nil { + b.Fatal(err) + } + } + }) + + runtime.GC() + + b.Run("new", func(b *testing.B) { + obj := SampleNewBase() + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err == 0 { + b.Fatal(err) + } + obj = base.NewBase() + b.ResetTimer() + for i := 0; i < b.N; i++ { + if _, err := obj.FastRead(buf); err != nil { + b.Fatal(err) + } + } + }) + + runtime.GC() + + b.Run("new-mask-half", func(b *testing.B) { + obj := SampleNewBase() + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err == 0 { + b.Fatal(err) + } + obj = base.NewBase() + + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", "$.Meta.List[1]", "$.Meta.Set[1]") + if err != nil { + b.Fatal(err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + obj.SetFieldMask(fm) + if _, err := obj.FastRead(buf); err != nil { + b.Fatal(err) + } + } + }) +} diff --git a/codegen/fieldmask/run.sh b/codegen/fieldmask/run.sh new file mode 100644 index 0000000..b727579 --- /dev/null +++ b/codegen/fieldmask/run.sh @@ -0,0 +1,21 @@ +# Copyright 2023 CloudWeGo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/bin/bash + +kitex -module test -gen-path old_gen test_fieldmask.thrift +kitex -module test -thrift with_field_mask -thrift with_reflection test_fieldmask.thrift +go get github.com/cloudwego/thriftgo@main +go mod tidy +go test ./... diff --git a/codegen/fieldmask/test_fieldmask.thrift b/codegen/fieldmask/test_fieldmask.thrift new file mode 100644 index 0000000..1ba3ee0 --- /dev/null +++ b/codegen/fieldmask/test_fieldmask.thrift @@ -0,0 +1,89 @@ +# Copyright 2022 CloudWeGo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +namespace go base + +struct TrafficEnv { + 0: string Name = "", + 1: bool Open = false, + 2: string Env = "", + 256: i64 Code, +} + +struct Base { + 0: string Addr = "", + 1: string LogID = "", + 2: string Caller = "", + 5: optional TrafficEnv TrafficEnv, + 255: optional ExtraInfo Extra, + 256: MetaInfo Meta, +} + +struct ExtraInfo { + 1: map F1 + 2: map F2, + 3: list F3 + 4: set F4, + 5: map F5 + 6: map F6 + 7: map> F7 + 8: map> F8 + 9: map>> F9 + 10: map F10 +} + +struct MetaInfo { + 1: map IntMap, + 2: map StrMap, + 3: list List, + 4: set Set, + 11: map> MapList + 12: list>> ListMapList + 255: Base Base, +} + +typedef Val Key + +struct Val { + 1: string id + 2: string name +} + +typedef double Float + +typedef i64 Int + +typedef string Str + +enum Ex { + A = 1, + B = 2, + C = 3 +} + +struct BaseResp { + 1: string StatusMessage = "", + 2: i32 StatusCode = 0, + 3: optional map Extra, + + 4: map F1 + 5: map F2, + 6: list F3 + 7: set F4, + 8: map F5 + 9: map F6 + 10: map F7 + 11: map> F8 + 12: list>> F9 +} From 240f2db983a3f95dd0e98cf91bdb4f73b2b611db Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Fri, 24 Nov 2023 21:35:52 +0800 Subject: [PATCH 02/13] add benchmark --- codegen/fieldmask/baseline.thrift | 62 + codegen/fieldmask/baseline_test.go | 269 + codegen/fieldmask/nesting.prof | Bin 0 -> 5387 bytes .../test_gen/baseline/baseline-reflection.go | 144 + .../fieldmask/test_gen/baseline/baseline.go | 5923 +++++++++++++++++ .../fieldmask/test_gen/baseline/k-baseline.go | 4556 +++++++++++++ .../fieldmask/test_gen/baseline/k-consts.go | 4 + 7 files changed, 10958 insertions(+) create mode 100644 codegen/fieldmask/baseline.thrift create mode 100644 codegen/fieldmask/baseline_test.go create mode 100644 codegen/fieldmask/nesting.prof create mode 100644 codegen/fieldmask/test_gen/baseline/baseline-reflection.go create mode 100644 codegen/fieldmask/test_gen/baseline/baseline.go create mode 100644 codegen/fieldmask/test_gen/baseline/k-baseline.go create mode 100644 codegen/fieldmask/test_gen/baseline/k-consts.go diff --git a/codegen/fieldmask/baseline.thrift b/codegen/fieldmask/baseline.thrift new file mode 100644 index 0000000..7a54d06 --- /dev/null +++ b/codegen/fieldmask/baseline.thrift @@ -0,0 +1,62 @@ +namespace go baseline + +struct Simple { + 1: byte ByteField + 2: i64 I64Field (api.js_conv = "") + 3: double DoubleField + 4: i32 I32Field + 5: string StringField, + 6: binary BinaryField +} + +struct PartialSimple { + 1: byte ByteField + 3: double DoubleField + 6: binary BinaryField +} + +struct Nesting { + 1: string String (api.header = "String") + 2: list ListSimple + 3: double Double (api.path = "double") + 4: i32 I32 (api.http_code = "", api.body = "I32") + 5: list ListI32 (api.query = "ListI32") + 6: i64 I64 + 7: map MapStringString + 8: Simple SimpleStruct + 9: map MapI32I64 + 10: list ListString + 11: binary Binary + 12: map MapI64String + 13: list ListI64 (api.cookie = "list_i64"), + 14: byte Byte + 15: map MapStringSimple +} + +struct PartialNesting { + 2: list ListSimple + 8: PartialSimple SimpleStruct + 15: map MapStringSimple +} + +struct Nesting2 { + 1: map MapSimpleNesting + 2: Simple SimpleStruct + 3: byte Byte + 4: double Double + 5: list ListNesting + 6: i64 I64 + 7: Nesting NestingStruct + 8: binary Binary + 9: string String + 10: set SetNesting + 11: i32 I32 +} + +service BaselineService { + Simple SimpleMethod(1: Simple req) (api.post = "/simple") + PartialSimple PartialSimpleMethod(1: PartialSimple req) + Nesting NestingMethod(1: Nesting req) (api.post = "/nesting") + PartialNesting PartialNestingMethod(1: PartialNesting req) + Nesting2 Nesting2Method(1: Nesting2 req) (api.post = "/nesting2") +} \ No newline at end of file diff --git a/codegen/fieldmask/baseline_test.go b/codegen/fieldmask/baseline_test.go new file mode 100644 index 0000000..ec6a2ce --- /dev/null +++ b/codegen/fieldmask/baseline_test.go @@ -0,0 +1,269 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package test + +import ( + "bytes" + "math" + "strconv" + "strings" + "testing" + + "test/test_gen/baseline" + + "github.com/cloudwego/thriftgo/fieldmask" +) + +var ( + bytesCount int = 2 + stringCount int = 2 + listCount int = 16 +) + +func getString() string { + return strings.Repeat("你好,\b\n\r\t世界", stringCount) +} + +func getBytes() []byte { + return bytes.Repeat([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, bytesCount) +} + +func getSimpleValue() *baseline.Simple { + return &baseline.Simple{ + ByteField: math.MaxInt8, + I64Field: math.MaxInt64, + DoubleField: math.MaxFloat64, + I32Field: math.MaxInt32, + StringField: getString(), + BinaryField: getBytes(), + } +} + +func getNestingValue() *baseline.Nesting { + var ret = &baseline.Nesting{ + String_: getString(), + ListSimple: []*baseline.Simple{}, + Double: math.MaxFloat64, + I32: math.MaxInt32, + ListI32: []int32{}, + I64: math.MaxInt64, + MapStringString: map[string]string{}, + SimpleStruct: getSimpleValue(), + MapI32I64: map[int32]int64{}, + ListString: []string{}, + Binary: getBytes(), + MapI64String: map[int64]string{}, + ListI64: []int64{}, + Byte: math.MaxInt8, + MapStringSimple: map[string]*baseline.Simple{}, + } + + for i := 0; i < listCount; i++ { + ret.ListSimple = append(ret.ListSimple, getSimpleValue()) + ret.ListI32 = append(ret.ListI32, math.MinInt32) + ret.ListI64 = append(ret.ListI64, math.MinInt64) + ret.ListString = append(ret.ListString, getString()) + } + + for i := 0; i < listCount; i++ { + ret.MapStringString[strconv.Itoa(i)] = getString() + ret.MapI32I64[int32(i)] = math.MinInt64 + ret.MapI64String[int64(i)] = getString() + ret.MapStringSimple[strconv.Itoa(i)] = getSimpleValue() + } + + return ret +} + +func BenchmarkFastWriteSimple(b *testing.B) { + b.Run("full", func(b *testing.B) { + obj := getSimpleValue() + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = obj.BLength() + _ = obj.FastWriteNocopy(data, nil) + } + }) + b.Run("half", func(b *testing.B) { + obj := getSimpleValue() + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.ByteField", "$.DoubleField", "$.StringField") + if err != nil { + b.Fatal(err) + } + obj.SetFieldMask(fm) + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + obj.SetFieldMask(fm) + _ = obj.BLength() + _ = obj.FastWriteNocopy(data, nil) + } + }) +} + +func BenchmarkFastReadSimple(b *testing.B) { + b.Run("full", func(b *testing.B) { + obj := getSimpleValue() + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + obj = baseline.NewSimple() + n, err := obj.FastRead(data) + if n != len(data) { + b.Fatal(err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, _ = obj.FastRead(data) + } + }) + b.Run("half", func(b *testing.B) { + obj := getSimpleValue() + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), + "$.ByteField", "$.DoubleField", "$.StringField") + if err != nil { + b.Fatal(err) + } + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + obj = baseline.NewSimple() + obj.SetFieldMask(fm) + n, err := obj.FastRead(data) + if n != len(data) { + b.Fatal(err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + obj.SetFieldMask(fm) + _, _ = obj.FastRead(data) + } + }) +} + +func BenchmarkFastWriteNesting(b *testing.B) { + b.Run("full", func(b *testing.B) { + obj := getNestingValue() + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + // println("full data size: ", len(data)) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = obj.BLength() + _ = obj.FastWriteNocopy(data, nil) + } + }) + b.Run("half", func(b *testing.B) { + obj := getNestingValue() + // ins := []string{} + // for i := 0; i < listCount/2; i++ { + // ins = append(ins, strconv.Itoa(i)) + // } + // is := strings.Join(ins, ",") + // ss := strings.Join(ins, `","`) + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), + // "$.ListSimple["+is+"]", "$.I32", "$.ListI32["+is+"]", `$.MapStringString{"`+ss+`"}`, + // "$.MapI32I64{"+is+"}", "$.Binary", "$.ListI64["+is+"]", `$.MapStringSimple{"`+ss+`"}`, + "$.ListSimple", "$.I32", "$.ListI32", `$.MapStringString`, + "$.MapI32I64", "$.Binary", + ) + if err != nil { + b.Fatal(err) + } + obj.SetFieldMask(fm) + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + // println("half data size: ", len(data)) + b.ResetTimer() + for i := 0; i < b.N; i++ { + obj.SetFieldMask(fm) + _ = obj.BLength() + _ = obj.FastWriteNocopy(data, nil) + } + }) +} + +func BenchmarkFastReadNesting(b *testing.B) { + b.Run("full", func(b *testing.B) { + obj := getNestingValue() + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + obj = baseline.NewNesting() + n, err := obj.FastRead(data) + if n != len(data) { + b.Fatal(err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, _ = obj.FastRead(data) + } + }) + b.Run("half", func(b *testing.B) { + obj := getNestingValue() + // ins := []string{} + // for i := 0; i < listCount/2; i++ { + // ins = append(ins, strconv.Itoa(i)) + // } + // is := strings.Join(ins, ",") + // ss := strings.Join(ins, `","`) + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), + // "$.ListSimple["+is+"]", "$.I32", "$.ListI32["+is+"]", `$.MapStringString{"`+ss+`"}`, + // "$.MapI32I64{"+is+"}", "$.Binary", "$.ListI64["+is+"]", `$.MapStringSimple{"`+ss+`"}`, + "$.ListSimple", "$.I32", "$.ListI32", `$.MapStringString`, + "$.MapI32I64", "$.Binary", + ) + if err != nil { + b.Fatal(err) + } + data := make([]byte, obj.BLength()) + ret := obj.FastWriteNocopy(data, nil) + if ret != len(data) { + b.Fatal(ret) + } + obj = baseline.NewNesting() + obj.SetFieldMask(fm) + n, err := obj.FastRead(data) + if n != len(data) { + b.Fatal(err) + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + obj.SetFieldMask(fm) + _, _ = obj.FastRead(data) + } + }) +} diff --git a/codegen/fieldmask/nesting.prof b/codegen/fieldmask/nesting.prof new file mode 100644 index 0000000000000000000000000000000000000000..0ad3ffeb1068354e69d469075c52bec71e036412 GIT binary patch literal 5387 zcmV+m74+&KiwFP!00004|Ezj>d{pJt|L;jMlamZd&JB<`ED4uOfSUj_$s~l}4$2~; z(xSCHog_n;lFX!;iKuNgSOh_K#3Gv@E{I|+YKt3+f-Dt55pma_1zNSXYTHj+m$&cd z+2-C!0tR0H!#mG&o^!tEd%ov9Pn@{n@Q249eeA9S{@g5Jn30EB66I4|zlkby7cA^$l8vnkv3 z+B@?sgiLzkt7Ck3CT{YH-I)jkrq^EMvkn#Ki z{r_D%!Sa9yck*9-;6Wex%pUfm%tG+evA4y~UVKq{=EXe9Gke%~XA~A-2DZPkD<{{> zGBUF~UJD_cwjV#veaXhp@`W$im{0kp*Zyn1g#h&FToFko?)M=p%twYCgIrHGa07nG zp|5V51C|E>Ut*RAa`4S;VF$2)3QV*Q@%VGlAj3raeST&xeXvg$&Bc2pJh@m%g{Ifu zz~S-H?tck*e7Hiw-@j%=f_XD{x13G}AV z*NHU-uH;@T=L_+^9^yO$`%yoW>=is!h1j3^n_hce4-27)=6$Sk@jtm~`R`pMvG&s) zt5qp%%ScOyUvkV3M8B0wdg3B}Ji|va#JN4On2OC3dm&FzADZ(g;bb;`nV)8e`UtKS zKwoOVcMVus&zb97zwdH@+ti>x~0xpy{>W<`vqXwk;Qn zi|{u2a}io(nO^%Q{&O)cIVgO|#fS2c6&e~;=-aP{4juyZ4^e8 z2Y&pswC%@1G|2SY$GL5jUSA9r5@td`QAPnE@aoHI^U4=Uy6 z5C+qKC72RE7pn%R;vYiGb^Nu+tP&VXM|O1KLtp$t`p_4L&=AvW|Bd@#)9!yL9~N;R zoRS+d)Rs<^(W^I$!pOl@vQ*0H#m(Y`ez;58?1w{XsOhzLaGS$u-Y3fDoOGLI<-?@S z;q-}?hS#&xSTHD#a^D)TJkSfD#O{-HhD#g{lSR%?Qnz({&*Ll*}Z;+FLIszxd;sG<4Khz)&lHZL28S2YTO zQMB`Zv7#UDVE+e_DqbA=avIFCM(k)?G?3*mg)w^~F{h?_VlPQK1NUsx}K3+R~* zf8^b#1kbfR;Kx5@2mvg?VKmGn`y5w=UZ6w)VGQljBwdkC_A$Cuj-{=7$#TBLX&+-% z`#`vm7SC06_?b72*%wNL5iX*Sel0|e;oa$7;3C}x#?c3|QK>GFiO>0v73OJa%^Js( zRSe_lP7ZvBM%xMZ@d6oy3A9QFuuK->L^^R)z$tsZE2Ig96Gb;ixS0O^vRIRWyVIF^ zu^Nmf(K;;@&v9U!q)d`YLAZoI*G05Dy@)R9*Ix>A5lp6?+`lXsfGuJ?;+ZJVg#kF6 zhMQ=|U6v;c337dypz*zw=DjHVmE3i)>r%m2gv;oi{b~gts$45BQ!6f~l~0KkeerWn zGpF`0x4Af$z!duURrIQ4C5IdUc&M{0cEMAY4g*lTBH6V;38)RCVHq z@6cAsUPaALB>s*hF~U{!$w{jGDpBP{@LgIqe-58fBqlkyHl01+)s^=>deS}DxqQ$2 zo|xN8;rp~z`aTdhF)Ir!yxQ`BAq7dsQ|^O-7^I+CVQ=KLvapgWO|siufqq{FS_D6! zcTR{QRtjM@e$FQ?hX_AVp#6~cNaa^rpRXI0=ZC87enk5gs^lz6PtK2Ya(+y2y(;)N z2tVa|>w`fUq7a|s`OH0yw*B`Qzjw_T*&-Gz~SYeew9X%^2qx5dvX-=wBa}q*5 zZFJ9?7D59(ez!oT6d&s$CgD=7qAJsCKg`FN2<`c+K*oo&IWms))Hg(Ur53|<+QDlh zOZ9`ncr?TEs6r|C!CO8vYTa4uH@wC5MuPI?h8AZ7~$gd=_!QO z$!{z!log?cHuL=Il)9F*Xe@t52j{7-yeJ*Zp9%6>2(9#$9LPHjFm4o>-9pPG7ZpcTAd^GBNZ(+9a5 zq=1${JEOfC=fRGGDx4jrwle`V!fZx|bR)kASz)2po1EE9PeBAXGTQh@k>C;dmCy2k z5C4)Yly3x{OXr$i`#(Mx=r=N+bU*xx(Yh|WsT13;m`sNOa~Qp&0a(ZD!C5qi$$~K8 zCPtshLhOUD^OoWSbQ3G(XBse<(W87~<0$c2&1GmVlg-!WQAebcYr($xZ_nGupmh)Uz7Q9Yc#5 zZ?2XBOBk)uK#I}afTfJ~FA#5=0lZhfUIy?yI?v3t7rHTA!tx82GLP3949gg;lFuJO zyqSxA1%@pT^u!gsE&1?Yl14#1pUyW+?0H=5EARrkz#L=$z%pPtqZ9hb&3sCCJYB|? z^D_)s!RQ(N1os}lbQ*9gqxor>La$8J+l0@Vaa7KIdZQoVZe+SPZu@ zdT5=v&{g8kQbpby-<3_a635b5lk67PvA41Q11)hZ!LJ#;C%dGYLR7PKocuL2)#?GT ziqVU*;j7j8QtMRvcQ&m`9bv%jj8@;OXt0*kz|gG^ZfDZ8t1@no`Eq@^WTeE%fYpo^ zq{)s`E2~-gFcFdgYZz@_uFm66a;{Zt)OnU4)-syEROosLudqBo_z{0G%Y_hLNEe!9 zf7|84S|;%_U>&0)iv?Zf6Ps(%I=RU8Wz6~7^Yx78cECUlQ?TCg=?+G3bDryKP>y)5 zD(tD(=H9^y=P@1U21XC2HB<-w4XKh5WB0ODJ~uNuz%#|Aoxdo$a5G@1lXS7n! zU>noHyq_uLOW*-Ui}d4)Yl`ZWy$59WECaSOT6_{mi-d4`L__oS|7Hj-_9PE>TbXzjOJ_-oE?cvGetp; z#PKxV^xBIuEdw59v|cAm{L#eGibvR^DqSvLCrQ4zf*h;aY8mi5Mn{hb4h_P;@hR7V z?RRV%FI?A`Dup@0?-{*utJqe9Yk4mnhBwQ}yap%G1hd3m<;LsxY?e@Jg6)jnICZkO z>ttJgc#P4r99=!g${yzm<*^jTet4YGd%Qq9NU2lukE@2^+F!z_OyQaVPcYh|1$#YD zrL*%1Rfd)UPck~tE@ZO+pW<_{v+7AUQC6MviNBt3^R7>03gs$`;3-C1MqY z{6|XgD4a+WO|)ME*UqQ3|4xp|QdODSkPDw@)iIU<&oR13PA#40l;={ELDAj2<>9!e%OLhR zLF{F;mcJ}`)B}p^{Jk!n+Q(>z9t!x&zH8aOR4o~>pV0zdOI;|{ehrB$v6EHXHsBA8 zR;LM$6WexgzrzJ81C>sThaB0Y8O}7j<%xIf_a_bPqVeQ`lc!kl!vX0cl@yVwDS5g#misZYg z>NVg9qdWCYb+c3l6$BhnB(e;6mC=)2!ugCPuFnp%uPPQ<1{`Iy@kUW_1-O?>uyf>5 zrUb(UTczq+2E4{-n>H{0VC9&9%`yKvqm_EzKhDu}a`Jkr@4vz5xPGVG$!~^^sW({a zz&9DayI!QX)0FgPYD#*G(ff-;I630~>TsEQ%kk=MM(sLZ9Y)!=RlfRW0jp)9{};+m zgqvHMB8iZvKHe5fhBE70+CsiqI2KPt>f^D7M5rtoNhE_aqshoM(;6eOU|l#7X^O@o z0lR!^w7I1zQWh9HITCA3&Inxom9V;LH)Ja~k8JAm176(ud0;iDWd^SQeNbjWjic zCQDDsyRl)cT3gE32F6BW^)s5otux1m6UnPuqsfS}9GKn~tFH`A2wr(cvFR|TiBlTm zA%p)T8fy&LL~F1qULS4>HpVLhp^9LlwLYj82J5tIe0xvzRc>zz zx5esbgev&Q?%-27QUy(|ZLwsuITEnT>zczYWr6tBk=E%=@mZnLuANcqgU#U<;fDI} zKy$bynvAr@BG)8CRo!tz!#kemt8!#0)QwF}PU7|PmTSAuhfylrn#O2yMq6E=KHeOx zZ;H1y%!)L|C1AmpnT^4=WV9&}n3`;j#u~4PPi>0UN5)>8jD)6km36+MIo=RFxy=i% zt_X|@REd?sbg+(FOC(!4c2iEiQS4}GjVI&v@upy1az<-(dNNQKjfGpUouWPm1Usd# z3XdQD-`(tZXiy%?{q30RXe^pM4a(`7{6@kaE1*zecZWLZd>a)yt4r`D(2en+P?6?v zVrIZD7Yw~LoS0b_5dRFdoHoqbE+<4)plU=#AXE{ms;mrER)$7aR926uo?c%Yu9;q4 zSyfTx93B)NG{!>(sWOW+H^;AzghqT#b;@Pa!p#je)qzB)^5n%eRf%^xKqI@erDHjs z_9-=Ikh;*B$ViJWj&Um0huKR=id9&k@{QH@mBD zN}OVsby*Oi*LGixgqLF@jnSAx*=S;1b4&8tkWX_s+|Upja%%o2l5KSf?$w}3tUlfl zjWuc=s*5&`i#0^UvA~qJrSk&uz9ebjatk;XhNkwTq$4=D>=97~4$9i4A%jn9h48bhdm pXlR>0{klkN{A4#1wJyllrDlz" + } + return fmt.Sprintf("Simple(%+v)", *p) +} + +func (p *Simple) DeepEqual(ano *Simple) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.ByteField) { + return false + } + if !p.Field2DeepEqual(ano.I64Field) { + return false + } + if !p.Field3DeepEqual(ano.DoubleField) { + return false + } + if !p.Field4DeepEqual(ano.I32Field) { + return false + } + if !p.Field5DeepEqual(ano.StringField) { + return false + } + if !p.Field6DeepEqual(ano.BinaryField) { + return false + } + return true +} + +func (p *Simple) Field1DeepEqual(src int8) bool { + + if p.ByteField != src { + return false + } + return true +} +func (p *Simple) Field2DeepEqual(src int64) bool { + + if p.I64Field != src { + return false + } + return true +} +func (p *Simple) Field3DeepEqual(src float64) bool { + + if p.DoubleField != src { + return false + } + return true +} +func (p *Simple) Field4DeepEqual(src int32) bool { + + if p.I32Field != src { + return false + } + return true +} +func (p *Simple) Field5DeepEqual(src string) bool { + + if strings.Compare(p.StringField, src) != 0 { + return false + } + return true +} +func (p *Simple) Field6DeepEqual(src []byte) bool { + + if bytes.Compare(p.BinaryField, src) != 0 { + return false + } + return true +} + +type PartialSimple struct { + ByteField int8 `thrift:"ByteField,1" frugal:"1,default,byte" json:"ByteField"` + DoubleField float64 `thrift:"DoubleField,3" frugal:"3,default,double" json:"DoubleField"` + BinaryField []byte `thrift:"BinaryField,6" frugal:"6,default,binary" json:"BinaryField"` + _fieldmask *fieldmask.FieldMask +} + +func NewPartialSimple() *PartialSimple { + return &PartialSimple{} +} + +func (p *PartialSimple) InitDefault() { + *p = PartialSimple{} +} + +func (p *PartialSimple) GetByteField() (v int8) { + return p.ByteField +} + +func (p *PartialSimple) GetDoubleField() (v float64) { + return p.DoubleField +} + +func (p *PartialSimple) GetBinaryField() (v []byte) { + return p.BinaryField +} +func (p *PartialSimple) SetByteField(val int8) { + p.ByteField = val +} +func (p *PartialSimple) SetDoubleField(val float64) { + p.DoubleField = val +} +func (p *PartialSimple) SetBinaryField(val []byte) { + p.BinaryField = val +} + +func (p *PartialSimple) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *PartialSimple) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_PartialSimple = map[int16]string{ + 1: "ByteField", + 3: "DoubleField", + 6: "BinaryField", +} + +func (p *PartialSimple) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField6(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialSimple[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PartialSimple) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadByte(); err != nil { + return err + } else { + p.ByteField = v + } + return nil +} +func (p *PartialSimple) ReadField3(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadDouble(); err != nil { + return err + } else { + p.DoubleField = v + } + return nil +} +func (p *PartialSimple) ReadField6(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadBinary(); err != nil { + return err + } else { + p.BinaryField = []byte(v) + } + return nil +} + +func (p *PartialSimple) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PartialSimple"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(3); ex { + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(6); ex { + if err = p.writeField6(oprot); err != nil { + fieldId = 6 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PartialSimple) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("ByteField", thrift.BYTE, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteByte(p.ByteField); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *PartialSimple) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("DoubleField", thrift.DOUBLE, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteDouble(p.DoubleField); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *PartialSimple) writeField6(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("BinaryField", thrift.STRING, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBinary([]byte(p.BinaryField)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} + +func (p *PartialSimple) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PartialSimple(%+v)", *p) +} + +func (p *PartialSimple) DeepEqual(ano *PartialSimple) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.ByteField) { + return false + } + if !p.Field3DeepEqual(ano.DoubleField) { + return false + } + if !p.Field6DeepEqual(ano.BinaryField) { + return false + } + return true +} + +func (p *PartialSimple) Field1DeepEqual(src int8) bool { + + if p.ByteField != src { + return false + } + return true +} +func (p *PartialSimple) Field3DeepEqual(src float64) bool { + + if p.DoubleField != src { + return false + } + return true +} +func (p *PartialSimple) Field6DeepEqual(src []byte) bool { + + if bytes.Compare(p.BinaryField, src) != 0 { + return false + } + return true +} + +type Nesting struct { + String_ string `thrift:"String,1" frugal:"1,default,string" json:"String"` + ListSimple []*Simple `thrift:"ListSimple,2" frugal:"2,default,list" json:"ListSimple"` + Double float64 `thrift:"Double,3" frugal:"3,default,double" json:"Double"` + I32 int32 `thrift:"I32,4" frugal:"4,default,i32" json:"I32"` + ListI32 []int32 `thrift:"ListI32,5" frugal:"5,default,list" json:"ListI32"` + I64 int64 `thrift:"I64,6" frugal:"6,default,i64" json:"I64"` + MapStringString map[string]string `thrift:"MapStringString,7" frugal:"7,default,map" json:"MapStringString"` + SimpleStruct *Simple `thrift:"SimpleStruct,8" frugal:"8,default,Simple" json:"SimpleStruct"` + MapI32I64 map[int32]int64 `thrift:"MapI32I64,9" frugal:"9,default,map" json:"MapI32I64"` + ListString []string `thrift:"ListString,10" frugal:"10,default,list" json:"ListString"` + Binary []byte `thrift:"Binary,11" frugal:"11,default,binary" json:"Binary"` + MapI64String map[int64]string `thrift:"MapI64String,12" frugal:"12,default,map" json:"MapI64String"` + ListI64 []int64 `thrift:"ListI64,13" frugal:"13,default,list" json:"ListI64"` + Byte int8 `thrift:"Byte,14" frugal:"14,default,byte" json:"Byte"` + MapStringSimple map[string]*Simple `thrift:"MapStringSimple,15" frugal:"15,default,map" json:"MapStringSimple"` + _fieldmask *fieldmask.FieldMask +} + +func NewNesting() *Nesting { + return &Nesting{} +} + +func (p *Nesting) InitDefault() { + *p = Nesting{} +} + +func (p *Nesting) GetString() (v string) { + return p.String_ +} + +func (p *Nesting) GetListSimple() (v []*Simple) { + return p.ListSimple +} + +func (p *Nesting) GetDouble() (v float64) { + return p.Double +} + +func (p *Nesting) GetI32() (v int32) { + return p.I32 +} + +func (p *Nesting) GetListI32() (v []int32) { + return p.ListI32 +} + +func (p *Nesting) GetI64() (v int64) { + return p.I64 +} + +func (p *Nesting) GetMapStringString() (v map[string]string) { + return p.MapStringString +} + +var Nesting_SimpleStruct_DEFAULT *Simple + +func (p *Nesting) GetSimpleStruct() (v *Simple) { + if !p.IsSetSimpleStruct() { + return Nesting_SimpleStruct_DEFAULT + } + return p.SimpleStruct +} + +func (p *Nesting) GetMapI32I64() (v map[int32]int64) { + return p.MapI32I64 +} + +func (p *Nesting) GetListString() (v []string) { + return p.ListString +} + +func (p *Nesting) GetBinary() (v []byte) { + return p.Binary +} + +func (p *Nesting) GetMapI64String() (v map[int64]string) { + return p.MapI64String +} + +func (p *Nesting) GetListI64() (v []int64) { + return p.ListI64 +} + +func (p *Nesting) GetByte() (v int8) { + return p.Byte +} + +func (p *Nesting) GetMapStringSimple() (v map[string]*Simple) { + return p.MapStringSimple +} +func (p *Nesting) SetString(val string) { + p.String_ = val +} +func (p *Nesting) SetListSimple(val []*Simple) { + p.ListSimple = val +} +func (p *Nesting) SetDouble(val float64) { + p.Double = val +} +func (p *Nesting) SetI32(val int32) { + p.I32 = val +} +func (p *Nesting) SetListI32(val []int32) { + p.ListI32 = val +} +func (p *Nesting) SetI64(val int64) { + p.I64 = val +} +func (p *Nesting) SetMapStringString(val map[string]string) { + p.MapStringString = val +} +func (p *Nesting) SetSimpleStruct(val *Simple) { + p.SimpleStruct = val +} +func (p *Nesting) SetMapI32I64(val map[int32]int64) { + p.MapI32I64 = val +} +func (p *Nesting) SetListString(val []string) { + p.ListString = val +} +func (p *Nesting) SetBinary(val []byte) { + p.Binary = val +} +func (p *Nesting) SetMapI64String(val map[int64]string) { + p.MapI64String = val +} +func (p *Nesting) SetListI64(val []int64) { + p.ListI64 = val +} +func (p *Nesting) SetByte(val int8) { + p.Byte = val +} +func (p *Nesting) SetMapStringSimple(val map[string]*Simple) { + p.MapStringSimple = val +} + +func (p *Nesting) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *Nesting) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_Nesting = map[int16]string{ + 1: "String", + 2: "ListSimple", + 3: "Double", + 4: "I32", + 5: "ListI32", + 6: "I64", + 7: "MapStringString", + 8: "SimpleStruct", + 9: "MapI32I64", + 10: "ListString", + 11: "Binary", + 12: "MapI64String", + 13: "ListI64", + 14: "Byte", + 15: "MapStringSimple", +} + +func (p *Nesting) IsSetSimpleStruct() bool { + return p.SimpleStruct != nil +} + +func (p *Nesting) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField2(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.I32 { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField5(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.I64 { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField6(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 7: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField7(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField8(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 9: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField9(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 10: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField10(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 11: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField11(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 12: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField12(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 13: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField13(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 14: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField14(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 15: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField15(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Nesting) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.String_ = v + } + return nil +} +func (p *Nesting) ReadField2(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + p.ListSimple = make([]*Simple, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.STRUCT); err != nil { + return err + } + continue + } else { + _elem := NewSimple() + _elem.SetFieldMask(nfm) + if err := _elem.Read(iprot); err != nil { + return err + } + + p.ListSimple = append(p.ListSimple, _elem) + } + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField3(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadDouble(); err != nil { + return err + } else { + p.Double = v + } + return nil +} +func (p *Nesting) ReadField4(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + p.I32 = v + } + return nil +} +func (p *Nesting) ReadField5(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + p.ListI32 = make([]int32, 0, size) + for i := 0; i < size; i++ { + if _, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.I32); err != nil { + return err + } + continue + } else { + + var _elem int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _elem = v + } + + p.ListI32 = append(p.ListI32, _elem) + } + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField6(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + p.I64 = v + } + return nil +} +func (p *Nesting) ReadField7(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + p.MapStringString = make(map[string]string, size) + for i := 0; i < size; i++ { + var _key string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _key = v + } + if _, ex := fm.Str(string(_key)); !ex { + if err := iprot.Skip(thrift.STRING); err != nil { + return err + } + continue + } else { + + var _val string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _val = v + } + + p.MapStringString[_key] = _val + } + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField8(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.SimpleStruct = NewSimple() + p.SimpleStruct.SetFieldMask(fm) + if err := p.SimpleStruct.Read(iprot); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField9(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + p.MapI32I64 = make(map[int32]int64, size) + for i := 0; i < size; i++ { + var _key int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _key = v + } + if _, ex := fm.Int(int(_key)); !ex { + if err := iprot.Skip(thrift.I64); err != nil { + return err + } + continue + } else { + + var _val int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _val = v + } + + p.MapI32I64[_key] = _val + } + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField10(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + p.ListString = make([]string, 0, size) + for i := 0; i < size; i++ { + if _, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.STRING); err != nil { + return err + } + continue + } else { + + var _elem string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _elem = v + } + + p.ListString = append(p.ListString, _elem) + } + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField11(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadBinary(); err != nil { + return err + } else { + p.Binary = []byte(v) + } + return nil +} +func (p *Nesting) ReadField12(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + p.MapI64String = make(map[int64]string, size) + for i := 0; i < size; i++ { + var _key int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _key = v + } + if _, ex := fm.Int(int(_key)); !ex { + if err := iprot.Skip(thrift.STRING); err != nil { + return err + } + continue + } else { + + var _val string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _val = v + } + + p.MapI64String[_key] = _val + } + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField13(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + p.ListI64 = make([]int64, 0, size) + for i := 0; i < size; i++ { + if _, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.I64); err != nil { + return err + } + continue + } else { + + var _elem int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _elem = v + } + + p.ListI64 = append(p.ListI64, _elem) + } + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting) ReadField14(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadByte(); err != nil { + return err + } else { + p.Byte = v + } + return nil +} +func (p *Nesting) ReadField15(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + p.MapStringSimple = make(map[string]*Simple, size) + for i := 0; i < size; i++ { + var _key string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _key = v + } + if nfm, ex := fm.Str(string(_key)); !ex { + if err := iprot.Skip(thrift.STRUCT); err != nil { + return err + } + continue + } else { + _val := NewSimple() + _val.SetFieldMask(nfm) + if err := _val.Read(iprot); err != nil { + return err + } + + p.MapStringSimple[_key] = _val + } + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + return nil +} + +func (p *Nesting) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Nesting"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(2); ex { + if err = p.writeField2(oprot, nfm); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(3); ex { + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(4); ex { + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(5); ex { + if err = p.writeField5(oprot, nfm); err != nil { + fieldId = 5 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(6); ex { + if err = p.writeField6(oprot); err != nil { + fieldId = 6 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(7); ex { + if err = p.writeField7(oprot, nfm); err != nil { + fieldId = 7 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(8); ex { + if err = p.writeField8(oprot, nfm); err != nil { + fieldId = 8 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(9); ex { + if err = p.writeField9(oprot, nfm); err != nil { + fieldId = 9 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(10); ex { + if err = p.writeField10(oprot, nfm); err != nil { + fieldId = 10 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(11); ex { + if err = p.writeField11(oprot); err != nil { + fieldId = 11 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(12); ex { + if err = p.writeField12(oprot, nfm); err != nil { + fieldId = 12 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(13); ex { + if err = p.writeField13(oprot, nfm); err != nil { + fieldId = 13 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(14); ex { + if err = p.writeField14(oprot); err != nil { + fieldId = 14 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(15); ex { + if err = p.writeField15(oprot, nfm); err != nil { + fieldId = 15 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Nesting) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("String", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.String_); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *Nesting) writeField2(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("ListSimple", thrift.LIST, 2); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.ListSimple) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteListBegin(thrift.STRUCT, l); err != nil { + return err + } + } else { + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListSimple)); err != nil { + return err + } + } + for i, v := range p.ListSimple { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *Nesting) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteDouble(p.Double); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *Nesting) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("I32", thrift.I32, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.I32); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *Nesting) writeField5(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("ListI32", thrift.LIST, 5); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.ListI32) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteListBegin(thrift.I32, l); err != nil { + return err + } + } else { + if err := oprot.WriteListBegin(thrift.I32, len(p.ListI32)); err != nil { + return err + } + } + for i, v := range p.ListI32 { + if _, ex := fm.Int(i); !ex { + continue + } else { + if err := oprot.WriteI32(v); err != nil { + return err + } + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +} +func (p *Nesting) writeField6(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("I64", thrift.I64, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.I64); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} +func (p *Nesting) writeField7(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("MapStringString", thrift.MAP, 7); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.MapStringString) + for k := range p.MapStringString { + if _, ex := fm.Str(string(k)); !ex { + l-- + } + } + if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, l); err != nil { + return err + } + } else { + if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString)); err != nil { + return err + } + } + for k, v := range p.MapStringString { + ks := string(k) + if _, ex := fm.Str(ks); !ex { + continue + } else { + if err := oprot.WriteString(k); err != nil { + return err + } + if err := oprot.WriteString(v); err != nil { + return err + } + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) +} +func (p *Nesting) writeField8(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 8); err != nil { + goto WriteFieldBeginError + } + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + if err := p.SimpleStruct.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) +} +func (p *Nesting) writeField9(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("MapI32I64", thrift.MAP, 9); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.MapI32I64) + for k := range p.MapI32I64 { + if _, ex := fm.Int(int(k)); !ex { + l-- + } + } + if err := oprot.WriteMapBegin(thrift.I32, thrift.I64, l); err != nil { + return err + } + } else { + if err := oprot.WriteMapBegin(thrift.I32, thrift.I64, len(p.MapI32I64)); err != nil { + return err + } + } + for k, v := range p.MapI32I64 { + if _, ex := fm.Int(int(k)); !ex { + continue + } else { + if err := oprot.WriteI32(k); err != nil { + return err + } + if err := oprot.WriteI64(v); err != nil { + return err + } + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) +} +func (p *Nesting) writeField10(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("ListString", thrift.LIST, 10); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.ListString) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteListBegin(thrift.STRING, l); err != nil { + return err + } + } else { + if err := oprot.WriteListBegin(thrift.STRING, len(p.ListString)); err != nil { + return err + } + } + for i, v := range p.ListString { + if _, ex := fm.Int(i); !ex { + continue + } else { + if err := oprot.WriteString(v); err != nil { + return err + } + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) +} +func (p *Nesting) writeField11(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 11); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) +} +func (p *Nesting) writeField12(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("MapI64String", thrift.MAP, 12); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.MapI64String) + for k := range p.MapI64String { + if _, ex := fm.Int(int(k)); !ex { + l-- + } + } + if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, l); err != nil { + return err + } + } else { + if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, len(p.MapI64String)); err != nil { + return err + } + } + for k, v := range p.MapI64String { + if _, ex := fm.Int(int(k)); !ex { + continue + } else { + if err := oprot.WriteI64(k); err != nil { + return err + } + if err := oprot.WriteString(v); err != nil { + return err + } + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) +} +func (p *Nesting) writeField13(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("ListI64", thrift.LIST, 13); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.ListI64) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteListBegin(thrift.I64, l); err != nil { + return err + } + } else { + if err := oprot.WriteListBegin(thrift.I64, len(p.ListI64)); err != nil { + return err + } + } + for i, v := range p.ListI64 { + if _, ex := fm.Int(i); !ex { + continue + } else { + if err := oprot.WriteI64(v); err != nil { + return err + } + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err) +} +func (p *Nesting) writeField14(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 14); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteByte(p.Byte); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 14 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 14 end error: ", p), err) +} +func (p *Nesting) writeField15(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("MapStringSimple", thrift.MAP, 15); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.MapStringSimple) + for k := range p.MapStringSimple { + if _, ex := fm.Str(string(k)); !ex { + l-- + } + } + if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, l); err != nil { + return err + } + } else { + if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)); err != nil { + return err + } + } + for k, v := range p.MapStringSimple { + ks := string(k) + if nfm, ex := fm.Str(ks); !ex { + continue + } else { + if err := oprot.WriteString(k); err != nil { + return err + } + if v != nil { + v.SetFieldMask(nfm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) +} + +func (p *Nesting) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Nesting(%+v)", *p) +} + +func (p *Nesting) DeepEqual(ano *Nesting) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.String_) { + return false + } + if !p.Field2DeepEqual(ano.ListSimple) { + return false + } + if !p.Field3DeepEqual(ano.Double) { + return false + } + if !p.Field4DeepEqual(ano.I32) { + return false + } + if !p.Field5DeepEqual(ano.ListI32) { + return false + } + if !p.Field6DeepEqual(ano.I64) { + return false + } + if !p.Field7DeepEqual(ano.MapStringString) { + return false + } + if !p.Field8DeepEqual(ano.SimpleStruct) { + return false + } + if !p.Field9DeepEqual(ano.MapI32I64) { + return false + } + if !p.Field10DeepEqual(ano.ListString) { + return false + } + if !p.Field11DeepEqual(ano.Binary) { + return false + } + if !p.Field12DeepEqual(ano.MapI64String) { + return false + } + if !p.Field13DeepEqual(ano.ListI64) { + return false + } + if !p.Field14DeepEqual(ano.Byte) { + return false + } + if !p.Field15DeepEqual(ano.MapStringSimple) { + return false + } + return true +} + +func (p *Nesting) Field1DeepEqual(src string) bool { + + if strings.Compare(p.String_, src) != 0 { + return false + } + return true +} +func (p *Nesting) Field2DeepEqual(src []*Simple) bool { + + if len(p.ListSimple) != len(src) { + return false + } + for i, v := range p.ListSimple { + _src := src[i] + if !v.DeepEqual(_src) { + return false + } + } + return true +} +func (p *Nesting) Field3DeepEqual(src float64) bool { + + if p.Double != src { + return false + } + return true +} +func (p *Nesting) Field4DeepEqual(src int32) bool { + + if p.I32 != src { + return false + } + return true +} +func (p *Nesting) Field5DeepEqual(src []int32) bool { + + if len(p.ListI32) != len(src) { + return false + } + for i, v := range p.ListI32 { + _src := src[i] + if v != _src { + return false + } + } + return true +} +func (p *Nesting) Field6DeepEqual(src int64) bool { + + if p.I64 != src { + return false + } + return true +} +func (p *Nesting) Field7DeepEqual(src map[string]string) bool { + + if len(p.MapStringString) != len(src) { + return false + } + for k, v := range p.MapStringString { + _src := src[k] + if strings.Compare(v, _src) != 0 { + return false + } + } + return true +} +func (p *Nesting) Field8DeepEqual(src *Simple) bool { + + if !p.SimpleStruct.DeepEqual(src) { + return false + } + return true +} +func (p *Nesting) Field9DeepEqual(src map[int32]int64) bool { + + if len(p.MapI32I64) != len(src) { + return false + } + for k, v := range p.MapI32I64 { + _src := src[k] + if v != _src { + return false + } + } + return true +} +func (p *Nesting) Field10DeepEqual(src []string) bool { + + if len(p.ListString) != len(src) { + return false + } + for i, v := range p.ListString { + _src := src[i] + if strings.Compare(v, _src) != 0 { + return false + } + } + return true +} +func (p *Nesting) Field11DeepEqual(src []byte) bool { + + if bytes.Compare(p.Binary, src) != 0 { + return false + } + return true +} +func (p *Nesting) Field12DeepEqual(src map[int64]string) bool { + + if len(p.MapI64String) != len(src) { + return false + } + for k, v := range p.MapI64String { + _src := src[k] + if strings.Compare(v, _src) != 0 { + return false + } + } + return true +} +func (p *Nesting) Field13DeepEqual(src []int64) bool { + + if len(p.ListI64) != len(src) { + return false + } + for i, v := range p.ListI64 { + _src := src[i] + if v != _src { + return false + } + } + return true +} +func (p *Nesting) Field14DeepEqual(src int8) bool { + + if p.Byte != src { + return false + } + return true +} +func (p *Nesting) Field15DeepEqual(src map[string]*Simple) bool { + + if len(p.MapStringSimple) != len(src) { + return false + } + for k, v := range p.MapStringSimple { + _src := src[k] + if !v.DeepEqual(_src) { + return false + } + } + return true +} + +type PartialNesting struct { + ListSimple []*PartialSimple `thrift:"ListSimple,2" frugal:"2,default,list" json:"ListSimple"` + SimpleStruct *PartialSimple `thrift:"SimpleStruct,8" frugal:"8,default,PartialSimple" json:"SimpleStruct"` + MapStringSimple map[string]*PartialSimple `thrift:"MapStringSimple,15" frugal:"15,default,map" json:"MapStringSimple"` + _fieldmask *fieldmask.FieldMask +} + +func NewPartialNesting() *PartialNesting { + return &PartialNesting{} +} + +func (p *PartialNesting) InitDefault() { + *p = PartialNesting{} +} + +func (p *PartialNesting) GetListSimple() (v []*PartialSimple) { + return p.ListSimple +} + +var PartialNesting_SimpleStruct_DEFAULT *PartialSimple + +func (p *PartialNesting) GetSimpleStruct() (v *PartialSimple) { + if !p.IsSetSimpleStruct() { + return PartialNesting_SimpleStruct_DEFAULT + } + return p.SimpleStruct +} + +func (p *PartialNesting) GetMapStringSimple() (v map[string]*PartialSimple) { + return p.MapStringSimple +} +func (p *PartialNesting) SetListSimple(val []*PartialSimple) { + p.ListSimple = val +} +func (p *PartialNesting) SetSimpleStruct(val *PartialSimple) { + p.SimpleStruct = val +} +func (p *PartialNesting) SetMapStringSimple(val map[string]*PartialSimple) { + p.MapStringSimple = val +} + +func (p *PartialNesting) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *PartialNesting) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_PartialNesting = map[int16]string{ + 2: "ListSimple", + 8: "SimpleStruct", + 15: "MapStringSimple", +} + +func (p *PartialNesting) IsSetSimpleStruct() bool { + return p.SimpleStruct != nil +} + +func (p *PartialNesting) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 2: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField2(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField8(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 15: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField15(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialNesting[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PartialNesting) ReadField2(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + p.ListSimple = make([]*PartialSimple, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.STRUCT); err != nil { + return err + } + continue + } else { + _elem := NewPartialSimple() + _elem.SetFieldMask(nfm) + if err := _elem.Read(iprot); err != nil { + return err + } + + p.ListSimple = append(p.ListSimple, _elem) + } + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + return nil +} +func (p *PartialNesting) ReadField8(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.SimpleStruct = NewPartialSimple() + p.SimpleStruct.SetFieldMask(fm) + if err := p.SimpleStruct.Read(iprot); err != nil { + return err + } + return nil +} +func (p *PartialNesting) ReadField15(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + p.MapStringSimple = make(map[string]*PartialSimple, size) + for i := 0; i < size; i++ { + var _key string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _key = v + } + if nfm, ex := fm.Str(string(_key)); !ex { + if err := iprot.Skip(thrift.STRUCT); err != nil { + return err + } + continue + } else { + _val := NewPartialSimple() + _val.SetFieldMask(nfm) + if err := _val.Read(iprot); err != nil { + return err + } + + p.MapStringSimple[_key] = _val + } + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + return nil +} + +func (p *PartialNesting) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PartialNesting"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(2); ex { + if err = p.writeField2(oprot, nfm); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(8); ex { + if err = p.writeField8(oprot, nfm); err != nil { + fieldId = 8 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(15); ex { + if err = p.writeField15(oprot, nfm); err != nil { + fieldId = 15 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PartialNesting) writeField2(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("ListSimple", thrift.LIST, 2); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.ListSimple) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteListBegin(thrift.STRUCT, l); err != nil { + return err + } + } else { + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListSimple)); err != nil { + return err + } + } + for i, v := range p.ListSimple { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *PartialNesting) writeField8(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 8); err != nil { + goto WriteFieldBeginError + } + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + if err := p.SimpleStruct.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) +} +func (p *PartialNesting) writeField15(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("MapStringSimple", thrift.MAP, 15); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.MapStringSimple) + for k := range p.MapStringSimple { + if _, ex := fm.Str(string(k)); !ex { + l-- + } + } + if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, l); err != nil { + return err + } + } else { + if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)); err != nil { + return err + } + } + for k, v := range p.MapStringSimple { + ks := string(k) + if nfm, ex := fm.Str(ks); !ex { + continue + } else { + if err := oprot.WriteString(k); err != nil { + return err + } + if v != nil { + v.SetFieldMask(nfm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) +} + +func (p *PartialNesting) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PartialNesting(%+v)", *p) +} + +func (p *PartialNesting) DeepEqual(ano *PartialNesting) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field2DeepEqual(ano.ListSimple) { + return false + } + if !p.Field8DeepEqual(ano.SimpleStruct) { + return false + } + if !p.Field15DeepEqual(ano.MapStringSimple) { + return false + } + return true +} + +func (p *PartialNesting) Field2DeepEqual(src []*PartialSimple) bool { + + if len(p.ListSimple) != len(src) { + return false + } + for i, v := range p.ListSimple { + _src := src[i] + if !v.DeepEqual(_src) { + return false + } + } + return true +} +func (p *PartialNesting) Field8DeepEqual(src *PartialSimple) bool { + + if !p.SimpleStruct.DeepEqual(src) { + return false + } + return true +} +func (p *PartialNesting) Field15DeepEqual(src map[string]*PartialSimple) bool { + + if len(p.MapStringSimple) != len(src) { + return false + } + for k, v := range p.MapStringSimple { + _src := src[k] + if !v.DeepEqual(_src) { + return false + } + } + return true +} + +type Nesting2 struct { + MapSimpleNesting map[*Simple]*Nesting `thrift:"MapSimpleNesting,1" frugal:"1,default,map" json:"MapSimpleNesting"` + SimpleStruct *Simple `thrift:"SimpleStruct,2" frugal:"2,default,Simple" json:"SimpleStruct"` + Byte int8 `thrift:"Byte,3" frugal:"3,default,byte" json:"Byte"` + Double float64 `thrift:"Double,4" frugal:"4,default,double" json:"Double"` + ListNesting []*Nesting `thrift:"ListNesting,5" frugal:"5,default,list" json:"ListNesting"` + I64 int64 `thrift:"I64,6" frugal:"6,default,i64" json:"I64"` + NestingStruct *Nesting `thrift:"NestingStruct,7" frugal:"7,default,Nesting" json:"NestingStruct"` + Binary []byte `thrift:"Binary,8" frugal:"8,default,binary" json:"Binary"` + String_ string `thrift:"String,9" frugal:"9,default,string" json:"String"` + SetNesting []*Nesting `thrift:"SetNesting,10" frugal:"10,default,set" json:"SetNesting"` + I32 int32 `thrift:"I32,11" frugal:"11,default,i32" json:"I32"` + _fieldmask *fieldmask.FieldMask +} + +func NewNesting2() *Nesting2 { + return &Nesting2{} +} + +func (p *Nesting2) InitDefault() { + *p = Nesting2{} +} + +func (p *Nesting2) GetMapSimpleNesting() (v map[*Simple]*Nesting) { + return p.MapSimpleNesting +} + +var Nesting2_SimpleStruct_DEFAULT *Simple + +func (p *Nesting2) GetSimpleStruct() (v *Simple) { + if !p.IsSetSimpleStruct() { + return Nesting2_SimpleStruct_DEFAULT + } + return p.SimpleStruct +} + +func (p *Nesting2) GetByte() (v int8) { + return p.Byte +} + +func (p *Nesting2) GetDouble() (v float64) { + return p.Double +} + +func (p *Nesting2) GetListNesting() (v []*Nesting) { + return p.ListNesting +} + +func (p *Nesting2) GetI64() (v int64) { + return p.I64 +} + +var Nesting2_NestingStruct_DEFAULT *Nesting + +func (p *Nesting2) GetNestingStruct() (v *Nesting) { + if !p.IsSetNestingStruct() { + return Nesting2_NestingStruct_DEFAULT + } + return p.NestingStruct +} + +func (p *Nesting2) GetBinary() (v []byte) { + return p.Binary +} + +func (p *Nesting2) GetString() (v string) { + return p.String_ +} + +func (p *Nesting2) GetSetNesting() (v []*Nesting) { + return p.SetNesting +} + +func (p *Nesting2) GetI32() (v int32) { + return p.I32 +} +func (p *Nesting2) SetMapSimpleNesting(val map[*Simple]*Nesting) { + p.MapSimpleNesting = val +} +func (p *Nesting2) SetSimpleStruct(val *Simple) { + p.SimpleStruct = val +} +func (p *Nesting2) SetByte(val int8) { + p.Byte = val +} +func (p *Nesting2) SetDouble(val float64) { + p.Double = val +} +func (p *Nesting2) SetListNesting(val []*Nesting) { + p.ListNesting = val +} +func (p *Nesting2) SetI64(val int64) { + p.I64 = val +} +func (p *Nesting2) SetNestingStruct(val *Nesting) { + p.NestingStruct = val +} +func (p *Nesting2) SetBinary(val []byte) { + p.Binary = val +} +func (p *Nesting2) SetString(val string) { + p.String_ = val +} +func (p *Nesting2) SetSetNesting(val []*Nesting) { + p.SetNesting = val +} +func (p *Nesting2) SetI32(val int32) { + p.I32 = val +} + +func (p *Nesting2) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *Nesting2) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_Nesting2 = map[int16]string{ + 1: "MapSimpleNesting", + 2: "SimpleStruct", + 3: "Byte", + 4: "Double", + 5: "ListNesting", + 6: "I64", + 7: "NestingStruct", + 8: "Binary", + 9: "String", + 10: "SetNesting", + 11: "I32", +} + +func (p *Nesting2) IsSetSimpleStruct() bool { + return p.SimpleStruct != nil +} + +func (p *Nesting2) IsSetNestingStruct() bool { + return p.NestingStruct != nil +} + +func (p *Nesting2) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField2(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField5(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.I64 { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField6(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 7: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField7(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField8(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 9: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField9(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 10: + if fieldTypeId == thrift.SET { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField10(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 11: + if fieldTypeId == thrift.I32 { + if _, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField11(iprot); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting2[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Nesting2) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + p.MapSimpleNesting = make(map[*Simple]*Nesting, size) + for i := 0; i < size; i++ { + _key := NewSimple() + _key.SetFieldMask(fm) + if err := _key.Read(iprot); err != nil { + return err + } + fm = nil + _val := NewNesting() + _val.SetFieldMask(fm) + if err := _val.Read(iprot); err != nil { + return err + } + + p.MapSimpleNesting[_key] = _val + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting2) ReadField2(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.SimpleStruct = NewSimple() + p.SimpleStruct.SetFieldMask(fm) + if err := p.SimpleStruct.Read(iprot); err != nil { + return err + } + return nil +} +func (p *Nesting2) ReadField3(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadByte(); err != nil { + return err + } else { + p.Byte = v + } + return nil +} +func (p *Nesting2) ReadField4(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadDouble(); err != nil { + return err + } else { + p.Double = v + } + return nil +} +func (p *Nesting2) ReadField5(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + p.ListNesting = make([]*Nesting, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.STRUCT); err != nil { + return err + } + continue + } else { + _elem := NewNesting() + _elem.SetFieldMask(nfm) + if err := _elem.Read(iprot); err != nil { + return err + } + + p.ListNesting = append(p.ListNesting, _elem) + } + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting2) ReadField6(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + p.I64 = v + } + return nil +} +func (p *Nesting2) ReadField7(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.NestingStruct = NewNesting() + p.NestingStruct.SetFieldMask(fm) + if err := p.NestingStruct.Read(iprot); err != nil { + return err + } + return nil +} +func (p *Nesting2) ReadField8(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadBinary(); err != nil { + return err + } else { + p.Binary = []byte(v) + } + return nil +} +func (p *Nesting2) ReadField9(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.String_ = v + } + return nil +} +func (p *Nesting2) ReadField10(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + _, size, err := iprot.ReadSetBegin() + if err != nil { + return err + } + p.SetNesting = make([]*Nesting, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + if err := iprot.Skip(thrift.STRUCT); err != nil { + return err + } + continue + } else { + _elem := NewNesting() + _elem.SetFieldMask(nfm) + if err := _elem.Read(iprot); err != nil { + return err + } + + p.SetNesting = append(p.SetNesting, _elem) + } + } + if err := iprot.ReadSetEnd(); err != nil { + return err + } + return nil +} +func (p *Nesting2) ReadField11(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + p.I32 = v + } + return nil +} + +func (p *Nesting2) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Nesting2"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot, nfm); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(2); ex { + if err = p.writeField2(oprot, nfm); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(3); ex { + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(4); ex { + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(5); ex { + if err = p.writeField5(oprot, nfm); err != nil { + fieldId = 5 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(6); ex { + if err = p.writeField6(oprot); err != nil { + fieldId = 6 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(7); ex { + if err = p.writeField7(oprot, nfm); err != nil { + fieldId = 7 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(8); ex { + if err = p.writeField8(oprot); err != nil { + fieldId = 8 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(9); ex { + if err = p.writeField9(oprot); err != nil { + fieldId = 9 + goto WriteFieldError + } + } + if nfm, ex := p._fieldmask.Field(10); ex { + if err = p.writeField10(oprot, nfm); err != nil { + fieldId = 10 + goto WriteFieldError + } + } + if _, ex := p._fieldmask.Field(11); ex { + if err = p.writeField11(oprot); err != nil { + fieldId = 11 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Nesting2) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("MapSimpleNesting", thrift.MAP, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)); err != nil { + return err + } + for k, v := range p.MapSimpleNesting { + fm = nil + if k != nil { + k.SetFieldMask(fm) + } + if err := k.Write(oprot); err != nil { + return err + } + if v != nil { + v.SetFieldMask(fm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *Nesting2) writeField2(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 2); err != nil { + goto WriteFieldBeginError + } + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + if err := p.SimpleStruct.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *Nesting2) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteByte(p.Byte); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *Nesting2) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteDouble(p.Double); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *Nesting2) writeField5(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("ListNesting", thrift.LIST, 5); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.ListNesting) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteListBegin(thrift.STRUCT, l); err != nil { + return err + } + } else { + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListNesting)); err != nil { + return err + } + } + for i, v := range p.ListNesting { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +} +func (p *Nesting2) writeField6(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("I64", thrift.I64, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.I64); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} +func (p *Nesting2) writeField7(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("NestingStruct", thrift.STRUCT, 7); err != nil { + goto WriteFieldBeginError + } + if p.NestingStruct != nil { + p.NestingStruct.SetFieldMask(fm) + } + if err := p.NestingStruct.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) +} +func (p *Nesting2) writeField8(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 8); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) +} +func (p *Nesting2) writeField9(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("String", thrift.STRING, 9); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.String_); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) +} +func (p *Nesting2) writeField10(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("SetNesting", thrift.SET, 10); err != nil { + goto WriteFieldBeginError + } + if !fm.All() { + l := len(p.SetNesting) + for i := 0; i < l; i++ { + if _, ex := fm.Int(i); !ex { + l-- + } + } + if err := oprot.WriteSetBegin(thrift.STRUCT, l); err != nil { + return err + } + } else { + if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.SetNesting)); err != nil { + return err + } + } + for i := 0; i < len(p.SetNesting); i++ { + for j := i + 1; j < len(p.SetNesting); j++ { + if func(tgt, src *Nesting) bool { + if !tgt.DeepEqual(src) { + return false + } + return true + }(p.SetNesting[i], p.SetNesting[j]) { + return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) + } + } + } + for i, v := range p.SetNesting { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + if err := v.Write(oprot); err != nil { + return err + } + } + } + if err := oprot.WriteSetEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) +} +func (p *Nesting2) writeField11(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("I32", thrift.I32, 11); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.I32); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) +} + +func (p *Nesting2) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Nesting2(%+v)", *p) +} + +func (p *Nesting2) DeepEqual(ano *Nesting2) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.MapSimpleNesting) { + return false + } + if !p.Field2DeepEqual(ano.SimpleStruct) { + return false + } + if !p.Field3DeepEqual(ano.Byte) { + return false + } + if !p.Field4DeepEqual(ano.Double) { + return false + } + if !p.Field5DeepEqual(ano.ListNesting) { + return false + } + if !p.Field6DeepEqual(ano.I64) { + return false + } + if !p.Field7DeepEqual(ano.NestingStruct) { + return false + } + if !p.Field8DeepEqual(ano.Binary) { + return false + } + if !p.Field9DeepEqual(ano.String_) { + return false + } + if !p.Field10DeepEqual(ano.SetNesting) { + return false + } + if !p.Field11DeepEqual(ano.I32) { + return false + } + return true +} + +func (p *Nesting2) Field1DeepEqual(src map[*Simple]*Nesting) bool { + + if len(p.MapSimpleNesting) != len(src) { + return false + } + for k, v := range p.MapSimpleNesting { + _src := src[k] + if !v.DeepEqual(_src) { + return false + } + } + return true +} +func (p *Nesting2) Field2DeepEqual(src *Simple) bool { + + if !p.SimpleStruct.DeepEqual(src) { + return false + } + return true +} +func (p *Nesting2) Field3DeepEqual(src int8) bool { + + if p.Byte != src { + return false + } + return true +} +func (p *Nesting2) Field4DeepEqual(src float64) bool { + + if p.Double != src { + return false + } + return true +} +func (p *Nesting2) Field5DeepEqual(src []*Nesting) bool { + + if len(p.ListNesting) != len(src) { + return false + } + for i, v := range p.ListNesting { + _src := src[i] + if !v.DeepEqual(_src) { + return false + } + } + return true +} +func (p *Nesting2) Field6DeepEqual(src int64) bool { + + if p.I64 != src { + return false + } + return true +} +func (p *Nesting2) Field7DeepEqual(src *Nesting) bool { + + if !p.NestingStruct.DeepEqual(src) { + return false + } + return true +} +func (p *Nesting2) Field8DeepEqual(src []byte) bool { + + if bytes.Compare(p.Binary, src) != 0 { + return false + } + return true +} +func (p *Nesting2) Field9DeepEqual(src string) bool { + + if strings.Compare(p.String_, src) != 0 { + return false + } + return true +} +func (p *Nesting2) Field10DeepEqual(src []*Nesting) bool { + + if len(p.SetNesting) != len(src) { + return false + } + for i, v := range p.SetNesting { + _src := src[i] + if !v.DeepEqual(_src) { + return false + } + } + return true +} +func (p *Nesting2) Field11DeepEqual(src int32) bool { + + if p.I32 != src { + return false + } + return true +} + +type BaselineService interface { + SimpleMethod(ctx context.Context, req *Simple) (r *Simple, err error) + + PartialSimpleMethod(ctx context.Context, req *PartialSimple) (r *PartialSimple, err error) + + NestingMethod(ctx context.Context, req *Nesting) (r *Nesting, err error) + + PartialNestingMethod(ctx context.Context, req *PartialNesting) (r *PartialNesting, err error) + + Nesting2Method(ctx context.Context, req *Nesting2) (r *Nesting2, err error) +} + +type BaselineServiceClient struct { + c thrift.TClient +} + +func NewBaselineServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BaselineServiceClient { + return &BaselineServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewBaselineServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BaselineServiceClient { + return &BaselineServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewBaselineServiceClient(c thrift.TClient) *BaselineServiceClient { + return &BaselineServiceClient{ + c: c, + } +} + +func (p *BaselineServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *BaselineServiceClient) SimpleMethod(ctx context.Context, req *Simple) (r *Simple, err error) { + var _args BaselineServiceSimpleMethodArgs + _args.Req = req + var _result BaselineServiceSimpleMethodResult + if err = p.Client_().Call(ctx, "SimpleMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *BaselineServiceClient) PartialSimpleMethod(ctx context.Context, req *PartialSimple) (r *PartialSimple, err error) { + var _args BaselineServicePartialSimpleMethodArgs + _args.Req = req + var _result BaselineServicePartialSimpleMethodResult + if err = p.Client_().Call(ctx, "PartialSimpleMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *BaselineServiceClient) NestingMethod(ctx context.Context, req *Nesting) (r *Nesting, err error) { + var _args BaselineServiceNestingMethodArgs + _args.Req = req + var _result BaselineServiceNestingMethodResult + if err = p.Client_().Call(ctx, "NestingMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *BaselineServiceClient) PartialNestingMethod(ctx context.Context, req *PartialNesting) (r *PartialNesting, err error) { + var _args BaselineServicePartialNestingMethodArgs + _args.Req = req + var _result BaselineServicePartialNestingMethodResult + if err = p.Client_().Call(ctx, "PartialNestingMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *BaselineServiceClient) Nesting2Method(ctx context.Context, req *Nesting2) (r *Nesting2, err error) { + var _args BaselineServiceNesting2MethodArgs + _args.Req = req + var _result BaselineServiceNesting2MethodResult + if err = p.Client_().Call(ctx, "Nesting2Method", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type BaselineServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler BaselineService +} + +func (p *BaselineServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *BaselineServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *BaselineServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewBaselineServiceProcessor(handler BaselineService) *BaselineServiceProcessor { + self := &BaselineServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("SimpleMethod", &baselineServiceProcessorSimpleMethod{handler: handler}) + self.AddToProcessorMap("PartialSimpleMethod", &baselineServiceProcessorPartialSimpleMethod{handler: handler}) + self.AddToProcessorMap("NestingMethod", &baselineServiceProcessorNestingMethod{handler: handler}) + self.AddToProcessorMap("PartialNestingMethod", &baselineServiceProcessorPartialNestingMethod{handler: handler}) + self.AddToProcessorMap("Nesting2Method", &baselineServiceProcessorNesting2Method{handler: handler}) + return self +} +func (p *BaselineServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type baselineServiceProcessorSimpleMethod struct { + handler BaselineService +} + +func (p *baselineServiceProcessorSimpleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := BaselineServiceSimpleMethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("SimpleMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := BaselineServiceSimpleMethodResult{} + var retval *Simple + if retval, err2 = p.handler.SimpleMethod(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing SimpleMethod: "+err2.Error()) + oprot.WriteMessageBegin("SimpleMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("SimpleMethod", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type baselineServiceProcessorPartialSimpleMethod struct { + handler BaselineService +} + +func (p *baselineServiceProcessorPartialSimpleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := BaselineServicePartialSimpleMethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PartialSimpleMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := BaselineServicePartialSimpleMethodResult{} + var retval *PartialSimple + if retval, err2 = p.handler.PartialSimpleMethod(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialSimpleMethod: "+err2.Error()) + oprot.WriteMessageBegin("PartialSimpleMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PartialSimpleMethod", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type baselineServiceProcessorNestingMethod struct { + handler BaselineService +} + +func (p *baselineServiceProcessorNestingMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := BaselineServiceNestingMethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("NestingMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := BaselineServiceNestingMethodResult{} + var retval *Nesting + if retval, err2 = p.handler.NestingMethod(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing NestingMethod: "+err2.Error()) + oprot.WriteMessageBegin("NestingMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("NestingMethod", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type baselineServiceProcessorPartialNestingMethod struct { + handler BaselineService +} + +func (p *baselineServiceProcessorPartialNestingMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := BaselineServicePartialNestingMethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PartialNestingMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := BaselineServicePartialNestingMethodResult{} + var retval *PartialNesting + if retval, err2 = p.handler.PartialNestingMethod(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialNestingMethod: "+err2.Error()) + oprot.WriteMessageBegin("PartialNestingMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PartialNestingMethod", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type baselineServiceProcessorNesting2Method struct { + handler BaselineService +} + +func (p *baselineServiceProcessorNesting2Method) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := BaselineServiceNesting2MethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Nesting2Method", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := BaselineServiceNesting2MethodResult{} + var retval *Nesting2 + if retval, err2 = p.handler.Nesting2Method(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Nesting2Method: "+err2.Error()) + oprot.WriteMessageBegin("Nesting2Method", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Nesting2Method", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type BaselineServiceSimpleMethodArgs struct { + Req *Simple `thrift:"req,1" frugal:"1,default,Simple" json:"req"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServiceSimpleMethodArgs() *BaselineServiceSimpleMethodArgs { + return &BaselineServiceSimpleMethodArgs{} +} + +func (p *BaselineServiceSimpleMethodArgs) InitDefault() { + *p = BaselineServiceSimpleMethodArgs{} +} + +var BaselineServiceSimpleMethodArgs_Req_DEFAULT *Simple + +func (p *BaselineServiceSimpleMethodArgs) GetReq() (v *Simple) { + if !p.IsSetReq() { + return BaselineServiceSimpleMethodArgs_Req_DEFAULT + } + return p.Req +} +func (p *BaselineServiceSimpleMethodArgs) SetReq(val *Simple) { + p.Req = val +} + +func (p *BaselineServiceSimpleMethodArgs) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServiceSimpleMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServiceSimpleMethodArgs = map[int16]string{ + 1: "req", +} + +func (p *BaselineServiceSimpleMethodArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BaselineServiceSimpleMethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Req = NewSimple() + p.Req.SetFieldMask(fm) + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServiceSimpleMethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SimpleMethod_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot, nfm); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServiceSimpleMethodArgs(%+v)", *p) +} + +func (p *BaselineServiceSimpleMethodArgs) DeepEqual(ano *BaselineServiceSimpleMethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BaselineServiceSimpleMethodArgs) Field1DeepEqual(src *Simple) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BaselineServiceSimpleMethodResult struct { + Success *Simple `thrift:"success,0,optional" frugal:"0,optional,Simple" json:"success,omitempty"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServiceSimpleMethodResult() *BaselineServiceSimpleMethodResult { + return &BaselineServiceSimpleMethodResult{} +} + +func (p *BaselineServiceSimpleMethodResult) InitDefault() { + *p = BaselineServiceSimpleMethodResult{} +} + +var BaselineServiceSimpleMethodResult_Success_DEFAULT *Simple + +func (p *BaselineServiceSimpleMethodResult) GetSuccess() (v *Simple) { + if !p.IsSetSuccess() { + return BaselineServiceSimpleMethodResult_Success_DEFAULT + } + return p.Success +} +func (p *BaselineServiceSimpleMethodResult) SetSuccess(x interface{}) { + p.Success = x.(*Simple) +} + +func (p *BaselineServiceSimpleMethodResult) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServiceSimpleMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServiceSimpleMethodResult = map[int16]string{ + 0: "success", +} + +func (p *BaselineServiceSimpleMethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BaselineServiceSimpleMethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField0(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Success = NewSimple() + p.Success.SetFieldMask(fm) + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServiceSimpleMethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SimpleMethod_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + if err = p.writeField0(oprot, nfm); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServiceSimpleMethodResult(%+v)", *p) +} + +func (p *BaselineServiceSimpleMethodResult) DeepEqual(ano *BaselineServiceSimpleMethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BaselineServiceSimpleMethodResult) Field0DeepEqual(src *Simple) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type BaselineServicePartialSimpleMethodArgs struct { + Req *PartialSimple `thrift:"req,1" frugal:"1,default,PartialSimple" json:"req"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServicePartialSimpleMethodArgs() *BaselineServicePartialSimpleMethodArgs { + return &BaselineServicePartialSimpleMethodArgs{} +} + +func (p *BaselineServicePartialSimpleMethodArgs) InitDefault() { + *p = BaselineServicePartialSimpleMethodArgs{} +} + +var BaselineServicePartialSimpleMethodArgs_Req_DEFAULT *PartialSimple + +func (p *BaselineServicePartialSimpleMethodArgs) GetReq() (v *PartialSimple) { + if !p.IsSetReq() { + return BaselineServicePartialSimpleMethodArgs_Req_DEFAULT + } + return p.Req +} +func (p *BaselineServicePartialSimpleMethodArgs) SetReq(val *PartialSimple) { + p.Req = val +} + +func (p *BaselineServicePartialSimpleMethodArgs) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServicePartialSimpleMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServicePartialSimpleMethodArgs = map[int16]string{ + 1: "req", +} + +func (p *BaselineServicePartialSimpleMethodArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BaselineServicePartialSimpleMethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Req = NewPartialSimple() + p.Req.SetFieldMask(fm) + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServicePartialSimpleMethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PartialSimpleMethod_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot, nfm); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServicePartialSimpleMethodArgs(%+v)", *p) +} + +func (p *BaselineServicePartialSimpleMethodArgs) DeepEqual(ano *BaselineServicePartialSimpleMethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BaselineServicePartialSimpleMethodArgs) Field1DeepEqual(src *PartialSimple) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BaselineServicePartialSimpleMethodResult struct { + Success *PartialSimple `thrift:"success,0,optional" frugal:"0,optional,PartialSimple" json:"success,omitempty"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServicePartialSimpleMethodResult() *BaselineServicePartialSimpleMethodResult { + return &BaselineServicePartialSimpleMethodResult{} +} + +func (p *BaselineServicePartialSimpleMethodResult) InitDefault() { + *p = BaselineServicePartialSimpleMethodResult{} +} + +var BaselineServicePartialSimpleMethodResult_Success_DEFAULT *PartialSimple + +func (p *BaselineServicePartialSimpleMethodResult) GetSuccess() (v *PartialSimple) { + if !p.IsSetSuccess() { + return BaselineServicePartialSimpleMethodResult_Success_DEFAULT + } + return p.Success +} +func (p *BaselineServicePartialSimpleMethodResult) SetSuccess(x interface{}) { + p.Success = x.(*PartialSimple) +} + +func (p *BaselineServicePartialSimpleMethodResult) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServicePartialSimpleMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServicePartialSimpleMethodResult = map[int16]string{ + 0: "success", +} + +func (p *BaselineServicePartialSimpleMethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BaselineServicePartialSimpleMethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField0(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Success = NewPartialSimple() + p.Success.SetFieldMask(fm) + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServicePartialSimpleMethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PartialSimpleMethod_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + if err = p.writeField0(oprot, nfm); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServicePartialSimpleMethodResult(%+v)", *p) +} + +func (p *BaselineServicePartialSimpleMethodResult) DeepEqual(ano *BaselineServicePartialSimpleMethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BaselineServicePartialSimpleMethodResult) Field0DeepEqual(src *PartialSimple) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type BaselineServiceNestingMethodArgs struct { + Req *Nesting `thrift:"req,1" frugal:"1,default,Nesting" json:"req"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServiceNestingMethodArgs() *BaselineServiceNestingMethodArgs { + return &BaselineServiceNestingMethodArgs{} +} + +func (p *BaselineServiceNestingMethodArgs) InitDefault() { + *p = BaselineServiceNestingMethodArgs{} +} + +var BaselineServiceNestingMethodArgs_Req_DEFAULT *Nesting + +func (p *BaselineServiceNestingMethodArgs) GetReq() (v *Nesting) { + if !p.IsSetReq() { + return BaselineServiceNestingMethodArgs_Req_DEFAULT + } + return p.Req +} +func (p *BaselineServiceNestingMethodArgs) SetReq(val *Nesting) { + p.Req = val +} + +func (p *BaselineServiceNestingMethodArgs) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServiceNestingMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServiceNestingMethodArgs = map[int16]string{ + 1: "req", +} + +func (p *BaselineServiceNestingMethodArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BaselineServiceNestingMethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Req = NewNesting() + p.Req.SetFieldMask(fm) + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServiceNestingMethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("NestingMethod_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot, nfm); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServiceNestingMethodArgs(%+v)", *p) +} + +func (p *BaselineServiceNestingMethodArgs) DeepEqual(ano *BaselineServiceNestingMethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BaselineServiceNestingMethodArgs) Field1DeepEqual(src *Nesting) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BaselineServiceNestingMethodResult struct { + Success *Nesting `thrift:"success,0,optional" frugal:"0,optional,Nesting" json:"success,omitempty"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServiceNestingMethodResult() *BaselineServiceNestingMethodResult { + return &BaselineServiceNestingMethodResult{} +} + +func (p *BaselineServiceNestingMethodResult) InitDefault() { + *p = BaselineServiceNestingMethodResult{} +} + +var BaselineServiceNestingMethodResult_Success_DEFAULT *Nesting + +func (p *BaselineServiceNestingMethodResult) GetSuccess() (v *Nesting) { + if !p.IsSetSuccess() { + return BaselineServiceNestingMethodResult_Success_DEFAULT + } + return p.Success +} +func (p *BaselineServiceNestingMethodResult) SetSuccess(x interface{}) { + p.Success = x.(*Nesting) +} + +func (p *BaselineServiceNestingMethodResult) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServiceNestingMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServiceNestingMethodResult = map[int16]string{ + 0: "success", +} + +func (p *BaselineServiceNestingMethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BaselineServiceNestingMethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField0(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Success = NewNesting() + p.Success.SetFieldMask(fm) + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServiceNestingMethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("NestingMethod_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + if err = p.writeField0(oprot, nfm); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServiceNestingMethodResult(%+v)", *p) +} + +func (p *BaselineServiceNestingMethodResult) DeepEqual(ano *BaselineServiceNestingMethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BaselineServiceNestingMethodResult) Field0DeepEqual(src *Nesting) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type BaselineServicePartialNestingMethodArgs struct { + Req *PartialNesting `thrift:"req,1" frugal:"1,default,PartialNesting" json:"req"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServicePartialNestingMethodArgs() *BaselineServicePartialNestingMethodArgs { + return &BaselineServicePartialNestingMethodArgs{} +} + +func (p *BaselineServicePartialNestingMethodArgs) InitDefault() { + *p = BaselineServicePartialNestingMethodArgs{} +} + +var BaselineServicePartialNestingMethodArgs_Req_DEFAULT *PartialNesting + +func (p *BaselineServicePartialNestingMethodArgs) GetReq() (v *PartialNesting) { + if !p.IsSetReq() { + return BaselineServicePartialNestingMethodArgs_Req_DEFAULT + } + return p.Req +} +func (p *BaselineServicePartialNestingMethodArgs) SetReq(val *PartialNesting) { + p.Req = val +} + +func (p *BaselineServicePartialNestingMethodArgs) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServicePartialNestingMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServicePartialNestingMethodArgs = map[int16]string{ + 1: "req", +} + +func (p *BaselineServicePartialNestingMethodArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BaselineServicePartialNestingMethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Req = NewPartialNesting() + p.Req.SetFieldMask(fm) + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServicePartialNestingMethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PartialNestingMethod_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot, nfm); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServicePartialNestingMethodArgs(%+v)", *p) +} + +func (p *BaselineServicePartialNestingMethodArgs) DeepEqual(ano *BaselineServicePartialNestingMethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BaselineServicePartialNestingMethodArgs) Field1DeepEqual(src *PartialNesting) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BaselineServicePartialNestingMethodResult struct { + Success *PartialNesting `thrift:"success,0,optional" frugal:"0,optional,PartialNesting" json:"success,omitempty"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServicePartialNestingMethodResult() *BaselineServicePartialNestingMethodResult { + return &BaselineServicePartialNestingMethodResult{} +} + +func (p *BaselineServicePartialNestingMethodResult) InitDefault() { + *p = BaselineServicePartialNestingMethodResult{} +} + +var BaselineServicePartialNestingMethodResult_Success_DEFAULT *PartialNesting + +func (p *BaselineServicePartialNestingMethodResult) GetSuccess() (v *PartialNesting) { + if !p.IsSetSuccess() { + return BaselineServicePartialNestingMethodResult_Success_DEFAULT + } + return p.Success +} +func (p *BaselineServicePartialNestingMethodResult) SetSuccess(x interface{}) { + p.Success = x.(*PartialNesting) +} + +func (p *BaselineServicePartialNestingMethodResult) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServicePartialNestingMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServicePartialNestingMethodResult = map[int16]string{ + 0: "success", +} + +func (p *BaselineServicePartialNestingMethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BaselineServicePartialNestingMethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField0(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Success = NewPartialNesting() + p.Success.SetFieldMask(fm) + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServicePartialNestingMethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PartialNestingMethod_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + if err = p.writeField0(oprot, nfm); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServicePartialNestingMethodResult(%+v)", *p) +} + +func (p *BaselineServicePartialNestingMethodResult) DeepEqual(ano *BaselineServicePartialNestingMethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BaselineServicePartialNestingMethodResult) Field0DeepEqual(src *PartialNesting) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type BaselineServiceNesting2MethodArgs struct { + Req *Nesting2 `thrift:"req,1" frugal:"1,default,Nesting2" json:"req"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServiceNesting2MethodArgs() *BaselineServiceNesting2MethodArgs { + return &BaselineServiceNesting2MethodArgs{} +} + +func (p *BaselineServiceNesting2MethodArgs) InitDefault() { + *p = BaselineServiceNesting2MethodArgs{} +} + +var BaselineServiceNesting2MethodArgs_Req_DEFAULT *Nesting2 + +func (p *BaselineServiceNesting2MethodArgs) GetReq() (v *Nesting2) { + if !p.IsSetReq() { + return BaselineServiceNesting2MethodArgs_Req_DEFAULT + } + return p.Req +} +func (p *BaselineServiceNesting2MethodArgs) SetReq(val *Nesting2) { + p.Req = val +} + +func (p *BaselineServiceNesting2MethodArgs) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServiceNesting2MethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServiceNesting2MethodArgs = map[int16]string{ + 1: "req", +} + +func (p *BaselineServiceNesting2MethodArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BaselineServiceNesting2MethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField1(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Req = NewNesting2() + p.Req.SetFieldMask(fm) + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServiceNesting2MethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Nesting2Method_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + if err = p.writeField1(oprot, nfm); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServiceNesting2MethodArgs(%+v)", *p) +} + +func (p *BaselineServiceNesting2MethodArgs) DeepEqual(ano *BaselineServiceNesting2MethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BaselineServiceNesting2MethodArgs) Field1DeepEqual(src *Nesting2) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BaselineServiceNesting2MethodResult struct { + Success *Nesting2 `thrift:"success,0,optional" frugal:"0,optional,Nesting2" json:"success,omitempty"` + _fieldmask *fieldmask.FieldMask +} + +func NewBaselineServiceNesting2MethodResult() *BaselineServiceNesting2MethodResult { + return &BaselineServiceNesting2MethodResult{} +} + +func (p *BaselineServiceNesting2MethodResult) InitDefault() { + *p = BaselineServiceNesting2MethodResult{} +} + +var BaselineServiceNesting2MethodResult_Success_DEFAULT *Nesting2 + +func (p *BaselineServiceNesting2MethodResult) GetSuccess() (v *Nesting2) { + if !p.IsSetSuccess() { + return BaselineServiceNesting2MethodResult_Success_DEFAULT + } + return p.Success +} +func (p *BaselineServiceNesting2MethodResult) SetSuccess(x interface{}) { + p.Success = x.(*Nesting2) +} + +func (p *BaselineServiceNesting2MethodResult) GetFieldMask() *fieldmask.FieldMask { + return p._fieldmask +} +func (p *BaselineServiceNesting2MethodResult) SetFieldMask(fm *fieldmask.FieldMask) { + p._fieldmask = fm +} + +var fieldIDToName_BaselineServiceNesting2MethodResult = map[int16]string{ + 0: "success", +} + +func (p *BaselineServiceNesting2MethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BaselineServiceNesting2MethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + if err = p.ReadField0(iprot, nfm); err != nil { + goto ReadFieldError + } + break + } + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { + p.Success = NewNesting2() + p.Success.SetFieldMask(fm) + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BaselineServiceNesting2MethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Nesting2Method_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + if err = p.writeField0(oprot, nfm); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BaselineServiceNesting2MethodResult(%+v)", *p) +} + +func (p *BaselineServiceNesting2MethodResult) DeepEqual(ano *BaselineServiceNesting2MethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BaselineServiceNesting2MethodResult) Field0DeepEqual(src *Nesting2) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/codegen/fieldmask/test_gen/baseline/k-baseline.go b/codegen/fieldmask/test_gen/baseline/k-baseline.go new file mode 100644 index 0000000..37db4c9 --- /dev/null +++ b/codegen/fieldmask/test_gen/baseline/k-baseline.go @@ -0,0 +1,4556 @@ +// Code generated by Kitex v0.7.3. DO NOT EDIT. + +package baseline + +import ( + "bytes" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex/pkg/protocol/bthrift" + "github.com/cloudwego/thriftgo/fieldmask" + "reflect" + "strings" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *Simple) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I64 { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField2(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField3(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.I32 { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField4(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField5(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField6(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Simple[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Simple) FastReadField1(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.ByteField = v + + } + return offset, nil +} + +func (p *Simple) FastReadField2(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.I64Field = v + + } + return offset, nil +} + +func (p *Simple) FastReadField3(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.DoubleField = v + + } + return offset, nil +} + +func (p *Simple) FastReadField4(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.I32Field = v + + } + return offset, nil +} + +func (p *Simple) FastReadField5(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.StringField = v + + } + return offset, nil +} + +func (p *Simple) FastReadField6(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.BinaryField = []byte(v) + + } + return offset, nil +} + +// for compatibility +func (p *Simple) FastWrite(buf []byte) int { + return 0 +} + +func (p *Simple) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Simple") + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(2); ex { + offset += p.fastWriteField2(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(3); ex { + offset += p.fastWriteField3(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(4); ex { + offset += p.fastWriteField4(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(5); ex { + offset += p.fastWriteField5(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(6); ex { + offset += p.fastWriteField6(buf[offset:], binaryWriter) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Simple) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Simple") + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + l += p.field1Length() + } + if _, ex := p._fieldmask.Field(2); ex { + l += p.field2Length() + } + if _, ex := p._fieldmask.Field(3); ex { + l += p.field3Length() + } + if _, ex := p._fieldmask.Field(4); ex { + l += p.field4Length() + } + if _, ex := p._fieldmask.Field(5); ex { + l += p.field5Length() + } + if _, ex := p._fieldmask.Field(6); ex { + l += p.field6Length() + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Simple) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ByteField", thrift.BYTE, 1) + offset += bthrift.Binary.WriteByte(buf[offset:], p.ByteField) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Simple) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64Field", thrift.I64, 2) + offset += bthrift.Binary.WriteI64(buf[offset:], p.I64Field) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Simple) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DoubleField", thrift.DOUBLE, 3) + offset += bthrift.Binary.WriteDouble(buf[offset:], p.DoubleField) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Simple) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32Field", thrift.I32, 4) + offset += bthrift.Binary.WriteI32(buf[offset:], p.I32Field) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Simple) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StringField", thrift.STRING, 5) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.StringField) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Simple) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BinaryField", thrift.STRING, 6) + offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.BinaryField)) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Simple) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ByteField", thrift.BYTE, 1) + l += bthrift.Binary.ByteLength(p.ByteField) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Simple) field2Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("I64Field", thrift.I64, 2) + l += bthrift.Binary.I64Length(p.I64Field) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Simple) field3Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("DoubleField", thrift.DOUBLE, 3) + l += bthrift.Binary.DoubleLength(p.DoubleField) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Simple) field4Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("I32Field", thrift.I32, 4) + l += bthrift.Binary.I32Length(p.I32Field) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Simple) field5Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("StringField", thrift.STRING, 5) + l += bthrift.Binary.StringLengthNocopy(p.StringField) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Simple) field6Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("BinaryField", thrift.STRING, 6) + l += bthrift.Binary.BinaryLengthNocopy([]byte(p.BinaryField)) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PartialSimple) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField3(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField6(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialSimple[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PartialSimple) FastReadField1(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.ByteField = v + + } + return offset, nil +} + +func (p *PartialSimple) FastReadField3(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.DoubleField = v + + } + return offset, nil +} + +func (p *PartialSimple) FastReadField6(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.BinaryField = []byte(v) + + } + return offset, nil +} + +// for compatibility +func (p *PartialSimple) FastWrite(buf []byte) int { + return 0 +} + +func (p *PartialSimple) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimple") + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(3); ex { + offset += p.fastWriteField3(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(6); ex { + offset += p.fastWriteField6(buf[offset:], binaryWriter) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PartialSimple) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("PartialSimple") + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + l += p.field1Length() + } + if _, ex := p._fieldmask.Field(3); ex { + l += p.field3Length() + } + if _, ex := p._fieldmask.Field(6); ex { + l += p.field6Length() + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PartialSimple) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ByteField", thrift.BYTE, 1) + offset += bthrift.Binary.WriteByte(buf[offset:], p.ByteField) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PartialSimple) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DoubleField", thrift.DOUBLE, 3) + offset += bthrift.Binary.WriteDouble(buf[offset:], p.DoubleField) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PartialSimple) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BinaryField", thrift.STRING, 6) + offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.BinaryField)) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PartialSimple) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ByteField", thrift.BYTE, 1) + l += bthrift.Binary.ByteLength(p.ByteField) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PartialSimple) field3Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("DoubleField", thrift.DOUBLE, 3) + l += bthrift.Binary.DoubleLength(p.DoubleField) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PartialSimple) field6Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("BinaryField", thrift.STRING, 6) + l += bthrift.Binary.BinaryLengthNocopy([]byte(p.BinaryField)) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField2(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField3(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.I32 { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField4(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField5(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.I64 { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField6(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 7: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField7(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField8(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 9: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField9(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 10: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField10(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 11: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField11(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 12: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField12(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 13: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField13(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 14: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField14(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 15: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField15(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Nesting) FastReadField1(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.String_ = v + + } + return offset, nil +} + +func (p *Nesting) FastReadField2(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.ListSimple = make([]*Simple, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) + offset += l + if err != nil { + return offset, err + } + continue + } else { + _elem := NewSimple() + _elem.SetFieldMask(nfm) + if l, err := _elem.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.ListSimple = append(p.ListSimple, _elem) + } + } + if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField3(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Double = v + + } + return offset, nil +} + +func (p *Nesting) FastReadField4(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.I32 = v + + } + return offset, nil +} + +func (p *Nesting) FastReadField5(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.ListI32 = make([]int32, 0, size) + for i := 0; i < size; i++ { + if _, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.I32) + offset += l + if err != nil { + return offset, err + } + continue + } else { + var _elem int32 + if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _elem = v + + } + + p.ListI32 = append(p.ListI32, _elem) + } + } + if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField6(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.I64 = v + + } + return offset, nil +} + +func (p *Nesting) FastReadField7(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.MapStringString = make(map[string]string, size) + for i := 0; i < size; i++ { + var _key string + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _key = v + + } + if _, ex := fm.Str(string(_key)); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRING) + offset += l + if err != nil { + return offset, err + } + continue + } else { + + var _val string + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _val = v + + } + + p.MapStringString[_key] = _val + } + } + if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField8(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.SimpleStruct = tmp + return offset, nil +} + +func (p *Nesting) FastReadField9(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.MapI32I64 = make(map[int32]int64, size) + for i := 0; i < size; i++ { + var _key int32 + if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _key = v + + } + if _, ex := fm.Int(int(_key)); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.I64) + offset += l + if err != nil { + return offset, err + } + continue + } else { + + var _val int64 + if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _val = v + + } + + p.MapI32I64[_key] = _val + } + } + if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField10(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.ListString = make([]string, 0, size) + for i := 0; i < size; i++ { + if _, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRING) + offset += l + if err != nil { + return offset, err + } + continue + } else { + var _elem string + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _elem = v + + } + + p.ListString = append(p.ListString, _elem) + } + } + if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField11(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Binary = []byte(v) + + } + return offset, nil +} + +func (p *Nesting) FastReadField12(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.MapI64String = make(map[int64]string, size) + for i := 0; i < size; i++ { + var _key int64 + if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _key = v + + } + if _, ex := fm.Int(int(_key)); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRING) + offset += l + if err != nil { + return offset, err + } + continue + } else { + + var _val string + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _val = v + + } + + p.MapI64String[_key] = _val + } + } + if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField13(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.ListI64 = make([]int64, 0, size) + for i := 0; i < size; i++ { + if _, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.I64) + offset += l + if err != nil { + return offset, err + } + continue + } else { + var _elem int64 + if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _elem = v + + } + + p.ListI64 = append(p.ListI64, _elem) + } + } + if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting) FastReadField14(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Byte = v + + } + return offset, nil +} + +func (p *Nesting) FastReadField15(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.MapStringSimple = make(map[string]*Simple, size) + for i := 0; i < size; i++ { + var _key string + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _key = v + + } + if nfm, ex := fm.Str(string(_key)); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) + offset += l + if err != nil { + return offset, err + } + continue + } else { + _val := NewSimple() + _val.SetFieldMask(nfm) + if l, err := _val.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.MapStringSimple[_key] = _val + } + } + if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +// for compatibility +func (p *Nesting) FastWrite(buf []byte) int { + return 0 +} + +func (p *Nesting) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting") + if p != nil { + if _, ex := p._fieldmask.Field(3); ex { + offset += p.fastWriteField3(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(4); ex { + offset += p.fastWriteField4(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(6); ex { + offset += p.fastWriteField6(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(14); ex { + offset += p.fastWriteField14(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + if nfm, ex := p._fieldmask.Field(2); ex { + offset += p.fastWriteField2(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(5); ex { + offset += p.fastWriteField5(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(7); ex { + offset += p.fastWriteField7(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(8); ex { + offset += p.fastWriteField8(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(9); ex { + offset += p.fastWriteField9(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(10); ex { + offset += p.fastWriteField10(buf[offset:], binaryWriter, nfm) + } + if _, ex := p._fieldmask.Field(11); ex { + offset += p.fastWriteField11(buf[offset:], binaryWriter) + } + if nfm, ex := p._fieldmask.Field(12); ex { + offset += p.fastWriteField12(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(13); ex { + offset += p.fastWriteField13(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(15); ex { + offset += p.fastWriteField15(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Nesting) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Nesting") + if p != nil { + if _, ex := p._fieldmask.Field(1); ex { + l += p.field1Length() + } + if nfm, ex := p._fieldmask.Field(2); ex { + l += p.field2Length(nfm) + } + if _, ex := p._fieldmask.Field(3); ex { + l += p.field3Length() + } + if _, ex := p._fieldmask.Field(4); ex { + l += p.field4Length() + } + if nfm, ex := p._fieldmask.Field(5); ex { + l += p.field5Length(nfm) + } + if _, ex := p._fieldmask.Field(6); ex { + l += p.field6Length() + } + if nfm, ex := p._fieldmask.Field(7); ex { + l += p.field7Length(nfm) + } + if nfm, ex := p._fieldmask.Field(8); ex { + l += p.field8Length(nfm) + } + if nfm, ex := p._fieldmask.Field(9); ex { + l += p.field9Length(nfm) + } + if nfm, ex := p._fieldmask.Field(10); ex { + l += p.field10Length(nfm) + } + if _, ex := p._fieldmask.Field(11); ex { + l += p.field11Length() + } + if nfm, ex := p._fieldmask.Field(12); ex { + l += p.field12Length(nfm) + } + if nfm, ex := p._fieldmask.Field(13); ex { + l += p.field13Length(nfm) + } + if _, ex := p._fieldmask.Field(14); ex { + l += p.field14Length() + } + if nfm, ex := p._fieldmask.Field(15); ex { + l += p.field15Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Nesting) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListSimple", thrift.LIST, 2) + listBeginOffset := offset + offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + var length int + for i, v := range p.ListSimple { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + length++ + if v != nil { + v.SetFieldMask(nfm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + } + bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) + offset += bthrift.Binary.WriteListEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 3) + offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32", thrift.I32, 4) + offset += bthrift.Binary.WriteI32(buf[offset:], p.I32) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListI32", thrift.LIST, 5) + listBeginOffset := offset + offset += bthrift.Binary.ListBeginLength(thrift.I32, 0) + var length int + for i, v := range p.ListI32 { + if _, ex := fm.Int(i); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteI32(buf[offset:], v) + } + } + bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I32, length) + offset += bthrift.Binary.WriteListEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64", thrift.I64, 6) + offset += bthrift.Binary.WriteI64(buf[offset:], p.I64) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString", thrift.MAP, 7) + mapBeginOffset := offset + offset += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, 0) + var length int + for k, v := range p.MapStringString { + ks := string(k) + if _, ex := fm.Str(ks); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + } + } + bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRING, thrift.STRING, length) + offset += bthrift.Binary.WriteMapEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 8) + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapI32I64", thrift.MAP, 9) + mapBeginOffset := offset + offset += bthrift.Binary.MapBeginLength(thrift.I32, thrift.I64, 0) + var length int + for k, v := range p.MapI32I64 { + if _, ex := fm.Int(int(k)); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteI32(buf[offset:], k) + offset += bthrift.Binary.WriteI64(buf[offset:], v) + } + } + bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I32, thrift.I64, length) + offset += bthrift.Binary.WriteMapEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListString", thrift.LIST, 10) + listBeginOffset := offset + offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) + var length int + for i, v := range p.ListString { + if _, ex := fm.Int(i); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + } + } + bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) + offset += bthrift.Binary.WriteListEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 11) + offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapI64String", thrift.MAP, 12) + mapBeginOffset := offset + offset += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, 0) + var length int + for k, v := range p.MapI64String { + if _, ex := fm.Int(int(k)); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteI64(buf[offset:], k) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) + } + } + bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I64, thrift.STRING, length) + offset += bthrift.Binary.WriteMapEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListI64", thrift.LIST, 13) + listBeginOffset := offset + offset += bthrift.Binary.ListBeginLength(thrift.I64, 0) + var length int + for i, v := range p.ListI64 { + if _, ex := fm.Int(i); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteI64(buf[offset:], v) + } + } + bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I64, length) + offset += bthrift.Binary.WriteListEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 14) + offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringSimple", thrift.MAP, 15) + mapBeginOffset := offset + offset += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, 0) + var length int + for k, v := range p.MapStringSimple { + ks := string(k) + if nfm, ex := fm.Str(ks); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) + if v != nil { + v.SetFieldMask(nfm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + } + bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRING, thrift.STRUCT, length) + offset += bthrift.Binary.WriteMapEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.String_) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field2Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ListSimple", thrift.LIST, 2) + l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListSimple)) + for i, v := range p.ListSimple { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + l += v.BLength() + } + } + l += bthrift.Binary.ListEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field3Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 3) + l += bthrift.Binary.DoubleLength(p.Double) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field4Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("I32", thrift.I32, 4) + l += bthrift.Binary.I32Length(p.I32) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field5Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ListI32", thrift.LIST, 5) + l += bthrift.Binary.ListBeginLength(thrift.I32, len(p.ListI32)) + for i, v := range p.ListI32 { + if _, ex := fm.Int(i); !ex { + continue + } else { + l += bthrift.Binary.I32Length(v) + } + } + l += bthrift.Binary.ListEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field6Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("I64", thrift.I64, 6) + l += bthrift.Binary.I64Length(p.I64) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field7Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("MapStringString", thrift.MAP, 7) + l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString)) + for k, v := range p.MapStringString { + ks := string(k) + if _, ex := fm.Str(ks); !ex { + continue + } else { + + l += bthrift.Binary.StringLengthNocopy(k) + l += bthrift.Binary.StringLengthNocopy(v) + } + } + l += bthrift.Binary.MapEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field8Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 8) + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + l += p.SimpleStruct.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field9Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("MapI32I64", thrift.MAP, 9) + l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.I64, len(p.MapI32I64)) + for k, v := range p.MapI32I64 { + if _, ex := fm.Int(int(k)); !ex { + continue + } else { + + l += bthrift.Binary.I32Length(k) + l += bthrift.Binary.I64Length(v) + } + } + l += bthrift.Binary.MapEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field10Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ListString", thrift.LIST, 10) + l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.ListString)) + for i, v := range p.ListString { + if _, ex := fm.Int(i); !ex { + continue + } else { + l += bthrift.Binary.StringLengthNocopy(v) + } + } + l += bthrift.Binary.ListEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field11Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 11) + l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field12Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("MapI64String", thrift.MAP, 12) + l += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, len(p.MapI64String)) + for k, v := range p.MapI64String { + if _, ex := fm.Int(int(k)); !ex { + continue + } else { + + l += bthrift.Binary.I64Length(k) + l += bthrift.Binary.StringLengthNocopy(v) + } + } + l += bthrift.Binary.MapEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field13Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ListI64", thrift.LIST, 13) + l += bthrift.Binary.ListBeginLength(thrift.I64, len(p.ListI64)) + for i, v := range p.ListI64 { + if _, ex := fm.Int(i); !ex { + continue + } else { + l += bthrift.Binary.I64Length(v) + } + } + l += bthrift.Binary.ListEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field14Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 14) + l += bthrift.Binary.ByteLength(p.Byte) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting) field15Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("MapStringSimple", thrift.MAP, 15) + l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) + for k, v := range p.MapStringSimple { + ks := string(k) + if nfm, ex := fm.Str(ks); !ex { + continue + } else { + + l += bthrift.Binary.StringLengthNocopy(k) + if v != nil { + v.SetFieldMask(nfm) + } + l += v.BLength() + } + } + l += bthrift.Binary.MapEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PartialNesting) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 2: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField2(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField8(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 15: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField15(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialNesting[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PartialNesting) FastReadField2(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.ListSimple = make([]*PartialSimple, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) + offset += l + if err != nil { + return offset, err + } + continue + } else { + _elem := NewPartialSimple() + _elem.SetFieldMask(nfm) + if l, err := _elem.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.ListSimple = append(p.ListSimple, _elem) + } + } + if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *PartialNesting) FastReadField8(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewPartialSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.SimpleStruct = tmp + return offset, nil +} + +func (p *PartialNesting) FastReadField15(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.MapStringSimple = make(map[string]*PartialSimple, size) + for i := 0; i < size; i++ { + var _key string + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + _key = v + + } + if nfm, ex := fm.Str(string(_key)); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) + offset += l + if err != nil { + return offset, err + } + continue + } else { + _val := NewPartialSimple() + _val.SetFieldMask(nfm) + if l, err := _val.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.MapStringSimple[_key] = _val + } + } + if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +// for compatibility +func (p *PartialNesting) FastWrite(buf []byte) int { + return 0 +} + +func (p *PartialNesting) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNesting") + if p != nil { + if nfm, ex := p._fieldmask.Field(2); ex { + offset += p.fastWriteField2(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(8); ex { + offset += p.fastWriteField8(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(15); ex { + offset += p.fastWriteField15(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PartialNesting) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("PartialNesting") + if p != nil { + if nfm, ex := p._fieldmask.Field(2); ex { + l += p.field2Length(nfm) + } + if nfm, ex := p._fieldmask.Field(8); ex { + l += p.field8Length(nfm) + } + if nfm, ex := p._fieldmask.Field(15); ex { + l += p.field15Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PartialNesting) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListSimple", thrift.LIST, 2) + listBeginOffset := offset + offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + var length int + for i, v := range p.ListSimple { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + length++ + if v != nil { + v.SetFieldMask(nfm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + } + bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) + offset += bthrift.Binary.WriteListEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PartialNesting) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 8) + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PartialNesting) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringSimple", thrift.MAP, 15) + mapBeginOffset := offset + offset += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, 0) + var length int + for k, v := range p.MapStringSimple { + ks := string(k) + if nfm, ex := fm.Str(ks); !ex { + continue + } else { + length++ + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) + if v != nil { + v.SetFieldMask(nfm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + } + bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRING, thrift.STRUCT, length) + offset += bthrift.Binary.WriteMapEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PartialNesting) field2Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ListSimple", thrift.LIST, 2) + l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListSimple)) + for i, v := range p.ListSimple { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + l += v.BLength() + } + } + l += bthrift.Binary.ListEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PartialNesting) field8Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 8) + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + l += p.SimpleStruct.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PartialNesting) field15Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("MapStringSimple", thrift.MAP, 15) + l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) + for k, v := range p.MapStringSimple { + ks := string(k) + if nfm, ex := fm.Str(ks); !ex { + continue + } else { + + l += bthrift.Binary.StringLengthNocopy(k) + if v != nil { + v.SetFieldMask(nfm) + } + l += v.BLength() + } + } + l += bthrift.Binary.MapEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.MAP { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField2(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.BYTE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField3(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.DOUBLE { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField4(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.LIST { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField5(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.I64 { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField6(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 7: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField7(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 8: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField8(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 9: + if fieldTypeId == thrift.STRING { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField9(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 10: + if fieldTypeId == thrift.SET { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField10(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + case 11: + if fieldTypeId == thrift.I32 { + if _, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField11(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting2[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Nesting2) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.MapSimpleNesting = make(map[*Simple]*Nesting, size) + for i := 0; i < size; i++ { + _key := NewSimple() + _key.SetFieldMask(fm) + if l, err := _key.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + fm = nil + _val := NewNesting() + _val.SetFieldMask(fm) + if l, err := _val.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.MapSimpleNesting[_key] = _val + } + if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting2) FastReadField2(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.SimpleStruct = tmp + return offset, nil +} + +func (p *Nesting2) FastReadField3(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Byte = v + + } + return offset, nil +} + +func (p *Nesting2) FastReadField4(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Double = v + + } + return offset, nil +} + +func (p *Nesting2) FastReadField5(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.ListNesting = make([]*Nesting, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) + offset += l + if err != nil { + return offset, err + } + continue + } else { + _elem := NewNesting() + _elem.SetFieldMask(nfm) + if l, err := _elem.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.ListNesting = append(p.ListNesting, _elem) + } + } + if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting2) FastReadField6(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.I64 = v + + } + return offset, nil +} + +func (p *Nesting2) FastReadField7(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewNesting() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.NestingStruct = tmp + return offset, nil +} + +func (p *Nesting2) FastReadField8(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Binary = []byte(v) + + } + return offset, nil +} + +func (p *Nesting2) FastReadField9(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.String_ = v + + } + return offset, nil +} + +func (p *Nesting2) FastReadField10(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) + offset += l + if err != nil { + return offset, err + } + p.SetNesting = make([]*Nesting, 0, size) + for i := 0; i < size; i++ { + if nfm, ex := fm.Int(i); !ex { + l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) + offset += l + if err != nil { + return offset, err + } + continue + } else { + _elem := NewNesting() + _elem.SetFieldMask(nfm) + if l, err := _elem.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + + p.SetNesting = append(p.SetNesting, _elem) + } + } + if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + return offset, nil +} + +func (p *Nesting2) FastReadField11(buf []byte) (int, error) { + offset := 0 + if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.I32 = v + + } + return offset, nil +} + +// for compatibility +func (p *Nesting2) FastWrite(buf []byte) int { + return 0 +} + +func (p *Nesting2) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2") + if p != nil { + if _, ex := p._fieldmask.Field(3); ex { + offset += p.fastWriteField3(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(4); ex { + offset += p.fastWriteField4(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(6); ex { + offset += p.fastWriteField6(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(11); ex { + offset += p.fastWriteField11(buf[offset:], binaryWriter) + } + if nfm, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(2); ex { + offset += p.fastWriteField2(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(5); ex { + offset += p.fastWriteField5(buf[offset:], binaryWriter, nfm) + } + if nfm, ex := p._fieldmask.Field(7); ex { + offset += p.fastWriteField7(buf[offset:], binaryWriter, nfm) + } + if _, ex := p._fieldmask.Field(8); ex { + offset += p.fastWriteField8(buf[offset:], binaryWriter) + } + if _, ex := p._fieldmask.Field(9); ex { + offset += p.fastWriteField9(buf[offset:], binaryWriter) + } + if nfm, ex := p._fieldmask.Field(10); ex { + offset += p.fastWriteField10(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Nesting2") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + l += p.field1Length(nfm) + } + if nfm, ex := p._fieldmask.Field(2); ex { + l += p.field2Length(nfm) + } + if _, ex := p._fieldmask.Field(3); ex { + l += p.field3Length() + } + if _, ex := p._fieldmask.Field(4); ex { + l += p.field4Length() + } + if nfm, ex := p._fieldmask.Field(5); ex { + l += p.field5Length(nfm) + } + if _, ex := p._fieldmask.Field(6); ex { + l += p.field6Length() + } + if nfm, ex := p._fieldmask.Field(7); ex { + l += p.field7Length(nfm) + } + if _, ex := p._fieldmask.Field(8); ex { + l += p.field8Length() + } + if _, ex := p._fieldmask.Field(9); ex { + l += p.field9Length() + } + if nfm, ex := p._fieldmask.Field(10); ex { + l += p.field10Length(nfm) + } + if _, ex := p._fieldmask.Field(11); ex { + l += p.field11Length() + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Nesting2) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapSimpleNesting", thrift.MAP, 1) + mapBeginOffset := offset + offset += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, 0) + var length int + for k, v := range p.MapSimpleNesting { + fm = nil + length++ + if k != nil { + k.SetFieldMask(fm) + } + offset += k.FastWriteNocopy(buf[offset:], binaryWriter) + if v != nil { + v.SetFieldMask(fm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRUCT, thrift.STRUCT, length) + offset += bthrift.Binary.WriteMapEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 2) + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 3) + offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 4) + offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListNesting", thrift.LIST, 5) + listBeginOffset := offset + offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) + var length int + for i, v := range p.ListNesting { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + length++ + if v != nil { + v.SetFieldMask(nfm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + } + bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) + offset += bthrift.Binary.WriteListEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64", thrift.I64, 6) + offset += bthrift.Binary.WriteI64(buf[offset:], p.I64) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "NestingStruct", thrift.STRUCT, 7) + if p.NestingStruct != nil { + p.NestingStruct.SetFieldMask(fm) + } + offset += p.NestingStruct.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 8) + offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 9) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SetNesting", thrift.SET, 10) + setBeginOffset := offset + offset += bthrift.Binary.SetBeginLength(thrift.STRUCT, 0) + + for i := 0; i < len(p.SetNesting); i++ { + for j := i + 1; j < len(p.SetNesting); j++ { + if func(tgt, src *Nesting) bool { + if !tgt.DeepEqual(src) { + return false + } + return true + }(p.SetNesting[i], p.SetNesting[j]) { + panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) + } + } + } + var length int + for i, v := range p.SetNesting { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + length++ + if v != nil { + v.SetFieldMask(nfm) + } + offset += v.FastWriteNocopy(buf[offset:], binaryWriter) + } + } + bthrift.Binary.WriteSetBegin(buf[setBeginOffset:], thrift.STRUCT, length) + offset += bthrift.Binary.WriteSetEnd(buf[offset:]) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32", thrift.I32, 11) + offset += bthrift.Binary.WriteI32(buf[offset:], p.I32) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Nesting2) field1Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("MapSimpleNesting", thrift.MAP, 1) + l += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)) + for k, v := range p.MapSimpleNesting { + fm = nil + + if k != nil { + k.SetFieldMask(fm) + } + l += k.BLength() + if v != nil { + v.SetFieldMask(fm) + } + l += v.BLength() + } + l += bthrift.Binary.MapEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field2Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 2) + if p.SimpleStruct != nil { + p.SimpleStruct.SetFieldMask(fm) + } + l += p.SimpleStruct.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field3Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 3) + l += bthrift.Binary.ByteLength(p.Byte) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field4Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 4) + l += bthrift.Binary.DoubleLength(p.Double) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field5Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("ListNesting", thrift.LIST, 5) + l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListNesting)) + for i, v := range p.ListNesting { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + l += v.BLength() + } + } + l += bthrift.Binary.ListEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field6Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("I64", thrift.I64, 6) + l += bthrift.Binary.I64Length(p.I64) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field7Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("NestingStruct", thrift.STRUCT, 7) + if p.NestingStruct != nil { + p.NestingStruct.SetFieldMask(fm) + } + l += p.NestingStruct.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field8Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 8) + l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field9Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 9) + l += bthrift.Binary.StringLengthNocopy(p.String_) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field10Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("SetNesting", thrift.SET, 10) + l += bthrift.Binary.SetBeginLength(thrift.STRUCT, len(p.SetNesting)) + + for i := 0; i < len(p.SetNesting); i++ { + for j := i + 1; j < len(p.SetNesting); j++ { + if func(tgt, src *Nesting) bool { + if !tgt.DeepEqual(src) { + return false + } + return true + }(p.SetNesting[i], p.SetNesting[j]) { + panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) + } + } + } + for i, v := range p.SetNesting { + if nfm, ex := fm.Int(i); !ex { + continue + } else { + if v != nil { + v.SetFieldMask(nfm) + } + l += v.BLength() + } + } + l += bthrift.Binary.SetEndLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Nesting2) field11Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("I32", thrift.I32, 11) + l += bthrift.Binary.I32Length(p.I32) + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BaselineServiceSimpleMethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServiceSimpleMethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServiceSimpleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SimpleMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceSimpleMethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("SimpleMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + l += p.field1Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServiceSimpleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceSimpleMethodArgs) field1Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BaselineServiceSimpleMethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField0(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceSimpleMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServiceSimpleMethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServiceSimpleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SimpleMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceSimpleMethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("SimpleMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + l += p.field0Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServiceSimpleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BaselineServiceSimpleMethodResult) field0Length(fm *fieldmask.FieldMask) int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BaselineServicePartialSimpleMethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewPartialSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServicePartialSimpleMethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServicePartialSimpleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimpleMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServicePartialSimpleMethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("PartialSimpleMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + l += p.field1Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServicePartialSimpleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BaselineServicePartialSimpleMethodArgs) field1Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BaselineServicePartialSimpleMethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField0(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialSimpleMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewPartialSimple() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServicePartialSimpleMethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServicePartialSimpleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimpleMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServicePartialSimpleMethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("PartialSimpleMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + l += p.field0Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServicePartialSimpleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BaselineServicePartialSimpleMethodResult) field0Length(fm *fieldmask.FieldMask) int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BaselineServiceNestingMethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewNesting() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServiceNestingMethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServiceNestingMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NestingMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceNestingMethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("NestingMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + l += p.field1Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServiceNestingMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceNestingMethodArgs) field1Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BaselineServiceNestingMethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField0(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNestingMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewNesting() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServiceNestingMethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServiceNestingMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NestingMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceNestingMethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("NestingMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + l += p.field0Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServiceNestingMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BaselineServiceNestingMethodResult) field0Length(fm *fieldmask.FieldMask) int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BaselineServicePartialNestingMethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewPartialNesting() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServicePartialNestingMethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServicePartialNestingMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNestingMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServicePartialNestingMethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("PartialNestingMethod_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + l += p.field1Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServicePartialNestingMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BaselineServicePartialNestingMethodArgs) field1Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BaselineServicePartialNestingMethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField0(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServicePartialNestingMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewPartialNesting() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServicePartialNestingMethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServicePartialNestingMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNestingMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServicePartialNestingMethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("PartialNestingMethod_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + l += p.field0Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServicePartialNestingMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BaselineServicePartialNestingMethodResult) field0Length(fm *fieldmask.FieldMask) int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BaselineServiceNesting2MethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField1(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewNesting2() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServiceNesting2MethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServiceNesting2MethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2Method_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceNesting2MethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Nesting2Method_args") + if p != nil { + if nfm, ex := p._fieldmask.Field(1); ex { + l += p.field1Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServiceNesting2MethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceNesting2MethodArgs) field1Length(fm *fieldmask.FieldMask) int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + if p.Req != nil { + p.Req.SetFieldMask(fm) + } + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BaselineServiceNesting2MethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if nfm, ex := p._fieldmask.Field(fieldId); ex { + l, err = p.FastReadField0(buf[offset:], nfm) + offset += l + if err != nil { + goto ReadFieldError + } + break + } + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BaselineServiceNesting2MethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { + offset := 0 + tmp := NewNesting2() + tmp.SetFieldMask(fm) + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BaselineServiceNesting2MethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BaselineServiceNesting2MethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2Method_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) + } + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BaselineServiceNesting2MethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Nesting2Method_result") + if p != nil { + if nfm, ex := p._fieldmask.Field(0); ex { + l += p.field0Length(nfm) + } + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BaselineServiceNesting2MethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BaselineServiceNesting2MethodResult) field0Length(fm *fieldmask.FieldMask) int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + if p.Success != nil { + p.Success.SetFieldMask(fm) + } + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BaselineServiceSimpleMethodArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BaselineServiceSimpleMethodResult) GetResult() interface{} { + return p.Success +} + +func (p *BaselineServicePartialSimpleMethodArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BaselineServicePartialSimpleMethodResult) GetResult() interface{} { + return p.Success +} + +func (p *BaselineServiceNestingMethodArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BaselineServiceNestingMethodResult) GetResult() interface{} { + return p.Success +} + +func (p *BaselineServicePartialNestingMethodArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BaselineServicePartialNestingMethodResult) GetResult() interface{} { + return p.Success +} + +func (p *BaselineServiceNesting2MethodArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BaselineServiceNesting2MethodResult) GetResult() interface{} { + return p.Success +} diff --git a/codegen/fieldmask/test_gen/baseline/k-consts.go b/codegen/fieldmask/test_gen/baseline/k-consts.go new file mode 100644 index 0000000..e86733b --- /dev/null +++ b/codegen/fieldmask/test_gen/baseline/k-consts.go @@ -0,0 +1,4 @@ +package baseline + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} From ff5f75124e797cabc4ecb81e3448e331020da7b1 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 4 Dec 2023 15:42:10 +0800 Subject: [PATCH 03/13] test: fieldmask serdes --- .gitignore | 1 + CREDITS | 14 + codegen/codegen_run.sh | 2 +- codegen/fieldmask/baseline_test.go | 18 +- codegen/fieldmask/main_test.go | 159 +- codegen/fieldmask/run.sh | 5 +- codegen/fieldmask/test_fieldmask.thrift | 41 +- .../test_fieldmask2.thrift} | 41 +- .../test_gen/baseline/baseline-reflection.go | 144 - .../fieldmask/test_gen/baseline/baseline.go | 5923 ----------------- .../fieldmask/test_gen/baseline/k-baseline.go | 4556 ------------- .../fieldmask/test_gen/baseline/k-consts.go | 4 - 12 files changed, 214 insertions(+), 10694 deletions(-) rename codegen/{basic_idls/test_fieldmask.thrift => fieldmask/test_fieldmask2.thrift} (69%) delete mode 100644 codegen/fieldmask/test_gen/baseline/baseline-reflection.go delete mode 100644 codegen/fieldmask/test_gen/baseline/baseline.go delete mode 100644 codegen/fieldmask/test_gen/baseline/k-baseline.go delete mode 100644 codegen/fieldmask/test_gen/baseline/k-consts.go diff --git a/.gitignore b/.gitignore index a20c4c8..a306b3a 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ testdata/ kitex_gen/ kitex_gen_slim/ old_gen/ +halfway_gen/ grpc_gen/ go.mod go.sum diff --git a/CREDITS b/CREDITS index e69de29..56dfc7a 100644 --- a/CREDITS +++ b/CREDITS @@ -0,0 +1,14 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + diff --git a/codegen/codegen_run.sh b/codegen/codegen_run.sh index 2ef934a..d843057 100755 --- a/codegen/codegen_run.sh +++ b/codegen/codegen_run.sh @@ -76,7 +76,7 @@ function run_test { #run fieldmask tests... cd fieldmask sh run.sh - if test $? -nq 0 + if test $? != 0 then echo "run fieldmask test failed" exit 3 diff --git a/codegen/fieldmask/baseline_test.go b/codegen/fieldmask/baseline_test.go index ec6a2ce..5953c1b 100644 --- a/codegen/fieldmask/baseline_test.go +++ b/codegen/fieldmask/baseline_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "test/test_gen/baseline" + "test/kitex_gen/baseline" "github.com/cloudwego/thriftgo/fieldmask" ) @@ -107,7 +107,7 @@ func BenchmarkFastWriteSimple(b *testing.B) { if err != nil { b.Fatal(err) } - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) data := make([]byte, obj.BLength()) ret := obj.FastWriteNocopy(data, nil) if ret != len(data) { @@ -115,7 +115,7 @@ func BenchmarkFastWriteSimple(b *testing.B) { } b.ResetTimer() for i := 0; i < b.N; i++ { - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) _ = obj.BLength() _ = obj.FastWriteNocopy(data, nil) } @@ -153,14 +153,14 @@ func BenchmarkFastReadSimple(b *testing.B) { b.Fatal(ret) } obj = baseline.NewSimple() - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) n, err := obj.FastRead(data) if n != len(data) { b.Fatal(err) } b.ResetTimer() for i := 0; i < b.N; i++ { - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) _, _ = obj.FastRead(data) } }) @@ -198,7 +198,7 @@ func BenchmarkFastWriteNesting(b *testing.B) { if err != nil { b.Fatal(err) } - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) data := make([]byte, obj.BLength()) ret := obj.FastWriteNocopy(data, nil) if ret != len(data) { @@ -207,7 +207,7 @@ func BenchmarkFastWriteNesting(b *testing.B) { // println("half data size: ", len(data)) b.ResetTimer() for i := 0; i < b.N; i++ { - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) _ = obj.BLength() _ = obj.FastWriteNocopy(data, nil) } @@ -255,14 +255,14 @@ func BenchmarkFastReadNesting(b *testing.B) { b.Fatal(ret) } obj = baseline.NewNesting() - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) n, err := obj.FastRead(data) if n != len(data) { b.Fatal(err) } b.ResetTimer() for i := 0; i < b.N; i++ { - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) _, _ = obj.FastRead(data) } }) diff --git a/codegen/fieldmask/main_test.go b/codegen/fieldmask/main_test.go index 891cccd..a71d505 100644 --- a/codegen/fieldmask/main_test.go +++ b/codegen/fieldmask/main_test.go @@ -15,8 +15,10 @@ package test import ( + "fmt" "runtime" - "test/kitex_gen/base" + hbase "test/halfway_gen/base" + nbase "test/kitex_gen/base" obase "test/old_gen/base" "testing" @@ -24,34 +26,41 @@ import ( "github.com/stretchr/testify/require" ) -func SampleNewBase() *base.Base { - obj := base.NewBase() +func SampleNewBase() *nbase.Base { + obj := nbase.NewBase() obj.Addr = "abcd" obj.Caller = "abcd" obj.LogID = "abcd" - obj.Meta = base.NewMetaInfo() - obj.Meta.StrMap = map[string]*base.Val{ - "abcd": base.NewVal(), - "1234": base.NewVal(), + obj.Meta = nbase.NewMetaInfo() + obj.Meta.StrMap = map[string]*nbase.Val{ + "abcd": nbase.NewVal(), + "1234": nbase.NewVal(), } - obj.Meta.IntMap = map[int64]*base.Val{ - 1: base.NewVal(), - 2: base.NewVal(), + obj.Meta.IntMap = map[int64]*nbase.Val{ + 1: nbase.NewVal(), + 2: nbase.NewVal(), } - v0 := base.NewVal() + v0 := nbase.NewVal() v0.Id = "a" v0.Name = "a" - v1 := base.NewVal() + v1 := nbase.NewVal() v1.Id = "b" v1.Name = "b" - obj.Meta.List = []*base.Val{v0, v1} - obj.Meta.Set = []*base.Val{v0, v1} - obj.Extra = base.NewExtraInfo() - obj.TrafficEnv = base.NewTrafficEnv() + obj.Meta.List = []*nbase.Val{v0, v1} + // v0 = nbase.NewVal() + // v0.ID = "a" + // v0.Name = "a" + // v1 = nbase.NewVal() + // v1.ID = "b" + // v1.Name = "b" + obj.Meta.Set = []*nbase.Val{v0, v1} + // obj.Extra = nbase.NewExtraInfo() + obj.TrafficEnv = nbase.NewTrafficEnv() obj.TrafficEnv.Code = 1 obj.TrafficEnv.Env = "abcd" obj.TrafficEnv.Name = "abcd" obj.TrafficEnv.Open = true + obj.Meta.Base = nbase.NewBase() return obj } @@ -77,12 +86,13 @@ func SampleOldBase() *obase.Base { v1.Name = "b" obj.Meta.List = []*obase.Val{v0, v1} obj.Meta.Set = []*obase.Val{v0, v1} - obj.Extra = obase.NewExtraInfo() + // obj.Extra = obase.NewExtraInfo() obj.TrafficEnv = obase.NewTrafficEnv() obj.TrafficEnv.Code = 1 obj.TrafficEnv.Env = "abcd" obj.TrafficEnv.Name = "abcd" obj.TrafficEnv.Open = true + obj.Meta.Base = obase.NewBase() return obj } @@ -100,10 +110,11 @@ func TestFastWrite(t *testing.T) { if err != nil { t.Fatal(err) } - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) out := make([]byte, obj.BLength()) + // out := make([]byte, 24000000) e := obj.FastWriteNocopy(out, nil) - var obj2 = base.NewBase() + var obj2 = nbase.NewBase() n, err := obj2.FastRead(out) if err != nil { t.Fatal(err) @@ -122,10 +133,10 @@ func TestFastWrite(t *testing.T) { require.Equal(t, "", obj2.Meta.IntMap[2].Id) require.Equal(t, obj.Meta.IntMap[2].Name, obj2.Meta.IntMap[2].Name) require.Equal(t, obj.Meta.StrMap["1234"].Id, obj2.Meta.StrMap["1234"].Id) - require.Equal(t, (*base.Val)(nil), obj2.Meta.StrMap["abcd"]) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.StrMap["abcd"]) + require.Equal(t, 1, len(obj2.Meta.List)) require.Equal(t, obj.Meta.List[1].Id, obj2.Meta.List[0].Id) require.Equal(t, obj.Meta.List[1].Name, obj2.Meta.List[0].Name) - require.Equal(t, 1, len(obj2.Meta.List)) require.Equal(t, 2, len(obj2.Meta.Set)) require.Equal(t, obj.Meta.Set[0].Id, obj2.Meta.Set[0].Id) require.Equal(t, "", obj2.Meta.Set[0].Name) @@ -137,7 +148,7 @@ func TestFastRead(t *testing.T) { obj := SampleNewBase() buf := make([]byte, obj.BLength()) e := obj.FastWriteNocopy(buf, nil) - obj2 := base.NewBase() + obj2 := nbase.NewBase() fm, err := fieldmask.NewFieldMask(obj2.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", @@ -150,7 +161,7 @@ func TestFastRead(t *testing.T) { if err != nil { t.Fatal(err) } - obj2.SetFieldMask(fm) + obj2.Set_FieldMask(fm) n, err := obj2.FastRead(buf) if err != nil { t.Fatal(err) @@ -171,7 +182,7 @@ func TestFastRead(t *testing.T) { require.Equal(t, "", obj2.Meta.IntMap[2].Id) require.Equal(t, obj.Meta.IntMap[2].Name, obj2.Meta.IntMap[2].Name) require.Equal(t, obj.Meta.StrMap["1234"].Id, obj2.Meta.StrMap["1234"].Id) - require.Equal(t, (*base.Val)(nil), obj2.Meta.StrMap["abcd"]) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.StrMap["abcd"]) require.Equal(t, obj.Meta.List[1].Id, obj2.Meta.List[0].Id) require.Equal(t, obj.Meta.List[1].Name, obj2.Meta.List[0].Name) require.Equal(t, 1, len(obj2.Meta.List)) @@ -182,6 +193,94 @@ func TestFastRead(t *testing.T) { require.Equal(t, obj.Meta.Set[1].Name, obj2.Meta.Set[1].Name) } +func TestMaskRequired(t *testing.T) { + fm, err := fieldmask.NewFieldMask(nbase.NewBaseResp().GetTypeDescriptor(), "$.F1", "$.F8") + if err != nil { + t.Fatal(err) + } + j, err := fm.MarshalJSON() + if err != nil { + t.Fatal(err) + } + println(string(j)) + nf, ex := fm.Field(111) + if !ex { + t.Fatal(nf) + } + + t.Run("read", func(t *testing.T) { + obj := nbase.NewBaseResp() + obj.F1 = map[nbase.Str]nbase.Str{"a": "b"} + obj.F8 = map[float64][]nbase.Str{1.0: []nbase.Str{"a"}} + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { + t.Fatal(err) + } + obj2 := nbase.NewBaseResp() + obj2.Set_FieldMask(fm) + if _, err := obj2.FastRead(buf); err != nil { + t.Fatal(err) + } + require.Equal(t, obj.F1, obj2.F1) + require.Equal(t, obj.F8, obj2.F8) + }) + + t.Run("write", func(t *testing.T) { + obj := nbase.NewBaseResp() + obj.F1 = map[nbase.Str]nbase.Str{"a": "b"} + obj.F8 = map[float64][]nbase.Str{1.0: []nbase.Str{"a"}} + obj.Set_FieldMask(fm) + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { + t.Fatal(err) + } + obj2 := nbase.NewBaseResp() + if _, err := obj2.FastRead(buf); err != nil { + t.Fatal(err) + } + fmt.Printf("%#v\n", obj2) + }) +} + +func TestSetMaskHalfway(t *testing.T) { + obj := hbase.NewBase() + obj.Extra = hbase.NewExtraInfo() + obj.Extra.F1 = map[string]string{"a": "b"} + obj.Extra.F8 = map[int64][]*hbase.Key{1: []*hbase.Key{hbase.NewKey()}} + + fm, err := fieldmask.NewFieldMask(obj.Extra.GetTypeDescriptor(), "$.F1") + if err != nil { + t.Fatal(err) + } + obj.Extra.Set_FieldMask(fm) + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { + t.Fatal(err) + } + obj2 := hbase.NewBase() + if _, err := obj2.FastRead(buf); err != nil { + t.Fatal(err) + } + require.Equal(t, obj.Extra.F1, obj2.Extra.F1) + require.Equal(t, map[int64][]*hbase.Key(nil), obj2.Extra.F8) + + fm, err = fieldmask.NewFieldMask(obj.Extra.GetTypeDescriptor(), "$.F8") + if err != nil { + t.Fatal(err) + } + obj.Extra.Set_FieldMask(fm) + buf = make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { + t.Fatal(err) + } + obj2 = hbase.NewBase() + if _, err := obj2.FastRead(buf); err != nil { + t.Fatal(err) + } + require.Equal(t, map[string]string(nil), obj2.Extra.F1) + require.Equal(t, obj.Extra.F8, obj2.Extra.F8) +} + func BenchmarkFastWriteWithFieldMask(b *testing.B) { b.Run("old", func(b *testing.B) { obj := SampleOldBase() @@ -214,13 +313,13 @@ func BenchmarkFastWriteWithFieldMask(b *testing.B) { b.Run("new-mask-half", func(b *testing.B) { obj := SampleNewBase() buf := make([]byte, obj.BLength()) - fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", "$.Meta.List[1]", "$.Meta.Set[1]") + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", "$.Meta.IntMap", "$.Meta.List") if err != nil { b.Fatal(err) } b.ResetTimer() for i := 0; i < b.N; i++ { - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) buf := buf[:obj.BLength()] if err := obj.FastWriteNocopy(buf, nil); err == 0 { b.Fatal(err) @@ -253,7 +352,7 @@ func BenchmarkFastReadWithFieldMask(b *testing.B) { if err := obj.FastWriteNocopy(buf, nil); err == 0 { b.Fatal(err) } - obj = base.NewBase() + obj = nbase.NewBase() b.ResetTimer() for i := 0; i < b.N; i++ { if _, err := obj.FastRead(buf); err != nil { @@ -270,15 +369,15 @@ func BenchmarkFastReadWithFieldMask(b *testing.B) { if err := obj.FastWriteNocopy(buf, nil); err == 0 { b.Fatal(err) } - obj = base.NewBase() + obj = nbase.NewBase() - fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", "$.Meta.List[1]", "$.Meta.Set[1]") + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", "$.LogID", "$.TrafficEnv.Code", "$.Meta.IntMap", "$.Meta.List") if err != nil { b.Fatal(err) } b.ResetTimer() for i := 0; i < b.N; i++ { - obj.SetFieldMask(fm) + obj.Set_FieldMask(fm) if _, err := obj.FastRead(buf); err != nil { b.Fatal(err) } diff --git a/codegen/fieldmask/run.sh b/codegen/fieldmask/run.sh index b727579..258a818 100644 --- a/codegen/fieldmask/run.sh +++ b/codegen/fieldmask/run.sh @@ -16,6 +16,9 @@ kitex -module test -gen-path old_gen test_fieldmask.thrift kitex -module test -thrift with_field_mask -thrift with_reflection test_fieldmask.thrift -go get github.com/cloudwego/thriftgo@main +cat test_fieldmask.thrift > test_fieldmask2.thrift +kitex -module test -thrift with_field_mask -thrift field_mask_halfway -thrift with_reflection -gen-path halfway_gen test_fieldmask2.thrift +kitex -module test -thrift with_field_mask -thrift with_reflection baseline.thrift +go get github.com/cloudwego/thriftgo@9e8d1cafba62a37789c431270a816ad35a6c46e0 go mod tidy go test ./... diff --git a/codegen/fieldmask/test_fieldmask.thrift b/codegen/fieldmask/test_fieldmask.thrift index 1ba3ee0..5caf7b9 100644 --- a/codegen/fieldmask/test_fieldmask.thrift +++ b/codegen/fieldmask/test_fieldmask.thrift @@ -1,3 +1,5 @@ +#! /bin/bash -e + # Copyright 2022 CloudWeGo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +24,7 @@ struct TrafficEnv { } struct Base { - 0: string Addr = "", + 0: required string Addr = "", 1: string LogID = "", 2: string Caller = "", 5: optional TrafficEnv TrafficEnv, @@ -73,17 +75,30 @@ enum Ex { } struct BaseResp { - 1: string StatusMessage = "", - 2: i32 StatusCode = 0, - 3: optional map Extra, + 1: optional string StatusMessage = "", + 2: required i32 StatusCode = 0, + 3: required bool R3, + 4: required byte R4, + 5: required i16 R5, + 6: required i64 R6, + 7: required double R7, + 8: required string R8, + 9: required Ex R9, + 10: required list R10, + 11: required set R11, + 12: required TrafficEnv R12, + 13: required map R13, + 0: required Key R0, - 4: map F1 - 5: map F2, - 6: list F3 - 7: set F4, - 8: map F5 - 9: map F6 - 10: map F7 - 11: map> F8 - 12: list>> F9 + 14: map F1 + 15: map F2, + 16: list F3 + 17: set F4, + 18: map F5 + 19: map F6 + 110: map F7 + 111: map> F8 + 112: list>> F9 + 113: map F10 } + diff --git a/codegen/basic_idls/test_fieldmask.thrift b/codegen/fieldmask/test_fieldmask2.thrift similarity index 69% rename from codegen/basic_idls/test_fieldmask.thrift rename to codegen/fieldmask/test_fieldmask2.thrift index 1ba3ee0..5caf7b9 100644 --- a/codegen/basic_idls/test_fieldmask.thrift +++ b/codegen/fieldmask/test_fieldmask2.thrift @@ -1,3 +1,5 @@ +#! /bin/bash -e + # Copyright 2022 CloudWeGo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +24,7 @@ struct TrafficEnv { } struct Base { - 0: string Addr = "", + 0: required string Addr = "", 1: string LogID = "", 2: string Caller = "", 5: optional TrafficEnv TrafficEnv, @@ -73,17 +75,30 @@ enum Ex { } struct BaseResp { - 1: string StatusMessage = "", - 2: i32 StatusCode = 0, - 3: optional map Extra, + 1: optional string StatusMessage = "", + 2: required i32 StatusCode = 0, + 3: required bool R3, + 4: required byte R4, + 5: required i16 R5, + 6: required i64 R6, + 7: required double R7, + 8: required string R8, + 9: required Ex R9, + 10: required list R10, + 11: required set R11, + 12: required TrafficEnv R12, + 13: required map R13, + 0: required Key R0, - 4: map F1 - 5: map F2, - 6: list F3 - 7: set F4, - 8: map F5 - 9: map F6 - 10: map F7 - 11: map> F8 - 12: list>> F9 + 14: map F1 + 15: map F2, + 16: list F3 + 17: set F4, + 18: map F5 + 19: map F6 + 110: map F7 + 111: map> F8 + 112: list>> F9 + 113: map F10 } + diff --git a/codegen/fieldmask/test_gen/baseline/baseline-reflection.go b/codegen/fieldmask/test_gen/baseline/baseline-reflection.go deleted file mode 100644 index 17b7346..0000000 --- a/codegen/fieldmask/test_gen/baseline/baseline-reflection.go +++ /dev/null @@ -1,144 +0,0 @@ -// Code generated by thriftgo (0.3.3). DO NOT EDIT. - -package baseline - -import ( - "reflect" - - "github.com/cloudwego/thriftgo/thrift_reflection" -) - -// IDL Name: baseline -// IDL Path: baseline.thrift - -var file_baseline_thrift_go_types = []interface{}{ - (*Simple)(nil), // Struct 0: baseline.Simple - (*PartialSimple)(nil), // Struct 1: baseline.PartialSimple - (*Nesting)(nil), // Struct 2: baseline.Nesting - (*PartialNesting)(nil), // Struct 3: baseline.PartialNesting - (*Nesting2)(nil), // Struct 4: baseline.Nesting2 -} -var file_baseline_thrift *thrift_reflection.FileDescriptor -var file_idl_baseline_rawDesc = []byte{ - 0x1f, 0x8b, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xcc, 0x58, 0xff, 0x4e, 0xdb, 0x3c, - 0x14, 0xbd, 0x34, 0x69, 0x92, 0x36, 0xd, 0xf9, 0xa4, 0x6f, 0xcf, 0x1, 0x52, 0x5b, 0xf5, 0x1, - 0x10, 0x9a, 0x84, 0x34, 0xa6, 0x49, 0x7d, 0x0, 0x94, 0xb6, 0x86, 0x7a, 0xb, 0x4d, 0x48, 0x5c, - 0xa4, 0xbe, 0xfd, 0x64, 0xc7, 0xe, 0x50, 0x32, 0xe7, 0xba, 0xf6, 0x60, 0x7f, 0x15, 0x85, 0xeb, - 0xfb, 0xe3, 0xdc, 0xe3, 0xe3, 0x6b, 0xc7, 0x70, 0x6, 0x0, 0xe9, 0x2a, 0xab, 0x49, 0x4e, 0x77, - 0xe4, 0x82, 0x6d, 0x2b, 0x7a, 0xcf, 0x12, 0x18, 0xc4, 0x31, 0x0, 0x40, 0x2, 0x9e, 0xf8, 0x83, - 0x1b, 0xd, 0x1e, 0xa, 0x0, 0x88, 0x94, 0x69, 0xa, 0xfe, 0x84, 0xff, 0xa7, 0xdb, 0x43, 0xc, - 0x3, 0xfe, 0xf5, 0x4a, 0x7e, 0x5d, 0x92, 0xea, 0x99, 0xae, 0x49, 0xa, 0x1e, 0x5f, 0x33, 0xd4, - 0xad, 0x99, 0x2c, 0xe9, 0x63, 0x99, 0x93, 0x5b, 0xc2, 0xb6, 0xc5, 0x66, 0x2, 0x9e, 0xce, 0x36, - 0x68, 0x6c, 0x1, 0x93, 0x8b, 0x57, 0x91, 0x27, 0xa4, 0xbb, 0x18, 0x7c, 0x0, 0x8, 0xaf, 0xc9, - 0x7d, 0xb6, 0xcf, 0x59, 0x4, 0x43, 0xee, 0x3b, 0x81, 0x30, 0x4e, 0x39, 0x26, 0x31, 0x44, 0xd0, - 0x60, 0x33, 0x14, 0x1f, 0xb8, 0xbf, 0x28, 0x2b, 0xe9, 0x45, 0x59, 0xd4, 0x4c, 0x81, 0x15, 0x5e, - 0xd6, 0xc2, 0x57, 0xc, 0x1, 0xb7, 0x4d, 0x21, 0xe4, 0x9, 0xc2, 0x80, 0xaf, 0xd5, 0xa5, 0xf0, - 0xff, 0x8f, 0xac, 0x62, 0x34, 0xcb, 0xd, 0x40, 0x48, 0xde, 0x2c, 0x71, 0x85, 0xc5, 0x91, 0x57, - 0x33, 0x48, 0xc0, 0xb4, 0xec, 0xe4, 0x3b, 0xa9, 0x19, 0xdd, 0x3d, 0xa0, 0xa, 0xe, 0xa5, 0xb1, - 0xab, 0x52, 0x5b, 0x7f, 0xe, 0xfa, 0x1e, 0x5d, 0xee, 0x1a, 0x67, 0xa6, 0x8, 0x7c, 0x91, 0x78, - 0x9b, 0x0, 0x71, 0xfe, 0x76, 0x8d, 0x2b, 0x3c, 0x8e, 0xdd, 0xfe, 0xe5, 0xde, 0x9f, 0xcb, 0x38, - 0x53, 0x54, 0xcd, 0x91, 0xb2, 0x76, 0x55, 0xed, 0x8b, 0x43, 0x7, 0xed, 0x1f, 0xa9, 0xf6, 0x4f, - 0xbb, 0x50, 0x48, 0xc0, 0x57, 0xbe, 0x86, 0xd0, 0xfc, 0x77, 0xd8, 0xab, 0x87, 0x52, 0x94, 0xa4, - 0x74, 0x6, 0x3a, 0xd3, 0xd1, 0xd5, 0x81, 0x91, 0xaf, 0x94, 0xe4, 0x7d, 0x20, 0xfa, 0xab, 0x3, - 0xc3, 0xee, 0x69, 0x2d, 0x76, 0x37, 0x8b, 0x39, 0x26, 0x9e, 0x47, 0x17, 0xf3, 0xce, 0x70, 0x3, - 0x15, 0x8e, 0xaf, 0x8d, 0x39, 0x9a, 0x3f, 0xeb, 0xbb, 0x75, 0xb1, 0x7b, 0x56, 0x80, 0xa2, 0xd2, - 0x88, 0xaf, 0x8b, 0xfd, 0x2a, 0x47, 0x55, 0x1e, 0x6c, 0x84, 0x69, 0x67, 0x32, 0x9e, 0x61, 0xed, - 0xb3, 0x29, 0xae, 0xf6, 0x59, 0x37, 0xb5, 0x7c, 0xa3, 0x70, 0xf1, 0x92, 0x55, 0x74, 0xf7, 0x80, - 0xaa, 0xb1, 0x16, 0xa6, 0x9d, 0x41, 0x87, 0x66, 0x41, 0xaf, 0xe8, 0x2e, 0xab, 0xe, 0xa8, 0xa0, - 0x2b, 0x61, 0xda, 0x19, 0x34, 0xe8, 0xd8, 0x44, 0x47, 0x3b, 0x1, 0x7f, 0x14, 0xc9, 0x8d, 0xa0, - 0x4d, 0xe6, 0xc3, 0x37, 0xc2, 0xa7, 0x30, 0xf0, 0xdf, 0xe8, 0x8e, 0x3a, 0x3d, 0x65, 0x5f, 0x52, - 0xbd, 0x96, 0x9, 0x66, 0x5a, 0xf0, 0xf7, 0xec, 0xb5, 0x60, 0x8c, 0xb9, 0x60, 0x6c, 0x49, 0xb6, - 0x21, 0x95, 0xd2, 0xb, 0x19, 0x1, 0x3, 0xdf, 0xf8, 0x1b, 0xad, 0x59, 0xc3, 0xa9, 0x3e, 0x96, - 0xe4, 0xb4, 0x66, 0x13, 0xf0, 0x31, 0xb3, 0xa3, 0x5e, 0xe6, 0x50, 0x7d, 0xd, 0x1a, 0x32, 0xb9, - 0xe0, 0xd1, 0xcb, 0x21, 0x95, 0xb1, 0x6d, 0x8b, 0x51, 0xb3, 0x12, 0x93, 0x8a, 0x77, 0x33, 0x9b, - 0x5a, 0xeb, 0x9b, 0xd8, 0xc3, 0xa2, 0x55, 0x8c, 0x95, 0x77, 0xeb, 0x62, 0x43, 0x5a, 0x75, 0x57, - 0xe9, 0xad, 0x8a, 0xcd, 0x41, 0x7d, 0xe4, 0x31, 0x31, 0xb9, 0x85, 0xbc, 0x7f, 0xfd, 0xf9, 0x61, - 0x9a, 0x27, 0x6a, 0xd0, 0xeb, 0xa5, 0x38, 0xdd, 0x79, 0xaa, 0x4f, 0x7b, 0x52, 0xb5, 0xb9, 0xaa, - 0x1c, 0x70, 0x58, 0x2e, 0xe6, 0xa7, 0x9e, 0x93, 0xef, 0xf7, 0xa8, 0xf6, 0xda, 0x75, 0x9b, 0x95, - 0xcd, 0x3e, 0x40, 0xed, 0x37, 0xef, 0x31, 0x2b, 0x91, 0x5b, 0xb2, 0x6f, 0x13, 0x48, 0xb3, 0xce, - 0x1a, 0x42, 0xa3, 0x1a, 0xe4, 0x35, 0x70, 0xc9, 0xaa, 0xfd, 0x9a, 0x59, 0xdc, 0xdb, 0x22, 0xa3, - 0xa8, 0xa3, 0xdb, 0xac, 0xbc, 0x99, 0x4d, 0x11, 0x9d, 0xea, 0xc7, 0x4c, 0x90, 0xaa, 0x97, 0x78, - 0x8b, 0x79, 0x37, 0x5a, 0x23, 0xa3, 0xbc, 0x1b, 0x2d, 0xc3, 0x34, 0x1b, 0xa5, 0x65, 0xba, 0x36, - 0x8e, 0xcd, 0xb4, 0xac, 0x39, 0xa3, 0x2c, 0x8e, 0xa7, 0xd8, 0x8c, 0x36, 0xbc, 0x81, 0x8b, 0xb9, - 0x2b, 0xde, 0x8b, 0xfe, 0xd8, 0xa0, 0x35, 0x31, 0xca, 0xbe, 0x91, 0x93, 0x5e, 0xf2, 0xe1, 0x24, - 0xed, 0x4f, 0xcc, 0x4a, 0xde, 0x1d, 0xa1, 0xeb, 0xa2, 0xf8, 0x45, 0x5b, 0x51, 0x8e, 0xb8, 0xf7, - 0x3b, 0xba, 0x98, 0x63, 0x32, 0xf6, 0xf9, 0xa4, 0x75, 0xf2, 0x90, 0x75, 0x7e, 0xaa, 0xac, 0x61, - 0x4e, 0x6d, 0x87, 0xb2, 0xa6, 0x3b, 0xdb, 0x53, 0xbb, 0xf1, 0xe9, 0xe8, 0xb2, 0x8d, 0x99, 0x6e, - 0xdd, 0xe, 0x2e, 0x47, 0xf, 0x3d, 0xe, 0xe6, 0x17, 0x13, 0xe9, 0x46, 0x3c, 0x33, 0x99, 0x29, - 0xf8, 0xa7, 0x91, 0x4, 0x83, 0xa3, 0x25, 0x57, 0xda, 0xa7, 0xa, 0xc9, 0x92, 0x58, 0x67, 0xfc, - 0x1f, 0x7, 0x42, 0xe4, 0x22, 0x57, 0x39, 0x40, 0x42, 0xd6, 0xd6, 0x83, 0x44, 0xfb, 0x9e, 0xe6, - 0xe0, 0x62, 0xe5, 0x6a, 0xc, 0x30, 0x63, 0xb0, 0x9d, 0xaa, 0x99, 0xdd, 0xe2, 0xec, 0xa7, 0x7d, - 0xc3, 0x87, 0x4, 0xae, 0x1e, 0x38, 0x4a, 0x60, 0xe4, 0x43, 0xdf, 0x6c, 0xb3, 0xe7, 0x86, 0x8f, - 0x9b, 0x90, 0xd5, 0x7b, 0x33, 0x8a, 0x57, 0xda, 0xf7, 0x61, 0xb3, 0xa9, 0xd6, 0x7e, 0x1c, 0x32, - 0x53, 0x43, 0xfb, 0xb, 0xb7, 0xe1, 0x1c, 0xba, 0x24, 0x48, 0x6e, 0x79, 0x35, 0xb1, 0xa3, 0x96, - 0xd9, 0x1c, 0x6a, 0x73, 0x91, 0x7d, 0x3f, 0x81, 0x76, 0x3c, 0xe4, 0x6, 0x13, 0x78, 0xf5, 0xdc, - 0x9b, 0x42, 0x24, 0x7f, 0x47, 0xf2, 0x77, 0x2c, 0x7e, 0xe1, 0x77, 0x0, 0x0, 0x0, 0xff, 0xff, - 0xfc, 0xb4, 0x6, 0x32, 0x70, 0x1b, 0x0, 0x0, -} - -func init() { - if file_baseline_thrift != nil { - return - } - type x struct{} - builder := &thrift_reflection.FileDescriptorBuilder{ - Bytes: file_idl_baseline_rawDesc, - GoTypes: file_baseline_thrift_go_types, - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - } - file_baseline_thrift = thrift_reflection.BuildFileDescriptor(builder) -} - -func GetFileDescriptorForBaseline() *thrift_reflection.FileDescriptor { - return file_baseline_thrift -} -func (p *Simple) GetDescriptor() *thrift_reflection.StructDescriptor { - return file_baseline_thrift.GetStructDescriptor("Simple") -} - -func (p *Simple) GetTypeDescriptor() *thrift_reflection.TypeDescriptor { - ret := thrift_reflection.NewTypeDescriptor() - ret.Filepath = file_baseline_thrift.Filepath - ret.Name = "Simple" - return ret -} -func (p *PartialSimple) GetDescriptor() *thrift_reflection.StructDescriptor { - return file_baseline_thrift.GetStructDescriptor("PartialSimple") -} - -func (p *PartialSimple) GetTypeDescriptor() *thrift_reflection.TypeDescriptor { - ret := thrift_reflection.NewTypeDescriptor() - ret.Filepath = file_baseline_thrift.Filepath - ret.Name = "PartialSimple" - return ret -} -func (p *Nesting) GetDescriptor() *thrift_reflection.StructDescriptor { - return file_baseline_thrift.GetStructDescriptor("Nesting") -} - -func (p *Nesting) GetTypeDescriptor() *thrift_reflection.TypeDescriptor { - ret := thrift_reflection.NewTypeDescriptor() - ret.Filepath = file_baseline_thrift.Filepath - ret.Name = "Nesting" - return ret -} -func (p *PartialNesting) GetDescriptor() *thrift_reflection.StructDescriptor { - return file_baseline_thrift.GetStructDescriptor("PartialNesting") -} - -func (p *PartialNesting) GetTypeDescriptor() *thrift_reflection.TypeDescriptor { - ret := thrift_reflection.NewTypeDescriptor() - ret.Filepath = file_baseline_thrift.Filepath - ret.Name = "PartialNesting" - return ret -} -func (p *Nesting2) GetDescriptor() *thrift_reflection.StructDescriptor { - return file_baseline_thrift.GetStructDescriptor("Nesting2") -} - -func (p *Nesting2) GetTypeDescriptor() *thrift_reflection.TypeDescriptor { - ret := thrift_reflection.NewTypeDescriptor() - ret.Filepath = file_baseline_thrift.Filepath - ret.Name = "Nesting2" - return ret -} diff --git a/codegen/fieldmask/test_gen/baseline/baseline.go b/codegen/fieldmask/test_gen/baseline/baseline.go deleted file mode 100644 index ac4d049..0000000 --- a/codegen/fieldmask/test_gen/baseline/baseline.go +++ /dev/null @@ -1,5923 +0,0 @@ -// Code generated by thriftgo (0.3.3). DO NOT EDIT. - -package baseline - -import ( - "bytes" - "context" - "fmt" - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/thriftgo/fieldmask" - "strings" -) - -type Simple struct { - ByteField int8 `thrift:"ByteField,1" frugal:"1,default,byte" json:"ByteField"` - I64Field int64 `thrift:"I64Field,2" frugal:"2,default,i64" json:"I64Field"` - DoubleField float64 `thrift:"DoubleField,3" frugal:"3,default,double" json:"DoubleField"` - I32Field int32 `thrift:"I32Field,4" frugal:"4,default,i32" json:"I32Field"` - StringField string `thrift:"StringField,5" frugal:"5,default,string" json:"StringField"` - BinaryField []byte `thrift:"BinaryField,6" frugal:"6,default,binary" json:"BinaryField"` - _fieldmask *fieldmask.FieldMask -} - -func NewSimple() *Simple { - return &Simple{} -} - -func (p *Simple) InitDefault() { - *p = Simple{} -} - -func (p *Simple) GetByteField() (v int8) { - return p.ByteField -} - -func (p *Simple) GetI64Field() (v int64) { - return p.I64Field -} - -func (p *Simple) GetDoubleField() (v float64) { - return p.DoubleField -} - -func (p *Simple) GetI32Field() (v int32) { - return p.I32Field -} - -func (p *Simple) GetStringField() (v string) { - return p.StringField -} - -func (p *Simple) GetBinaryField() (v []byte) { - return p.BinaryField -} -func (p *Simple) SetByteField(val int8) { - p.ByteField = val -} -func (p *Simple) SetI64Field(val int64) { - p.I64Field = val -} -func (p *Simple) SetDoubleField(val float64) { - p.DoubleField = val -} -func (p *Simple) SetI32Field(val int32) { - p.I32Field = val -} -func (p *Simple) SetStringField(val string) { - p.StringField = val -} -func (p *Simple) SetBinaryField(val []byte) { - p.BinaryField = val -} - -func (p *Simple) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *Simple) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_Simple = map[int16]string{ - 1: "ByteField", - 2: "I64Field", - 3: "DoubleField", - 4: "I32Field", - 5: "StringField", - 6: "BinaryField", -} - -func (p *Simple) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.I64 { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 4: - if fieldTypeId == thrift.I32 { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField5(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Simple[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Simple) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.ByteField = v - } - return nil -} -func (p *Simple) ReadField2(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.I64Field = v - } - return nil -} -func (p *Simple) ReadField3(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.DoubleField = v - } - return nil -} -func (p *Simple) ReadField4(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.I32Field = v - } - return nil -} -func (p *Simple) ReadField5(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.StringField = v - } - return nil -} -func (p *Simple) ReadField6(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.BinaryField = []byte(v) - } - return nil -} - -func (p *Simple) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Simple"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(2); ex { - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(3); ex { - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(4); ex { - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(5); ex { - if err = p.writeField5(oprot); err != nil { - fieldId = 5 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(6); ex { - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Simple) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ByteField", thrift.BYTE, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.ByteField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} -func (p *Simple) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I64Field", thrift.I64, 2); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.I64Field); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} -func (p *Simple) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("DoubleField", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.DoubleField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} -func (p *Simple) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I32Field", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.I32Field); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} -func (p *Simple) writeField5(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("StringField", thrift.STRING, 5); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.StringField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} -func (p *Simple) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BinaryField", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.BinaryField)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *Simple) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Simple(%+v)", *p) -} - -func (p *Simple) DeepEqual(ano *Simple) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.ByteField) { - return false - } - if !p.Field2DeepEqual(ano.I64Field) { - return false - } - if !p.Field3DeepEqual(ano.DoubleField) { - return false - } - if !p.Field4DeepEqual(ano.I32Field) { - return false - } - if !p.Field5DeepEqual(ano.StringField) { - return false - } - if !p.Field6DeepEqual(ano.BinaryField) { - return false - } - return true -} - -func (p *Simple) Field1DeepEqual(src int8) bool { - - if p.ByteField != src { - return false - } - return true -} -func (p *Simple) Field2DeepEqual(src int64) bool { - - if p.I64Field != src { - return false - } - return true -} -func (p *Simple) Field3DeepEqual(src float64) bool { - - if p.DoubleField != src { - return false - } - return true -} -func (p *Simple) Field4DeepEqual(src int32) bool { - - if p.I32Field != src { - return false - } - return true -} -func (p *Simple) Field5DeepEqual(src string) bool { - - if strings.Compare(p.StringField, src) != 0 { - return false - } - return true -} -func (p *Simple) Field6DeepEqual(src []byte) bool { - - if bytes.Compare(p.BinaryField, src) != 0 { - return false - } - return true -} - -type PartialSimple struct { - ByteField int8 `thrift:"ByteField,1" frugal:"1,default,byte" json:"ByteField"` - DoubleField float64 `thrift:"DoubleField,3" frugal:"3,default,double" json:"DoubleField"` - BinaryField []byte `thrift:"BinaryField,6" frugal:"6,default,binary" json:"BinaryField"` - _fieldmask *fieldmask.FieldMask -} - -func NewPartialSimple() *PartialSimple { - return &PartialSimple{} -} - -func (p *PartialSimple) InitDefault() { - *p = PartialSimple{} -} - -func (p *PartialSimple) GetByteField() (v int8) { - return p.ByteField -} - -func (p *PartialSimple) GetDoubleField() (v float64) { - return p.DoubleField -} - -func (p *PartialSimple) GetBinaryField() (v []byte) { - return p.BinaryField -} -func (p *PartialSimple) SetByteField(val int8) { - p.ByteField = val -} -func (p *PartialSimple) SetDoubleField(val float64) { - p.DoubleField = val -} -func (p *PartialSimple) SetBinaryField(val []byte) { - p.BinaryField = val -} - -func (p *PartialSimple) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *PartialSimple) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_PartialSimple = map[int16]string{ - 1: "ByteField", - 3: "DoubleField", - 6: "BinaryField", -} - -func (p *PartialSimple) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialSimple[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialSimple) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.ByteField = v - } - return nil -} -func (p *PartialSimple) ReadField3(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.DoubleField = v - } - return nil -} -func (p *PartialSimple) ReadField6(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.BinaryField = []byte(v) - } - return nil -} - -func (p *PartialSimple) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialSimple"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(3); ex { - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(6); ex { - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PartialSimple) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("ByteField", thrift.BYTE, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.ByteField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} -func (p *PartialSimple) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("DoubleField", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.DoubleField); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} -func (p *PartialSimple) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("BinaryField", thrift.STRING, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.BinaryField)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} - -func (p *PartialSimple) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PartialSimple(%+v)", *p) -} - -func (p *PartialSimple) DeepEqual(ano *PartialSimple) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.ByteField) { - return false - } - if !p.Field3DeepEqual(ano.DoubleField) { - return false - } - if !p.Field6DeepEqual(ano.BinaryField) { - return false - } - return true -} - -func (p *PartialSimple) Field1DeepEqual(src int8) bool { - - if p.ByteField != src { - return false - } - return true -} -func (p *PartialSimple) Field3DeepEqual(src float64) bool { - - if p.DoubleField != src { - return false - } - return true -} -func (p *PartialSimple) Field6DeepEqual(src []byte) bool { - - if bytes.Compare(p.BinaryField, src) != 0 { - return false - } - return true -} - -type Nesting struct { - String_ string `thrift:"String,1" frugal:"1,default,string" json:"String"` - ListSimple []*Simple `thrift:"ListSimple,2" frugal:"2,default,list" json:"ListSimple"` - Double float64 `thrift:"Double,3" frugal:"3,default,double" json:"Double"` - I32 int32 `thrift:"I32,4" frugal:"4,default,i32" json:"I32"` - ListI32 []int32 `thrift:"ListI32,5" frugal:"5,default,list" json:"ListI32"` - I64 int64 `thrift:"I64,6" frugal:"6,default,i64" json:"I64"` - MapStringString map[string]string `thrift:"MapStringString,7" frugal:"7,default,map" json:"MapStringString"` - SimpleStruct *Simple `thrift:"SimpleStruct,8" frugal:"8,default,Simple" json:"SimpleStruct"` - MapI32I64 map[int32]int64 `thrift:"MapI32I64,9" frugal:"9,default,map" json:"MapI32I64"` - ListString []string `thrift:"ListString,10" frugal:"10,default,list" json:"ListString"` - Binary []byte `thrift:"Binary,11" frugal:"11,default,binary" json:"Binary"` - MapI64String map[int64]string `thrift:"MapI64String,12" frugal:"12,default,map" json:"MapI64String"` - ListI64 []int64 `thrift:"ListI64,13" frugal:"13,default,list" json:"ListI64"` - Byte int8 `thrift:"Byte,14" frugal:"14,default,byte" json:"Byte"` - MapStringSimple map[string]*Simple `thrift:"MapStringSimple,15" frugal:"15,default,map" json:"MapStringSimple"` - _fieldmask *fieldmask.FieldMask -} - -func NewNesting() *Nesting { - return &Nesting{} -} - -func (p *Nesting) InitDefault() { - *p = Nesting{} -} - -func (p *Nesting) GetString() (v string) { - return p.String_ -} - -func (p *Nesting) GetListSimple() (v []*Simple) { - return p.ListSimple -} - -func (p *Nesting) GetDouble() (v float64) { - return p.Double -} - -func (p *Nesting) GetI32() (v int32) { - return p.I32 -} - -func (p *Nesting) GetListI32() (v []int32) { - return p.ListI32 -} - -func (p *Nesting) GetI64() (v int64) { - return p.I64 -} - -func (p *Nesting) GetMapStringString() (v map[string]string) { - return p.MapStringString -} - -var Nesting_SimpleStruct_DEFAULT *Simple - -func (p *Nesting) GetSimpleStruct() (v *Simple) { - if !p.IsSetSimpleStruct() { - return Nesting_SimpleStruct_DEFAULT - } - return p.SimpleStruct -} - -func (p *Nesting) GetMapI32I64() (v map[int32]int64) { - return p.MapI32I64 -} - -func (p *Nesting) GetListString() (v []string) { - return p.ListString -} - -func (p *Nesting) GetBinary() (v []byte) { - return p.Binary -} - -func (p *Nesting) GetMapI64String() (v map[int64]string) { - return p.MapI64String -} - -func (p *Nesting) GetListI64() (v []int64) { - return p.ListI64 -} - -func (p *Nesting) GetByte() (v int8) { - return p.Byte -} - -func (p *Nesting) GetMapStringSimple() (v map[string]*Simple) { - return p.MapStringSimple -} -func (p *Nesting) SetString(val string) { - p.String_ = val -} -func (p *Nesting) SetListSimple(val []*Simple) { - p.ListSimple = val -} -func (p *Nesting) SetDouble(val float64) { - p.Double = val -} -func (p *Nesting) SetI32(val int32) { - p.I32 = val -} -func (p *Nesting) SetListI32(val []int32) { - p.ListI32 = val -} -func (p *Nesting) SetI64(val int64) { - p.I64 = val -} -func (p *Nesting) SetMapStringString(val map[string]string) { - p.MapStringString = val -} -func (p *Nesting) SetSimpleStruct(val *Simple) { - p.SimpleStruct = val -} -func (p *Nesting) SetMapI32I64(val map[int32]int64) { - p.MapI32I64 = val -} -func (p *Nesting) SetListString(val []string) { - p.ListString = val -} -func (p *Nesting) SetBinary(val []byte) { - p.Binary = val -} -func (p *Nesting) SetMapI64String(val map[int64]string) { - p.MapI64String = val -} -func (p *Nesting) SetListI64(val []int64) { - p.ListI64 = val -} -func (p *Nesting) SetByte(val int8) { - p.Byte = val -} -func (p *Nesting) SetMapStringSimple(val map[string]*Simple) { - p.MapStringSimple = val -} - -func (p *Nesting) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *Nesting) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_Nesting = map[int16]string{ - 1: "String", - 2: "ListSimple", - 3: "Double", - 4: "I32", - 5: "ListI32", - 6: "I64", - 7: "MapStringString", - 8: "SimpleStruct", - 9: "MapI32I64", - 10: "ListString", - 11: "Binary", - 12: "MapI64String", - 13: "ListI64", - 14: "Byte", - 15: "MapStringSimple", -} - -func (p *Nesting) IsSetSimpleStruct() bool { - return p.SimpleStruct != nil -} - -func (p *Nesting) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField2(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 4: - if fieldTypeId == thrift.I32 { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField5(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.I64 { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 7: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField7(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 8: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField8(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 9: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField9(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 10: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField10(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 11: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField11(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 12: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField12(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 13: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField13(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 14: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField14(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 15: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField15(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v - } - return nil -} -func (p *Nesting) ReadField2(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListSimple = make([]*Simple, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.STRUCT); err != nil { - return err - } - continue - } else { - _elem := NewSimple() - _elem.SetFieldMask(nfm) - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListSimple = append(p.ListSimple, _elem) - } - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField3(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v - } - return nil -} -func (p *Nesting) ReadField4(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.I32 = v - } - return nil -} -func (p *Nesting) ReadField5(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListI32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - if _, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.I32); err != nil { - return err - } - continue - } else { - - var _elem int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _elem = v - } - - p.ListI32 = append(p.ListI32, _elem) - } - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField6(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.I64 = v - } - return nil -} -func (p *Nesting) ReadField7(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - if _, ex := fm.Str(string(_key)); !ex { - if err := iprot.Skip(thrift.STRING); err != nil { - return err - } - continue - } else { - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapStringString[_key] = _val - } - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField8(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.SimpleStruct = NewSimple() - p.SimpleStruct.SetFieldMask(fm) - if err := p.SimpleStruct.Read(iprot); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField9(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapI32I64 = make(map[int32]int64, size) - for i := 0; i < size; i++ { - var _key int32 - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - _key = v - } - if _, ex := fm.Int(int(_key)); !ex { - if err := iprot.Skip(thrift.I64); err != nil { - return err - } - continue - } else { - - var _val int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _val = v - } - - p.MapI32I64[_key] = _val - } - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField10(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListString = make([]string, 0, size) - for i := 0; i < size; i++ { - if _, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.STRING); err != nil { - return err - } - continue - } else { - - var _elem string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _elem = v - } - - p.ListString = append(p.ListString, _elem) - } - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField11(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil -} -func (p *Nesting) ReadField12(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapI64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _key = v - } - if _, ex := fm.Int(int(_key)); !ex { - if err := iprot.Skip(thrift.STRING); err != nil { - return err - } - continue - } else { - - var _val string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _val = v - } - - p.MapI64String[_key] = _val - } - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField13(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListI64 = make([]int64, 0, size) - for i := 0; i < size; i++ { - if _, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.I64); err != nil { - return err - } - continue - } else { - - var _elem int64 - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - _elem = v - } - - p.ListI64 = append(p.ListI64, _elem) - } - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting) ReadField14(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.Byte = v - } - return nil -} -func (p *Nesting) ReadField15(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringSimple = make(map[string]*Simple, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - if nfm, ex := fm.Str(string(_key)); !ex { - if err := iprot.Skip(thrift.STRUCT); err != nil { - return err - } - continue - } else { - _val := NewSimple() - _val.SetFieldMask(nfm) - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapStringSimple[_key] = _val - } - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *Nesting) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(2); ex { - if err = p.writeField2(oprot, nfm); err != nil { - fieldId = 2 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(3); ex { - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(4); ex { - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(5); ex { - if err = p.writeField5(oprot, nfm); err != nil { - fieldId = 5 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(6); ex { - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(7); ex { - if err = p.writeField7(oprot, nfm); err != nil { - fieldId = 7 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(8); ex { - if err = p.writeField8(oprot, nfm); err != nil { - fieldId = 8 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(9); ex { - if err = p.writeField9(oprot, nfm); err != nil { - fieldId = 9 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(10); ex { - if err = p.writeField10(oprot, nfm); err != nil { - fieldId = 10 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(11); ex { - if err = p.writeField11(oprot); err != nil { - fieldId = 11 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(12); ex { - if err = p.writeField12(oprot, nfm); err != nil { - fieldId = 12 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(13); ex { - if err = p.writeField13(oprot, nfm); err != nil { - fieldId = 13 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(14); ex { - if err = p.writeField14(oprot); err != nil { - fieldId = 14 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(15); ex { - if err = p.writeField15(oprot, nfm); err != nil { - fieldId = 15 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Nesting) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} -func (p *Nesting) writeField2(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("ListSimple", thrift.LIST, 2); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.ListSimple) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteListBegin(thrift.STRUCT, l); err != nil { - return err - } - } else { - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListSimple)); err != nil { - return err - } - } - for i, v := range p.ListSimple { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} -func (p *Nesting) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} -func (p *Nesting) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I32", thrift.I32, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.I32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} -func (p *Nesting) writeField5(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("ListI32", thrift.LIST, 5); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.ListI32) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteListBegin(thrift.I32, l); err != nil { - return err - } - } else { - if err := oprot.WriteListBegin(thrift.I32, len(p.ListI32)); err != nil { - return err - } - } - for i, v := range p.ListI32 { - if _, ex := fm.Int(i); !ex { - continue - } else { - if err := oprot.WriteI32(v); err != nil { - return err - } - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} -func (p *Nesting) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I64", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.I64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} -func (p *Nesting) writeField7(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("MapStringString", thrift.MAP, 7); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.MapStringString) - for k := range p.MapStringString { - if _, ex := fm.Str(string(k)); !ex { - l-- - } - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, l); err != nil { - return err - } - } else { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.MapStringString)); err != nil { - return err - } - } - for k, v := range p.MapStringString { - ks := string(k) - if _, ex := fm.Str(ks); !ex { - continue - } else { - if err := oprot.WriteString(k); err != nil { - return err - } - if err := oprot.WriteString(v); err != nil { - return err - } - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} -func (p *Nesting) writeField8(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 8); err != nil { - goto WriteFieldBeginError - } - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - if err := p.SimpleStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} -func (p *Nesting) writeField9(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("MapI32I64", thrift.MAP, 9); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.MapI32I64) - for k := range p.MapI32I64 { - if _, ex := fm.Int(int(k)); !ex { - l-- - } - } - if err := oprot.WriteMapBegin(thrift.I32, thrift.I64, l); err != nil { - return err - } - } else { - if err := oprot.WriteMapBegin(thrift.I32, thrift.I64, len(p.MapI32I64)); err != nil { - return err - } - } - for k, v := range p.MapI32I64 { - if _, ex := fm.Int(int(k)); !ex { - continue - } else { - if err := oprot.WriteI32(k); err != nil { - return err - } - if err := oprot.WriteI64(v); err != nil { - return err - } - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} -func (p *Nesting) writeField10(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("ListString", thrift.LIST, 10); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.ListString) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteListBegin(thrift.STRING, l); err != nil { - return err - } - } else { - if err := oprot.WriteListBegin(thrift.STRING, len(p.ListString)); err != nil { - return err - } - } - for i, v := range p.ListString { - if _, ex := fm.Int(i); !ex { - continue - } else { - if err := oprot.WriteString(v); err != nil { - return err - } - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) -} -func (p *Nesting) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 11); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) -} -func (p *Nesting) writeField12(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("MapI64String", thrift.MAP, 12); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.MapI64String) - for k := range p.MapI64String { - if _, ex := fm.Int(int(k)); !ex { - l-- - } - } - if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, l); err != nil { - return err - } - } else { - if err := oprot.WriteMapBegin(thrift.I64, thrift.STRING, len(p.MapI64String)); err != nil { - return err - } - } - for k, v := range p.MapI64String { - if _, ex := fm.Int(int(k)); !ex { - continue - } else { - if err := oprot.WriteI64(k); err != nil { - return err - } - if err := oprot.WriteString(v); err != nil { - return err - } - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) -} -func (p *Nesting) writeField13(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("ListI64", thrift.LIST, 13); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.ListI64) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteListBegin(thrift.I64, l); err != nil { - return err - } - } else { - if err := oprot.WriteListBegin(thrift.I64, len(p.ListI64)); err != nil { - return err - } - } - for i, v := range p.ListI64 { - if _, ex := fm.Int(i); !ex { - continue - } else { - if err := oprot.WriteI64(v); err != nil { - return err - } - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err) -} -func (p *Nesting) writeField14(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 14); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.Byte); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 14 end error: ", p), err) -} -func (p *Nesting) writeField15(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("MapStringSimple", thrift.MAP, 15); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.MapStringSimple) - for k := range p.MapStringSimple { - if _, ex := fm.Str(string(k)); !ex { - l-- - } - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, l); err != nil { - return err - } - } else { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)); err != nil { - return err - } - } - for k, v := range p.MapStringSimple { - ks := string(k) - if nfm, ex := fm.Str(ks); !ex { - continue - } else { - if err := oprot.WriteString(k); err != nil { - return err - } - if v != nil { - v.SetFieldMask(nfm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) -} - -func (p *Nesting) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Nesting(%+v)", *p) -} - -func (p *Nesting) DeepEqual(ano *Nesting) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.String_) { - return false - } - if !p.Field2DeepEqual(ano.ListSimple) { - return false - } - if !p.Field3DeepEqual(ano.Double) { - return false - } - if !p.Field4DeepEqual(ano.I32) { - return false - } - if !p.Field5DeepEqual(ano.ListI32) { - return false - } - if !p.Field6DeepEqual(ano.I64) { - return false - } - if !p.Field7DeepEqual(ano.MapStringString) { - return false - } - if !p.Field8DeepEqual(ano.SimpleStruct) { - return false - } - if !p.Field9DeepEqual(ano.MapI32I64) { - return false - } - if !p.Field10DeepEqual(ano.ListString) { - return false - } - if !p.Field11DeepEqual(ano.Binary) { - return false - } - if !p.Field12DeepEqual(ano.MapI64String) { - return false - } - if !p.Field13DeepEqual(ano.ListI64) { - return false - } - if !p.Field14DeepEqual(ano.Byte) { - return false - } - if !p.Field15DeepEqual(ano.MapStringSimple) { - return false - } - return true -} - -func (p *Nesting) Field1DeepEqual(src string) bool { - - if strings.Compare(p.String_, src) != 0 { - return false - } - return true -} -func (p *Nesting) Field2DeepEqual(src []*Simple) bool { - - if len(p.ListSimple) != len(src) { - return false - } - for i, v := range p.ListSimple { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *Nesting) Field3DeepEqual(src float64) bool { - - if p.Double != src { - return false - } - return true -} -func (p *Nesting) Field4DeepEqual(src int32) bool { - - if p.I32 != src { - return false - } - return true -} -func (p *Nesting) Field5DeepEqual(src []int32) bool { - - if len(p.ListI32) != len(src) { - return false - } - for i, v := range p.ListI32 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *Nesting) Field6DeepEqual(src int64) bool { - - if p.I64 != src { - return false - } - return true -} -func (p *Nesting) Field7DeepEqual(src map[string]string) bool { - - if len(p.MapStringString) != len(src) { - return false - } - for k, v := range p.MapStringString { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *Nesting) Field8DeepEqual(src *Simple) bool { - - if !p.SimpleStruct.DeepEqual(src) { - return false - } - return true -} -func (p *Nesting) Field9DeepEqual(src map[int32]int64) bool { - - if len(p.MapI32I64) != len(src) { - return false - } - for k, v := range p.MapI32I64 { - _src := src[k] - if v != _src { - return false - } - } - return true -} -func (p *Nesting) Field10DeepEqual(src []string) bool { - - if len(p.ListString) != len(src) { - return false - } - for i, v := range p.ListString { - _src := src[i] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *Nesting) Field11DeepEqual(src []byte) bool { - - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true -} -func (p *Nesting) Field12DeepEqual(src map[int64]string) bool { - - if len(p.MapI64String) != len(src) { - return false - } - for k, v := range p.MapI64String { - _src := src[k] - if strings.Compare(v, _src) != 0 { - return false - } - } - return true -} -func (p *Nesting) Field13DeepEqual(src []int64) bool { - - if len(p.ListI64) != len(src) { - return false - } - for i, v := range p.ListI64 { - _src := src[i] - if v != _src { - return false - } - } - return true -} -func (p *Nesting) Field14DeepEqual(src int8) bool { - - if p.Byte != src { - return false - } - return true -} -func (p *Nesting) Field15DeepEqual(src map[string]*Simple) bool { - - if len(p.MapStringSimple) != len(src) { - return false - } - for k, v := range p.MapStringSimple { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} - -type PartialNesting struct { - ListSimple []*PartialSimple `thrift:"ListSimple,2" frugal:"2,default,list" json:"ListSimple"` - SimpleStruct *PartialSimple `thrift:"SimpleStruct,8" frugal:"8,default,PartialSimple" json:"SimpleStruct"` - MapStringSimple map[string]*PartialSimple `thrift:"MapStringSimple,15" frugal:"15,default,map" json:"MapStringSimple"` - _fieldmask *fieldmask.FieldMask -} - -func NewPartialNesting() *PartialNesting { - return &PartialNesting{} -} - -func (p *PartialNesting) InitDefault() { - *p = PartialNesting{} -} - -func (p *PartialNesting) GetListSimple() (v []*PartialSimple) { - return p.ListSimple -} - -var PartialNesting_SimpleStruct_DEFAULT *PartialSimple - -func (p *PartialNesting) GetSimpleStruct() (v *PartialSimple) { - if !p.IsSetSimpleStruct() { - return PartialNesting_SimpleStruct_DEFAULT - } - return p.SimpleStruct -} - -func (p *PartialNesting) GetMapStringSimple() (v map[string]*PartialSimple) { - return p.MapStringSimple -} -func (p *PartialNesting) SetListSimple(val []*PartialSimple) { - p.ListSimple = val -} -func (p *PartialNesting) SetSimpleStruct(val *PartialSimple) { - p.SimpleStruct = val -} -func (p *PartialNesting) SetMapStringSimple(val map[string]*PartialSimple) { - p.MapStringSimple = val -} - -func (p *PartialNesting) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *PartialNesting) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_PartialNesting = map[int16]string{ - 2: "ListSimple", - 8: "SimpleStruct", - 15: "MapStringSimple", -} - -func (p *PartialNesting) IsSetSimpleStruct() bool { - return p.SimpleStruct != nil -} - -func (p *PartialNesting) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 2: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField2(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 8: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField8(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 15: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField15(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialNesting[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialNesting) ReadField2(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListSimple = make([]*PartialSimple, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.STRUCT); err != nil { - return err - } - continue - } else { - _elem := NewPartialSimple() - _elem.SetFieldMask(nfm) - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListSimple = append(p.ListSimple, _elem) - } - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} -func (p *PartialNesting) ReadField8(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.SimpleStruct = NewPartialSimple() - p.SimpleStruct.SetFieldMask(fm) - if err := p.SimpleStruct.Read(iprot); err != nil { - return err - } - return nil -} -func (p *PartialNesting) ReadField15(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapStringSimple = make(map[string]*PartialSimple, size) - for i := 0; i < size; i++ { - var _key string - if v, err := iprot.ReadString(); err != nil { - return err - } else { - _key = v - } - if nfm, ex := fm.Str(string(_key)); !ex { - if err := iprot.Skip(thrift.STRUCT); err != nil { - return err - } - continue - } else { - _val := NewPartialSimple() - _val.SetFieldMask(nfm) - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapStringSimple[_key] = _val - } - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} - -func (p *PartialNesting) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialNesting"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(2); ex { - if err = p.writeField2(oprot, nfm); err != nil { - fieldId = 2 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(8); ex { - if err = p.writeField8(oprot, nfm); err != nil { - fieldId = 8 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(15); ex { - if err = p.writeField15(oprot, nfm); err != nil { - fieldId = 15 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PartialNesting) writeField2(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("ListSimple", thrift.LIST, 2); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.ListSimple) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteListBegin(thrift.STRUCT, l); err != nil { - return err - } - } else { - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListSimple)); err != nil { - return err - } - } - for i, v := range p.ListSimple { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} -func (p *PartialNesting) writeField8(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 8); err != nil { - goto WriteFieldBeginError - } - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - if err := p.SimpleStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} -func (p *PartialNesting) writeField15(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("MapStringSimple", thrift.MAP, 15); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.MapStringSimple) - for k := range p.MapStringSimple { - if _, ex := fm.Str(string(k)); !ex { - l-- - } - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, l); err != nil { - return err - } - } else { - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)); err != nil { - return err - } - } - for k, v := range p.MapStringSimple { - ks := string(k) - if nfm, ex := fm.Str(ks); !ex { - continue - } else { - if err := oprot.WriteString(k); err != nil { - return err - } - if v != nil { - v.SetFieldMask(nfm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) -} - -func (p *PartialNesting) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PartialNesting(%+v)", *p) -} - -func (p *PartialNesting) DeepEqual(ano *PartialNesting) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field2DeepEqual(ano.ListSimple) { - return false - } - if !p.Field8DeepEqual(ano.SimpleStruct) { - return false - } - if !p.Field15DeepEqual(ano.MapStringSimple) { - return false - } - return true -} - -func (p *PartialNesting) Field2DeepEqual(src []*PartialSimple) bool { - - if len(p.ListSimple) != len(src) { - return false - } - for i, v := range p.ListSimple { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *PartialNesting) Field8DeepEqual(src *PartialSimple) bool { - - if !p.SimpleStruct.DeepEqual(src) { - return false - } - return true -} -func (p *PartialNesting) Field15DeepEqual(src map[string]*PartialSimple) bool { - - if len(p.MapStringSimple) != len(src) { - return false - } - for k, v := range p.MapStringSimple { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} - -type Nesting2 struct { - MapSimpleNesting map[*Simple]*Nesting `thrift:"MapSimpleNesting,1" frugal:"1,default,map" json:"MapSimpleNesting"` - SimpleStruct *Simple `thrift:"SimpleStruct,2" frugal:"2,default,Simple" json:"SimpleStruct"` - Byte int8 `thrift:"Byte,3" frugal:"3,default,byte" json:"Byte"` - Double float64 `thrift:"Double,4" frugal:"4,default,double" json:"Double"` - ListNesting []*Nesting `thrift:"ListNesting,5" frugal:"5,default,list" json:"ListNesting"` - I64 int64 `thrift:"I64,6" frugal:"6,default,i64" json:"I64"` - NestingStruct *Nesting `thrift:"NestingStruct,7" frugal:"7,default,Nesting" json:"NestingStruct"` - Binary []byte `thrift:"Binary,8" frugal:"8,default,binary" json:"Binary"` - String_ string `thrift:"String,9" frugal:"9,default,string" json:"String"` - SetNesting []*Nesting `thrift:"SetNesting,10" frugal:"10,default,set" json:"SetNesting"` - I32 int32 `thrift:"I32,11" frugal:"11,default,i32" json:"I32"` - _fieldmask *fieldmask.FieldMask -} - -func NewNesting2() *Nesting2 { - return &Nesting2{} -} - -func (p *Nesting2) InitDefault() { - *p = Nesting2{} -} - -func (p *Nesting2) GetMapSimpleNesting() (v map[*Simple]*Nesting) { - return p.MapSimpleNesting -} - -var Nesting2_SimpleStruct_DEFAULT *Simple - -func (p *Nesting2) GetSimpleStruct() (v *Simple) { - if !p.IsSetSimpleStruct() { - return Nesting2_SimpleStruct_DEFAULT - } - return p.SimpleStruct -} - -func (p *Nesting2) GetByte() (v int8) { - return p.Byte -} - -func (p *Nesting2) GetDouble() (v float64) { - return p.Double -} - -func (p *Nesting2) GetListNesting() (v []*Nesting) { - return p.ListNesting -} - -func (p *Nesting2) GetI64() (v int64) { - return p.I64 -} - -var Nesting2_NestingStruct_DEFAULT *Nesting - -func (p *Nesting2) GetNestingStruct() (v *Nesting) { - if !p.IsSetNestingStruct() { - return Nesting2_NestingStruct_DEFAULT - } - return p.NestingStruct -} - -func (p *Nesting2) GetBinary() (v []byte) { - return p.Binary -} - -func (p *Nesting2) GetString() (v string) { - return p.String_ -} - -func (p *Nesting2) GetSetNesting() (v []*Nesting) { - return p.SetNesting -} - -func (p *Nesting2) GetI32() (v int32) { - return p.I32 -} -func (p *Nesting2) SetMapSimpleNesting(val map[*Simple]*Nesting) { - p.MapSimpleNesting = val -} -func (p *Nesting2) SetSimpleStruct(val *Simple) { - p.SimpleStruct = val -} -func (p *Nesting2) SetByte(val int8) { - p.Byte = val -} -func (p *Nesting2) SetDouble(val float64) { - p.Double = val -} -func (p *Nesting2) SetListNesting(val []*Nesting) { - p.ListNesting = val -} -func (p *Nesting2) SetI64(val int64) { - p.I64 = val -} -func (p *Nesting2) SetNestingStruct(val *Nesting) { - p.NestingStruct = val -} -func (p *Nesting2) SetBinary(val []byte) { - p.Binary = val -} -func (p *Nesting2) SetString(val string) { - p.String_ = val -} -func (p *Nesting2) SetSetNesting(val []*Nesting) { - p.SetNesting = val -} -func (p *Nesting2) SetI32(val int32) { - p.I32 = val -} - -func (p *Nesting2) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *Nesting2) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_Nesting2 = map[int16]string{ - 1: "MapSimpleNesting", - 2: "SimpleStruct", - 3: "Byte", - 4: "Double", - 5: "ListNesting", - 6: "I64", - 7: "NestingStruct", - 8: "Binary", - 9: "String", - 10: "SetNesting", - 11: "I32", -} - -func (p *Nesting2) IsSetSimpleStruct() bool { - return p.SimpleStruct != nil -} - -func (p *Nesting2) IsSetNestingStruct() bool { - return p.NestingStruct != nil -} - -func (p *Nesting2) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField2(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField3(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 4: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField4(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField5(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.I64 { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField6(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 7: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField7(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 8: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField8(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 9: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField9(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 10: - if fieldTypeId == thrift.SET { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField10(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 11: - if fieldTypeId == thrift.I32 { - if _, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField11(iprot); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting2[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting2) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return err - } - p.MapSimpleNesting = make(map[*Simple]*Nesting, size) - for i := 0; i < size; i++ { - _key := NewSimple() - _key.SetFieldMask(fm) - if err := _key.Read(iprot); err != nil { - return err - } - fm = nil - _val := NewNesting() - _val.SetFieldMask(fm) - if err := _val.Read(iprot); err != nil { - return err - } - - p.MapSimpleNesting[_key] = _val - } - if err := iprot.ReadMapEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting2) ReadField2(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.SimpleStruct = NewSimple() - p.SimpleStruct.SetFieldMask(fm) - if err := p.SimpleStruct.Read(iprot); err != nil { - return err - } - return nil -} -func (p *Nesting2) ReadField3(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadByte(); err != nil { - return err - } else { - p.Byte = v - } - return nil -} -func (p *Nesting2) ReadField4(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadDouble(); err != nil { - return err - } else { - p.Double = v - } - return nil -} -func (p *Nesting2) ReadField5(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return err - } - p.ListNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.STRUCT); err != nil { - return err - } - continue - } else { - _elem := NewNesting() - _elem.SetFieldMask(nfm) - if err := _elem.Read(iprot); err != nil { - return err - } - - p.ListNesting = append(p.ListNesting, _elem) - } - } - if err := iprot.ReadListEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting2) ReadField6(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadI64(); err != nil { - return err - } else { - p.I64 = v - } - return nil -} -func (p *Nesting2) ReadField7(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.NestingStruct = NewNesting() - p.NestingStruct.SetFieldMask(fm) - if err := p.NestingStruct.Read(iprot); err != nil { - return err - } - return nil -} -func (p *Nesting2) ReadField8(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadBinary(); err != nil { - return err - } else { - p.Binary = []byte(v) - } - return nil -} -func (p *Nesting2) ReadField9(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.String_ = v - } - return nil -} -func (p *Nesting2) ReadField10(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return err - } - p.SetNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - if err := iprot.Skip(thrift.STRUCT); err != nil { - return err - } - continue - } else { - _elem := NewNesting() - _elem.SetFieldMask(nfm) - if err := _elem.Read(iprot); err != nil { - return err - } - - p.SetNesting = append(p.SetNesting, _elem) - } - } - if err := iprot.ReadSetEnd(); err != nil { - return err - } - return nil -} -func (p *Nesting2) ReadField11(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadI32(); err != nil { - return err - } else { - p.I32 = v - } - return nil -} - -func (p *Nesting2) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting2"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot, nfm); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(2); ex { - if err = p.writeField2(oprot, nfm); err != nil { - fieldId = 2 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(3); ex { - if err = p.writeField3(oprot); err != nil { - fieldId = 3 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(4); ex { - if err = p.writeField4(oprot); err != nil { - fieldId = 4 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(5); ex { - if err = p.writeField5(oprot, nfm); err != nil { - fieldId = 5 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(6); ex { - if err = p.writeField6(oprot); err != nil { - fieldId = 6 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(7); ex { - if err = p.writeField7(oprot, nfm); err != nil { - fieldId = 7 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(8); ex { - if err = p.writeField8(oprot); err != nil { - fieldId = 8 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(9); ex { - if err = p.writeField9(oprot); err != nil { - fieldId = 9 - goto WriteFieldError - } - } - if nfm, ex := p._fieldmask.Field(10); ex { - if err = p.writeField10(oprot, nfm); err != nil { - fieldId = 10 - goto WriteFieldError - } - } - if _, ex := p._fieldmask.Field(11); ex { - if err = p.writeField11(oprot); err != nil { - fieldId = 11 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Nesting2) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("MapSimpleNesting", thrift.MAP, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteMapBegin(thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)); err != nil { - return err - } - for k, v := range p.MapSimpleNesting { - fm = nil - if k != nil { - k.SetFieldMask(fm) - } - if err := k.Write(oprot); err != nil { - return err - } - if v != nil { - v.SetFieldMask(fm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - if err := oprot.WriteMapEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} -func (p *Nesting2) writeField2(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("SimpleStruct", thrift.STRUCT, 2); err != nil { - goto WriteFieldBeginError - } - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - if err := p.SimpleStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} -func (p *Nesting2) writeField3(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Byte", thrift.BYTE, 3); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteByte(p.Byte); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) -} -func (p *Nesting2) writeField4(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Double", thrift.DOUBLE, 4); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteDouble(p.Double); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) -} -func (p *Nesting2) writeField5(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("ListNesting", thrift.LIST, 5); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.ListNesting) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteListBegin(thrift.STRUCT, l); err != nil { - return err - } - } else { - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.ListNesting)); err != nil { - return err - } - } - for i, v := range p.ListNesting { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - } - if err := oprot.WriteListEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) -} -func (p *Nesting2) writeField6(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I64", thrift.I64, 6); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI64(p.I64); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) -} -func (p *Nesting2) writeField7(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("NestingStruct", thrift.STRUCT, 7); err != nil { - goto WriteFieldBeginError - } - if p.NestingStruct != nil { - p.NestingStruct.SetFieldMask(fm) - } - if err := p.NestingStruct.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) -} -func (p *Nesting2) writeField8(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("Binary", thrift.STRING, 8); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteBinary([]byte(p.Binary)); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 8 end error: ", p), err) -} -func (p *Nesting2) writeField9(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("String", thrift.STRING, 9); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.String_); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) -} -func (p *Nesting2) writeField10(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("SetNesting", thrift.SET, 10); err != nil { - goto WriteFieldBeginError - } - if !fm.All() { - l := len(p.SetNesting) - for i := 0; i < l; i++ { - if _, ex := fm.Int(i); !ex { - l-- - } - } - if err := oprot.WriteSetBegin(thrift.STRUCT, l); err != nil { - return err - } - } else { - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.SetNesting)); err != nil { - return err - } - } - for i := 0; i < len(p.SetNesting); i++ { - for j := i + 1; j < len(p.SetNesting); j++ { - if func(tgt, src *Nesting) bool { - if !tgt.DeepEqual(src) { - return false - } - return true - }(p.SetNesting[i], p.SetNesting[j]) { - return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) - } - } - } - for i, v := range p.SetNesting { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - if err := v.Write(oprot); err != nil { - return err - } - } - } - if err := oprot.WriteSetEnd(); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) -} -func (p *Nesting2) writeField11(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("I32", thrift.I32, 11); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteI32(p.I32); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) -} - -func (p *Nesting2) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Nesting2(%+v)", *p) -} - -func (p *Nesting2) DeepEqual(ano *Nesting2) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.MapSimpleNesting) { - return false - } - if !p.Field2DeepEqual(ano.SimpleStruct) { - return false - } - if !p.Field3DeepEqual(ano.Byte) { - return false - } - if !p.Field4DeepEqual(ano.Double) { - return false - } - if !p.Field5DeepEqual(ano.ListNesting) { - return false - } - if !p.Field6DeepEqual(ano.I64) { - return false - } - if !p.Field7DeepEqual(ano.NestingStruct) { - return false - } - if !p.Field8DeepEqual(ano.Binary) { - return false - } - if !p.Field9DeepEqual(ano.String_) { - return false - } - if !p.Field10DeepEqual(ano.SetNesting) { - return false - } - if !p.Field11DeepEqual(ano.I32) { - return false - } - return true -} - -func (p *Nesting2) Field1DeepEqual(src map[*Simple]*Nesting) bool { - - if len(p.MapSimpleNesting) != len(src) { - return false - } - for k, v := range p.MapSimpleNesting { - _src := src[k] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *Nesting2) Field2DeepEqual(src *Simple) bool { - - if !p.SimpleStruct.DeepEqual(src) { - return false - } - return true -} -func (p *Nesting2) Field3DeepEqual(src int8) bool { - - if p.Byte != src { - return false - } - return true -} -func (p *Nesting2) Field4DeepEqual(src float64) bool { - - if p.Double != src { - return false - } - return true -} -func (p *Nesting2) Field5DeepEqual(src []*Nesting) bool { - - if len(p.ListNesting) != len(src) { - return false - } - for i, v := range p.ListNesting { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *Nesting2) Field6DeepEqual(src int64) bool { - - if p.I64 != src { - return false - } - return true -} -func (p *Nesting2) Field7DeepEqual(src *Nesting) bool { - - if !p.NestingStruct.DeepEqual(src) { - return false - } - return true -} -func (p *Nesting2) Field8DeepEqual(src []byte) bool { - - if bytes.Compare(p.Binary, src) != 0 { - return false - } - return true -} -func (p *Nesting2) Field9DeepEqual(src string) bool { - - if strings.Compare(p.String_, src) != 0 { - return false - } - return true -} -func (p *Nesting2) Field10DeepEqual(src []*Nesting) bool { - - if len(p.SetNesting) != len(src) { - return false - } - for i, v := range p.SetNesting { - _src := src[i] - if !v.DeepEqual(_src) { - return false - } - } - return true -} -func (p *Nesting2) Field11DeepEqual(src int32) bool { - - if p.I32 != src { - return false - } - return true -} - -type BaselineService interface { - SimpleMethod(ctx context.Context, req *Simple) (r *Simple, err error) - - PartialSimpleMethod(ctx context.Context, req *PartialSimple) (r *PartialSimple, err error) - - NestingMethod(ctx context.Context, req *Nesting) (r *Nesting, err error) - - PartialNestingMethod(ctx context.Context, req *PartialNesting) (r *PartialNesting, err error) - - Nesting2Method(ctx context.Context, req *Nesting2) (r *Nesting2, err error) -} - -type BaselineServiceClient struct { - c thrift.TClient -} - -func NewBaselineServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BaselineServiceClient { - return &BaselineServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewBaselineServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BaselineServiceClient { - return &BaselineServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewBaselineServiceClient(c thrift.TClient) *BaselineServiceClient { - return &BaselineServiceClient{ - c: c, - } -} - -func (p *BaselineServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *BaselineServiceClient) SimpleMethod(ctx context.Context, req *Simple) (r *Simple, err error) { - var _args BaselineServiceSimpleMethodArgs - _args.Req = req - var _result BaselineServiceSimpleMethodResult - if err = p.Client_().Call(ctx, "SimpleMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *BaselineServiceClient) PartialSimpleMethod(ctx context.Context, req *PartialSimple) (r *PartialSimple, err error) { - var _args BaselineServicePartialSimpleMethodArgs - _args.Req = req - var _result BaselineServicePartialSimpleMethodResult - if err = p.Client_().Call(ctx, "PartialSimpleMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *BaselineServiceClient) NestingMethod(ctx context.Context, req *Nesting) (r *Nesting, err error) { - var _args BaselineServiceNestingMethodArgs - _args.Req = req - var _result BaselineServiceNestingMethodResult - if err = p.Client_().Call(ctx, "NestingMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *BaselineServiceClient) PartialNestingMethod(ctx context.Context, req *PartialNesting) (r *PartialNesting, err error) { - var _args BaselineServicePartialNestingMethodArgs - _args.Req = req - var _result BaselineServicePartialNestingMethodResult - if err = p.Client_().Call(ctx, "PartialNestingMethod", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} -func (p *BaselineServiceClient) Nesting2Method(ctx context.Context, req *Nesting2) (r *Nesting2, err error) { - var _args BaselineServiceNesting2MethodArgs - _args.Req = req - var _result BaselineServiceNesting2MethodResult - if err = p.Client_().Call(ctx, "Nesting2Method", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type BaselineServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler BaselineService -} - -func (p *BaselineServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *BaselineServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *BaselineServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewBaselineServiceProcessor(handler BaselineService) *BaselineServiceProcessor { - self := &BaselineServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("SimpleMethod", &baselineServiceProcessorSimpleMethod{handler: handler}) - self.AddToProcessorMap("PartialSimpleMethod", &baselineServiceProcessorPartialSimpleMethod{handler: handler}) - self.AddToProcessorMap("NestingMethod", &baselineServiceProcessorNestingMethod{handler: handler}) - self.AddToProcessorMap("PartialNestingMethod", &baselineServiceProcessorPartialNestingMethod{handler: handler}) - self.AddToProcessorMap("Nesting2Method", &baselineServiceProcessorNesting2Method{handler: handler}) - return self -} -func (p *BaselineServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type baselineServiceProcessorSimpleMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorSimpleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServiceSimpleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("SimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServiceSimpleMethodResult{} - var retval *Simple - if retval, err2 = p.handler.SimpleMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing SimpleMethod: "+err2.Error()) - oprot.WriteMessageBegin("SimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("SimpleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorPartialSimpleMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorPartialSimpleMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServicePartialSimpleMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("PartialSimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServicePartialSimpleMethodResult{} - var retval *PartialSimple - if retval, err2 = p.handler.PartialSimpleMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialSimpleMethod: "+err2.Error()) - oprot.WriteMessageBegin("PartialSimpleMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("PartialSimpleMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorNestingMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorNestingMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServiceNestingMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("NestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServiceNestingMethodResult{} - var retval *Nesting - if retval, err2 = p.handler.NestingMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing NestingMethod: "+err2.Error()) - oprot.WriteMessageBegin("NestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("NestingMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorPartialNestingMethod struct { - handler BaselineService -} - -func (p *baselineServiceProcessorPartialNestingMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServicePartialNestingMethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("PartialNestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServicePartialNestingMethodResult{} - var retval *PartialNesting - if retval, err2 = p.handler.PartialNestingMethod(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PartialNestingMethod: "+err2.Error()) - oprot.WriteMessageBegin("PartialNestingMethod", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("PartialNestingMethod", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type baselineServiceProcessorNesting2Method struct { - handler BaselineService -} - -func (p *baselineServiceProcessorNesting2Method) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := BaselineServiceNesting2MethodArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Nesting2Method", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := BaselineServiceNesting2MethodResult{} - var retval *Nesting2 - if retval, err2 = p.handler.Nesting2Method(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Nesting2Method: "+err2.Error()) - oprot.WriteMessageBegin("Nesting2Method", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Nesting2Method", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type BaselineServiceSimpleMethodArgs struct { - Req *Simple `thrift:"req,1" frugal:"1,default,Simple" json:"req"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServiceSimpleMethodArgs() *BaselineServiceSimpleMethodArgs { - return &BaselineServiceSimpleMethodArgs{} -} - -func (p *BaselineServiceSimpleMethodArgs) InitDefault() { - *p = BaselineServiceSimpleMethodArgs{} -} - -var BaselineServiceSimpleMethodArgs_Req_DEFAULT *Simple - -func (p *BaselineServiceSimpleMethodArgs) GetReq() (v *Simple) { - if !p.IsSetReq() { - return BaselineServiceSimpleMethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *BaselineServiceSimpleMethodArgs) SetReq(val *Simple) { - p.Req = val -} - -func (p *BaselineServiceSimpleMethodArgs) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServiceSimpleMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServiceSimpleMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *BaselineServiceSimpleMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BaselineServiceSimpleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Req = NewSimple() - p.Req.SetFieldMask(fm) - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceSimpleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("SimpleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot, nfm); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServiceSimpleMethodArgs(%+v)", *p) -} - -func (p *BaselineServiceSimpleMethodArgs) DeepEqual(ano *BaselineServiceSimpleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServiceSimpleMethodArgs) Field1DeepEqual(src *Simple) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type BaselineServiceSimpleMethodResult struct { - Success *Simple `thrift:"success,0,optional" frugal:"0,optional,Simple" json:"success,omitempty"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServiceSimpleMethodResult() *BaselineServiceSimpleMethodResult { - return &BaselineServiceSimpleMethodResult{} -} - -func (p *BaselineServiceSimpleMethodResult) InitDefault() { - *p = BaselineServiceSimpleMethodResult{} -} - -var BaselineServiceSimpleMethodResult_Success_DEFAULT *Simple - -func (p *BaselineServiceSimpleMethodResult) GetSuccess() (v *Simple) { - if !p.IsSetSuccess() { - return BaselineServiceSimpleMethodResult_Success_DEFAULT - } - return p.Success -} -func (p *BaselineServiceSimpleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*Simple) -} - -func (p *BaselineServiceSimpleMethodResult) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServiceSimpleMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServiceSimpleMethodResult = map[int16]string{ - 0: "success", -} - -func (p *BaselineServiceSimpleMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *BaselineServiceSimpleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField0(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Success = NewSimple() - p.Success.SetFieldMask(fm) - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceSimpleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("SimpleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - if err = p.writeField0(oprot, nfm); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServiceSimpleMethodResult(%+v)", *p) -} - -func (p *BaselineServiceSimpleMethodResult) DeepEqual(ano *BaselineServiceSimpleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServiceSimpleMethodResult) Field0DeepEqual(src *Simple) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type BaselineServicePartialSimpleMethodArgs struct { - Req *PartialSimple `thrift:"req,1" frugal:"1,default,PartialSimple" json:"req"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServicePartialSimpleMethodArgs() *BaselineServicePartialSimpleMethodArgs { - return &BaselineServicePartialSimpleMethodArgs{} -} - -func (p *BaselineServicePartialSimpleMethodArgs) InitDefault() { - *p = BaselineServicePartialSimpleMethodArgs{} -} - -var BaselineServicePartialSimpleMethodArgs_Req_DEFAULT *PartialSimple - -func (p *BaselineServicePartialSimpleMethodArgs) GetReq() (v *PartialSimple) { - if !p.IsSetReq() { - return BaselineServicePartialSimpleMethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *BaselineServicePartialSimpleMethodArgs) SetReq(val *PartialSimple) { - p.Req = val -} - -func (p *BaselineServicePartialSimpleMethodArgs) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServicePartialSimpleMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServicePartialSimpleMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *BaselineServicePartialSimpleMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BaselineServicePartialSimpleMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Req = NewPartialSimple() - p.Req.SetFieldMask(fm) - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialSimpleMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialSimpleMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot, nfm); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServicePartialSimpleMethodArgs(%+v)", *p) -} - -func (p *BaselineServicePartialSimpleMethodArgs) DeepEqual(ano *BaselineServicePartialSimpleMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServicePartialSimpleMethodArgs) Field1DeepEqual(src *PartialSimple) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type BaselineServicePartialSimpleMethodResult struct { - Success *PartialSimple `thrift:"success,0,optional" frugal:"0,optional,PartialSimple" json:"success,omitempty"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServicePartialSimpleMethodResult() *BaselineServicePartialSimpleMethodResult { - return &BaselineServicePartialSimpleMethodResult{} -} - -func (p *BaselineServicePartialSimpleMethodResult) InitDefault() { - *p = BaselineServicePartialSimpleMethodResult{} -} - -var BaselineServicePartialSimpleMethodResult_Success_DEFAULT *PartialSimple - -func (p *BaselineServicePartialSimpleMethodResult) GetSuccess() (v *PartialSimple) { - if !p.IsSetSuccess() { - return BaselineServicePartialSimpleMethodResult_Success_DEFAULT - } - return p.Success -} -func (p *BaselineServicePartialSimpleMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*PartialSimple) -} - -func (p *BaselineServicePartialSimpleMethodResult) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServicePartialSimpleMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServicePartialSimpleMethodResult = map[int16]string{ - 0: "success", -} - -func (p *BaselineServicePartialSimpleMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *BaselineServicePartialSimpleMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField0(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Success = NewPartialSimple() - p.Success.SetFieldMask(fm) - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialSimpleMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialSimpleMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - if err = p.writeField0(oprot, nfm); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServicePartialSimpleMethodResult(%+v)", *p) -} - -func (p *BaselineServicePartialSimpleMethodResult) DeepEqual(ano *BaselineServicePartialSimpleMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServicePartialSimpleMethodResult) Field0DeepEqual(src *PartialSimple) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type BaselineServiceNestingMethodArgs struct { - Req *Nesting `thrift:"req,1" frugal:"1,default,Nesting" json:"req"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServiceNestingMethodArgs() *BaselineServiceNestingMethodArgs { - return &BaselineServiceNestingMethodArgs{} -} - -func (p *BaselineServiceNestingMethodArgs) InitDefault() { - *p = BaselineServiceNestingMethodArgs{} -} - -var BaselineServiceNestingMethodArgs_Req_DEFAULT *Nesting - -func (p *BaselineServiceNestingMethodArgs) GetReq() (v *Nesting) { - if !p.IsSetReq() { - return BaselineServiceNestingMethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *BaselineServiceNestingMethodArgs) SetReq(val *Nesting) { - p.Req = val -} - -func (p *BaselineServiceNestingMethodArgs) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServiceNestingMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServiceNestingMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *BaselineServiceNestingMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BaselineServiceNestingMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Req = NewNesting() - p.Req.SetFieldMask(fm) - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNestingMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NestingMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot, nfm); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServiceNestingMethodArgs(%+v)", *p) -} - -func (p *BaselineServiceNestingMethodArgs) DeepEqual(ano *BaselineServiceNestingMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServiceNestingMethodArgs) Field1DeepEqual(src *Nesting) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type BaselineServiceNestingMethodResult struct { - Success *Nesting `thrift:"success,0,optional" frugal:"0,optional,Nesting" json:"success,omitempty"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServiceNestingMethodResult() *BaselineServiceNestingMethodResult { - return &BaselineServiceNestingMethodResult{} -} - -func (p *BaselineServiceNestingMethodResult) InitDefault() { - *p = BaselineServiceNestingMethodResult{} -} - -var BaselineServiceNestingMethodResult_Success_DEFAULT *Nesting - -func (p *BaselineServiceNestingMethodResult) GetSuccess() (v *Nesting) { - if !p.IsSetSuccess() { - return BaselineServiceNestingMethodResult_Success_DEFAULT - } - return p.Success -} -func (p *BaselineServiceNestingMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*Nesting) -} - -func (p *BaselineServiceNestingMethodResult) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServiceNestingMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServiceNestingMethodResult = map[int16]string{ - 0: "success", -} - -func (p *BaselineServiceNestingMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *BaselineServiceNestingMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField0(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Success = NewNesting() - p.Success.SetFieldMask(fm) - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNestingMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("NestingMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - if err = p.writeField0(oprot, nfm); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServiceNestingMethodResult(%+v)", *p) -} - -func (p *BaselineServiceNestingMethodResult) DeepEqual(ano *BaselineServiceNestingMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServiceNestingMethodResult) Field0DeepEqual(src *Nesting) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type BaselineServicePartialNestingMethodArgs struct { - Req *PartialNesting `thrift:"req,1" frugal:"1,default,PartialNesting" json:"req"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServicePartialNestingMethodArgs() *BaselineServicePartialNestingMethodArgs { - return &BaselineServicePartialNestingMethodArgs{} -} - -func (p *BaselineServicePartialNestingMethodArgs) InitDefault() { - *p = BaselineServicePartialNestingMethodArgs{} -} - -var BaselineServicePartialNestingMethodArgs_Req_DEFAULT *PartialNesting - -func (p *BaselineServicePartialNestingMethodArgs) GetReq() (v *PartialNesting) { - if !p.IsSetReq() { - return BaselineServicePartialNestingMethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *BaselineServicePartialNestingMethodArgs) SetReq(val *PartialNesting) { - p.Req = val -} - -func (p *BaselineServicePartialNestingMethodArgs) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServicePartialNestingMethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServicePartialNestingMethodArgs = map[int16]string{ - 1: "req", -} - -func (p *BaselineServicePartialNestingMethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BaselineServicePartialNestingMethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Req = NewPartialNesting() - p.Req.SetFieldMask(fm) - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialNestingMethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialNestingMethod_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot, nfm); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServicePartialNestingMethodArgs(%+v)", *p) -} - -func (p *BaselineServicePartialNestingMethodArgs) DeepEqual(ano *BaselineServicePartialNestingMethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServicePartialNestingMethodArgs) Field1DeepEqual(src *PartialNesting) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type BaselineServicePartialNestingMethodResult struct { - Success *PartialNesting `thrift:"success,0,optional" frugal:"0,optional,PartialNesting" json:"success,omitempty"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServicePartialNestingMethodResult() *BaselineServicePartialNestingMethodResult { - return &BaselineServicePartialNestingMethodResult{} -} - -func (p *BaselineServicePartialNestingMethodResult) InitDefault() { - *p = BaselineServicePartialNestingMethodResult{} -} - -var BaselineServicePartialNestingMethodResult_Success_DEFAULT *PartialNesting - -func (p *BaselineServicePartialNestingMethodResult) GetSuccess() (v *PartialNesting) { - if !p.IsSetSuccess() { - return BaselineServicePartialNestingMethodResult_Success_DEFAULT - } - return p.Success -} -func (p *BaselineServicePartialNestingMethodResult) SetSuccess(x interface{}) { - p.Success = x.(*PartialNesting) -} - -func (p *BaselineServicePartialNestingMethodResult) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServicePartialNestingMethodResult) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServicePartialNestingMethodResult = map[int16]string{ - 0: "success", -} - -func (p *BaselineServicePartialNestingMethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *BaselineServicePartialNestingMethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField0(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Success = NewPartialNesting() - p.Success.SetFieldMask(fm) - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServicePartialNestingMethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("PartialNestingMethod_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - if err = p.writeField0(oprot, nfm); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServicePartialNestingMethodResult(%+v)", *p) -} - -func (p *BaselineServicePartialNestingMethodResult) DeepEqual(ano *BaselineServicePartialNestingMethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServicePartialNestingMethodResult) Field0DeepEqual(src *PartialNesting) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type BaselineServiceNesting2MethodArgs struct { - Req *Nesting2 `thrift:"req,1" frugal:"1,default,Nesting2" json:"req"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServiceNesting2MethodArgs() *BaselineServiceNesting2MethodArgs { - return &BaselineServiceNesting2MethodArgs{} -} - -func (p *BaselineServiceNesting2MethodArgs) InitDefault() { - *p = BaselineServiceNesting2MethodArgs{} -} - -var BaselineServiceNesting2MethodArgs_Req_DEFAULT *Nesting2 - -func (p *BaselineServiceNesting2MethodArgs) GetReq() (v *Nesting2) { - if !p.IsSetReq() { - return BaselineServiceNesting2MethodArgs_Req_DEFAULT - } - return p.Req -} -func (p *BaselineServiceNesting2MethodArgs) SetReq(val *Nesting2) { - p.Req = val -} - -func (p *BaselineServiceNesting2MethodArgs) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServiceNesting2MethodArgs) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServiceNesting2MethodArgs = map[int16]string{ - 1: "req", -} - -func (p *BaselineServiceNesting2MethodArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BaselineServiceNesting2MethodArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField1(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodArgs) ReadField1(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Req = NewNesting2() - p.Req.SetFieldMask(fm) - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNesting2MethodArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting2Method_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - if err = p.writeField1(oprot, nfm); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodArgs) writeField1(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServiceNesting2MethodArgs(%+v)", *p) -} - -func (p *BaselineServiceNesting2MethodArgs) DeepEqual(ano *BaselineServiceNesting2MethodArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BaselineServiceNesting2MethodArgs) Field1DeepEqual(src *Nesting2) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type BaselineServiceNesting2MethodResult struct { - Success *Nesting2 `thrift:"success,0,optional" frugal:"0,optional,Nesting2" json:"success,omitempty"` - _fieldmask *fieldmask.FieldMask -} - -func NewBaselineServiceNesting2MethodResult() *BaselineServiceNesting2MethodResult { - return &BaselineServiceNesting2MethodResult{} -} - -func (p *BaselineServiceNesting2MethodResult) InitDefault() { - *p = BaselineServiceNesting2MethodResult{} -} - -var BaselineServiceNesting2MethodResult_Success_DEFAULT *Nesting2 - -func (p *BaselineServiceNesting2MethodResult) GetSuccess() (v *Nesting2) { - if !p.IsSetSuccess() { - return BaselineServiceNesting2MethodResult_Success_DEFAULT - } - return p.Success -} -func (p *BaselineServiceNesting2MethodResult) SetSuccess(x interface{}) { - p.Success = x.(*Nesting2) -} - -func (p *BaselineServiceNesting2MethodResult) GetFieldMask() *fieldmask.FieldMask { - return p._fieldmask -} -func (p *BaselineServiceNesting2MethodResult) SetFieldMask(fm *fieldmask.FieldMask) { - p._fieldmask = fm -} - -var fieldIDToName_BaselineServiceNesting2MethodResult = map[int16]string{ - 0: "success", -} - -func (p *BaselineServiceNesting2MethodResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *BaselineServiceNesting2MethodResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - if err = p.ReadField0(iprot, nfm); err != nil { - goto ReadFieldError - } - break - } - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodResult) ReadField0(iprot thrift.TProtocol, fm *fieldmask.FieldMask) error { - p.Success = NewNesting2() - p.Success.SetFieldMask(fm) - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BaselineServiceNesting2MethodResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Nesting2Method_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - if err = p.writeField0(oprot, nfm); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodResult) writeField0(oprot thrift.TProtocol, fm *fieldmask.FieldMask) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BaselineServiceNesting2MethodResult(%+v)", *p) -} - -func (p *BaselineServiceNesting2MethodResult) DeepEqual(ano *BaselineServiceNesting2MethodResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BaselineServiceNesting2MethodResult) Field0DeepEqual(src *Nesting2) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} diff --git a/codegen/fieldmask/test_gen/baseline/k-baseline.go b/codegen/fieldmask/test_gen/baseline/k-baseline.go deleted file mode 100644 index 37db4c9..0000000 --- a/codegen/fieldmask/test_gen/baseline/k-baseline.go +++ /dev/null @@ -1,4556 +0,0 @@ -// Code generated by Kitex v0.7.3. DO NOT EDIT. - -package baseline - -import ( - "bytes" - "fmt" - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/kitex/pkg/protocol/bthrift" - "github.com/cloudwego/thriftgo/fieldmask" - "reflect" - "strings" -) - -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) - -func (p *Simple) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.I64 { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 4: - if fieldTypeId == thrift.I32 { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField5(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Simple[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Simple) FastReadField1(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.ByteField = v - - } - return offset, nil -} - -func (p *Simple) FastReadField2(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I64Field = v - - } - return offset, nil -} - -func (p *Simple) FastReadField3(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.DoubleField = v - - } - return offset, nil -} - -func (p *Simple) FastReadField4(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I32Field = v - - } - return offset, nil -} - -func (p *Simple) FastReadField5(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.StringField = v - - } - return offset, nil -} - -func (p *Simple) FastReadField6(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.BinaryField = []byte(v) - - } - return offset, nil -} - -// for compatibility -func (p *Simple) FastWrite(buf []byte) int { - return 0 -} - -func (p *Simple) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Simple") - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(2); ex { - offset += p.fastWriteField2(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(3); ex { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(4); ex { - offset += p.fastWriteField4(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(5); ex { - offset += p.fastWriteField5(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(6); ex { - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Simple) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Simple") - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - l += p.field1Length() - } - if _, ex := p._fieldmask.Field(2); ex { - l += p.field2Length() - } - if _, ex := p._fieldmask.Field(3); ex { - l += p.field3Length() - } - if _, ex := p._fieldmask.Field(4); ex { - l += p.field4Length() - } - if _, ex := p._fieldmask.Field(5); ex { - l += p.field5Length() - } - if _, ex := p._fieldmask.Field(6); ex { - l += p.field6Length() - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Simple) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ByteField", thrift.BYTE, 1) - offset += bthrift.Binary.WriteByte(buf[offset:], p.ByteField) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64Field", thrift.I64, 2) - offset += bthrift.Binary.WriteI64(buf[offset:], p.I64Field) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DoubleField", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.DoubleField) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32Field", thrift.I32, 4) - offset += bthrift.Binary.WriteI32(buf[offset:], p.I32Field) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "StringField", thrift.STRING, 5) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.StringField) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BinaryField", thrift.STRING, 6) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.BinaryField)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Simple) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ByteField", thrift.BYTE, 1) - l += bthrift.Binary.ByteLength(p.ByteField) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I64Field", thrift.I64, 2) - l += bthrift.Binary.I64Length(p.I64Field) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("DoubleField", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.DoubleField) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I32Field", thrift.I32, 4) - l += bthrift.Binary.I32Length(p.I32Field) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field5Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("StringField", thrift.STRING, 5) - l += bthrift.Binary.StringLengthNocopy(p.StringField) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Simple) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BinaryField", thrift.STRING, 6) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.BinaryField)) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialSimple) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialSimple[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialSimple) FastReadField1(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.ByteField = v - - } - return offset, nil -} - -func (p *PartialSimple) FastReadField3(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.DoubleField = v - - } - return offset, nil -} - -func (p *PartialSimple) FastReadField6(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.BinaryField = []byte(v) - - } - return offset, nil -} - -// for compatibility -func (p *PartialSimple) FastWrite(buf []byte) int { - return 0 -} - -func (p *PartialSimple) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimple") - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(3); ex { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(6); ex { - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PartialSimple) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialSimple") - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - l += p.field1Length() - } - if _, ex := p._fieldmask.Field(3); ex { - l += p.field3Length() - } - if _, ex := p._fieldmask.Field(6); ex { - l += p.field6Length() - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PartialSimple) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ByteField", thrift.BYTE, 1) - offset += bthrift.Binary.WriteByte(buf[offset:], p.ByteField) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialSimple) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "DoubleField", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.DoubleField) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialSimple) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "BinaryField", thrift.STRING, 6) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.BinaryField)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialSimple) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ByteField", thrift.BYTE, 1) - l += bthrift.Binary.ByteLength(p.ByteField) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialSimple) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("DoubleField", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.DoubleField) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialSimple) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("BinaryField", thrift.STRING, 6) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.BinaryField)) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField2(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 4: - if fieldTypeId == thrift.I32 { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField5(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.I64 { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 7: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField7(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 8: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField8(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 9: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField9(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 10: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField10(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 11: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField11(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 12: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField12(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 13: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField13(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 14: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField14(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 15: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField15(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting) FastReadField1(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.String_ = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField2(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListSimple = make([]*Simple, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) - offset += l - if err != nil { - return offset, err - } - continue - } else { - _elem := NewSimple() - _elem.SetFieldMask(nfm) - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListSimple = append(p.ListSimple, _elem) - } - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField3(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Double = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField4(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I32 = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField5(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListI32 = make([]int32, 0, size) - for i := 0; i < size; i++ { - if _, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.I32) - offset += l - if err != nil { - return offset, err - } - continue - } else { - var _elem int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListI32 = append(p.ListI32, _elem) - } - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField6(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I64 = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField7(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringString = make(map[string]string, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - if _, ex := fm.Str(string(_key)); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRING) - offset += l - if err != nil { - return offset, err - } - continue - } else { - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapStringString[_key] = _val - } - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField8(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.SimpleStruct = tmp - return offset, nil -} - -func (p *Nesting) FastReadField9(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapI32I64 = make(map[int32]int64, size) - for i := 0; i < size; i++ { - var _key int32 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - if _, ex := fm.Int(int(_key)); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.I64) - offset += l - if err != nil { - return offset, err - } - continue - } else { - - var _val int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapI32I64[_key] = _val - } - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField10(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListString = make([]string, 0, size) - for i := 0; i < size; i++ { - if _, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRING) - offset += l - if err != nil { - return offset, err - } - continue - } else { - var _elem string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListString = append(p.ListString, _elem) - } - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField11(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - - } - return offset, nil -} - -func (p *Nesting) FastReadField12(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapI64String = make(map[int64]string, size) - for i := 0; i < size; i++ { - var _key int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - if _, ex := fm.Int(int(_key)); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRING) - offset += l - if err != nil { - return offset, err - } - continue - } else { - - var _val string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _val = v - - } - - p.MapI64String[_key] = _val - } - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField13(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListI64 = make([]int64, 0, size) - for i := 0; i < size; i++ { - if _, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.I64) - offset += l - if err != nil { - return offset, err - } - continue - } else { - var _elem int64 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _elem = v - - } - - p.ListI64 = append(p.ListI64, _elem) - } - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting) FastReadField14(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Byte = v - - } - return offset, nil -} - -func (p *Nesting) FastReadField15(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringSimple = make(map[string]*Simple, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - if nfm, ex := fm.Str(string(_key)); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) - offset += l - if err != nil { - return offset, err - } - continue - } else { - _val := NewSimple() - _val.SetFieldMask(nfm) - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapStringSimple[_key] = _val - } - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *Nesting) FastWrite(buf []byte) int { - return 0 -} - -func (p *Nesting) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting") - if p != nil { - if _, ex := p._fieldmask.Field(3); ex { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(4); ex { - offset += p.fastWriteField4(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(6); ex { - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(14); ex { - offset += p.fastWriteField14(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - if nfm, ex := p._fieldmask.Field(2); ex { - offset += p.fastWriteField2(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(5); ex { - offset += p.fastWriteField5(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(7); ex { - offset += p.fastWriteField7(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(8); ex { - offset += p.fastWriteField8(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(9); ex { - offset += p.fastWriteField9(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(10); ex { - offset += p.fastWriteField10(buf[offset:], binaryWriter, nfm) - } - if _, ex := p._fieldmask.Field(11); ex { - offset += p.fastWriteField11(buf[offset:], binaryWriter) - } - if nfm, ex := p._fieldmask.Field(12); ex { - offset += p.fastWriteField12(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(13); ex { - offset += p.fastWriteField13(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(15); ex { - offset += p.fastWriteField15(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Nesting) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting") - if p != nil { - if _, ex := p._fieldmask.Field(1); ex { - l += p.field1Length() - } - if nfm, ex := p._fieldmask.Field(2); ex { - l += p.field2Length(nfm) - } - if _, ex := p._fieldmask.Field(3); ex { - l += p.field3Length() - } - if _, ex := p._fieldmask.Field(4); ex { - l += p.field4Length() - } - if nfm, ex := p._fieldmask.Field(5); ex { - l += p.field5Length(nfm) - } - if _, ex := p._fieldmask.Field(6); ex { - l += p.field6Length() - } - if nfm, ex := p._fieldmask.Field(7); ex { - l += p.field7Length(nfm) - } - if nfm, ex := p._fieldmask.Field(8); ex { - l += p.field8Length(nfm) - } - if nfm, ex := p._fieldmask.Field(9); ex { - l += p.field9Length(nfm) - } - if nfm, ex := p._fieldmask.Field(10); ex { - l += p.field10Length(nfm) - } - if _, ex := p._fieldmask.Field(11); ex { - l += p.field11Length() - } - if nfm, ex := p._fieldmask.Field(12); ex { - l += p.field12Length(nfm) - } - if nfm, ex := p._fieldmask.Field(13); ex { - l += p.field13Length(nfm) - } - if _, ex := p._fieldmask.Field(14); ex { - l += p.field14Length() - } - if nfm, ex := p._fieldmask.Field(15); ex { - l += p.field15Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Nesting) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListSimple", thrift.LIST, 2) - listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) - var length int - for i, v := range p.ListSimple { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - length++ - if v != nil { - v.SetFieldMask(nfm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 3) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32", thrift.I32, 4) - offset += bthrift.Binary.WriteI32(buf[offset:], p.I32) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListI32", thrift.LIST, 5) - listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.I32, 0) - var length int - for i, v := range p.ListI32 { - if _, ex := fm.Int(i); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteI32(buf[offset:], v) - } - } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I32, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.I64) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringString", thrift.MAP, 7) - mapBeginOffset := offset - offset += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, 0) - var length int - for k, v := range p.MapStringString { - ks := string(k) - if _, ex := fm.Str(ks); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - } - } - bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRING, thrift.STRING, length) - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 8) - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapI32I64", thrift.MAP, 9) - mapBeginOffset := offset - offset += bthrift.Binary.MapBeginLength(thrift.I32, thrift.I64, 0) - var length int - for k, v := range p.MapI32I64 { - if _, ex := fm.Int(int(k)); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteI32(buf[offset:], k) - offset += bthrift.Binary.WriteI64(buf[offset:], v) - } - } - bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I32, thrift.I64, length) - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListString", thrift.LIST, 10) - listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRING, 0) - var length int - for i, v := range p.ListString { - if _, ex := fm.Int(i); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - } - } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRING, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 11) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField12(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapI64String", thrift.MAP, 12) - mapBeginOffset := offset - offset += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, 0) - var length int - for k, v := range p.MapI64String { - if _, ex := fm.Int(int(k)); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteI64(buf[offset:], k) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, v) - } - } - bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I64, thrift.STRING, length) - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField13(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListI64", thrift.LIST, 13) - listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.I64, 0) - var length int - for i, v := range p.ListI64 { - if _, ex := fm.Int(i); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteI64(buf[offset:], v) - } - } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I64, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField14(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 14) - offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringSimple", thrift.MAP, 15) - mapBeginOffset := offset - offset += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, 0) - var length int - for k, v := range p.MapStringSimple { - ks := string(k) - if nfm, ex := fm.Str(ks); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - if v != nil { - v.SetFieldMask(nfm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - } - bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRING, thrift.STRUCT, length) - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.String_) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field2Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListSimple", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListSimple)) - for i, v := range p.ListSimple { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - l += v.BLength() - } - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 3) - l += bthrift.Binary.DoubleLength(p.Double) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I32", thrift.I32, 4) - l += bthrift.Binary.I32Length(p.I32) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field5Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListI32", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.I32, len(p.ListI32)) - for i, v := range p.ListI32 { - if _, ex := fm.Int(i); !ex { - continue - } else { - l += bthrift.Binary.I32Length(v) - } - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I64", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.I64) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field7Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringString", thrift.MAP, 7) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRING, len(p.MapStringString)) - for k, v := range p.MapStringString { - ks := string(k) - if _, ex := fm.Str(ks); !ex { - continue - } else { - - l += bthrift.Binary.StringLengthNocopy(k) - l += bthrift.Binary.StringLengthNocopy(v) - } - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field8Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 8) - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - l += p.SimpleStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field9Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapI32I64", thrift.MAP, 9) - l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.I64, len(p.MapI32I64)) - for k, v := range p.MapI32I64 { - if _, ex := fm.Int(int(k)); !ex { - continue - } else { - - l += bthrift.Binary.I32Length(k) - l += bthrift.Binary.I64Length(v) - } - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field10Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListString", thrift.LIST, 10) - l += bthrift.Binary.ListBeginLength(thrift.STRING, len(p.ListString)) - for i, v := range p.ListString { - if _, ex := fm.Int(i); !ex { - continue - } else { - l += bthrift.Binary.StringLengthNocopy(v) - } - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field11Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 11) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field12Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapI64String", thrift.MAP, 12) - l += bthrift.Binary.MapBeginLength(thrift.I64, thrift.STRING, len(p.MapI64String)) - for k, v := range p.MapI64String { - if _, ex := fm.Int(int(k)); !ex { - continue - } else { - - l += bthrift.Binary.I64Length(k) - l += bthrift.Binary.StringLengthNocopy(v) - } - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field13Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListI64", thrift.LIST, 13) - l += bthrift.Binary.ListBeginLength(thrift.I64, len(p.ListI64)) - for i, v := range p.ListI64 { - if _, ex := fm.Int(i); !ex { - continue - } else { - l += bthrift.Binary.I64Length(v) - } - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field14Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 14) - l += bthrift.Binary.ByteLength(p.Byte) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting) field15Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringSimple", thrift.MAP, 15) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) - for k, v := range p.MapStringSimple { - ks := string(k) - if nfm, ex := fm.Str(ks); !ex { - continue - } else { - - l += bthrift.Binary.StringLengthNocopy(k) - if v != nil { - v.SetFieldMask(nfm) - } - l += v.BLength() - } - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialNesting) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField2(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 8: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField8(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 15: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField15(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PartialNesting[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PartialNesting) FastReadField2(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListSimple = make([]*PartialSimple, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) - offset += l - if err != nil { - return offset, err - } - continue - } else { - _elem := NewPartialSimple() - _elem.SetFieldMask(nfm) - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListSimple = append(p.ListSimple, _elem) - } - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *PartialNesting) FastReadField8(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewPartialSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.SimpleStruct = tmp - return offset, nil -} - -func (p *PartialNesting) FastReadField15(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapStringSimple = make(map[string]*PartialSimple, size) - for i := 0; i < size; i++ { - var _key string - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - _key = v - - } - if nfm, ex := fm.Str(string(_key)); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) - offset += l - if err != nil { - return offset, err - } - continue - } else { - _val := NewPartialSimple() - _val.SetFieldMask(nfm) - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapStringSimple[_key] = _val - } - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -// for compatibility -func (p *PartialNesting) FastWrite(buf []byte) int { - return 0 -} - -func (p *PartialNesting) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNesting") - if p != nil { - if nfm, ex := p._fieldmask.Field(2); ex { - offset += p.fastWriteField2(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(8); ex { - offset += p.fastWriteField8(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(15); ex { - offset += p.fastWriteField15(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialNesting") - if p != nil { - if nfm, ex := p._fieldmask.Field(2); ex { - l += p.field2Length(nfm) - } - if nfm, ex := p._fieldmask.Field(8); ex { - l += p.field8Length(nfm) - } - if nfm, ex := p._fieldmask.Field(15); ex { - l += p.field15Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PartialNesting) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListSimple", thrift.LIST, 2) - listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) - var length int - for i, v := range p.ListSimple { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - length++ - if v != nil { - v.SetFieldMask(nfm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 8) - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) fastWriteField15(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapStringSimple", thrift.MAP, 15) - mapBeginOffset := offset - offset += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, 0) - var length int - for k, v := range p.MapStringSimple { - ks := string(k) - if nfm, ex := fm.Str(ks); !ex { - continue - } else { - length++ - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, k) - if v != nil { - v.SetFieldMask(nfm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - } - bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRING, thrift.STRUCT, length) - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PartialNesting) field2Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListSimple", thrift.LIST, 2) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListSimple)) - for i, v := range p.ListSimple { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - l += v.BLength() - } - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialNesting) field8Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 8) - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - l += p.SimpleStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PartialNesting) field15Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapStringSimple", thrift.MAP, 15) - l += bthrift.Binary.MapBeginLength(thrift.STRING, thrift.STRUCT, len(p.MapStringSimple)) - for k, v := range p.MapStringSimple { - ks := string(k) - if nfm, ex := fm.Str(ks); !ex { - continue - } else { - - l += bthrift.Binary.StringLengthNocopy(k) - if v != nil { - v.SetFieldMask(nfm) - } - l += v.BLength() - } - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.MAP { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField2(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 3: - if fieldTypeId == thrift.BYTE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField3(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 4: - if fieldTypeId == thrift.DOUBLE { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField4(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 5: - if fieldTypeId == thrift.LIST { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField5(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 6: - if fieldTypeId == thrift.I64 { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField6(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 7: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField7(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 8: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField8(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 9: - if fieldTypeId == thrift.STRING { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField9(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 10: - if fieldTypeId == thrift.SET { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField10(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - case 11: - if fieldTypeId == thrift.I32 { - if _, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField11(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Nesting2[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *Nesting2) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.MapSimpleNesting = make(map[*Simple]*Nesting, size) - for i := 0; i < size; i++ { - _key := NewSimple() - _key.SetFieldMask(fm) - if l, err := _key.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - fm = nil - _val := NewNesting() - _val.SetFieldMask(fm) - if l, err := _val.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.MapSimpleNesting[_key] = _val - } - if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField2(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.SimpleStruct = tmp - return offset, nil -} - -func (p *Nesting2) FastReadField3(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadByte(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Byte = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField4(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadDouble(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Double = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField5(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.ListNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) - offset += l - if err != nil { - return offset, err - } - continue - } else { - _elem := NewNesting() - _elem.SetFieldMask(nfm) - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.ListNesting = append(p.ListNesting, _elem) - } - } - if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField6(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I64 = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField7(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewNesting() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.NestingStruct = tmp - return offset, nil -} - -func (p *Nesting2) FastReadField8(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadBinary(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Binary = []byte(v) - - } - return offset, nil -} - -func (p *Nesting2) FastReadField9(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.String_ = v - - } - return offset, nil -} - -func (p *Nesting2) FastReadField10(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - _, size, l, err := bthrift.Binary.ReadSetBegin(buf[offset:]) - offset += l - if err != nil { - return offset, err - } - p.SetNesting = make([]*Nesting, 0, size) - for i := 0; i < size; i++ { - if nfm, ex := fm.Int(i); !ex { - l, err := bthrift.Binary.Skip(buf[offset:], thrift.STRUCT) - offset += l - if err != nil { - return offset, err - } - continue - } else { - _elem := NewNesting() - _elem.SetFieldMask(nfm) - if l, err := _elem.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - - p.SetNesting = append(p.SetNesting, _elem) - } - } - if l, err := bthrift.Binary.ReadSetEnd(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - return offset, nil -} - -func (p *Nesting2) FastReadField11(buf []byte) (int, error) { - offset := 0 - if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.I32 = v - - } - return offset, nil -} - -// for compatibility -func (p *Nesting2) FastWrite(buf []byte) int { - return 0 -} - -func (p *Nesting2) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2") - if p != nil { - if _, ex := p._fieldmask.Field(3); ex { - offset += p.fastWriteField3(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(4); ex { - offset += p.fastWriteField4(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(6); ex { - offset += p.fastWriteField6(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(11); ex { - offset += p.fastWriteField11(buf[offset:], binaryWriter) - } - if nfm, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(2); ex { - offset += p.fastWriteField2(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(5); ex { - offset += p.fastWriteField5(buf[offset:], binaryWriter, nfm) - } - if nfm, ex := p._fieldmask.Field(7); ex { - offset += p.fastWriteField7(buf[offset:], binaryWriter, nfm) - } - if _, ex := p._fieldmask.Field(8); ex { - offset += p.fastWriteField8(buf[offset:], binaryWriter) - } - if _, ex := p._fieldmask.Field(9); ex { - offset += p.fastWriteField9(buf[offset:], binaryWriter) - } - if nfm, ex := p._fieldmask.Field(10); ex { - offset += p.fastWriteField10(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting2") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - l += p.field1Length(nfm) - } - if nfm, ex := p._fieldmask.Field(2); ex { - l += p.field2Length(nfm) - } - if _, ex := p._fieldmask.Field(3); ex { - l += p.field3Length() - } - if _, ex := p._fieldmask.Field(4); ex { - l += p.field4Length() - } - if nfm, ex := p._fieldmask.Field(5); ex { - l += p.field5Length(nfm) - } - if _, ex := p._fieldmask.Field(6); ex { - l += p.field6Length() - } - if nfm, ex := p._fieldmask.Field(7); ex { - l += p.field7Length(nfm) - } - if _, ex := p._fieldmask.Field(8); ex { - l += p.field8Length() - } - if _, ex := p._fieldmask.Field(9); ex { - l += p.field9Length() - } - if nfm, ex := p._fieldmask.Field(10); ex { - l += p.field10Length(nfm) - } - if _, ex := p._fieldmask.Field(11); ex { - l += p.field11Length() - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Nesting2) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "MapSimpleNesting", thrift.MAP, 1) - mapBeginOffset := offset - offset += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, 0) - var length int - for k, v := range p.MapSimpleNesting { - fm = nil - length++ - if k != nil { - k.SetFieldMask(fm) - } - offset += k.FastWriteNocopy(buf[offset:], binaryWriter) - if v != nil { - v.SetFieldMask(fm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.STRUCT, thrift.STRUCT, length) - offset += bthrift.Binary.WriteMapEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SimpleStruct", thrift.STRUCT, 2) - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - offset += p.SimpleStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Byte", thrift.BYTE, 3) - offset += bthrift.Binary.WriteByte(buf[offset:], p.Byte) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField4(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Double", thrift.DOUBLE, 4) - offset += bthrift.Binary.WriteDouble(buf[offset:], p.Double) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField5(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ListNesting", thrift.LIST, 5) - listBeginOffset := offset - offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0) - var length int - for i, v := range p.ListNesting { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - length++ - if v != nil { - v.SetFieldMask(nfm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - } - bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteListEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField6(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I64", thrift.I64, 6) - offset += bthrift.Binary.WriteI64(buf[offset:], p.I64) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField7(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "NestingStruct", thrift.STRUCT, 7) - if p.NestingStruct != nil { - p.NestingStruct.SetFieldMask(fm) - } - offset += p.NestingStruct.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField8(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Binary", thrift.STRING, 8) - offset += bthrift.Binary.WriteBinaryNocopy(buf[offset:], binaryWriter, []byte(p.Binary)) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField9(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "String", thrift.STRING, 9) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.String_) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField10(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "SetNesting", thrift.SET, 10) - setBeginOffset := offset - offset += bthrift.Binary.SetBeginLength(thrift.STRUCT, 0) - - for i := 0; i < len(p.SetNesting); i++ { - for j := i + 1; j < len(p.SetNesting); j++ { - if func(tgt, src *Nesting) bool { - if !tgt.DeepEqual(src) { - return false - } - return true - }(p.SetNesting[i], p.SetNesting[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) - } - } - } - var length int - for i, v := range p.SetNesting { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - length++ - if v != nil { - v.SetFieldMask(nfm) - } - offset += v.FastWriteNocopy(buf[offset:], binaryWriter) - } - } - bthrift.Binary.WriteSetBegin(buf[setBeginOffset:], thrift.STRUCT, length) - offset += bthrift.Binary.WriteSetEnd(buf[offset:]) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) fastWriteField11(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "I32", thrift.I32, 11) - offset += bthrift.Binary.WriteI32(buf[offset:], p.I32) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Nesting2) field1Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("MapSimpleNesting", thrift.MAP, 1) - l += bthrift.Binary.MapBeginLength(thrift.STRUCT, thrift.STRUCT, len(p.MapSimpleNesting)) - for k, v := range p.MapSimpleNesting { - fm = nil - - if k != nil { - k.SetFieldMask(fm) - } - l += k.BLength() - if v != nil { - v.SetFieldMask(fm) - } - l += v.BLength() - } - l += bthrift.Binary.MapEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field2Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SimpleStruct", thrift.STRUCT, 2) - if p.SimpleStruct != nil { - p.SimpleStruct.SetFieldMask(fm) - } - l += p.SimpleStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field3Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Byte", thrift.BYTE, 3) - l += bthrift.Binary.ByteLength(p.Byte) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field4Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Double", thrift.DOUBLE, 4) - l += bthrift.Binary.DoubleLength(p.Double) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field5Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("ListNesting", thrift.LIST, 5) - l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(p.ListNesting)) - for i, v := range p.ListNesting { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - l += v.BLength() - } - } - l += bthrift.Binary.ListEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field6Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I64", thrift.I64, 6) - l += bthrift.Binary.I64Length(p.I64) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field7Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("NestingStruct", thrift.STRUCT, 7) - if p.NestingStruct != nil { - p.NestingStruct.SetFieldMask(fm) - } - l += p.NestingStruct.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field8Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("Binary", thrift.STRING, 8) - l += bthrift.Binary.BinaryLengthNocopy([]byte(p.Binary)) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field9Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("String", thrift.STRING, 9) - l += bthrift.Binary.StringLengthNocopy(p.String_) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field10Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("SetNesting", thrift.SET, 10) - l += bthrift.Binary.SetBeginLength(thrift.STRUCT, len(p.SetNesting)) - - for i := 0; i < len(p.SetNesting); i++ { - for j := i + 1; j < len(p.SetNesting); j++ { - if func(tgt, src *Nesting) bool { - if !tgt.DeepEqual(src) { - return false - } - return true - }(p.SetNesting[i], p.SetNesting[j]) { - panic(fmt.Errorf("%T error writing set field: slice is not unique", p.SetNesting[i])) - } - } - } - for i, v := range p.SetNesting { - if nfm, ex := fm.Int(i); !ex { - continue - } else { - if v != nil { - v.SetFieldMask(nfm) - } - l += v.BLength() - } - } - l += bthrift.Binary.SetEndLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Nesting2) field11Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("I32", thrift.I32, 11) - l += bthrift.Binary.I32Length(p.I32) - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaselineServiceSimpleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServiceSimpleMethodArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceSimpleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SimpleMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceSimpleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("SimpleMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - l += p.field1Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServiceSimpleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceSimpleMethodArgs) field1Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaselineServiceSimpleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField0(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceSimpleMethodResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceSimpleMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServiceSimpleMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceSimpleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "SimpleMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceSimpleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("SimpleMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - l += p.field0Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServiceSimpleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaselineServiceSimpleMethodResult) field0Length(fm *fieldmask.FieldMask) int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BaselineServicePartialSimpleMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewPartialSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServicePartialSimpleMethodArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServicePartialSimpleMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimpleMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServicePartialSimpleMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialSimpleMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - l += p.field1Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServicePartialSimpleMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaselineServicePartialSimpleMethodArgs) field1Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaselineServicePartialSimpleMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField0(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialSimpleMethodResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialSimpleMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewPartialSimple() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServicePartialSimpleMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServicePartialSimpleMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialSimpleMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServicePartialSimpleMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialSimpleMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - l += p.field0Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServicePartialSimpleMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaselineServicePartialSimpleMethodResult) field0Length(fm *fieldmask.FieldMask) int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BaselineServiceNestingMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewNesting() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServiceNestingMethodArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceNestingMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NestingMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceNestingMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NestingMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - l += p.field1Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServiceNestingMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceNestingMethodArgs) field1Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaselineServiceNestingMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField0(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNestingMethodResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNestingMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewNesting() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServiceNestingMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceNestingMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "NestingMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceNestingMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("NestingMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - l += p.field0Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServiceNestingMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaselineServiceNestingMethodResult) field0Length(fm *fieldmask.FieldMask) int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BaselineServicePartialNestingMethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewPartialNesting() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServicePartialNestingMethodArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServicePartialNestingMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNestingMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServicePartialNestingMethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialNestingMethod_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - l += p.field1Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServicePartialNestingMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaselineServicePartialNestingMethodArgs) field1Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaselineServicePartialNestingMethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField0(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServicePartialNestingMethodResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServicePartialNestingMethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewPartialNesting() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServicePartialNestingMethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServicePartialNestingMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PartialNestingMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServicePartialNestingMethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("PartialNestingMethod_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - l += p.field0Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServicePartialNestingMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaselineServicePartialNestingMethodResult) field0Length(fm *fieldmask.FieldMask) int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BaselineServiceNesting2MethodArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField1(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodArgs) FastReadField1(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewNesting2() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServiceNesting2MethodArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceNesting2MethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2Method_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - offset += p.fastWriteField1(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceNesting2MethodArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting2Method_args") - if p != nil { - if nfm, ex := p._fieldmask.Field(1); ex { - l += p.field1Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServiceNesting2MethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceNesting2MethodArgs) field1Length(fm *fieldmask.FieldMask) int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - if p.Req != nil { - p.Req.SetFieldMask(fm) - } - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BaselineServiceNesting2MethodResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if nfm, ex := p._fieldmask.Field(fieldId); ex { - l, err = p.FastReadField0(buf[offset:], nfm) - offset += l - if err != nil { - goto ReadFieldError - } - break - } - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BaselineServiceNesting2MethodResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BaselineServiceNesting2MethodResult) FastReadField0(buf []byte, fm *fieldmask.FieldMask) (int, error) { - offset := 0 - tmp := NewNesting2() - tmp.SetFieldMask(fm) - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *BaselineServiceNesting2MethodResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BaselineServiceNesting2MethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Nesting2Method_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - offset += p.fastWriteField0(buf[offset:], binaryWriter, nfm) - } - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BaselineServiceNesting2MethodResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Nesting2Method_result") - if p != nil { - if nfm, ex := p._fieldmask.Field(0); ex { - l += p.field0Length(nfm) - } - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BaselineServiceNesting2MethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter, fm *fieldmask.FieldMask) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BaselineServiceNesting2MethodResult) field0Length(fm *fieldmask.FieldMask) int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - if p.Success != nil { - p.Success.SetFieldMask(fm) - } - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BaselineServiceSimpleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServiceSimpleMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServicePartialSimpleMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServicePartialSimpleMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServiceNestingMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServiceNestingMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServicePartialNestingMethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServicePartialNestingMethodResult) GetResult() interface{} { - return p.Success -} - -func (p *BaselineServiceNesting2MethodArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BaselineServiceNesting2MethodResult) GetResult() interface{} { - return p.Success -} diff --git a/codegen/fieldmask/test_gen/baseline/k-consts.go b/codegen/fieldmask/test_gen/baseline/k-consts.go deleted file mode 100644 index e86733b..0000000 --- a/codegen/fieldmask/test_gen/baseline/k-consts.go +++ /dev/null @@ -1,4 +0,0 @@ -package baseline - -// KitexUnusedProtection is used to prevent 'imported and not used' error. -var KitexUnusedProtection = struct{}{} From 2a1951d1728ae40c693a4213deacaee6dcb9505b Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 4 Dec 2023 21:35:26 +0800 Subject: [PATCH 04/13] addjust run.sh --- codegen/fieldmask/run.sh | 2 +- idl/fieldmask.thrift | 17 +++++ run.sh | 23 +++++-- thriftrpc/fieldmask/handler.go | 40 ++++++++++++ thriftrpc/fieldmask/main_test.go | 105 +++++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+), 6 deletions(-) create mode 100644 idl/fieldmask.thrift create mode 100644 thriftrpc/fieldmask/handler.go create mode 100644 thriftrpc/fieldmask/main_test.go diff --git a/codegen/fieldmask/run.sh b/codegen/fieldmask/run.sh index 258a818..1442bd8 100644 --- a/codegen/fieldmask/run.sh +++ b/codegen/fieldmask/run.sh @@ -19,6 +19,6 @@ kitex -module test -thrift with_field_mask -thrift with_reflection test_fieldmas cat test_fieldmask.thrift > test_fieldmask2.thrift kitex -module test -thrift with_field_mask -thrift field_mask_halfway -thrift with_reflection -gen-path halfway_gen test_fieldmask2.thrift kitex -module test -thrift with_field_mask -thrift with_reflection baseline.thrift -go get github.com/cloudwego/thriftgo@9e8d1cafba62a37789c431270a816ad35a6c46e0 +go get github.com/cloudwego/thriftgo@8456d5c6b677978b68209c0febfc6f2b97ce7e8b go mod tidy go test ./... diff --git a/idl/fieldmask.thrift b/idl/fieldmask.thrift new file mode 100644 index 0000000..49d9b3c --- /dev/null +++ b/idl/fieldmask.thrift @@ -0,0 +1,17 @@ + +namespace go fieldmask + +struct BizRequest { + 1: string A + 2: required string B + 3: optional binary RespMask +} + +struct BizResponse { + 1: string A + 2: required string B +} + +service BizService { + BizResponse BizMethod1(1: BizRequest req) +} \ No newline at end of file diff --git a/run.sh b/run.sh index ce46ca1..919da1b 100755 --- a/run.sh +++ b/run.sh @@ -67,9 +67,6 @@ which protoc-gen-go || go_install google.golang.org/protobuf/cmd/protoc-gen-go@l # install protoc-gen-go and protoc-gen-go-kitexgrpc which protoc-gen-go-grpc || go_install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest -# Install thriftgo -which thriftgo || go_install github.com/cloudwego/thriftgo@latest - # Install kitex and generate codes LOCAL_REPO=$1 @@ -78,10 +75,22 @@ if [[ -n $LOCAL_REPO ]]; then go_install ${LOCAL_REPO}/tool/cmd/kitex cd - else - go_install github.com/cloudwego/kitex/tool/cmd/kitex@latest + which kitex || go_install github.com/cloudwego/kitex/tool/cmd/kitex@latest +fi + +# Install thriftgo +THRIFTGO_REPO=$2 + +if [[ -n $THRIFTGO_REPO ]]; then + cd ${THRIFTGO_REPO} + go_install ${THRIFTGO_REPO} + cd - +else + which thriftgo || go_install github.com/cloudwego/thriftgo@latest fi test -d kitex_gen && rm -rf kitex_gen +kitex -module kitex -module github.com/cloudwego/kitex-tests -thrift with_field_mask -thrift with_reflection ./idl/fieldmask.thrift kitex -module github.com/cloudwego/kitex-tests ./idl/stability.thrift kitex -module github.com/cloudwego/kitex-tests ./idl/http.thrift kitex -module github.com/cloudwego/kitex-tests ./idl/tenant.thrift @@ -104,7 +113,6 @@ mkdir grpc_gen protoc --go_out=grpc_gen/. ./idl/grpc_demo_2.proto protoc --go-grpc_out=grpc_gen/. ./idl/grpc_demo_2.proto - # Init dependencies go get github.com/apache/thrift@v0.13.0 go get github.com/cloudwego/kitex@develop @@ -113,6 +121,10 @@ if [[ -n $LOCAL_REPO ]]; then go mod edit -replace github.com/cloudwego/kitex=${LOCAL_REPO} fi +if [[ -n $THRIFTGO_REPO ]]; then + go mod edit -replace github.com/cloudwego/thriftgo=${THRIFTGO_REPO} +fi + go mod tidy # static check @@ -122,6 +134,7 @@ go vet -stdmethods=false $(go list ./...) # run tests packages=( +./thriftrpc/fieldmask/... ./thriftrpc/normalcall/... ./thriftrpc/muxcall/... ./thriftrpc/retrycall/... diff --git a/thriftrpc/fieldmask/handler.go b/thriftrpc/fieldmask/handler.go new file mode 100644 index 0000000..b74d899 --- /dev/null +++ b/thriftrpc/fieldmask/handler.go @@ -0,0 +1,40 @@ +package main + +import ( + "context" + "errors" + + fieldmask0 "github.com/cloudwego/kitex-tests/kitex_gen/fieldmask" + "github.com/cloudwego/thriftgo/fieldmask" +) + +// BizServiceImpl implements the last service interface defined in the IDL. +type BizServiceImpl struct{} + +// BizMethod1 implements the BizServiceImpl interface. +func (s *BizServiceImpl) BizMethod1(ctx context.Context, req *fieldmask0.BizRequest) (resp *fieldmask0.BizResponse, err error) { + // check if reques has been masked + if req.A != "" { // req.A not in mask + return nil, errors.New("request must mask BizRequest.A!") + } + if req.B == "" { + return nil, errors.New("request must not mask BizRequest.B!") + } + + resp = fieldmask0.NewBizResponse() + + // check if request carries a fieldmask + if req.RespMask != nil { + println("got fm", string(req.RespMask)) + fm, err := fieldmask.Unmarshal(req.RespMask) + if err != nil { + return nil, err + } + // set fieldmask for response + resp.Set_FieldMask(fm) + } + + resp.A = "A" + resp.B = "B" + return +} diff --git a/thriftrpc/fieldmask/main_test.go b/thriftrpc/fieldmask/main_test.go new file mode 100644 index 0000000..ab7b270 --- /dev/null +++ b/thriftrpc/fieldmask/main_test.go @@ -0,0 +1,105 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "context" + "fmt" + "net" + "sync" + "testing" + "time" + + fieldmask0 "github.com/cloudwego/kitex-tests/kitex_gen/fieldmask" + "github.com/cloudwego/kitex-tests/kitex_gen/fieldmask/bizservice" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/server" + "github.com/cloudwego/thriftgo/fieldmask" +) + +func TestMain(m *testing.M) { + addr, err := net.ResolveTCPAddr("tcp", ":8999") + if err != nil { + panic(err.Error()) + } + svr := bizservice.NewServer(new(BizServiceImpl), server.WithServiceAddr(addr)) + + go func() { + err = svr.Run() + if err != nil { + panic(err.Error()) + } + }() + + // initialize request and response fieldmasks and cache them + respMask, err := fieldmask.NewFieldMask((*fieldmask0.BizResponse)(nil).GetTypeDescriptor(), "$.A") + if err != nil { + panic(err) + } + fmCache.Store("BizResponse", respMask) + reqMask, err := fieldmask.NewFieldMask((*fieldmask0.BizRequest)(nil).GetTypeDescriptor(), "$.B", "$.RespMask") + if err != nil { + panic(err) + } + fmCache.Store("BizRequest", reqMask) + + time.Sleep(time.Second) + m.Run() + svr.Stop() +} + +var fmCache sync.Map + +func TestFieldMask(t *testing.T) { + cli, err := bizservice.NewClient("BizService", client.WithHostPorts(":8999")) + if err != nil { + t.Fatal(err) + } + + req := fieldmask0.NewBizRequest() + req.A = "A" + req.B = "B" + // try set request's fieldmask + reqMask, ok := fmCache.Load("BizRequest") + if ok { + req.Set_FieldMask(reqMask.(*fieldmask.FieldMask)) + } + + // try get reponse's fieldmask + respMask, ok := fmCache.Load("BizResponse") + if ok { + // serialize the respMask + fm, err := fieldmask.Marshal(respMask.(*fieldmask.FieldMask)) + if err != nil { + t.Fatal(err) + } + // let request carry fm + req.RespMask = fm + } + + resp, err := cli.BizMethod1(context.Background(), req) + if err != nil { + t.Fatal(err) + } + fmt.Printf("%#v\n", resp) + + if resp.A == "" { // resp.A must not in mask + t.Fatal() + } + if resp.B != "" { // resp.A must in mask + t.Fail() + } + +} From f35ea8f7014a19dedfc8e7c5e28a0a0dc9c9708c Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 4 Dec 2023 22:30:06 +0800 Subject: [PATCH 05/13] comments --- thriftrpc/fieldmask/handler.go | 2 +- thriftrpc/fieldmask/main_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/thriftrpc/fieldmask/handler.go b/thriftrpc/fieldmask/handler.go index b74d899..098d864 100644 --- a/thriftrpc/fieldmask/handler.go +++ b/thriftrpc/fieldmask/handler.go @@ -17,7 +17,7 @@ func (s *BizServiceImpl) BizMethod1(ctx context.Context, req *fieldmask0.BizRequ if req.A != "" { // req.A not in mask return nil, errors.New("request must mask BizRequest.A!") } - if req.B == "" { + if req.B == "" { // req.B in mask return nil, errors.New("request must not mask BizRequest.B!") } diff --git a/thriftrpc/fieldmask/main_test.go b/thriftrpc/fieldmask/main_test.go index ab7b270..4c63c62 100644 --- a/thriftrpc/fieldmask/main_test.go +++ b/thriftrpc/fieldmask/main_test.go @@ -95,10 +95,10 @@ func TestFieldMask(t *testing.T) { } fmt.Printf("%#v\n", resp) - if resp.A == "" { // resp.A must not in mask + if resp.A == "" { // resp.A in mask t.Fatal() } - if resp.B != "" { // resp.A must in mask + if resp.B != "" { // resp.B not in mask t.Fail() } From 113e8a2ed46bdabd036471e5c45680ac85e8b0d2 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Wed, 6 Dec 2023 11:35:46 +0800 Subject: [PATCH 06/13] test requred --- codegen/fieldmask/main_test.go | 1 + codegen/fieldmask/test_fieldmask.thrift | 2 +- codegen/fieldmask/test_fieldmask2.thrift | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/codegen/fieldmask/main_test.go b/codegen/fieldmask/main_test.go index a71d505..29805f9 100644 --- a/codegen/fieldmask/main_test.go +++ b/codegen/fieldmask/main_test.go @@ -229,6 +229,7 @@ func TestMaskRequired(t *testing.T) { obj := nbase.NewBaseResp() obj.F1 = map[nbase.Str]nbase.Str{"a": "b"} obj.F8 = map[float64][]nbase.Str{1.0: []nbase.Str{"a"}} + obj.R12 = nbase.NewTrafficEnv() obj.Set_FieldMask(fm) buf := make([]byte, obj.BLength()) if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { diff --git a/codegen/fieldmask/test_fieldmask.thrift b/codegen/fieldmask/test_fieldmask.thrift index 5caf7b9..dda5ad6 100644 --- a/codegen/fieldmask/test_fieldmask.thrift +++ b/codegen/fieldmask/test_fieldmask.thrift @@ -20,7 +20,7 @@ struct TrafficEnv { 0: string Name = "", 1: bool Open = false, 2: string Env = "", - 256: i64 Code, + 256: required i64 Code, } struct Base { diff --git a/codegen/fieldmask/test_fieldmask2.thrift b/codegen/fieldmask/test_fieldmask2.thrift index 5caf7b9..dda5ad6 100644 --- a/codegen/fieldmask/test_fieldmask2.thrift +++ b/codegen/fieldmask/test_fieldmask2.thrift @@ -20,7 +20,7 @@ struct TrafficEnv { 0: string Name = "", 1: bool Open = false, 2: string Env = "", - 256: i64 Code, + 256: required i64 Code, } struct Base { From 3fae52a62c2d02362763f31a109928ef083233f7 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Wed, 6 Dec 2023 11:44:01 +0800 Subject: [PATCH 07/13] update rpc test case --- idl/fieldmask.thrift | 1 + thriftrpc/fieldmask/handler.go | 1 + thriftrpc/fieldmask/main_test.go | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/idl/fieldmask.thrift b/idl/fieldmask.thrift index 49d9b3c..0df0a94 100644 --- a/idl/fieldmask.thrift +++ b/idl/fieldmask.thrift @@ -10,6 +10,7 @@ struct BizRequest { struct BizResponse { 1: string A 2: required string B + 3: string C } service BizService { diff --git a/thriftrpc/fieldmask/handler.go b/thriftrpc/fieldmask/handler.go index 098d864..7fe3e5a 100644 --- a/thriftrpc/fieldmask/handler.go +++ b/thriftrpc/fieldmask/handler.go @@ -36,5 +36,6 @@ func (s *BizServiceImpl) BizMethod1(ctx context.Context, req *fieldmask0.BizRequ resp.A = "A" resp.B = "B" + resp.C = "C" return } diff --git a/thriftrpc/fieldmask/main_test.go b/thriftrpc/fieldmask/main_test.go index 4c63c62..1466372 100644 --- a/thriftrpc/fieldmask/main_test.go +++ b/thriftrpc/fieldmask/main_test.go @@ -98,8 +98,10 @@ func TestFieldMask(t *testing.T) { if resp.A == "" { // resp.A in mask t.Fatal() } - if resp.B != "" { // resp.B not in mask + if resp.B == "" { // resp.B not in mask, but it's required, so still written + t.Fail() + } + if resp.C != "" { // resp.C not in mask t.Fail() } - } From 79776bae71b25d7cee6db4950860aa5289076a7c Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Wed, 6 Dec 2023 19:59:15 +0800 Subject: [PATCH 08/13] test option `fieldmask_write_zero` --- .gitignore | 5 +- codegen/fieldmask/main_test.go | 115 ++++++++++++++++++----- codegen/fieldmask/run.sh | 5 +- codegen/fieldmask/test_fieldmask3.thrift | 104 ++++++++++++++++++++ 4 files changed, 201 insertions(+), 28 deletions(-) create mode 100644 codegen/fieldmask/test_fieldmask3.thrift diff --git a/.gitignore b/.gitignore index a306b3a..361acd7 100644 --- a/.gitignore +++ b/.gitignore @@ -43,11 +43,8 @@ output/* testdata/ # Files produced by run.sh -kitex_gen/ kitex_gen_slim/ -old_gen/ -halfway_gen/ -grpc_gen/ +*_gen/ go.mod go.sum bin diff --git a/codegen/fieldmask/main_test.go b/codegen/fieldmask/main_test.go index 29805f9..e02cab1 100644 --- a/codegen/fieldmask/main_test.go +++ b/codegen/fieldmask/main_test.go @@ -15,11 +15,11 @@ package test import ( - "fmt" "runtime" hbase "test/halfway_gen/base" nbase "test/kitex_gen/base" obase "test/old_gen/base" + zbase "test/zero_gen/base" "testing" "github.com/cloudwego/thriftgo/fieldmask" @@ -194,7 +194,7 @@ func TestFastRead(t *testing.T) { } func TestMaskRequired(t *testing.T) { - fm, err := fieldmask.NewFieldMask(nbase.NewBaseResp().GetTypeDescriptor(), "$.F1", "$.F8") + fm, err := fieldmask.NewFieldMask(nbase.NewBaseResp().GetTypeDescriptor(), "$.F1", "$.F8", "$.R12.Env") if err != nil { t.Fatal(err) } @@ -212,6 +212,9 @@ func TestMaskRequired(t *testing.T) { obj := nbase.NewBaseResp() obj.F1 = map[nbase.Str]nbase.Str{"a": "b"} obj.F8 = map[float64][]nbase.Str{1.0: []nbase.Str{"a"}} + obj.R12 = nbase.NewTrafficEnv() + obj.R12.Name = "a" + obj.R12.Env = "a" buf := make([]byte, obj.BLength()) if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { t.Fatal(err) @@ -223,13 +226,30 @@ func TestMaskRequired(t *testing.T) { } require.Equal(t, obj.F1, obj2.F1) require.Equal(t, obj.F8, obj2.F8) + require.Equal(t, "", obj2.R12.Name) + require.Equal(t, obj.R12.Env, obj2.R12.Env) }) - t.Run("write", func(t *testing.T) { + t.Run("write current", func(t *testing.T) { obj := nbase.NewBaseResp() + obj.StatusCode = 1 + obj.R3 = true + obj.R4 = 1 + obj.R5 = 1 + obj.R6 = 1 + obj.R7 = 1 + obj.R8 = "R8" + obj.R9 = nbase.Ex_B + v := nbase.NewVal() + v.Id = "a" + obj.R10 = []*nbase.Val{v} + obj.R11 = []*nbase.Val{v} + obj.R12 = nbase.NewTrafficEnv() + obj.R12.Name = "a" + obj.R12.Env = "a" + obj.R13 = map[string]*nbase.Key{"a": v} obj.F1 = map[nbase.Str]nbase.Str{"a": "b"} obj.F8 = map[float64][]nbase.Str{1.0: []nbase.Str{"a"}} - obj.R12 = nbase.NewTrafficEnv() obj.Set_FieldMask(fm) buf := make([]byte, obj.BLength()) if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { @@ -239,7 +259,74 @@ func TestMaskRequired(t *testing.T) { if _, err := obj2.FastRead(buf); err != nil { t.Fatal(err) } - fmt.Printf("%#v\n", obj2) + + require.Equal(t, obj.F1, obj2.F1) + require.Equal(t, obj.F8, obj2.F8) + require.Equal(t, obj.StatusCode, obj2.StatusCode) + require.Equal(t, obj.R3, obj2.R3) + require.Equal(t, obj.R4, obj2.R4) + require.Equal(t, obj.R5, obj2.R5) + require.Equal(t, obj.R6, obj2.R6) + require.Equal(t, obj.R7, obj2.R7) + require.Equal(t, obj.R8, obj2.R8) + require.Equal(t, obj.R9, obj2.R9) + require.Equal(t, obj.R10, obj2.R10) + require.Equal(t, obj.R11, obj2.R11) + require.Equal(t, "", obj2.R12.Name) + require.Equal(t, obj.R12.Env, obj2.R12.Env) + require.Equal(t, obj.R13, obj2.R13) + }) + + t.Run("write zero", func(t *testing.T) { + fm, err := fieldmask.NewFieldMask(nbase.NewBaseResp().GetTypeDescriptor(), "$.F1", "$.F8", "$.R12") + if err != nil { + t.Fatal(err) + } + obj := zbase.NewBaseResp() + obj.F1 = map[zbase.Str]zbase.Str{"a": "b"} + obj.F8 = map[float64][]zbase.Str{1.0: []zbase.Str{"a"}} + obj.StatusCode = 1 + obj.R3 = true + obj.R4 = 1 + obj.R5 = 1 + obj.R6 = 1 + obj.R7 = 1 + obj.R8 = "R8" + obj.R9 = zbase.Ex_B + v := zbase.NewVal() + v.Id = "a" + obj.R10 = []*zbase.Val{v} + obj.R11 = []*zbase.Val{v} + obj.R12 = zbase.NewTrafficEnv() + obj.R12.Name = "a" + obj.R12.Env = "a" + obj.R13 = map[string]*zbase.Key{"a": v} + + obj.Set_FieldMask(fm) + buf := make([]byte, obj.BLength()) + if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { + t.Fatal(err) + } + obj2 := zbase.NewBaseResp() + if _, err := obj2.FastRead(buf); err != nil { + t.Fatal(err) + } + + require.Equal(t, obj.F1, obj2.F1) + require.Equal(t, obj.F8, obj2.F8) + require.Equal(t, int32(0), obj2.StatusCode) + require.Equal(t, false, obj2.R3) + require.Equal(t, int8(0), obj2.R4) + require.Equal(t, int16(0), obj2.R5) + require.Equal(t, int64(0), obj2.R6) + require.Equal(t, float64(0), obj2.R7) + require.Equal(t, "", obj2.R8) + require.Equal(t, zbase.Ex(0), obj2.R9) + require.Equal(t, []*zbase.Val{}, obj2.R10) + require.Equal(t, []*zbase.Val{}, obj2.R11) + obj.R12.Set_FieldMask(nil) + require.Equal(t, obj.R12, obj2.R12) + require.Equal(t, map[string]*zbase.Key{}, obj2.R13) }) } @@ -249,7 +336,7 @@ func TestSetMaskHalfway(t *testing.T) { obj.Extra.F1 = map[string]string{"a": "b"} obj.Extra.F8 = map[int64][]*hbase.Key{1: []*hbase.Key{hbase.NewKey()}} - fm, err := fieldmask.NewFieldMask(obj.Extra.GetTypeDescriptor(), "$.F1") + fm, err := fieldmask.NewFieldMask(obj.Extra.GetTypeDescriptor(), "$.F1", "$.F8") if err != nil { t.Fatal(err) } @@ -263,22 +350,6 @@ func TestSetMaskHalfway(t *testing.T) { t.Fatal(err) } require.Equal(t, obj.Extra.F1, obj2.Extra.F1) - require.Equal(t, map[int64][]*hbase.Key(nil), obj2.Extra.F8) - - fm, err = fieldmask.NewFieldMask(obj.Extra.GetTypeDescriptor(), "$.F8") - if err != nil { - t.Fatal(err) - } - obj.Extra.Set_FieldMask(fm) - buf = make([]byte, obj.BLength()) - if err := obj.FastWriteNocopy(buf, nil); err != len(buf) { - t.Fatal(err) - } - obj2 = hbase.NewBase() - if _, err := obj2.FastRead(buf); err != nil { - t.Fatal(err) - } - require.Equal(t, map[string]string(nil), obj2.Extra.F1) require.Equal(t, obj.Extra.F8, obj2.Extra.F8) } diff --git a/codegen/fieldmask/run.sh b/codegen/fieldmask/run.sh index 1442bd8..be03718 100644 --- a/codegen/fieldmask/run.sh +++ b/codegen/fieldmask/run.sh @@ -17,8 +17,9 @@ kitex -module test -gen-path old_gen test_fieldmask.thrift kitex -module test -thrift with_field_mask -thrift with_reflection test_fieldmask.thrift cat test_fieldmask.thrift > test_fieldmask2.thrift -kitex -module test -thrift with_field_mask -thrift field_mask_halfway -thrift with_reflection -gen-path halfway_gen test_fieldmask2.thrift +cat test_fieldmask.thrift > test_fieldmask3.thrift +kitex -module test -thrift with_field_mask -thrift field_mask_zero_required -thrift with_reflection -gen-path zero_gen test_fieldmask2.thrift +kitex -module test -thrift with_field_mask -thrift field_mask_halfway -thrift with_reflection -gen-path halfway_gen test_fieldmask3.thrift kitex -module test -thrift with_field_mask -thrift with_reflection baseline.thrift -go get github.com/cloudwego/thriftgo@8456d5c6b677978b68209c0febfc6f2b97ce7e8b go mod tidy go test ./... diff --git a/codegen/fieldmask/test_fieldmask3.thrift b/codegen/fieldmask/test_fieldmask3.thrift new file mode 100644 index 0000000..dda5ad6 --- /dev/null +++ b/codegen/fieldmask/test_fieldmask3.thrift @@ -0,0 +1,104 @@ +#! /bin/bash -e + +# Copyright 2022 CloudWeGo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +namespace go base + +struct TrafficEnv { + 0: string Name = "", + 1: bool Open = false, + 2: string Env = "", + 256: required i64 Code, +} + +struct Base { + 0: required string Addr = "", + 1: string LogID = "", + 2: string Caller = "", + 5: optional TrafficEnv TrafficEnv, + 255: optional ExtraInfo Extra, + 256: MetaInfo Meta, +} + +struct ExtraInfo { + 1: map F1 + 2: map F2, + 3: list F3 + 4: set F4, + 5: map F5 + 6: map F6 + 7: map> F7 + 8: map> F8 + 9: map>> F9 + 10: map F10 +} + +struct MetaInfo { + 1: map IntMap, + 2: map StrMap, + 3: list List, + 4: set Set, + 11: map> MapList + 12: list>> ListMapList + 255: Base Base, +} + +typedef Val Key + +struct Val { + 1: string id + 2: string name +} + +typedef double Float + +typedef i64 Int + +typedef string Str + +enum Ex { + A = 1, + B = 2, + C = 3 +} + +struct BaseResp { + 1: optional string StatusMessage = "", + 2: required i32 StatusCode = 0, + 3: required bool R3, + 4: required byte R4, + 5: required i16 R5, + 6: required i64 R6, + 7: required double R7, + 8: required string R8, + 9: required Ex R9, + 10: required list R10, + 11: required set R11, + 12: required TrafficEnv R12, + 13: required map R13, + 0: required Key R0, + + 14: map F1 + 15: map F2, + 16: list F3 + 17: set F4, + 18: map F5 + 19: map F6 + 110: map F7 + 111: map> F8 + 112: list>> F9 + 113: map F10 +} + From 5ff08b7d258ac519cc8e1611918a7468efce524f Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 15 Apr 2024 13:20:31 +0800 Subject: [PATCH 09/13] feat: (fieldmask) add black-list mode test --- thriftrpc/fieldmask/handler.go | 10 +++--- thriftrpc/fieldmask/main_test.go | 60 ++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/thriftrpc/fieldmask/handler.go b/thriftrpc/fieldmask/handler.go index 7fe3e5a..8b83a7c 100644 --- a/thriftrpc/fieldmask/handler.go +++ b/thriftrpc/fieldmask/handler.go @@ -14,18 +14,18 @@ type BizServiceImpl struct{} // BizMethod1 implements the BizServiceImpl interface. func (s *BizServiceImpl) BizMethod1(ctx context.Context, req *fieldmask0.BizRequest) (resp *fieldmask0.BizResponse, err error) { // check if reques has been masked - if req.A != "" { // req.A not in mask - return nil, errors.New("request must mask BizRequest.A!") + if req.A != "" { // req.A must be filtered + return nil, errors.New("request must filter BizRequest.A!") } - if req.B == "" { // req.B in mask - return nil, errors.New("request must not mask BizRequest.B!") + if req.B == "" { // req.B must not be filtered + return nil, errors.New("request must not filter BizRequest.B!") } resp = fieldmask0.NewBizResponse() // check if request carries a fieldmask if req.RespMask != nil { - println("got fm", string(req.RespMask)) + println("got fieldmask", string(req.RespMask)) fm, err := fieldmask.Unmarshal(req.RespMask) if err != nil { return nil, err diff --git a/thriftrpc/fieldmask/main_test.go b/thriftrpc/fieldmask/main_test.go index 1466372..e590f31 100644 --- a/thriftrpc/fieldmask/main_test.go +++ b/thriftrpc/fieldmask/main_test.go @@ -55,6 +55,18 @@ func TestMain(m *testing.M) { } fmCache.Store("BizRequest", reqMask) + // black list mod + respMaskBlack, err := fieldmask.Options{BlackListMode: true}.NewFieldMask((*fieldmask0.BizResponse)(nil).GetTypeDescriptor(), "$.A", "$.B") + if err != nil { + panic(err) + } + fmCache.Store("BizResponse-Black", respMaskBlack) + reqMaskBlack, err := fieldmask.Options{BlackListMode: true}.NewFieldMask((*fieldmask0.BizRequest)(nil).GetTypeDescriptor(), "$.A") + if err != nil { + panic(err) + } + fmCache.Store("BizRequest-Black", reqMaskBlack) + time.Sleep(time.Second) m.Run() svr.Stop() @@ -71,7 +83,7 @@ func TestFieldMask(t *testing.T) { req := fieldmask0.NewBizRequest() req.A = "A" req.B = "B" - // try set request's fieldmask + // try load request's fieldmask reqMask, ok := fmCache.Load("BizRequest") if ok { req.Set_FieldMask(reqMask.(*fieldmask.FieldMask)) @@ -96,7 +108,7 @@ func TestFieldMask(t *testing.T) { fmt.Printf("%#v\n", resp) if resp.A == "" { // resp.A in mask - t.Fatal() + t.Fail() } if resp.B == "" { // resp.B not in mask, but it's required, so still written t.Fail() @@ -105,3 +117,47 @@ func TestFieldMask(t *testing.T) { t.Fail() } } + +func TestFieldMask_BlackList(t *testing.T) { + cli, err := bizservice.NewClient("BizService", client.WithHostPorts(":8999")) + if err != nil { + t.Fatal(err) + } + + req := fieldmask0.NewBizRequest() + req.A = "A" + req.B = "B" + // try load request's fieldmask + reqMask, ok := fmCache.Load("BizRequest-Black") + if ok { + req.Set_FieldMask(reqMask.(*fieldmask.FieldMask)) + } + + // try get reponse's fieldmask + respMask, ok := fmCache.Load("BizResponse-Black") + if ok { + // serialize the respMask + fm, err := fieldmask.Marshal(respMask.(*fieldmask.FieldMask)) + if err != nil { + t.Fatal(err) + } + // let request carry fm + req.RespMask = fm + } + + resp, err := cli.BizMethod1(context.Background(), req) + if err != nil { + t.Fatal(err) + } + fmt.Printf("%#v\n", resp) + + if resp.A != "" { // resp.A in mask + t.Fail() + } + if resp.B == "" { // resp.B not in mask, but it's required, so still written + t.Fail() + } + if resp.C == "" { // resp.C not in mask + t.Fail() + } +} From 63f79c2c2a26bc6e46859a02b046b9a8ca3429f7 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 6 May 2024 15:32:36 +0800 Subject: [PATCH 10/13] add black-list tests --- codegen/fieldmask/main_test.go | 187 +++++++++++++++++------ codegen/fieldmask/test_fieldmask.thrift | 2 + codegen/fieldmask/test_fieldmask2.thrift | 2 + codegen/fieldmask/test_fieldmask3.thrift | 2 + 4 files changed, 147 insertions(+), 46 deletions(-) diff --git a/codegen/fieldmask/main_test.go b/codegen/fieldmask/main_test.go index e02cab1..85ca264 100644 --- a/codegen/fieldmask/main_test.go +++ b/codegen/fieldmask/main_test.go @@ -16,6 +16,7 @@ package test import ( "runtime" + "sync" hbase "test/halfway_gen/base" nbase "test/kitex_gen/base" obase "test/old_gen/base" @@ -26,11 +27,42 @@ import ( "github.com/stretchr/testify/require" ) +var fieldmaskCache sync.Map + +func init() { + // new a obj to get its TypeDescriptor + obj := nbase.NewBase() + + // construct a fieldmask with TypeDescriptor and thrift pathes + fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), + "$.Enum", "$.EnumMap{1}", "$.LogID", "$.TrafficEnv.Name", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", + "$.Meta.List[1]", "$.Meta.Set[0].id", "$.Meta.Set[1].name") + if err != nil { + panic(err) + } + + // cache it for future usage of nbase.Base + fieldmaskCache.Store("Mask1ForBase", fm) + + fm2, err := fieldmask.Options{BlackListMode: true}.NewFieldMask(obj.GetTypeDescriptor(), + "$.Enum", "$.EnumMap{1}", "$.LogID", "$.TrafficEnv.Name", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", + "$.Meta.List[1]", "$.Meta.Set[0].id", "$.Meta.Set[1].name") + if err != nil { + panic(err) + } + fieldmaskCache.Store("Mask1ForBase-Black", fm2) +} + func SampleNewBase() *nbase.Base { obj := nbase.NewBase() obj.Addr = "abcd" obj.Caller = "abcd" obj.LogID = "abcd" + obj.Enum = nbase.Ex_A + obj.EnumMap = map[nbase.Ex]string{ + nbase.Ex_A: "a", + nbase.Ex_B: "b", + } obj.Meta = nbase.NewMetaInfo() obj.Meta.StrMap = map[string]*nbase.Val{ "abcd": nbase.NewVal(), @@ -96,21 +128,14 @@ func SampleOldBase() *obase.Base { return obj } -func TestFastWrite(t *testing.T) { +func TestFastWrite_WhiteList(t *testing.T) { var obj = SampleNewBase() - fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Addr", - "$.LogID", - "$.TrafficEnv.Code", - "$.Meta.IntMap{1}.id", - "$.Meta.IntMap{2}.name", - "$.Meta.StrMap{\"1234\"}", - "$.Meta.List[1]", - "$.Meta.Set[0].id", - "$.Meta.Set[1].name") - if err != nil { - t.Fatal(err) + // Load fieldmask from cache + fm, _ := fieldmaskCache.Load("Mask1ForBase") + if fm != nil { + // load ok, set fieldmask onto the object using codegen API + obj.Set_FieldMask(fm.(*fieldmask.FieldMask)) } - obj.Set_FieldMask(fm) out := make([]byte, obj.BLength()) // out := make([]byte, 24000000) e := obj.FastWriteNocopy(out, nil) @@ -120,77 +145,147 @@ func TestFastWrite(t *testing.T) { t.Fatal(err) } require.Equal(t, e, n) + require.Equal(t, obj.Addr, obj2.Addr) + require.Equal(t, obj.Enum, obj2.Enum) + require.Equal(t, map[nbase.Ex]string{nbase.Ex_A: "a"}, obj2.EnumMap) require.Equal(t, obj.LogID, obj2.LogID) require.Equal(t, "", obj2.Caller) - require.Equal(t, "", obj2.TrafficEnv.Name) + require.Equal(t, obj.TrafficEnv.Name, obj2.TrafficEnv.Name) require.Equal(t, false, obj2.TrafficEnv.Open) require.Equal(t, "", obj2.TrafficEnv.Env) require.Equal(t, obj.TrafficEnv.Code, obj2.TrafficEnv.Code) - require.Equal(t, 2, len(obj2.Meta.IntMap)) require.Equal(t, obj.Meta.IntMap[1].Id, obj2.Meta.IntMap[1].Id) - require.Equal(t, "", obj2.Meta.IntMap[1].Name) - require.Equal(t, "", obj2.Meta.IntMap[2].Id) - require.Equal(t, obj.Meta.IntMap[2].Name, obj2.Meta.IntMap[2].Name) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.IntMap[0]) require.Equal(t, obj.Meta.StrMap["1234"].Id, obj2.Meta.StrMap["1234"].Id) require.Equal(t, (*nbase.Val)(nil), obj2.Meta.StrMap["abcd"]) require.Equal(t, 1, len(obj2.Meta.List)) - require.Equal(t, obj.Meta.List[1].Id, obj2.Meta.List[0].Id) - require.Equal(t, obj.Meta.List[1].Name, obj2.Meta.List[0].Name) + require.Equal(t, "b", obj2.Meta.List[0].Id) + require.Equal(t, "b", obj2.Meta.List[0].Name) require.Equal(t, 2, len(obj2.Meta.Set)) - require.Equal(t, obj.Meta.Set[0].Id, obj2.Meta.Set[0].Id) + require.Equal(t, "a", obj2.Meta.Set[0].Id) require.Equal(t, "", obj2.Meta.Set[0].Name) require.Equal(t, "", obj2.Meta.Set[1].Id) - require.Equal(t, obj.Meta.Set[1].Name, obj2.Meta.Set[1].Name) + require.Equal(t, "b", obj2.Meta.Set[1].Name) +} + +func TestFastWrite_BlackList(t *testing.T) { + var obj = SampleNewBase() + // Load fieldmask from cache + fm, _ := fieldmaskCache.Load("Mask1ForBase-Black") + if fm != nil { + // load ok, set fieldmask onto the object using codegen API + obj.Set_FieldMask(fm.(*fieldmask.FieldMask)) + } + out := make([]byte, obj.BLength()) + // out := make([]byte, 24000000) + e := obj.FastWriteNocopy(out, nil) + var obj2 = nbase.NewBase() + n, err := obj2.FastRead(out) + if err != nil { + t.Fatal(err) + } + require.Equal(t, e, n) + + require.Equal(t, obj.Addr, obj2.Addr) + require.Equal(t, nbase.Ex(0), obj2.Enum) + require.Equal(t, map[nbase.Ex]string{nbase.Ex_B: "b"}, obj2.EnumMap) + require.Equal(t, "", obj2.LogID) + require.Equal(t, obj.Caller, obj2.Caller) + require.Equal(t, "", obj2.TrafficEnv.Name) + require.Equal(t, obj.TrafficEnv.Open, obj2.TrafficEnv.Open) + require.Equal(t, obj.TrafficEnv.Env, obj2.TrafficEnv.Env) + require.Equal(t, obj.TrafficEnv.Code, obj2.TrafficEnv.Code) // required + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.IntMap[1]) + require.Equal(t, obj.Meta.IntMap[0], obj2.Meta.IntMap[0]) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.StrMap["1234"]) + require.Equal(t, obj.Meta.StrMap["abcd"], obj2.Meta.StrMap["abcd"]) + require.Equal(t, 1, len(obj2.Meta.List)) + require.Equal(t, "a", obj2.Meta.List[0].Id) + require.Equal(t, "a", obj2.Meta.List[0].Name) + require.Equal(t, 2, len(obj2.Meta.Set)) + require.Equal(t, "", obj2.Meta.Set[0].Id) + require.Equal(t, "a", obj2.Meta.Set[0].Name) + require.Equal(t, "b", obj2.Meta.Set[1].Id) + require.Equal(t, "", obj2.Meta.Set[1].Name) } -func TestFastRead(t *testing.T) { +func TestFastRead_WhiteList(t *testing.T) { obj := SampleNewBase() buf := make([]byte, obj.BLength()) e := obj.FastWriteNocopy(buf, nil) obj2 := nbase.NewBase() - fm, err := fieldmask.NewFieldMask(obj2.GetTypeDescriptor(), "$.Addr", - "$.LogID", - "$.TrafficEnv.Code", - "$.Meta.IntMap{1}.id", - "$.Meta.IntMap{2}.name", - "$.Meta.StrMap{\"1234\"}", - "$.Meta.List[1]", - "$.Meta.Set[0].id", - "$.Meta.Set[1].name") - if err != nil { - t.Fatal(err) + fm, _ := fieldmaskCache.Load("Mask1ForBase") + if fm != nil { + obj2.Set_FieldMask(fm.(*fieldmask.FieldMask)) } - obj2.Set_FieldMask(fm) + n, err := obj2.FastRead(buf) if err != nil { t.Fatal(err) } require.Equal(t, e, n) - require.Equal(t, e, n) - require.Equal(t, obj.Addr, obj2.Addr) + require.Equal(t, "", obj2.Addr) + require.Equal(t, obj.Enum, obj2.Enum) + require.Equal(t, map[nbase.Ex]string{nbase.Ex_A: "a"}, obj2.EnumMap) require.Equal(t, obj.LogID, obj2.LogID) require.Equal(t, "", obj2.Caller) - require.Equal(t, "", obj2.TrafficEnv.Name) + require.Equal(t, obj.TrafficEnv.Name, obj2.TrafficEnv.Name) require.Equal(t, false, obj2.TrafficEnv.Open) require.Equal(t, "", obj2.TrafficEnv.Env) require.Equal(t, obj.TrafficEnv.Code, obj2.TrafficEnv.Code) - require.Equal(t, 2, len(obj2.Meta.IntMap)) require.Equal(t, obj.Meta.IntMap[1].Id, obj2.Meta.IntMap[1].Id) - require.Equal(t, "", obj2.Meta.IntMap[1].Name) - require.Equal(t, "", obj2.Meta.IntMap[2].Id) - require.Equal(t, obj.Meta.IntMap[2].Name, obj2.Meta.IntMap[2].Name) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.IntMap[0]) require.Equal(t, obj.Meta.StrMap["1234"].Id, obj2.Meta.StrMap["1234"].Id) require.Equal(t, (*nbase.Val)(nil), obj2.Meta.StrMap["abcd"]) - require.Equal(t, obj.Meta.List[1].Id, obj2.Meta.List[0].Id) - require.Equal(t, obj.Meta.List[1].Name, obj2.Meta.List[0].Name) require.Equal(t, 1, len(obj2.Meta.List)) + require.Equal(t, "b", obj2.Meta.List[0].Id) + require.Equal(t, "b", obj2.Meta.List[0].Name) require.Equal(t, 2, len(obj2.Meta.Set)) - require.Equal(t, obj.Meta.Set[0].Id, obj2.Meta.Set[0].Id) + require.Equal(t, "a", obj2.Meta.Set[0].Id) require.Equal(t, "", obj2.Meta.Set[0].Name) require.Equal(t, "", obj2.Meta.Set[1].Id) - require.Equal(t, obj.Meta.Set[1].Name, obj2.Meta.Set[1].Name) + require.Equal(t, "b", obj2.Meta.Set[1].Name) +} + +func TestFastRead_BlackList(t *testing.T) { + obj := SampleNewBase() + buf := make([]byte, obj.BLength()) + e := obj.FastWriteNocopy(buf, nil) + obj2 := nbase.NewBase() + fm, _ := fieldmaskCache.Load("Mask1ForBase-Black") + if fm != nil { + obj2.Set_FieldMask(fm.(*fieldmask.FieldMask)) + } + + n, err := obj2.FastRead(buf) + if err != nil { + t.Fatal(err) + } + require.Equal(t, e, n) + + require.Equal(t, obj.Addr, obj2.Addr) + require.Equal(t, nbase.Ex(0), obj2.Enum) + require.Equal(t, map[nbase.Ex]string{nbase.Ex_B: "b"}, obj2.EnumMap) + require.Equal(t, "", obj2.LogID) + require.Equal(t, obj.Caller, obj2.Caller) + require.Equal(t, "", obj2.TrafficEnv.Name) + require.Equal(t, obj.TrafficEnv.Open, obj2.TrafficEnv.Open) + require.Equal(t, obj.TrafficEnv.Env, obj2.TrafficEnv.Env) + require.Equal(t, int64(0), obj2.TrafficEnv.Code) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.IntMap[1]) + require.Equal(t, obj.Meta.IntMap[0], obj2.Meta.IntMap[0]) + require.Equal(t, (*nbase.Val)(nil), obj2.Meta.StrMap["1234"]) + require.Equal(t, obj.Meta.StrMap["abcd"], obj2.Meta.StrMap["abcd"]) + require.Equal(t, 1, len(obj2.Meta.List)) + require.Equal(t, "a", obj2.Meta.List[0].Id) + require.Equal(t, "a", obj2.Meta.List[0].Name) + require.Equal(t, 2, len(obj2.Meta.Set)) + require.Equal(t, "", obj2.Meta.Set[0].Id) + require.Equal(t, "a", obj2.Meta.Set[0].Name) + require.Equal(t, "b", obj2.Meta.Set[1].Id) + require.Equal(t, "", obj2.Meta.Set[1].Name) } func TestMaskRequired(t *testing.T) { diff --git a/codegen/fieldmask/test_fieldmask.thrift b/codegen/fieldmask/test_fieldmask.thrift index dda5ad6..b085e00 100644 --- a/codegen/fieldmask/test_fieldmask.thrift +++ b/codegen/fieldmask/test_fieldmask.thrift @@ -28,6 +28,8 @@ struct Base { 1: string LogID = "", 2: string Caller = "", 5: optional TrafficEnv TrafficEnv, + 9: Ex Enum, + 10: map EnumMap, 255: optional ExtraInfo Extra, 256: MetaInfo Meta, } diff --git a/codegen/fieldmask/test_fieldmask2.thrift b/codegen/fieldmask/test_fieldmask2.thrift index dda5ad6..b085e00 100644 --- a/codegen/fieldmask/test_fieldmask2.thrift +++ b/codegen/fieldmask/test_fieldmask2.thrift @@ -28,6 +28,8 @@ struct Base { 1: string LogID = "", 2: string Caller = "", 5: optional TrafficEnv TrafficEnv, + 9: Ex Enum, + 10: map EnumMap, 255: optional ExtraInfo Extra, 256: MetaInfo Meta, } diff --git a/codegen/fieldmask/test_fieldmask3.thrift b/codegen/fieldmask/test_fieldmask3.thrift index dda5ad6..b085e00 100644 --- a/codegen/fieldmask/test_fieldmask3.thrift +++ b/codegen/fieldmask/test_fieldmask3.thrift @@ -28,6 +28,8 @@ struct Base { 1: string LogID = "", 2: string Caller = "", 5: optional TrafficEnv TrafficEnv, + 9: Ex Enum, + 10: map EnumMap, 255: optional ExtraInfo Extra, 256: MetaInfo Meta, } From 927279280bd127e3f2597e05645ec44cd66874f4 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 6 May 2024 15:41:55 +0800 Subject: [PATCH 11/13] add license --- thriftrpc/fieldmask/handler.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/thriftrpc/fieldmask/handler.go b/thriftrpc/fieldmask/handler.go index 8b83a7c..7ff8ba5 100644 --- a/thriftrpc/fieldmask/handler.go +++ b/thriftrpc/fieldmask/handler.go @@ -1,3 +1,17 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package main import ( From 05768d85abc1b587afa6272a9715b102195a2733 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 6 May 2024 15:44:13 +0800 Subject: [PATCH 12/13] add --- codegen/fieldmask/baseline.thrift | 14 ++++++++++++++ idl/fieldmask.thrift | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/codegen/fieldmask/baseline.thrift b/codegen/fieldmask/baseline.thrift index 7a54d06..7a33de0 100644 --- a/codegen/fieldmask/baseline.thrift +++ b/codegen/fieldmask/baseline.thrift @@ -1,3 +1,17 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + namespace go baseline struct Simple { diff --git a/idl/fieldmask.thrift b/idl/fieldmask.thrift index 0df0a94..2bcf48c 100644 --- a/idl/fieldmask.thrift +++ b/idl/fieldmask.thrift @@ -1,3 +1,16 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. namespace go fieldmask From 407c1a2206bf255adf31bfe6409d056297a52bd6 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Mon, 6 May 2024 15:54:58 +0800 Subject: [PATCH 13/13] update --- codegen/fieldmask/main_test.go | 2 +- thriftrpc/fieldmask/handler.go | 4 ++-- thriftrpc/fieldmask/main_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codegen/fieldmask/main_test.go b/codegen/fieldmask/main_test.go index 85ca264..4648d1f 100644 --- a/codegen/fieldmask/main_test.go +++ b/codegen/fieldmask/main_test.go @@ -33,7 +33,7 @@ func init() { // new a obj to get its TypeDescriptor obj := nbase.NewBase() - // construct a fieldmask with TypeDescriptor and thrift pathes + // construct a fieldmask with TypeDescriptor and thrift paths fm, err := fieldmask.NewFieldMask(obj.GetTypeDescriptor(), "$.Enum", "$.EnumMap{1}", "$.LogID", "$.TrafficEnv.Name", "$.TrafficEnv.Code", "$.Meta.IntMap{1}", "$.Meta.StrMap{\"1234\"}", "$.Meta.List[1]", "$.Meta.Set[0].id", "$.Meta.Set[1].name") diff --git a/thriftrpc/fieldmask/handler.go b/thriftrpc/fieldmask/handler.go index 7ff8ba5..62c3c79 100644 --- a/thriftrpc/fieldmask/handler.go +++ b/thriftrpc/fieldmask/handler.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package fieldmask import ( "context" @@ -27,7 +27,7 @@ type BizServiceImpl struct{} // BizMethod1 implements the BizServiceImpl interface. func (s *BizServiceImpl) BizMethod1(ctx context.Context, req *fieldmask0.BizRequest) (resp *fieldmask0.BizResponse, err error) { - // check if reques has been masked + // check if request has been masked if req.A != "" { // req.A must be filtered return nil, errors.New("request must filter BizRequest.A!") } diff --git a/thriftrpc/fieldmask/main_test.go b/thriftrpc/fieldmask/main_test.go index e590f31..4eadd2a 100644 --- a/thriftrpc/fieldmask/main_test.go +++ b/thriftrpc/fieldmask/main_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package fieldmask import ( "context" @@ -89,7 +89,7 @@ func TestFieldMask(t *testing.T) { req.Set_FieldMask(reqMask.(*fieldmask.FieldMask)) } - // try get reponse's fieldmask + // try get response's fieldmask respMask, ok := fmCache.Load("BizResponse") if ok { // serialize the respMask