diff --git a/go.mod b/go.mod index 990c6850a..3fb5ee120 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/charmbracelet/bubbletea v1.3.4 github.com/dchest/siphash v1.2.3 github.com/dgryski/go-maglev v0.0.0-20200611225407-8961b9b1b8e6 + github.com/golang/protobuf v1.5.0 github.com/google/btree v1.1.3 github.com/google/flatbuffers v24.12.23+incompatible github.com/google/go-cmp v0.7.0 diff --git a/go.sum b/go.sum index 08b41fb80..3cd097582 100644 --- a/go.sum +++ b/go.sum @@ -26,11 +26,14 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= github.com/go-faster/xor v0.3.0 h1:tc0bdVe31Wj999e5rEj7K3DhHyQNp2VydYyLFj3YSN8= github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ= +github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/flatbuffers v24.12.23+incompatible h1:ubBKR94NR4pXUCY/MUsRVzd9umNW7ht7EG9hHfS9FX8= github.com/google/flatbuffers v24.12.23+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk= @@ -97,6 +100,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/internal/speed/Makefile b/internal/speed/Makefile index 427ee7104..284d20ac0 100644 --- a/internal/speed/Makefile +++ b/internal/speed/Makefile @@ -2,3 +2,90 @@ .PHONY: proto proto: protoc --go_out=../../../../../../.. speed.proto + + +.PHONY: gen_methods +gen_methods: + bash scripts/create_proto.sh + bash scripts/create_tl.sh + +COUNT ?= 3 + +.PHONY: all_benchmarks +all_benchmarks: + go test -bench=. -count=$(COUNT) + +.PHONY: all_new_benchmarks +all_new_benchmarks: + go test -bench='^BenchmarkNew' -count=$(COUNT) + + +# ----------- POINT --------------- +.PHONY: point_write_gen +point_write_gen: + go test -bench='^BenchmarkPointWrite.*Gen' -count=$(COUNT) + +.PHONY: point_write +point_write: + go test -bench='^BenchmarkPointWrite' -count=$(COUNT) + +.PHONY: point_read_gen +point_read_gen: + go test -bench='^BenchmarkPointRead.*Gen' -count=$(COUNT) + +.PHONY: point_read +point_read: + go test -bench='^BenchmarkPointRead' -count=$(COUNT) + +# ----------- POINTS --------------- +.PHONY: points_read_gen +points_read_gen: + go test -bench='^BenchmarkPointsRead.*Gen' -count=$(COUNT) + +.PHONY: points_write_gen +points_write_gen: + go test -bench='^BenchmarkPointsWrite.*Gen' -count=$(COUNT) + +.PHONY: points_new_write_gen +points_new_write_gen: + go test -bench='^BenchmarkNewPoints/Write' -count=$(COUNT) + +.PHONY: points_new_read_gen +points_new_read_gen: + go test -bench='^BenchmarkNewPoints/Read' -count=$(COUNT) + + +# ----------- memcache.value --------------- +.PHONY: memcache_value_read_gen +memcache_value_read_gen: + go test -bench='^BenchmarkMemcacheValueRead.*Gen' -count=$(COUNT) + +.PHONY: memcache_value_write_gen +memcache_value_write_gen: + go test -bench='^BenchmarkMemcacheValueWrite.*Gen' -count=$(COUNT) + +.PHONY: memcache_value_new_read_gen +memcache_value_new_read_gen: + go test -bench='^BenchmarkNewMemcacheValue/Read' -count=$(COUNT) + +.PHONY: memcache_value_new_write_gen +memcache_value_new_write_gen: + go test -bench='^BenchmarkNewMemcacheValue/Write' -count=$(COUNT) + + +# ----------- memcache.values --------------- +.PHONY: memcache_values_read_gen +memcache_values_read_gen: + go test -bench='^BenchmarkMemcacheValuesRead.*Gen' -count=$(COUNT) + +.PHONY: memcache_values_write_gen +memcache_values_write_gen: + go test -bench='^BenchmarkMemcacheValuesWrite.*Gen' -count=$(COUNT) + +.PHONY: memcache_values_new_read_gen +memcache_values_new_read_gen: + go test -bench='^BenchmarkNewMemcacheValues/Read' -count=$(COUNT) + +.PHONY: memcache_values_new_write_gen +memcache_values_new_write_gen: + go test -bench='^BenchmarkNewMemcacheValues/Write' -count=$(COUNT) \ No newline at end of file diff --git a/internal/speed/bench_base.go b/internal/speed/bench_base.go new file mode 100644 index 000000000..04cbd4e20 --- /dev/null +++ b/internal/speed/bench_base.go @@ -0,0 +1,270 @@ +package speed + +import ( + "testing" + + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" + "google.golang.org/protobuf/encoding/protowire" +) + +type TLData[T any] struct { + WriteTL1Boxed func(x *T, buf []byte) []byte + ReadTL1Boxed func(x *T, buf []byte) ([]byte, error) + + WriteTL2 func(x *T, w []byte, tctx *basictl.TL2WriteContext) []byte + ReadTL2 func(x *T, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) +} + +type ProtoData[P any] struct { + Size func(x *P) int + + MarshalToSizedBuffer func(x *P, dAtA []byte) (int, error) + Marshal func(x *P) (dAtA []byte, err error) + + Unmarshal func(x *P, dAtA []byte) error +} + +type benchDataGenerator[T, P any] struct { + TLProvider TLData[T] + ProtoProvider ProtoData[P] + + GenerateSamples func() []T + GenerateBuffer func() []byte + MapSample func(T) P + + CompareTLResult func(*T, *T) bool + CompareProtoResult func(*P, *P) bool +} + +func benchBase[T, P any](b *testing.B, gen benchDataGenerator[T, P]) { + values := gen.GenerateSamples() + protoValues := make([]P, len(values)) + for i := range protoValues { + protoValues[i] = gen.MapSample(values[i]) + } + + b.Run("Read", func(b *testing.B) { + b.Run("TL1", func(b *testing.B) { + buf := gen.GenerateBuffer() + for i := range values { + buf = gen.TLProvider.WriteTL1Boxed(&values[i], buf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + + var p T + + for i := 0; i < finish; i++ { + buf2 := buf + for range values { + var err error + + buf2, err = gen.TLProvider.ReadTL1Boxed(&p, buf2) + if err != nil { + b.Fatalf("bad") + } + //if gen.CompareTLResult != nil && !gen.CompareTLResult(&p, &v) { + // b.Fatalf("bad") + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) + }) + + b.Run("TL2", func(b *testing.B) { + buf := gen.GenerateBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 10000)} + + for i := range values { + buf = gen.TLProvider.WriteTL2(&values[i], buf, &ctx) + } + + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + + var p T + + for i := 0; i < finish; i++ { + buf2 := buf + for range values { + var err error + + buf2, err = gen.TLProvider.ReadTL2(&p, buf2, nil) + if err != nil { + b.Fatalf("bad") + } + //if gen.CompareTLResult != nil && !gen.CompareTLResult(p, v) { + // b.Fatalf("bad") + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) + }) + + //b.Run("Proto", func(b *testing.B) { + // b.Run("New_Object", func(b *testing.B) { + b.Run("Proto_New_Object", func(b *testing.B) { + buf := gen.GenerateBuffer() + for j := range protoValues { + tmpBuf, err := gen.ProtoProvider.Marshal(&protoValues[j]) + if err != nil { + b.Fatalf("bad") + } + buf = protowire.AppendBytes(buf, tmpBuf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(protoValues) + + for i := 0; i < finish; i++ { + buf2 := buf + for j := 0; j < len(protoValues); j++ { + var err error + var p P + + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = gen.ProtoProvider.Unmarshal(&p, str) + if err != nil { + b.Fatalf("bad") + } + + //if gen.CompareProtoResult != nil { + // if !gen.CompareProtoResult(p, protoValues[j]) { + // b.Fatalf("bad") + // } + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) + }) + + b.Run("Proto_Same_Object", func(b *testing.B) { + //b.Run("Same_Object", func(b *testing.B) { + buf := gen.GenerateBuffer() + for j := range protoValues { + tmpBuf, err := gen.ProtoProvider.Marshal(&protoValues[j]) + if err != nil { + b.Fatalf("bad") + } + buf = protowire.AppendBytes(buf, tmpBuf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(protoValues) + + var p P + + for i := 0; i < finish; i++ { + buf2 := buf + for j := 0; j < len(protoValues); j++ { + var err error + + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = gen.ProtoProvider.Unmarshal(&p, str) + if err != nil { + b.Fatalf("bad") + } + + //if gen.CompareProtoResult != nil { + // if !gen.CompareProtoResult(p, protoValues[j]) { + // b.Fatalf("bad") + // } + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) + }) + //}) + }) + + b.Run("Write", func(b *testing.B) { + b.Run("TL1", func(b *testing.B) { + buf := gen.GenerateBuffer() + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for j := range values { + buf = gen.TLProvider.WriteTL1Boxed(&values[j], buf) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) + }) + + b.Run("TL2", func(b *testing.B) { + buf := gen.GenerateBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for j := range values { + buf = gen.TLProvider.WriteTL2(&values[j], buf, &ctx) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) + }) + + b.Run("Proto", func(b *testing.B) { + buf := gen.GenerateBuffer() + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(protoValues) + for i := 0; i < finish; i++ { + for vIndex := range protoValues { + s := gen.ProtoProvider.Size(&protoValues[vIndex]) + pointer := len(buf) + buf = append(buf, make([]byte, s)...) + + _, err := gen.ProtoProvider.MarshalToSizedBuffer(&protoValues[vIndex], buf[pointer:]) + if err != nil { + b.Fatal(err) + } + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) + }) + }) +} diff --git a/internal/speed/objects.go b/internal/speed/objects.go index c47fce1a9..7abed81c3 100644 --- a/internal/speed/objects.go +++ b/internal/speed/objects.go @@ -4,6 +4,13 @@ import ( "strings" "testing" + "github.com/VKCOM/tl/internal/speed/speed_proto/pb" + "github.com/VKCOM/tl/internal/speed/speed_proto_fast/pb_fast" + + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" + "github.com/VKCOM/tl/internal/speed/speed_tl/tl" + tlmem "github.com/VKCOM/tl/internal/speed/speed_tl/tlmemcache" + "github.com/VKCOM/tl/internal/tlcodegen/test/gen/goldmaster/tlmemcache" ) @@ -19,6 +26,7 @@ func (p *point) Reset() { p.z = 0 } +const smallerChunkSize = 100 const chunkSize = 1000 const bufferSize = 1024 * 1024 * 128 const writeExcessField = false @@ -48,10 +56,197 @@ func prepareStringsBuffer() ([]string, []byte) { return values, buf } +func prepareTLMemValuesBuffer() ([]tlmem.Value, []byte) { + basicValues := make([]tlmem.Value, 0, 5) + // empty + v := tlmem.Value{} + v.SetNotFound() + basicValues = append(basicValues, v) + // some long value + v = tlmem.Value{} + v.SetLongvalue(tlmem.Longvalue{Value: 1212123213, Flags: 0x110101}) + basicValues = append(basicValues, v) + // some long str value + v = tlmem.Value{} + v.SetStrvalueWithDelay(tlmem.StrvalueWithDelay{Value: strings.Repeat("a", 257), Flags: 0x111011}) + basicValues = append(basicValues, v) + // some sh0rt str value + v = tlmem.Value{} + v.SetStrvalueWithTime(tlmem.StrvalueWithTime{Value: strings.Repeat("b", 10), Flags: 0x111011}) + basicValues = append(basicValues, v) + + values := make([]tlmem.Value, smallerChunkSize) + for i := 0; i < smallerChunkSize; i++ { + values[i] = basicValues[(i*53+17)%len(basicValues)] + } + buf := make([]byte, 0, bufferSize) + return values, buf +} + +func prepareTLMemValuessBuffer() ([]tlmem.Values, []byte) { + values, buf := prepareTLMemValuesBuffer() + + result := make([]tlmem.Values, smallerChunkSize) + for i := 0; i < smallerChunkSize; i++ { + start := (i*83 + 11) % len(values) + sz := (i*29 + 43) % len(values) + + for j := 0; j < sz; j++ { + result[i].Values = append(result[i].Values, values[(start+j)%len(values)]) + } + } + + return result, buf +} + +func mapTLMemcacheValueToProto(value tlmem.Value) pb_fast.Value { + result := pb_fast.Value{} + switch { + case value.IsNotFound(): + result.Kind = &pb_fast.Value_NotFound{NotFound: &pb_fast.NotFound{}} + case value.IsLongvalue(): + x, _ := value.AsLongvalue() + result.Kind = &pb_fast.Value_Longvalue{Longvalue: &pb_fast.LongValue{Value: x.Value, Flags: x.Flags}} + case value.IsStrvalue(): + x, _ := value.AsStrvalue() + result.Kind = &pb_fast.Value_Strvalue{Strvalue: &pb_fast.StrValue{Value: x.Value, Flags: x.Flags}} + case value.IsLongvalueWithTime(): + x, _ := value.AsLongvalueWithTime() + result.Kind = &pb_fast.Value_LongvalueWithTime{LongvalueWithTime: &pb_fast.LongValueWithTime{Value: x.Value, Flags: x.Flags, ModificationTime: x.ModificationTime}} + case value.IsStrvalueWithTime(): + x, _ := value.AsStrvalueWithTime() + result.Kind = &pb_fast.Value_StrvalueWithTime{StrvalueWithTime: &pb_fast.StrValueWithTime{Value: x.Value, Flags: x.Flags, ModificationTime: x.ModificationTime}} + case value.IsStrvalueWithDelay(): + x, _ := value.AsStrvalueWithDelay() + result.Kind = &pb_fast.Value_StrvalueWithDelay{StrvalueWithDelay: &pb_fast.StrValueWithDelay{Value: x.Value, Flags: x.Flags, Delay: x.Delay}} + } + + return result +} + +func prepareProtoMemValuesBuffer() ([]pb_fast.Value, []byte) { + values, buf := prepareTLMemValuesBuffer() + + result := make([]pb_fast.Value, len(values)) + for i, value := range values { + result[i] = mapTLMemcacheValueToProto(value) + } + + return result, buf +} + +func prepareProtoMemValuessBuffer() ([]pb_fast.Values, []byte) { + values, buf := prepareTLMemValuessBuffer() + + result := make([]pb_fast.Values, len(values)) + for i, value := range values { + result[i] = pb_fast.Values{Values: make([]*pb_fast.Value, 0)} + for _, tlValue := range value.Values { + protoValue := mapTLMemcacheValueToProto(tlValue) + result[i].Values = append(result[i].Values, &protoValue) + } + } + + return result, buf +} + +var basePoints = []point{{1, 0, 1}, {5, 5, 0}, {0, 10, 0}, {100, 100, 100}, + {1024, 1024, 1024}, {10000000, 10000000, 10000000}, {1000, 1000, 1000}, + {50, 50, 50}, {200, 200, 200}, {0, 0, 0}} + func preparePointsBuffer() ([]point, []byte) { - values := []point{{1, 0, 1}, {5, 5, 0}, {0, 10, 0}, {100, 100, 100}, - {1024, 1024, 1024}, {10000000, 10000000, 10000000}, {1000, 1000, 1000}, - {50, 50, 50}, {200, 200, 200}, {0, 0, 0}} + values := make([]point, len(basePoints)) + copy(values, basePoints) + + for len(values) < chunkSize { + values = append(values, values...) + } + values = values[:chunkSize] + buf := make([]byte, 0, bufferSize) // worst case + return values, buf +} + +func preparePointssBuffer() ([][]point, []byte) { + values := make([][]point, 4) + // empty array + values[0] = make([]point, 0) + // some array + values[1] = basePoints + // big array + values[2] = make([]point, 100) + for i := range values[2] { + values[2][i] = basePoints[i%len(basePoints)] + } + // huge array + values[3] = make([]point, 1000) + for i := range values[3] { + values[3][i] = basePoints[(i*41+7)%len(basePoints)] + } + buf := make([]byte, 0, bufferSize) + + result := make([][]point, smallerChunkSize) + for i := range result { + result[i] = values[i%len(values)] + } + + return result, buf +} + +func prepareTLPointssBuffer() ([]tl.Points, []byte) { + p, buf := preparePointssBuffer() + result := make([]tl.Points, len(p)) + for i := range result { + result[i] = tl.Points{Values: make([]tl.Point, len(p[i]))} + for j := range result[i].Values { + result[i].Values[j].X = p[i][j].x + result[i].Values[j].Y = p[i][j].y + result[i].Values[j].Z = p[i][j].z + } + } + + return result, buf +} + +func prepareProtoPointssBuffer() ([]pb_fast.PointsPB, []byte) { + p, buf := preparePointssBuffer() + result := make([]pb_fast.PointsPB, len(p)) + for i := range result { + result[i] = pb_fast.PointsPB{Points: make([]*pb_fast.PointPB, len(p[i]))} + for j := range result[i].Points { + result[i].Points[j] = &pb_fast.PointPB{X: p[i][j].x, Y: p[i][j].y, Z: p[i][j].z} + } + } + + return result, buf +} + +func prepareTLPointsBuffer() ([]tl.Point, []byte, basictl.TL2WriteContext) { + points, buf := preparePointsBuffer() + tlPoints := make([]tl.Point, len(points)) + for i, p := range points { + tlPoints[i] = tl.Point{X: p.x, Y: p.y, Z: p.z} + } + return tlPoints, buf, basictl.TL2WriteContext{} +} + +func prepareProtoPointsBuffer() ([]pb.PointPB, []byte) { + values := make([]pb.PointPB, 0) + for _, p := range basePoints { + values = append(values, pb.PointPB{X: p.x, Y: p.y, Z: p.z}) + } + for len(values) < chunkSize { + values = append(values, values...) + } + values = values[:chunkSize] + buf := make([]byte, 0, bufferSize) // worst case + return values, buf +} + +func prepareProtoFastPointsBuffer() ([]pb_fast.PointPB, []byte) { + values := make([]pb_fast.PointPB, 0) + for _, p := range basePoints { + values = append(values, pb_fast.PointPB{X: p.x, Y: p.y, Z: p.z}) + } for len(values) < chunkSize { values = append(values, values...) } diff --git a/internal/speed/point_read_test.go b/internal/speed/point_read_test.go index c3b9ac962..fe50ff17a 100644 --- a/internal/speed/point_read_test.go +++ b/internal/speed/point_read_test.go @@ -3,7 +3,11 @@ package speed import ( "testing" + "github.com/VKCOM/tl/internal/speed/speed_proto/pb" + "github.com/VKCOM/tl/internal/speed/speed_proto_fast/pb_fast" + "github.com/VKCOM/tl/internal/speed/speed_tl/tl" "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/proto" "github.com/VKCOM/tl/pkg/basictl" ) @@ -36,6 +40,34 @@ func BenchmarkPointReadTL(b *testing.B) { printSizes(b, int64(len(buf))*int64(finish)) } +func BenchmarkPointReadTLGen(b *testing.B) { + values, buf, _ := prepareTLPointsBuffer() + for _, v := range values { + buf = v.WriteTL1(buf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tl.Point + buf2, err = p.ReadTL1(buf2) + if err != nil { + b.Fatalf("bad") + } + if p != v { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + func BenchmarkPointReadTL2(b *testing.B) { values, buf := preparePointsBuffer() for _, v := range values { @@ -64,6 +96,34 @@ func BenchmarkPointReadTL2(b *testing.B) { printSizes(b, int64(len(buf))*int64(finish)) } +func BenchmarkPointReadTL2Gen(b *testing.B) { + values, buf, ctx := prepareTLPointsBuffer() + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tl.Point + buf2, err = p.ReadTL2(buf2, nil) + if err != nil { + b.Fatalf("bad") + } + if p != v { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + func BenchmarkPointReadTLBad(b *testing.B) { values, buf := preparePointsBuffer() for _, v := range values { @@ -237,6 +297,72 @@ func BenchmarkPointReadProtobuf(b *testing.B) { printSizes(b, int64(len(buf))*int64(finish)) } +func BenchmarkPointReadProtobufGen(b *testing.B) { + values, buf := prepareProtoPointsBuffer() + for v := range values { + buf = protobufAppendPoint(buf, &point{x: values[v].X, y: values[v].Y, z: values[v].Z}, writeExcessField) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for v := range values { + var err error + var res pb.PointPB // reuse + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = proto.UnmarshalOptions{}.Unmarshal(str, &res) + if err != nil { + b.Fatalf("bad") + } + if res.X != values[v].X || res.Y != values[v].Y || res.Z != values[v].Z { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkPointReadProtobufFastGen(b *testing.B) { + values, buf := prepareProtoFastPointsBuffer() + for v := range values { + buf = protobufAppendPoint(buf, &point{x: values[v].X, y: values[v].Y, z: values[v].Z}, writeExcessField) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for v := range values { + var err error + var res pb_fast.PointPB // reuse + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = res.Unmarshal(str) + if err != nil { + b.Fatalf("bad") + } + if res.X != values[v].X || res.Y != values[v].Y || res.Z != values[v].Z { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + func BenchmarkPointReadProtobufOptimistic(b *testing.B) { values, buf := preparePointsBuffer() for _, v := range values { diff --git a/internal/speed/point_write_test.go b/internal/speed/point_write_test.go index df9cc0dce..073ed678c 100644 --- a/internal/speed/point_write_test.go +++ b/internal/speed/point_write_test.go @@ -4,6 +4,7 @@ import ( "testing" "capnproto.org/go/capnp/v3" + "google.golang.org/protobuf/proto" flatbuffers "github.com/google/flatbuffers/go" ) @@ -26,6 +27,24 @@ func BenchmarkPointWriteTL(b *testing.B) { printSizes(b, total+int64(len(buf))) } +func BenchmarkPointWriteTLGen(b *testing.B) { + values, buf, _ := prepareTLPointsBuffer() + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL1(buf) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + func BenchmarkPointWriteTLBad(b *testing.B) { values, buf := preparePointsBuffer() b.ReportAllocs() @@ -80,6 +99,25 @@ func BenchmarkPointWriteTL2Dumb(b *testing.B) { printSizes(b, total+int64(len(buf))) } +func BenchmarkPointWriteTL2Gen(b *testing.B) { + values, buf, ctx := prepareTLPointsBuffer() + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + func BenchmarkPointWriteMsgp(b *testing.B) { values, buf := preparePointsBuffer() b.ReportAllocs() @@ -152,6 +190,50 @@ func BenchmarkPointWriteProtobuf(b *testing.B) { printSizes(b, total+int64(len(buf))) } +func BenchmarkPointWriteProtobufGen(b *testing.B) { + values, buf := prepareProtoPointsBuffer() + opts := proto.MarshalOptions{} + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for vIndex := range values { + buf, _ = opts.MarshalAppend(buf, &values[vIndex]) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkPointWriteProtobufFastGen(b *testing.B) { + values, buf := prepareProtoFastPointsBuffer() + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for vIndex := range values { + s := values[vIndex].Size() + pointer := len(buf) + buf = append(buf, make([]byte, s)...) + + _, err := values[vIndex].MarshalToSizedBuffer(buf[pointer:]) + if err != nil { + b.Fatal(err) + } + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + func TestFlatbuffers(t *testing.T) { fb := flatbuffers.NewBuilder(0) p1 := point{x: 1, y: 0, z: 3} diff --git a/internal/speed/schemas/speed.proto b/internal/speed/schemas/speed.proto new file mode 100644 index 000000000..2ad0dec82 --- /dev/null +++ b/internal/speed/schemas/speed.proto @@ -0,0 +1,122 @@ +syntax = "proto3"; +package statshouse; + +option go_package = "github.com/VKCOM/tl/internal/speed/pb"; + +message PointPB { + uint32 x = 1; + uint32 y = 2; + uint32 z = 3; +} + +message PointsPB { + repeated PointPB points = 1; +} + +message NotFound {} + +message StrValue { + string value = 1; + int32 flags = 2; +} + +message LongValue { + int64 value = 1; + int32 flags = 2; +} + +message StrValueWithTime { + string value = 1; + int32 flags = 2; + int32 modification_time = 3; +} + +message LongValueWithTime { + int64 value = 1; + int32 flags = 2; + int32 modification_time = 3; +} + +message StrValueWithDelay { + string value = 1; + int32 flags = 2; + int32 delay = 3; +} + +message Value { + oneof kind { + NotFound not_found = 1; + StrValue strvalue = 2; + LongValue longvalue = 3; + StrValueWithTime strvalue_with_time = 4; + LongValueWithTime longvalue_with_time = 5; + StrValueWithDelay strvalue_with_delay = 6; + } +} + +message Values { + repeated Value values = 1; +} + +message PartialPointPB { + uint32 mask = 1; + uint32 x = 2; + uint32 y = 3; + uint32 z = 4; +} + +message PartialPointsPB { + repeated PartialPointPB points = 1; +} + +message UnionPointValuePB { + uint32 mask = 1; + uint32 x = 2; + uint32 y = 3; + uint32 z = 4; +} + +message UnionPointErrorPB { + string err = 1; +} + + +message UnionPointPB { + oneof kind { + UnionPointValuePB value = 1; + UnionPointErrorPB error = 2; + } +} + +message UnionPointsPB { + repeated UnionPointPB points = 1; +} + +// to compile +// sudo apt-get install libprotobuf-dev +// go install google.golang.org/protobuf/cmd/protoc-gen-go +// /go/src/gitlab.corp.mail.ru/vkgo/vkgo$ protoc -I=projects/vktl/internal/speed --go_out=../../.. speed.proto + +// or +// go install github.com/gogo/protobuf/protoc-gen-gofast@latest +// user@boot3879:~/go/src/github.com/VKCOM/tl/internal/speed$ protoc --gofast_out=../../../../../../.. speed.proto + + +// to compile if proto3 format not supported, for example by protocute + +// 1. comment out line: option go_package = "github.com/VKCOM/statshouse/internal/receiver/pb"; +// 2. add +// message MapFieldEntry { +// optional string key = 1; +// optional string value = 2; +// } +// 3. replace Metric with +// message Metric { +// string name = 1; +// map tags = 2; +// double counter = 3; +// uint32 ts = 4; // UNIX seconds UTC +// repeated double value = 5; +// repeated int64 unique = 6; +// } +// 4. ./protocute --cpp_out=. ~/go/src/github.com/VKCOM/statshouse/internal/receiver/statshouse.proto diff --git a/internal/speed/schemas/speed.tl b/internal/speed/schemas/speed.tl new file mode 100644 index 000000000..7aa431a98 --- /dev/null +++ b/internal/speed/schemas/speed.tl @@ -0,0 +1,23 @@ +vector#1cb5c415 {t:Type} # [t] = Vector t; + +point x:# y:# z:# = Point; +points values:vector = Points; + +memcache.not_found = memcache.Value; +memcache.strvalue value:string flags:int = memcache.Value; +memcache.longvalue value:long flags:int = memcache.Value; +memcache.strvalueWithTime value:string flags:int modificationTime:int = memcache.Value; +memcache.longvalueWithTime value:long flags:int modificationTime:int = memcache.Value; +memcache.strvalueWithDelay value:string flags:int delay:int = memcache.Value; + +memcache.values values:vector = memcache.Values; + +partialPoint mask:# x:mask.0?# y:mask.1?# z:mask.2?# = PartialPoint; + +partialPoints values:vector = PartialPoints; + +unionPointValue mask:# x:mask.0?# y:mask.1?# z:mask.2?# = UnionPoint; +unionPointError err:string = UnionPoint; + +unionPoints values:vector = UnionPoints; + diff --git a/internal/speed/schemas/speed_fast.proto b/internal/speed/schemas/speed_fast.proto new file mode 100644 index 000000000..77f63341c --- /dev/null +++ b/internal/speed/schemas/speed_fast.proto @@ -0,0 +1,93 @@ +syntax = "proto3"; +package tl_fast; + +option go_package = "github.com/VKCOM/tl/internal/speed/pb_fast"; + +message PointPB { + uint32 x = 1; + uint32 y = 2; + uint32 z = 3; +} + +message PointsPB { + repeated PointPB points = 1; +} + +message NotFound {} + +message StrValue { + string value = 1; + int32 flags = 2; +} + +message LongValue { + int64 value = 1; + int32 flags = 2; +} + +message StrValueWithTime { + string value = 1; + int32 flags = 2; + int32 modification_time = 3; +} + +message LongValueWithTime { + int64 value = 1; + int32 flags = 2; + int32 modification_time = 3; +} + +message StrValueWithDelay { + string value = 1; + int32 flags = 2; + int32 delay = 3; +} + +message Value { + oneof kind { + NotFound not_found = 1; + StrValue strvalue = 2; + LongValue longvalue = 3; + StrValueWithTime strvalue_with_time = 4; + LongValueWithTime longvalue_with_time = 5; + StrValueWithDelay strvalue_with_delay = 6; + } +} + +message Values { + repeated Value values = 1; +} + +message PartialPointPB { + uint32 mask = 1; + uint32 x = 2; + uint32 y = 3; + uint32 z = 4; +} + +message PartialPointsPB { + repeated PartialPointPB points = 1; +} + +message UnionPointValuePB { + uint32 mask = 1; + uint32 x = 2; + uint32 y = 3; + uint32 z = 4; +} + +message UnionPointErrorPB { + string err = 1; +} + + +message UnionPointPB { + oneof kind { + UnionPointValuePB value = 1; + UnionPointErrorPB error = 2; + } +} + +message UnionPointsPB { + repeated UnionPointPB points = 1; +} diff --git a/internal/speed/scripts/create_proto.sh b/internal/speed/scripts/create_proto.sh new file mode 100755 index 000000000..53912b987 --- /dev/null +++ b/internal/speed/scripts/create_proto.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +path=speed_proto +fast_path=speed_proto_fast + +rm -rf $path/pb +rm -rf $fast_path/pb_fast + + +mkdir -p $path/pb +protoc \ + -I ./schemas \ + --go_out=./$path/pb \ + --go_opt=paths=source_relative \ + ./schemas/speed.proto + +mkdir -p $fast_path/pb_fast +protoc \ + -I ./schemas \ + --gofast_out=paths=source_relative:./$fast_path/pb_fast \ + ./schemas/speed_fast.proto \ No newline at end of file diff --git a/internal/speed/scripts/create_tl.sh b/internal/speed/scripts/create_tl.sh new file mode 100755 index 000000000..18e76dc34 --- /dev/null +++ b/internal/speed/scripts/create_tl.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +path=speed_tl +tl2gen=../../target/bin/tl2gen + +mkdir -p $path + +$tl2gen --language=go \ + --tl2WhiteList=* \ + --outdir=$path \ + --pkgPath=github.com/VKCOM/tl/internal/speed/$path/tl \ + schemas/speed.tl \ No newline at end of file diff --git a/internal/speed/speed.proto b/internal/speed/speed.proto deleted file mode 100644 index 4e2bdf882..000000000 --- a/internal/speed/speed.proto +++ /dev/null @@ -1,39 +0,0 @@ -syntax = "proto3"; -package statshouse; - -option go_package = "github.com/VKCOM/tl/internal/speed/pb"; - -message PointPB { - uint32 x = 1; - uint32 y = 2; - uint32 z = 3; -} - -// to compile -// sudo apt-get install libprotobuf-dev -// go install google.golang.org/protobuf/cmd/protoc-gen-go -// /go/src/gitlab.corp.mail.ru/vkgo/vkgo$ protoc -I=projects/vktl/internal/speed --go_out=../../.. speed.proto - -// or -// go install github.com/gogo/protobuf/protoc-gen-gofast@latest -// user@boot3879:~/go/src/github.com/VKCOM/tl/internal/speed$ protoc --gofast_out=../../../../../../.. speed.proto - - -// to compile if proto3 format not supported, for example by protocute - -// 1. comment out line: option go_package = "github.com/VKCOM/statshouse/internal/receiver/pb"; -// 2. add -// message MapFieldEntry { -// optional string key = 1; -// optional string value = 2; -// } -// 3. replace Metric with -// message Metric { -// string name = 1; -// map tags = 2; -// double counter = 3; -// uint32 ts = 4; // UNIX seconds UTC -// repeated double value = 5; -// repeated int64 unique = 6; -// } -// 4. ./protocute --cpp_out=. ~/go/src/github.com/VKCOM/statshouse/internal/receiver/statshouse.proto diff --git a/internal/speed/speed_proto/pb/speed.pb.go b/internal/speed/speed_proto/pb/speed.pb.go new file mode 100644 index 000000000..a24c45e49 --- /dev/null +++ b/internal/speed/speed_proto/pb/speed.pb.go @@ -0,0 +1,1136 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.11 +// protoc v3.12.4 +// source: speed.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PointPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + X uint32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` + Y uint32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` + Z uint32 `protobuf:"varint,3,opt,name=z,proto3" json:"z,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PointPB) Reset() { + *x = PointPB{} + mi := &file_speed_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PointPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PointPB) ProtoMessage() {} + +func (x *PointPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PointPB.ProtoReflect.Descriptor instead. +func (*PointPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{0} +} + +func (x *PointPB) GetX() uint32 { + if x != nil { + return x.X + } + return 0 +} + +func (x *PointPB) GetY() uint32 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *PointPB) GetZ() uint32 { + if x != nil { + return x.Z + } + return 0 +} + +type PointsPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + Points []*PointPB `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PointsPB) Reset() { + *x = PointsPB{} + mi := &file_speed_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PointsPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PointsPB) ProtoMessage() {} + +func (x *PointsPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PointsPB.ProtoReflect.Descriptor instead. +func (*PointsPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{1} +} + +func (x *PointsPB) GetPoints() []*PointPB { + if x != nil { + return x.Points + } + return nil +} + +type NotFound struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NotFound) Reset() { + *x = NotFound{} + mi := &file_speed_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NotFound) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotFound) ProtoMessage() {} + +func (x *NotFound) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NotFound.ProtoReflect.Descriptor instead. +func (*NotFound) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{2} +} + +type StrValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StrValue) Reset() { + *x = StrValue{} + mi := &file_speed_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StrValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StrValue) ProtoMessage() {} + +func (x *StrValue) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StrValue.ProtoReflect.Descriptor instead. +func (*StrValue) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{3} +} + +func (x *StrValue) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *StrValue) GetFlags() int32 { + if x != nil { + return x.Flags + } + return 0 +} + +type LongValue struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LongValue) Reset() { + *x = LongValue{} + mi := &file_speed_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LongValue) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LongValue) ProtoMessage() {} + +func (x *LongValue) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LongValue.ProtoReflect.Descriptor instead. +func (*LongValue) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{4} +} + +func (x *LongValue) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *LongValue) GetFlags() int32 { + if x != nil { + return x.Flags + } + return 0 +} + +type StrValueWithTime struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + ModificationTime int32 `protobuf:"varint,3,opt,name=modification_time,json=modificationTime,proto3" json:"modification_time,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StrValueWithTime) Reset() { + *x = StrValueWithTime{} + mi := &file_speed_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StrValueWithTime) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StrValueWithTime) ProtoMessage() {} + +func (x *StrValueWithTime) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StrValueWithTime.ProtoReflect.Descriptor instead. +func (*StrValueWithTime) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{5} +} + +func (x *StrValueWithTime) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *StrValueWithTime) GetFlags() int32 { + if x != nil { + return x.Flags + } + return 0 +} + +func (x *StrValueWithTime) GetModificationTime() int32 { + if x != nil { + return x.ModificationTime + } + return 0 +} + +type LongValueWithTime struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + ModificationTime int32 `protobuf:"varint,3,opt,name=modification_time,json=modificationTime,proto3" json:"modification_time,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LongValueWithTime) Reset() { + *x = LongValueWithTime{} + mi := &file_speed_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LongValueWithTime) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LongValueWithTime) ProtoMessage() {} + +func (x *LongValueWithTime) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LongValueWithTime.ProtoReflect.Descriptor instead. +func (*LongValueWithTime) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{6} +} + +func (x *LongValueWithTime) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *LongValueWithTime) GetFlags() int32 { + if x != nil { + return x.Flags + } + return 0 +} + +func (x *LongValueWithTime) GetModificationTime() int32 { + if x != nil { + return x.ModificationTime + } + return 0 +} + +type StrValueWithDelay struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + Delay int32 `protobuf:"varint,3,opt,name=delay,proto3" json:"delay,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StrValueWithDelay) Reset() { + *x = StrValueWithDelay{} + mi := &file_speed_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StrValueWithDelay) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StrValueWithDelay) ProtoMessage() {} + +func (x *StrValueWithDelay) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StrValueWithDelay.ProtoReflect.Descriptor instead. +func (*StrValueWithDelay) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{7} +} + +func (x *StrValueWithDelay) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *StrValueWithDelay) GetFlags() int32 { + if x != nil { + return x.Flags + } + return 0 +} + +func (x *StrValueWithDelay) GetDelay() int32 { + if x != nil { + return x.Delay + } + return 0 +} + +type Value struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Kind: + // + // *Value_NotFound + // *Value_Strvalue + // *Value_Longvalue + // *Value_StrvalueWithTime + // *Value_LongvalueWithTime + // *Value_StrvalueWithDelay + Kind isValue_Kind `protobuf_oneof:"kind"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Value) Reset() { + *x = Value{} + mi := &file_speed_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Value) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Value) ProtoMessage() {} + +func (x *Value) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Value.ProtoReflect.Descriptor instead. +func (*Value) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{8} +} + +func (x *Value) GetKind() isValue_Kind { + if x != nil { + return x.Kind + } + return nil +} + +func (x *Value) GetNotFound() *NotFound { + if x != nil { + if x, ok := x.Kind.(*Value_NotFound); ok { + return x.NotFound + } + } + return nil +} + +func (x *Value) GetStrvalue() *StrValue { + if x != nil { + if x, ok := x.Kind.(*Value_Strvalue); ok { + return x.Strvalue + } + } + return nil +} + +func (x *Value) GetLongvalue() *LongValue { + if x != nil { + if x, ok := x.Kind.(*Value_Longvalue); ok { + return x.Longvalue + } + } + return nil +} + +func (x *Value) GetStrvalueWithTime() *StrValueWithTime { + if x != nil { + if x, ok := x.Kind.(*Value_StrvalueWithTime); ok { + return x.StrvalueWithTime + } + } + return nil +} + +func (x *Value) GetLongvalueWithTime() *LongValueWithTime { + if x != nil { + if x, ok := x.Kind.(*Value_LongvalueWithTime); ok { + return x.LongvalueWithTime + } + } + return nil +} + +func (x *Value) GetStrvalueWithDelay() *StrValueWithDelay { + if x != nil { + if x, ok := x.Kind.(*Value_StrvalueWithDelay); ok { + return x.StrvalueWithDelay + } + } + return nil +} + +type isValue_Kind interface { + isValue_Kind() +} + +type Value_NotFound struct { + NotFound *NotFound `protobuf:"bytes,1,opt,name=not_found,json=notFound,proto3,oneof"` +} + +type Value_Strvalue struct { + Strvalue *StrValue `protobuf:"bytes,2,opt,name=strvalue,proto3,oneof"` +} + +type Value_Longvalue struct { + Longvalue *LongValue `protobuf:"bytes,3,opt,name=longvalue,proto3,oneof"` +} + +type Value_StrvalueWithTime struct { + StrvalueWithTime *StrValueWithTime `protobuf:"bytes,4,opt,name=strvalue_with_time,json=strvalueWithTime,proto3,oneof"` +} + +type Value_LongvalueWithTime struct { + LongvalueWithTime *LongValueWithTime `protobuf:"bytes,5,opt,name=longvalue_with_time,json=longvalueWithTime,proto3,oneof"` +} + +type Value_StrvalueWithDelay struct { + StrvalueWithDelay *StrValueWithDelay `protobuf:"bytes,6,opt,name=strvalue_with_delay,json=strvalueWithDelay,proto3,oneof"` +} + +func (*Value_NotFound) isValue_Kind() {} + +func (*Value_Strvalue) isValue_Kind() {} + +func (*Value_Longvalue) isValue_Kind() {} + +func (*Value_StrvalueWithTime) isValue_Kind() {} + +func (*Value_LongvalueWithTime) isValue_Kind() {} + +func (*Value_StrvalueWithDelay) isValue_Kind() {} + +type Values struct { + state protoimpl.MessageState `protogen:"open.v1"` + Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Values) Reset() { + *x = Values{} + mi := &file_speed_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Values) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Values) ProtoMessage() {} + +func (x *Values) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Values.ProtoReflect.Descriptor instead. +func (*Values) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{9} +} + +func (x *Values) GetValues() []*Value { + if x != nil { + return x.Values + } + return nil +} + +type PartialPointPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + Mask uint32 `protobuf:"varint,1,opt,name=mask,proto3" json:"mask,omitempty"` + X uint32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"` + Y uint32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"` + Z uint32 `protobuf:"varint,4,opt,name=z,proto3" json:"z,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PartialPointPB) Reset() { + *x = PartialPointPB{} + mi := &file_speed_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PartialPointPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PartialPointPB) ProtoMessage() {} + +func (x *PartialPointPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PartialPointPB.ProtoReflect.Descriptor instead. +func (*PartialPointPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{10} +} + +func (x *PartialPointPB) GetMask() uint32 { + if x != nil { + return x.Mask + } + return 0 +} + +func (x *PartialPointPB) GetX() uint32 { + if x != nil { + return x.X + } + return 0 +} + +func (x *PartialPointPB) GetY() uint32 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *PartialPointPB) GetZ() uint32 { + if x != nil { + return x.Z + } + return 0 +} + +type PartialPointsPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + Points []*PartialPointPB `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PartialPointsPB) Reset() { + *x = PartialPointsPB{} + mi := &file_speed_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PartialPointsPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PartialPointsPB) ProtoMessage() {} + +func (x *PartialPointsPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PartialPointsPB.ProtoReflect.Descriptor instead. +func (*PartialPointsPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{11} +} + +func (x *PartialPointsPB) GetPoints() []*PartialPointPB { + if x != nil { + return x.Points + } + return nil +} + +type UnionPointValuePB struct { + state protoimpl.MessageState `protogen:"open.v1"` + Mask uint32 `protobuf:"varint,1,opt,name=mask,proto3" json:"mask,omitempty"` + X uint32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"` + Y uint32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"` + Z uint32 `protobuf:"varint,4,opt,name=z,proto3" json:"z,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UnionPointValuePB) Reset() { + *x = UnionPointValuePB{} + mi := &file_speed_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnionPointValuePB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnionPointValuePB) ProtoMessage() {} + +func (x *UnionPointValuePB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnionPointValuePB.ProtoReflect.Descriptor instead. +func (*UnionPointValuePB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{12} +} + +func (x *UnionPointValuePB) GetMask() uint32 { + if x != nil { + return x.Mask + } + return 0 +} + +func (x *UnionPointValuePB) GetX() uint32 { + if x != nil { + return x.X + } + return 0 +} + +func (x *UnionPointValuePB) GetY() uint32 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *UnionPointValuePB) GetZ() uint32 { + if x != nil { + return x.Z + } + return 0 +} + +type UnionPointErrorPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UnionPointErrorPB) Reset() { + *x = UnionPointErrorPB{} + mi := &file_speed_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnionPointErrorPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnionPointErrorPB) ProtoMessage() {} + +func (x *UnionPointErrorPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnionPointErrorPB.ProtoReflect.Descriptor instead. +func (*UnionPointErrorPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{13} +} + +func (x *UnionPointErrorPB) GetErr() string { + if x != nil { + return x.Err + } + return "" +} + +type UnionPointPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Kind: + // + // *UnionPointPB_Value + // *UnionPointPB_Error + Kind isUnionPointPB_Kind `protobuf_oneof:"kind"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UnionPointPB) Reset() { + *x = UnionPointPB{} + mi := &file_speed_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnionPointPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnionPointPB) ProtoMessage() {} + +func (x *UnionPointPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnionPointPB.ProtoReflect.Descriptor instead. +func (*UnionPointPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{14} +} + +func (x *UnionPointPB) GetKind() isUnionPointPB_Kind { + if x != nil { + return x.Kind + } + return nil +} + +func (x *UnionPointPB) GetValue() *UnionPointValuePB { + if x != nil { + if x, ok := x.Kind.(*UnionPointPB_Value); ok { + return x.Value + } + } + return nil +} + +func (x *UnionPointPB) GetError() *UnionPointErrorPB { + if x != nil { + if x, ok := x.Kind.(*UnionPointPB_Error); ok { + return x.Error + } + } + return nil +} + +type isUnionPointPB_Kind interface { + isUnionPointPB_Kind() +} + +type UnionPointPB_Value struct { + Value *UnionPointValuePB `protobuf:"bytes,1,opt,name=value,proto3,oneof"` +} + +type UnionPointPB_Error struct { + Error *UnionPointErrorPB `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +func (*UnionPointPB_Value) isUnionPointPB_Kind() {} + +func (*UnionPointPB_Error) isUnionPointPB_Kind() {} + +type UnionPointsPB struct { + state protoimpl.MessageState `protogen:"open.v1"` + Points []*UnionPointPB `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UnionPointsPB) Reset() { + *x = UnionPointsPB{} + mi := &file_speed_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UnionPointsPB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnionPointsPB) ProtoMessage() {} + +func (x *UnionPointsPB) ProtoReflect() protoreflect.Message { + mi := &file_speed_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnionPointsPB.ProtoReflect.Descriptor instead. +func (*UnionPointsPB) Descriptor() ([]byte, []int) { + return file_speed_proto_rawDescGZIP(), []int{15} +} + +func (x *UnionPointsPB) GetPoints() []*UnionPointPB { + if x != nil { + return x.Points + } + return nil +} + +var File_speed_proto protoreflect.FileDescriptor + +const file_speed_proto_rawDesc = "" + + "\n" + + "\vspeed.proto\x12\n" + + "statshouse\"3\n" + + "\aPointPB\x12\f\n" + + "\x01x\x18\x01 \x01(\rR\x01x\x12\f\n" + + "\x01y\x18\x02 \x01(\rR\x01y\x12\f\n" + + "\x01z\x18\x03 \x01(\rR\x01z\"7\n" + + "\bPointsPB\x12+\n" + + "\x06points\x18\x01 \x03(\v2\x13.statshouse.PointPBR\x06points\"\n" + + "\n" + + "\bNotFound\"6\n" + + "\bStrValue\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x14\n" + + "\x05flags\x18\x02 \x01(\x05R\x05flags\"7\n" + + "\tLongValue\x12\x14\n" + + "\x05value\x18\x01 \x01(\x03R\x05value\x12\x14\n" + + "\x05flags\x18\x02 \x01(\x05R\x05flags\"k\n" + + "\x10StrValueWithTime\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x14\n" + + "\x05flags\x18\x02 \x01(\x05R\x05flags\x12+\n" + + "\x11modification_time\x18\x03 \x01(\x05R\x10modificationTime\"l\n" + + "\x11LongValueWithTime\x12\x14\n" + + "\x05value\x18\x01 \x01(\x03R\x05value\x12\x14\n" + + "\x05flags\x18\x02 \x01(\x05R\x05flags\x12+\n" + + "\x11modification_time\x18\x03 \x01(\x05R\x10modificationTime\"U\n" + + "\x11StrValueWithDelay\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x14\n" + + "\x05flags\x18\x02 \x01(\x05R\x05flags\x12\x14\n" + + "\x05delay\x18\x03 \x01(\x05R\x05delay\"\x9f\x03\n" + + "\x05Value\x123\n" + + "\tnot_found\x18\x01 \x01(\v2\x14.statshouse.NotFoundH\x00R\bnotFound\x122\n" + + "\bstrvalue\x18\x02 \x01(\v2\x14.statshouse.StrValueH\x00R\bstrvalue\x125\n" + + "\tlongvalue\x18\x03 \x01(\v2\x15.statshouse.LongValueH\x00R\tlongvalue\x12L\n" + + "\x12strvalue_with_time\x18\x04 \x01(\v2\x1c.statshouse.StrValueWithTimeH\x00R\x10strvalueWithTime\x12O\n" + + "\x13longvalue_with_time\x18\x05 \x01(\v2\x1d.statshouse.LongValueWithTimeH\x00R\x11longvalueWithTime\x12O\n" + + "\x13strvalue_with_delay\x18\x06 \x01(\v2\x1d.statshouse.StrValueWithDelayH\x00R\x11strvalueWithDelayB\x06\n" + + "\x04kind\"3\n" + + "\x06Values\x12)\n" + + "\x06values\x18\x01 \x03(\v2\x11.statshouse.ValueR\x06values\"N\n" + + "\x0ePartialPointPB\x12\x12\n" + + "\x04mask\x18\x01 \x01(\rR\x04mask\x12\f\n" + + "\x01x\x18\x02 \x01(\rR\x01x\x12\f\n" + + "\x01y\x18\x03 \x01(\rR\x01y\x12\f\n" + + "\x01z\x18\x04 \x01(\rR\x01z\"E\n" + + "\x0fPartialPointsPB\x122\n" + + "\x06points\x18\x01 \x03(\v2\x1a.statshouse.PartialPointPBR\x06points\"Q\n" + + "\x11UnionPointValuePB\x12\x12\n" + + "\x04mask\x18\x01 \x01(\rR\x04mask\x12\f\n" + + "\x01x\x18\x02 \x01(\rR\x01x\x12\f\n" + + "\x01y\x18\x03 \x01(\rR\x01y\x12\f\n" + + "\x01z\x18\x04 \x01(\rR\x01z\"%\n" + + "\x11UnionPointErrorPB\x12\x10\n" + + "\x03err\x18\x01 \x01(\tR\x03err\"\x84\x01\n" + + "\fUnionPointPB\x125\n" + + "\x05value\x18\x01 \x01(\v2\x1d.statshouse.UnionPointValuePBH\x00R\x05value\x125\n" + + "\x05error\x18\x02 \x01(\v2\x1d.statshouse.UnionPointErrorPBH\x00R\x05errorB\x06\n" + + "\x04kind\"A\n" + + "\rUnionPointsPB\x120\n" + + "\x06points\x18\x01 \x03(\v2\x18.statshouse.UnionPointPBR\x06pointsB'Z%github.com/VKCOM/tl/internal/speed/pbb\x06proto3" + +var ( + file_speed_proto_rawDescOnce sync.Once + file_speed_proto_rawDescData []byte +) + +func file_speed_proto_rawDescGZIP() []byte { + file_speed_proto_rawDescOnce.Do(func() { + file_speed_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_speed_proto_rawDesc), len(file_speed_proto_rawDesc))) + }) + return file_speed_proto_rawDescData +} + +var file_speed_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_speed_proto_goTypes = []any{ + (*PointPB)(nil), // 0: statshouse.PointPB + (*PointsPB)(nil), // 1: statshouse.PointsPB + (*NotFound)(nil), // 2: statshouse.NotFound + (*StrValue)(nil), // 3: statshouse.StrValue + (*LongValue)(nil), // 4: statshouse.LongValue + (*StrValueWithTime)(nil), // 5: statshouse.StrValueWithTime + (*LongValueWithTime)(nil), // 6: statshouse.LongValueWithTime + (*StrValueWithDelay)(nil), // 7: statshouse.StrValueWithDelay + (*Value)(nil), // 8: statshouse.Value + (*Values)(nil), // 9: statshouse.Values + (*PartialPointPB)(nil), // 10: statshouse.PartialPointPB + (*PartialPointsPB)(nil), // 11: statshouse.PartialPointsPB + (*UnionPointValuePB)(nil), // 12: statshouse.UnionPointValuePB + (*UnionPointErrorPB)(nil), // 13: statshouse.UnionPointErrorPB + (*UnionPointPB)(nil), // 14: statshouse.UnionPointPB + (*UnionPointsPB)(nil), // 15: statshouse.UnionPointsPB +} +var file_speed_proto_depIdxs = []int32{ + 0, // 0: statshouse.PointsPB.points:type_name -> statshouse.PointPB + 2, // 1: statshouse.Value.not_found:type_name -> statshouse.NotFound + 3, // 2: statshouse.Value.strvalue:type_name -> statshouse.StrValue + 4, // 3: statshouse.Value.longvalue:type_name -> statshouse.LongValue + 5, // 4: statshouse.Value.strvalue_with_time:type_name -> statshouse.StrValueWithTime + 6, // 5: statshouse.Value.longvalue_with_time:type_name -> statshouse.LongValueWithTime + 7, // 6: statshouse.Value.strvalue_with_delay:type_name -> statshouse.StrValueWithDelay + 8, // 7: statshouse.Values.values:type_name -> statshouse.Value + 10, // 8: statshouse.PartialPointsPB.points:type_name -> statshouse.PartialPointPB + 12, // 9: statshouse.UnionPointPB.value:type_name -> statshouse.UnionPointValuePB + 13, // 10: statshouse.UnionPointPB.error:type_name -> statshouse.UnionPointErrorPB + 14, // 11: statshouse.UnionPointsPB.points:type_name -> statshouse.UnionPointPB + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name +} + +func init() { file_speed_proto_init() } +func file_speed_proto_init() { + if File_speed_proto != nil { + return + } + file_speed_proto_msgTypes[8].OneofWrappers = []any{ + (*Value_NotFound)(nil), + (*Value_Strvalue)(nil), + (*Value_Longvalue)(nil), + (*Value_StrvalueWithTime)(nil), + (*Value_LongvalueWithTime)(nil), + (*Value_StrvalueWithDelay)(nil), + } + file_speed_proto_msgTypes[14].OneofWrappers = []any{ + (*UnionPointPB_Value)(nil), + (*UnionPointPB_Error)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_speed_proto_rawDesc), len(file_speed_proto_rawDesc)), + NumEnums: 0, + NumMessages: 16, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_speed_proto_goTypes, + DependencyIndexes: file_speed_proto_depIdxs, + MessageInfos: file_speed_proto_msgTypes, + }.Build() + File_speed_proto = out.File + file_speed_proto_goTypes = nil + file_speed_proto_depIdxs = nil +} diff --git a/internal/speed/speed_proto_fast/pb_fast/speed_fast.pb.go b/internal/speed/speed_proto_fast/pb_fast/speed_fast.pb.go new file mode 100644 index 000000000..3edd2438f --- /dev/null +++ b/internal/speed/speed_proto_fast/pb_fast/speed_fast.pb.go @@ -0,0 +1,4160 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: speed_fast.proto + +package pb_fast + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type PointPB struct { + X uint32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` + Y uint32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` + Z uint32 `protobuf:"varint,3,opt,name=z,proto3" json:"z,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PointPB) Reset() { *m = PointPB{} } +func (m *PointPB) String() string { return proto.CompactTextString(m) } +func (*PointPB) ProtoMessage() {} +func (*PointPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{0} +} +func (m *PointPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PointPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PointPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PointPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_PointPB.Merge(m, src) +} +func (m *PointPB) XXX_Size() int { + return m.Size() +} +func (m *PointPB) XXX_DiscardUnknown() { + xxx_messageInfo_PointPB.DiscardUnknown(m) +} + +var xxx_messageInfo_PointPB proto.InternalMessageInfo + +func (m *PointPB) GetX() uint32 { + if m != nil { + return m.X + } + return 0 +} + +func (m *PointPB) GetY() uint32 { + if m != nil { + return m.Y + } + return 0 +} + +func (m *PointPB) GetZ() uint32 { + if m != nil { + return m.Z + } + return 0 +} + +type PointsPB struct { + Points []*PointPB `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PointsPB) Reset() { *m = PointsPB{} } +func (m *PointsPB) String() string { return proto.CompactTextString(m) } +func (*PointsPB) ProtoMessage() {} +func (*PointsPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{1} +} +func (m *PointsPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PointsPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PointsPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PointsPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_PointsPB.Merge(m, src) +} +func (m *PointsPB) XXX_Size() int { + return m.Size() +} +func (m *PointsPB) XXX_DiscardUnknown() { + xxx_messageInfo_PointsPB.DiscardUnknown(m) +} + +var xxx_messageInfo_PointsPB proto.InternalMessageInfo + +func (m *PointsPB) GetPoints() []*PointPB { + if m != nil { + return m.Points + } + return nil +} + +type NotFound struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NotFound) Reset() { *m = NotFound{} } +func (m *NotFound) String() string { return proto.CompactTextString(m) } +func (*NotFound) ProtoMessage() {} +func (*NotFound) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{2} +} +func (m *NotFound) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NotFound) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NotFound.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NotFound) XXX_Merge(src proto.Message) { + xxx_messageInfo_NotFound.Merge(m, src) +} +func (m *NotFound) XXX_Size() int { + return m.Size() +} +func (m *NotFound) XXX_DiscardUnknown() { + xxx_messageInfo_NotFound.DiscardUnknown(m) +} + +var xxx_messageInfo_NotFound proto.InternalMessageInfo + +type StrValue struct { + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StrValue) Reset() { *m = StrValue{} } +func (m *StrValue) String() string { return proto.CompactTextString(m) } +func (*StrValue) ProtoMessage() {} +func (*StrValue) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{3} +} +func (m *StrValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StrValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StrValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StrValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_StrValue.Merge(m, src) +} +func (m *StrValue) XXX_Size() int { + return m.Size() +} +func (m *StrValue) XXX_DiscardUnknown() { + xxx_messageInfo_StrValue.DiscardUnknown(m) +} + +var xxx_messageInfo_StrValue proto.InternalMessageInfo + +func (m *StrValue) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func (m *StrValue) GetFlags() int32 { + if m != nil { + return m.Flags + } + return 0 +} + +type LongValue struct { + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LongValue) Reset() { *m = LongValue{} } +func (m *LongValue) String() string { return proto.CompactTextString(m) } +func (*LongValue) ProtoMessage() {} +func (*LongValue) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{4} +} +func (m *LongValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LongValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LongValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LongValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_LongValue.Merge(m, src) +} +func (m *LongValue) XXX_Size() int { + return m.Size() +} +func (m *LongValue) XXX_DiscardUnknown() { + xxx_messageInfo_LongValue.DiscardUnknown(m) +} + +var xxx_messageInfo_LongValue proto.InternalMessageInfo + +func (m *LongValue) GetValue() int64 { + if m != nil { + return m.Value + } + return 0 +} + +func (m *LongValue) GetFlags() int32 { + if m != nil { + return m.Flags + } + return 0 +} + +type StrValueWithTime struct { + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + ModificationTime int32 `protobuf:"varint,3,opt,name=modification_time,json=modificationTime,proto3" json:"modification_time,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StrValueWithTime) Reset() { *m = StrValueWithTime{} } +func (m *StrValueWithTime) String() string { return proto.CompactTextString(m) } +func (*StrValueWithTime) ProtoMessage() {} +func (*StrValueWithTime) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{5} +} +func (m *StrValueWithTime) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StrValueWithTime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StrValueWithTime.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StrValueWithTime) XXX_Merge(src proto.Message) { + xxx_messageInfo_StrValueWithTime.Merge(m, src) +} +func (m *StrValueWithTime) XXX_Size() int { + return m.Size() +} +func (m *StrValueWithTime) XXX_DiscardUnknown() { + xxx_messageInfo_StrValueWithTime.DiscardUnknown(m) +} + +var xxx_messageInfo_StrValueWithTime proto.InternalMessageInfo + +func (m *StrValueWithTime) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func (m *StrValueWithTime) GetFlags() int32 { + if m != nil { + return m.Flags + } + return 0 +} + +func (m *StrValueWithTime) GetModificationTime() int32 { + if m != nil { + return m.ModificationTime + } + return 0 +} + +type LongValueWithTime struct { + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + ModificationTime int32 `protobuf:"varint,3,opt,name=modification_time,json=modificationTime,proto3" json:"modification_time,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LongValueWithTime) Reset() { *m = LongValueWithTime{} } +func (m *LongValueWithTime) String() string { return proto.CompactTextString(m) } +func (*LongValueWithTime) ProtoMessage() {} +func (*LongValueWithTime) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{6} +} +func (m *LongValueWithTime) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LongValueWithTime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LongValueWithTime.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LongValueWithTime) XXX_Merge(src proto.Message) { + xxx_messageInfo_LongValueWithTime.Merge(m, src) +} +func (m *LongValueWithTime) XXX_Size() int { + return m.Size() +} +func (m *LongValueWithTime) XXX_DiscardUnknown() { + xxx_messageInfo_LongValueWithTime.DiscardUnknown(m) +} + +var xxx_messageInfo_LongValueWithTime proto.InternalMessageInfo + +func (m *LongValueWithTime) GetValue() int64 { + if m != nil { + return m.Value + } + return 0 +} + +func (m *LongValueWithTime) GetFlags() int32 { + if m != nil { + return m.Flags + } + return 0 +} + +func (m *LongValueWithTime) GetModificationTime() int32 { + if m != nil { + return m.ModificationTime + } + return 0 +} + +type StrValueWithDelay struct { + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + Flags int32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"` + Delay int32 `protobuf:"varint,3,opt,name=delay,proto3" json:"delay,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StrValueWithDelay) Reset() { *m = StrValueWithDelay{} } +func (m *StrValueWithDelay) String() string { return proto.CompactTextString(m) } +func (*StrValueWithDelay) ProtoMessage() {} +func (*StrValueWithDelay) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{7} +} +func (m *StrValueWithDelay) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StrValueWithDelay) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StrValueWithDelay.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StrValueWithDelay) XXX_Merge(src proto.Message) { + xxx_messageInfo_StrValueWithDelay.Merge(m, src) +} +func (m *StrValueWithDelay) XXX_Size() int { + return m.Size() +} +func (m *StrValueWithDelay) XXX_DiscardUnknown() { + xxx_messageInfo_StrValueWithDelay.DiscardUnknown(m) +} + +var xxx_messageInfo_StrValueWithDelay proto.InternalMessageInfo + +func (m *StrValueWithDelay) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func (m *StrValueWithDelay) GetFlags() int32 { + if m != nil { + return m.Flags + } + return 0 +} + +func (m *StrValueWithDelay) GetDelay() int32 { + if m != nil { + return m.Delay + } + return 0 +} + +type Value struct { + // Types that are valid to be assigned to Kind: + // + // *Value_NotFound + // *Value_Strvalue + // *Value_Longvalue + // *Value_StrvalueWithTime + // *Value_LongvalueWithTime + // *Value_StrvalueWithDelay + Kind isValue_Kind `protobuf_oneof:"kind"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Value) Reset() { *m = Value{} } +func (m *Value) String() string { return proto.CompactTextString(m) } +func (*Value) ProtoMessage() {} +func (*Value) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{8} +} +func (m *Value) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Value.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_Value.Merge(m, src) +} +func (m *Value) XXX_Size() int { + return m.Size() +} +func (m *Value) XXX_DiscardUnknown() { + xxx_messageInfo_Value.DiscardUnknown(m) +} + +var xxx_messageInfo_Value proto.InternalMessageInfo + +type isValue_Kind interface { + isValue_Kind() + MarshalTo([]byte) (int, error) + Size() int +} + +type Value_NotFound struct { + NotFound *NotFound `protobuf:"bytes,1,opt,name=not_found,json=notFound,proto3,oneof" json:"not_found,omitempty"` +} +type Value_Strvalue struct { + Strvalue *StrValue `protobuf:"bytes,2,opt,name=strvalue,proto3,oneof" json:"strvalue,omitempty"` +} +type Value_Longvalue struct { + Longvalue *LongValue `protobuf:"bytes,3,opt,name=longvalue,proto3,oneof" json:"longvalue,omitempty"` +} +type Value_StrvalueWithTime struct { + StrvalueWithTime *StrValueWithTime `protobuf:"bytes,4,opt,name=strvalue_with_time,json=strvalueWithTime,proto3,oneof" json:"strvalue_with_time,omitempty"` +} +type Value_LongvalueWithTime struct { + LongvalueWithTime *LongValueWithTime `protobuf:"bytes,5,opt,name=longvalue_with_time,json=longvalueWithTime,proto3,oneof" json:"longvalue_with_time,omitempty"` +} +type Value_StrvalueWithDelay struct { + StrvalueWithDelay *StrValueWithDelay `protobuf:"bytes,6,opt,name=strvalue_with_delay,json=strvalueWithDelay,proto3,oneof" json:"strvalue_with_delay,omitempty"` +} + +func (*Value_NotFound) isValue_Kind() {} +func (*Value_Strvalue) isValue_Kind() {} +func (*Value_Longvalue) isValue_Kind() {} +func (*Value_StrvalueWithTime) isValue_Kind() {} +func (*Value_LongvalueWithTime) isValue_Kind() {} +func (*Value_StrvalueWithDelay) isValue_Kind() {} + +func (m *Value) GetKind() isValue_Kind { + if m != nil { + return m.Kind + } + return nil +} + +func (m *Value) GetNotFound() *NotFound { + if x, ok := m.GetKind().(*Value_NotFound); ok { + return x.NotFound + } + return nil +} + +func (m *Value) GetStrvalue() *StrValue { + if x, ok := m.GetKind().(*Value_Strvalue); ok { + return x.Strvalue + } + return nil +} + +func (m *Value) GetLongvalue() *LongValue { + if x, ok := m.GetKind().(*Value_Longvalue); ok { + return x.Longvalue + } + return nil +} + +func (m *Value) GetStrvalueWithTime() *StrValueWithTime { + if x, ok := m.GetKind().(*Value_StrvalueWithTime); ok { + return x.StrvalueWithTime + } + return nil +} + +func (m *Value) GetLongvalueWithTime() *LongValueWithTime { + if x, ok := m.GetKind().(*Value_LongvalueWithTime); ok { + return x.LongvalueWithTime + } + return nil +} + +func (m *Value) GetStrvalueWithDelay() *StrValueWithDelay { + if x, ok := m.GetKind().(*Value_StrvalueWithDelay); ok { + return x.StrvalueWithDelay + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Value) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Value_NotFound)(nil), + (*Value_Strvalue)(nil), + (*Value_Longvalue)(nil), + (*Value_StrvalueWithTime)(nil), + (*Value_LongvalueWithTime)(nil), + (*Value_StrvalueWithDelay)(nil), + } +} + +type Values struct { + Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Values) Reset() { *m = Values{} } +func (m *Values) String() string { return proto.CompactTextString(m) } +func (*Values) ProtoMessage() {} +func (*Values) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{9} +} +func (m *Values) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Values) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Values.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Values) XXX_Merge(src proto.Message) { + xxx_messageInfo_Values.Merge(m, src) +} +func (m *Values) XXX_Size() int { + return m.Size() +} +func (m *Values) XXX_DiscardUnknown() { + xxx_messageInfo_Values.DiscardUnknown(m) +} + +var xxx_messageInfo_Values proto.InternalMessageInfo + +func (m *Values) GetValues() []*Value { + if m != nil { + return m.Values + } + return nil +} + +type PartialPointPB struct { + Mask uint32 `protobuf:"varint,1,opt,name=mask,proto3" json:"mask,omitempty"` + X uint32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"` + Y uint32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"` + Z uint32 `protobuf:"varint,4,opt,name=z,proto3" json:"z,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PartialPointPB) Reset() { *m = PartialPointPB{} } +func (m *PartialPointPB) String() string { return proto.CompactTextString(m) } +func (*PartialPointPB) ProtoMessage() {} +func (*PartialPointPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{10} +} +func (m *PartialPointPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PartialPointPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PartialPointPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PartialPointPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_PartialPointPB.Merge(m, src) +} +func (m *PartialPointPB) XXX_Size() int { + return m.Size() +} +func (m *PartialPointPB) XXX_DiscardUnknown() { + xxx_messageInfo_PartialPointPB.DiscardUnknown(m) +} + +var xxx_messageInfo_PartialPointPB proto.InternalMessageInfo + +func (m *PartialPointPB) GetMask() uint32 { + if m != nil { + return m.Mask + } + return 0 +} + +func (m *PartialPointPB) GetX() uint32 { + if m != nil { + return m.X + } + return 0 +} + +func (m *PartialPointPB) GetY() uint32 { + if m != nil { + return m.Y + } + return 0 +} + +func (m *PartialPointPB) GetZ() uint32 { + if m != nil { + return m.Z + } + return 0 +} + +type PartialPointsPB struct { + Points []*PartialPointPB `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PartialPointsPB) Reset() { *m = PartialPointsPB{} } +func (m *PartialPointsPB) String() string { return proto.CompactTextString(m) } +func (*PartialPointsPB) ProtoMessage() {} +func (*PartialPointsPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{11} +} +func (m *PartialPointsPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PartialPointsPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PartialPointsPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PartialPointsPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_PartialPointsPB.Merge(m, src) +} +func (m *PartialPointsPB) XXX_Size() int { + return m.Size() +} +func (m *PartialPointsPB) XXX_DiscardUnknown() { + xxx_messageInfo_PartialPointsPB.DiscardUnknown(m) +} + +var xxx_messageInfo_PartialPointsPB proto.InternalMessageInfo + +func (m *PartialPointsPB) GetPoints() []*PartialPointPB { + if m != nil { + return m.Points + } + return nil +} + +type UnionPointValuePB struct { + Mask uint32 `protobuf:"varint,1,opt,name=mask,proto3" json:"mask,omitempty"` + X uint32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"` + Y uint32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"` + Z uint32 `protobuf:"varint,4,opt,name=z,proto3" json:"z,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UnionPointValuePB) Reset() { *m = UnionPointValuePB{} } +func (m *UnionPointValuePB) String() string { return proto.CompactTextString(m) } +func (*UnionPointValuePB) ProtoMessage() {} +func (*UnionPointValuePB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{12} +} +func (m *UnionPointValuePB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnionPointValuePB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnionPointValuePB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UnionPointValuePB) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnionPointValuePB.Merge(m, src) +} +func (m *UnionPointValuePB) XXX_Size() int { + return m.Size() +} +func (m *UnionPointValuePB) XXX_DiscardUnknown() { + xxx_messageInfo_UnionPointValuePB.DiscardUnknown(m) +} + +var xxx_messageInfo_UnionPointValuePB proto.InternalMessageInfo + +func (m *UnionPointValuePB) GetMask() uint32 { + if m != nil { + return m.Mask + } + return 0 +} + +func (m *UnionPointValuePB) GetX() uint32 { + if m != nil { + return m.X + } + return 0 +} + +func (m *UnionPointValuePB) GetY() uint32 { + if m != nil { + return m.Y + } + return 0 +} + +func (m *UnionPointValuePB) GetZ() uint32 { + if m != nil { + return m.Z + } + return 0 +} + +type UnionPointErrorPB struct { + Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UnionPointErrorPB) Reset() { *m = UnionPointErrorPB{} } +func (m *UnionPointErrorPB) String() string { return proto.CompactTextString(m) } +func (*UnionPointErrorPB) ProtoMessage() {} +func (*UnionPointErrorPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{13} +} +func (m *UnionPointErrorPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnionPointErrorPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnionPointErrorPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UnionPointErrorPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnionPointErrorPB.Merge(m, src) +} +func (m *UnionPointErrorPB) XXX_Size() int { + return m.Size() +} +func (m *UnionPointErrorPB) XXX_DiscardUnknown() { + xxx_messageInfo_UnionPointErrorPB.DiscardUnknown(m) +} + +var xxx_messageInfo_UnionPointErrorPB proto.InternalMessageInfo + +func (m *UnionPointErrorPB) GetErr() string { + if m != nil { + return m.Err + } + return "" +} + +type UnionPointPB struct { + // Types that are valid to be assigned to Kind: + // + // *UnionPointPB_Value + // *UnionPointPB_Error + Kind isUnionPointPB_Kind `protobuf_oneof:"kind"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UnionPointPB) Reset() { *m = UnionPointPB{} } +func (m *UnionPointPB) String() string { return proto.CompactTextString(m) } +func (*UnionPointPB) ProtoMessage() {} +func (*UnionPointPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{14} +} +func (m *UnionPointPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnionPointPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnionPointPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UnionPointPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnionPointPB.Merge(m, src) +} +func (m *UnionPointPB) XXX_Size() int { + return m.Size() +} +func (m *UnionPointPB) XXX_DiscardUnknown() { + xxx_messageInfo_UnionPointPB.DiscardUnknown(m) +} + +var xxx_messageInfo_UnionPointPB proto.InternalMessageInfo + +type isUnionPointPB_Kind interface { + isUnionPointPB_Kind() + MarshalTo([]byte) (int, error) + Size() int +} + +type UnionPointPB_Value struct { + Value *UnionPointValuePB `protobuf:"bytes,1,opt,name=value,proto3,oneof" json:"value,omitempty"` +} +type UnionPointPB_Error struct { + Error *UnionPointErrorPB `protobuf:"bytes,2,opt,name=error,proto3,oneof" json:"error,omitempty"` +} + +func (*UnionPointPB_Value) isUnionPointPB_Kind() {} +func (*UnionPointPB_Error) isUnionPointPB_Kind() {} + +func (m *UnionPointPB) GetKind() isUnionPointPB_Kind { + if m != nil { + return m.Kind + } + return nil +} + +func (m *UnionPointPB) GetValue() *UnionPointValuePB { + if x, ok := m.GetKind().(*UnionPointPB_Value); ok { + return x.Value + } + return nil +} + +func (m *UnionPointPB) GetError() *UnionPointErrorPB { + if x, ok := m.GetKind().(*UnionPointPB_Error); ok { + return x.Error + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*UnionPointPB) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*UnionPointPB_Value)(nil), + (*UnionPointPB_Error)(nil), + } +} + +type UnionPointsPB struct { + Points []*UnionPointPB `protobuf:"bytes,1,rep,name=points,proto3" json:"points,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UnionPointsPB) Reset() { *m = UnionPointsPB{} } +func (m *UnionPointsPB) String() string { return proto.CompactTextString(m) } +func (*UnionPointsPB) ProtoMessage() {} +func (*UnionPointsPB) Descriptor() ([]byte, []int) { + return fileDescriptor_8a78604d82c90401, []int{15} +} +func (m *UnionPointsPB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnionPointsPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnionPointsPB.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UnionPointsPB) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnionPointsPB.Merge(m, src) +} +func (m *UnionPointsPB) XXX_Size() int { + return m.Size() +} +func (m *UnionPointsPB) XXX_DiscardUnknown() { + xxx_messageInfo_UnionPointsPB.DiscardUnknown(m) +} + +var xxx_messageInfo_UnionPointsPB proto.InternalMessageInfo + +func (m *UnionPointsPB) GetPoints() []*UnionPointPB { + if m != nil { + return m.Points + } + return nil +} + +func init() { + proto.RegisterType((*PointPB)(nil), "tl_fast.PointPB") + proto.RegisterType((*PointsPB)(nil), "tl_fast.PointsPB") + proto.RegisterType((*NotFound)(nil), "tl_fast.NotFound") + proto.RegisterType((*StrValue)(nil), "tl_fast.StrValue") + proto.RegisterType((*LongValue)(nil), "tl_fast.LongValue") + proto.RegisterType((*StrValueWithTime)(nil), "tl_fast.StrValueWithTime") + proto.RegisterType((*LongValueWithTime)(nil), "tl_fast.LongValueWithTime") + proto.RegisterType((*StrValueWithDelay)(nil), "tl_fast.StrValueWithDelay") + proto.RegisterType((*Value)(nil), "tl_fast.Value") + proto.RegisterType((*Values)(nil), "tl_fast.Values") + proto.RegisterType((*PartialPointPB)(nil), "tl_fast.PartialPointPB") + proto.RegisterType((*PartialPointsPB)(nil), "tl_fast.PartialPointsPB") + proto.RegisterType((*UnionPointValuePB)(nil), "tl_fast.UnionPointValuePB") + proto.RegisterType((*UnionPointErrorPB)(nil), "tl_fast.UnionPointErrorPB") + proto.RegisterType((*UnionPointPB)(nil), "tl_fast.UnionPointPB") + proto.RegisterType((*UnionPointsPB)(nil), "tl_fast.UnionPointsPB") +} + +func init() { proto.RegisterFile("speed_fast.proto", fileDescriptor_8a78604d82c90401) } + +var fileDescriptor_8a78604d82c90401 = []byte{ + // 618 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0xeb, 0xd8, 0x4d, 0xa6, 0x3f, 0xd8, 0x4b, 0x11, 0x81, 0x43, 0x54, 0x59, 0x02, 0x55, + 0x20, 0xe2, 0x2a, 0x45, 0x70, 0x41, 0x1c, 0xcc, 0x8f, 0x82, 0x28, 0xc5, 0x18, 0x5a, 0x24, 0x2e, + 0x91, 0xd3, 0x38, 0xc9, 0x2a, 0xce, 0x6e, 0x64, 0x6f, 0xa0, 0xe9, 0x81, 0x37, 0xe0, 0xce, 0x23, + 0x71, 0xe4, 0x11, 0x50, 0x78, 0x11, 0xb4, 0xbb, 0x5e, 0xc7, 0xf9, 0x11, 0x52, 0x05, 0xb7, 0x99, + 0xdd, 0xf9, 0xbe, 0xf9, 0x3c, 0xe3, 0x6f, 0xc1, 0x4a, 0xc7, 0x51, 0xd4, 0x6d, 0xf7, 0xc2, 0x94, + 0x35, 0xc6, 0x09, 0x65, 0x14, 0x6d, 0xb2, 0x58, 0xa4, 0xce, 0x11, 0x6c, 0xfa, 0x14, 0x13, 0xe6, + 0x7b, 0x68, 0x1b, 0xb4, 0x8b, 0x9a, 0xb6, 0xaf, 0x1d, 0xec, 0x04, 0xda, 0x05, 0xcf, 0xa6, 0xb5, + 0x0d, 0x99, 0x4d, 0x79, 0x76, 0x59, 0xd3, 0x65, 0x76, 0xe9, 0x3c, 0x84, 0x8a, 0x00, 0xa5, 0xbe, + 0x87, 0x0e, 0xc0, 0x1c, 0x8b, 0xb8, 0xa6, 0xed, 0xeb, 0x07, 0x5b, 0x4d, 0xab, 0x91, 0x51, 0x37, + 0x32, 0xde, 0x20, 0xbb, 0x77, 0x00, 0x2a, 0x27, 0x94, 0xbd, 0xa4, 0x13, 0xd2, 0x75, 0x1e, 0x41, + 0xe5, 0x3d, 0x4b, 0xce, 0xc2, 0x78, 0x12, 0xa1, 0x3d, 0x30, 0x3e, 0xf3, 0x40, 0xf4, 0xae, 0x06, + 0x32, 0xe1, 0xa7, 0xbd, 0x38, 0xec, 0xa7, 0x42, 0x83, 0x11, 0xc8, 0xc4, 0x79, 0x0c, 0xd5, 0x63, + 0x4a, 0xfa, 0x6b, 0x80, 0xfa, 0xdf, 0x81, 0x43, 0xb0, 0x54, 0xc3, 0x8f, 0x98, 0x0d, 0x3e, 0xe0, + 0xd1, 0x95, 0x1a, 0xa3, 0xfb, 0x60, 0x8f, 0x68, 0x17, 0xf7, 0xf0, 0x79, 0xc8, 0x30, 0x25, 0x6d, + 0x86, 0x47, 0x91, 0x18, 0x88, 0x11, 0x58, 0xc5, 0x0b, 0x4e, 0xec, 0xc4, 0x60, 0xe7, 0x2a, 0xd7, + 0x77, 0xd3, 0xff, 0x63, 0xb7, 0x53, 0xb0, 0x8b, 0x9f, 0xf6, 0x3c, 0x8a, 0xc3, 0xe9, 0x95, 0xbe, + 0x6d, 0x0f, 0x8c, 0x2e, 0x07, 0x65, 0x1d, 0x64, 0xe2, 0x7c, 0xd3, 0xc1, 0x90, 0x73, 0x3e, 0x84, + 0x2a, 0xa1, 0xac, 0xdd, 0xe3, 0x9b, 0x13, 0x7c, 0x5b, 0x4d, 0x3b, 0xdf, 0xb2, 0x5a, 0x69, 0xab, + 0x14, 0x54, 0x48, 0x16, 0x23, 0x17, 0x2a, 0x29, 0x4b, 0xa4, 0x80, 0x8d, 0x25, 0x80, 0xd2, 0xca, + 0x01, 0xaa, 0x08, 0x35, 0xa1, 0x1a, 0x53, 0xd2, 0x97, 0x08, 0x5d, 0x20, 0x50, 0x8e, 0xc8, 0x67, + 0xd9, 0x2a, 0x05, 0xf3, 0x32, 0xf4, 0x0a, 0x90, 0xc2, 0xb7, 0xbf, 0x60, 0x36, 0x90, 0x53, 0x2a, + 0x0b, 0xf0, 0xad, 0x95, 0x76, 0x6a, 0x0f, 0xad, 0x52, 0x60, 0x29, 0x58, 0xbe, 0x9b, 0x63, 0xb8, + 0x9e, 0xf3, 0x16, 0xb8, 0x0c, 0xc1, 0x75, 0x7b, 0x55, 0x48, 0x81, 0xcc, 0xce, 0x81, 0x45, 0xb6, + 0x45, 0x61, 0x72, 0xba, 0xe6, 0x12, 0xdb, 0xca, 0xd2, 0x38, 0x5b, 0x51, 0x9a, 0x38, 0xf4, 0x4c, + 0x28, 0x0f, 0x31, 0xe9, 0x3a, 0x87, 0x60, 0x8a, 0xf2, 0x14, 0xdd, 0x05, 0x53, 0xd4, 0x28, 0xcb, + 0xed, 0xe6, 0x94, 0xa2, 0x20, 0xc8, 0x6e, 0x9d, 0x13, 0xd8, 0xf5, 0xc3, 0x84, 0xe1, 0x30, 0x56, + 0x16, 0x47, 0x50, 0x1e, 0x85, 0xe9, 0x30, 0x73, 0xb9, 0x88, 0xa5, 0xed, 0x37, 0x16, 0x6c, 0xaf, + 0x2f, 0xd8, 0xbe, 0xac, 0x6c, 0xef, 0xc1, 0xb5, 0x22, 0x1f, 0x77, 0xbf, 0xbb, 0xe4, 0xfe, 0x9b, + 0x73, 0xf7, 0x2f, 0x74, 0xce, 0x1f, 0x81, 0x77, 0x60, 0x9f, 0x12, 0x4c, 0x89, 0x38, 0x17, 0x72, + 0xff, 0x59, 0xd6, 0x9d, 0x22, 0xe5, 0x8b, 0x24, 0xa1, 0x89, 0xef, 0x21, 0x0b, 0xf4, 0x28, 0x49, + 0xb2, 0xbf, 0x9f, 0x87, 0xce, 0x57, 0xd8, 0x9e, 0x97, 0xf9, 0x1e, 0x6a, 0x16, 0x1d, 0x52, 0xdc, + 0xcb, 0x8a, 0xbe, 0x56, 0x49, 0xf9, 0xa7, 0x09, 0x46, 0xc4, 0x1b, 0x64, 0x3f, 0xf5, 0x3a, 0x4c, + 0x26, 0x80, 0x63, 0x44, 0x69, 0xbe, 0xbf, 0xa7, 0xb0, 0x33, 0xaf, 0xe2, 0xb3, 0x7b, 0xb0, 0x34, + 0xbb, 0x1b, 0x6b, 0xd8, 0xe6, 0x93, 0xf3, 0x9e, 0xfc, 0x98, 0xd5, 0xb5, 0x9f, 0xb3, 0xba, 0xf6, + 0x6b, 0x56, 0xd7, 0xbe, 0xff, 0xae, 0x97, 0x3e, 0xdd, 0xeb, 0x63, 0x36, 0x98, 0x74, 0x1a, 0xe7, + 0x74, 0xe4, 0x9e, 0xbd, 0x7e, 0xf6, 0xf6, 0x8d, 0xcb, 0x62, 0x17, 0x13, 0x16, 0x25, 0x24, 0x8c, + 0x5d, 0xf1, 0xe6, 0xbb, 0xe3, 0x8e, 0xa0, 0xec, 0x98, 0xe2, 0xdd, 0x3f, 0xfa, 0x13, 0x00, 0x00, + 0xff, 0xff, 0x56, 0x0f, 0x7d, 0x07, 0x0b, 0x06, 0x00, 0x00, +} + +func (m *PointPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PointPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PointPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Z != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Z)) + i-- + dAtA[i] = 0x18 + } + if m.Y != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Y)) + i-- + dAtA[i] = 0x10 + } + if m.X != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.X)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PointsPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PointsPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PointsPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Points) > 0 { + for iNdEx := len(m.Points) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Points[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *NotFound) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NotFound) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NotFound) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + return len(dAtA) - i, nil +} + +func (m *StrValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StrValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StrValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Flags != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Flags)) + i-- + dAtA[i] = 0x10 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintSpeedFast(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LongValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LongValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LongValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Flags != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Flags)) + i-- + dAtA[i] = 0x10 + } + if m.Value != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StrValueWithTime) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StrValueWithTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StrValueWithTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.ModificationTime != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.ModificationTime)) + i-- + dAtA[i] = 0x18 + } + if m.Flags != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Flags)) + i-- + dAtA[i] = 0x10 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintSpeedFast(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LongValueWithTime) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LongValueWithTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LongValueWithTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.ModificationTime != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.ModificationTime)) + i-- + dAtA[i] = 0x18 + } + if m.Flags != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Flags)) + i-- + dAtA[i] = 0x10 + } + if m.Value != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Value)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StrValueWithDelay) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StrValueWithDelay) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StrValueWithDelay) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Delay != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Delay)) + i-- + dAtA[i] = 0x18 + } + if m.Flags != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Flags)) + i-- + dAtA[i] = 0x10 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintSpeedFast(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Value) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Value) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Kind != nil { + { + size := m.Kind.Size() + i -= size + if _, err := m.Kind.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Value_NotFound) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value_NotFound) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.NotFound != nil { + { + size, err := m.NotFound.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *Value_Strvalue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value_Strvalue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Strvalue != nil { + { + size, err := m.Strvalue.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *Value_Longvalue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value_Longvalue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Longvalue != nil { + { + size, err := m.Longvalue.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *Value_StrvalueWithTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value_StrvalueWithTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.StrvalueWithTime != nil { + { + size, err := m.StrvalueWithTime.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *Value_LongvalueWithTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value_LongvalueWithTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.LongvalueWithTime != nil { + { + size, err := m.LongvalueWithTime.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} +func (m *Value_StrvalueWithDelay) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Value_StrvalueWithDelay) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.StrvalueWithDelay != nil { + { + size, err := m.StrvalueWithDelay.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + return len(dAtA) - i, nil +} +func (m *Values) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Values) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Values) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Values) > 0 { + for iNdEx := len(m.Values) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Values[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PartialPointPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PartialPointPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PartialPointPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Z != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Z)) + i-- + dAtA[i] = 0x20 + } + if m.Y != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Y)) + i-- + dAtA[i] = 0x18 + } + if m.X != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.X)) + i-- + dAtA[i] = 0x10 + } + if m.Mask != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Mask)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PartialPointsPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PartialPointsPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PartialPointsPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Points) > 0 { + for iNdEx := len(m.Points) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Points[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *UnionPointValuePB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UnionPointValuePB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnionPointValuePB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Z != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Z)) + i-- + dAtA[i] = 0x20 + } + if m.Y != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Y)) + i-- + dAtA[i] = 0x18 + } + if m.X != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.X)) + i-- + dAtA[i] = 0x10 + } + if m.Mask != 0 { + i = encodeVarintSpeedFast(dAtA, i, uint64(m.Mask)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UnionPointErrorPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UnionPointErrorPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnionPointErrorPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Err) > 0 { + i -= len(m.Err) + copy(dAtA[i:], m.Err) + i = encodeVarintSpeedFast(dAtA, i, uint64(len(m.Err))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UnionPointPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UnionPointPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnionPointPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Kind != nil { + { + size := m.Kind.Size() + i -= size + if _, err := m.Kind.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *UnionPointPB_Value) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnionPointPB_Value) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Value != nil { + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *UnionPointPB_Error) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnionPointPB_Error) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Error != nil { + { + size, err := m.Error.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *UnionPointsPB) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UnionPointsPB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnionPointsPB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Points) > 0 { + for iNdEx := len(m.Points) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Points[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpeedFast(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintSpeedFast(dAtA []byte, offset int, v uint64) int { + offset -= sovSpeedFast(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PointPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.X != 0 { + n += 1 + sovSpeedFast(uint64(m.X)) + } + if m.Y != 0 { + n += 1 + sovSpeedFast(uint64(m.Y)) + } + if m.Z != 0 { + n += 1 + sovSpeedFast(uint64(m.Z)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *PointsPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Points) > 0 { + for _, e := range m.Points { + l = e.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *NotFound) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *StrValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovSpeedFast(uint64(l)) + } + if m.Flags != 0 { + n += 1 + sovSpeedFast(uint64(m.Flags)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *LongValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sovSpeedFast(uint64(m.Value)) + } + if m.Flags != 0 { + n += 1 + sovSpeedFast(uint64(m.Flags)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *StrValueWithTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovSpeedFast(uint64(l)) + } + if m.Flags != 0 { + n += 1 + sovSpeedFast(uint64(m.Flags)) + } + if m.ModificationTime != 0 { + n += 1 + sovSpeedFast(uint64(m.ModificationTime)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *LongValueWithTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sovSpeedFast(uint64(m.Value)) + } + if m.Flags != 0 { + n += 1 + sovSpeedFast(uint64(m.Flags)) + } + if m.ModificationTime != 0 { + n += 1 + sovSpeedFast(uint64(m.ModificationTime)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *StrValueWithDelay) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovSpeedFast(uint64(l)) + } + if m.Flags != 0 { + n += 1 + sovSpeedFast(uint64(m.Flags)) + } + if m.Delay != 0 { + n += 1 + sovSpeedFast(uint64(m.Delay)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Value) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Kind != nil { + n += m.Kind.Size() + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Value_NotFound) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NotFound != nil { + l = m.NotFound.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *Value_Strvalue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Strvalue != nil { + l = m.Strvalue.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *Value_Longvalue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Longvalue != nil { + l = m.Longvalue.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *Value_StrvalueWithTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StrvalueWithTime != nil { + l = m.StrvalueWithTime.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *Value_LongvalueWithTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LongvalueWithTime != nil { + l = m.LongvalueWithTime.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *Value_StrvalueWithDelay) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StrvalueWithDelay != nil { + l = m.StrvalueWithDelay.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *Values) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Values) > 0 { + for _, e := range m.Values { + l = e.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *PartialPointPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Mask != 0 { + n += 1 + sovSpeedFast(uint64(m.Mask)) + } + if m.X != 0 { + n += 1 + sovSpeedFast(uint64(m.X)) + } + if m.Y != 0 { + n += 1 + sovSpeedFast(uint64(m.Y)) + } + if m.Z != 0 { + n += 1 + sovSpeedFast(uint64(m.Z)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *PartialPointsPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Points) > 0 { + for _, e := range m.Points { + l = e.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UnionPointValuePB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Mask != 0 { + n += 1 + sovSpeedFast(uint64(m.Mask)) + } + if m.X != 0 { + n += 1 + sovSpeedFast(uint64(m.X)) + } + if m.Y != 0 { + n += 1 + sovSpeedFast(uint64(m.Y)) + } + if m.Z != 0 { + n += 1 + sovSpeedFast(uint64(m.Z)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UnionPointErrorPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Err) + if l > 0 { + n += 1 + l + sovSpeedFast(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UnionPointPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Kind != nil { + n += m.Kind.Size() + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UnionPointPB_Value) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != nil { + l = m.Value.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *UnionPointPB_Error) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Error != nil { + l = m.Error.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + return n +} +func (m *UnionPointsPB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Points) > 0 { + for _, e := range m.Points { + l = e.Size() + n += 1 + l + sovSpeedFast(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovSpeedFast(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSpeedFast(x uint64) (n int) { + return sovSpeedFast(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PointPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PointPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PointPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field X", wireType) + } + m.X = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.X |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Y", wireType) + } + m.Y = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Y |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Z", wireType) + } + m.Z = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Z |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PointsPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PointsPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PointsPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Points", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Points = append(m.Points, &PointPB{}) + if err := m.Points[len(m.Points)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NotFound) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NotFound: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NotFound: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StrValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StrValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StrValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + } + m.Flags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Flags |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LongValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LongValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LongValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + m.Value = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + } + m.Flags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Flags |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StrValueWithTime) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StrValueWithTime: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StrValueWithTime: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + } + m.Flags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Flags |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ModificationTime", wireType) + } + m.ModificationTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ModificationTime |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LongValueWithTime) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LongValueWithTime: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LongValueWithTime: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + m.Value = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + } + m.Flags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Flags |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ModificationTime", wireType) + } + m.ModificationTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ModificationTime |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StrValueWithDelay) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StrValueWithDelay: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StrValueWithDelay: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + } + m.Flags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Flags |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Delay", wireType) + } + m.Delay = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Delay |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Value) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Value: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NotFound", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &NotFound{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_NotFound{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Strvalue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &StrValue{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_Strvalue{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Longvalue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &LongValue{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_Longvalue{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StrvalueWithTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &StrValueWithTime{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_StrvalueWithTime{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LongvalueWithTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &LongValueWithTime{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_LongvalueWithTime{v} + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StrvalueWithDelay", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &StrValueWithDelay{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_StrvalueWithDelay{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Values) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Values: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Values: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Values = append(m.Values, &Value{}) + if err := m.Values[len(m.Values)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PartialPointPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PartialPointPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PartialPointPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Mask", wireType) + } + m.Mask = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Mask |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field X", wireType) + } + m.X = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.X |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Y", wireType) + } + m.Y = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Y |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Z", wireType) + } + m.Z = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Z |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PartialPointsPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PartialPointsPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PartialPointsPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Points", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Points = append(m.Points, &PartialPointPB{}) + if err := m.Points[len(m.Points)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnionPointValuePB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UnionPointValuePB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnionPointValuePB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Mask", wireType) + } + m.Mask = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Mask |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field X", wireType) + } + m.X = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.X |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Y", wireType) + } + m.Y = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Y |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Z", wireType) + } + m.Z = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Z |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnionPointErrorPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UnionPointErrorPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnionPointErrorPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Err", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Err = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnionPointPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UnionPointPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnionPointPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &UnionPointValuePB{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &UnionPointPB_Value{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &UnionPointErrorPB{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &UnionPointPB_Error{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnionPointsPB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UnionPointsPB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnionPointsPB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Points", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpeedFast + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpeedFast + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Points = append(m.Points, &UnionPointPB{}) + if err := m.Points[len(m.Points)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpeedFast(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpeedFast + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSpeedFast(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSpeedFast + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSpeedFast + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSpeedFast + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSpeedFast + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSpeedFast = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSpeedFast = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSpeedFast = fmt.Errorf("proto: unexpected end of group") +) diff --git a/internal/speed/speed_tl/basictl/basictl.go b/internal/speed/speed_tl/basictl/basictl.go new file mode 100644 index 000000000..f3409af44 --- /dev/null +++ b/internal/speed/speed_tl/basictl/basictl.go @@ -0,0 +1,844 @@ +// Code generated by tl2gen; DO NOT EDIT. +package basictl + +import ( + "encoding/base64" + "encoding/binary" + "fmt" + "io" + "math" + "strconv" + "unicode/utf8" + + "github.com/mailru/easyjson/jlexer" +) + +const ( + tinyStringLen = 253 + mediumStringMarker = 254 + hugeStringMarker = 255 + maxMediumStringLen = (1 << 24) - 1 + maxHugeStringLen = (1 << 56) - 1 +) + +type JSONWriteContext struct { + LegacyTypeNames bool + Short bool + + IsTL2 bool +} + +type JSONReadContext struct { + LegacyTypeNames bool + + IsTL2 bool +} + +type JsonLexer = jlexer.Lexer + +var errBadPadding = fmt.Errorf("non-canonical non-zero string padding") + +func CheckLengthSanity(r []byte, natParam uint32, minObjectSize uint32) error { + if uint64(len(r)) < uint64(natParam)*uint64(minObjectSize) { + return fmt.Errorf("invalid length: %d for remaining reader length: %d and min object size %d: %w", natParam, len(r), minObjectSize, io.ErrUnexpectedEOF) + } + return nil +} + +func ReadBool(r []byte, v *bool, falseTag uint32, trueTag uint32) ([]byte, error) { + tag, r, err := NatReadTag(r) + if err != nil { + return r, err + } + switch tag { + case falseTag: + *v = false + case trueTag: + *v = true + default: + return r, fmt.Errorf("invalid bool tag: 0x%x", tag) + } + return r, nil +} + +func NatRead(r []byte, dst *uint32) ([]byte, error) { + if len(r) < 4 { + return r, io.ErrUnexpectedEOF + } + *dst = binary.LittleEndian.Uint32(r) + return r[4:], nil +} + +func NatWrite(w []byte, v uint32) []byte { + return append(w, byte(v), byte(v>>8), byte(v>>16), byte(v>>24)) +} + +func nat64Write(w []byte, v uint64) []byte { + return append(w, byte(v), byte(v>>8), byte(v>>16), byte(v>>24), byte(v>>32), byte(v>>40), byte(v>>48), byte(v>>56)) +} + +func IntRead(r []byte, dst *int32) ([]byte, error) { + if len(r) < 4 { + return r, io.ErrUnexpectedEOF + } + *dst = int32(binary.LittleEndian.Uint32(r)) + return r[4:], nil +} + +func IntWrite(w []byte, v int32) []byte { + return append(w, byte(v), byte(v>>8), byte(v>>16), byte(v>>24)) +} + +func LongRead(r []byte, dst *int64) ([]byte, error) { + if len(r) < 8 { + return r, io.ErrUnexpectedEOF + } + *dst = int64(binary.LittleEndian.Uint64(r)) + return r[8:], nil +} + +func LongWrite(w []byte, v int64) []byte { + return nat64Write(w, uint64(v)) +} + +func FloatRead(r []byte, dst *float32) ([]byte, error) { + if len(r) < 4 { + return r, io.ErrUnexpectedEOF + } + *dst = math.Float32frombits(binary.LittleEndian.Uint32(r)) + return r[4:], nil +} + +func FloatWrite(w []byte, v float32) []byte { + return NatWrite(w, math.Float32bits(v)) +} + +func DoubleRead(r []byte, dst *float64) ([]byte, error) { + if len(r) < 8 { + return r, io.ErrUnexpectedEOF + } + *dst = math.Float64frombits(binary.LittleEndian.Uint64(r)) + return r[8:], nil +} + +func DoubleWrite(w []byte, v float64) []byte { + return nat64Write(w, math.Float64bits(v)) +} + +func StringRead(r []byte, dst *string) ([]byte, error) { + if len(r) == 0 { + return r, io.ErrUnexpectedEOF + } + b0 := r[0] + + var l int + var p int + switch { + case b0 <= tinyStringLen: + l = int(b0) + r = r[1:] + p = l + 1 + case b0 == mediumStringMarker: + if len(r) < 4 { + return r, io.ErrUnexpectedEOF + } + l = (int(r[3]) << 16) + (int(r[2]) << 8) + (int(r[1]) << 0) + r = r[4:] + p = l // +4 + if l <= tinyStringLen { + return r, fmt.Errorf("non-canonical (medium) string format for length: %d", l) + } + default: // hugeStringMarker + if len(r) < 8 { + return r, io.ErrUnexpectedEOF + } + l64 := (uint64(r[7]) << 48) + (uint64(r[6]) << 40) + (uint64(r[5]) << 32) + (uint64(r[4]) << 24) + (uint64(r[3]) << 16) + (uint64(r[2]) << 8) + (uint64(r[1]) << 0) + r = r[8:] + if l64 > math.MaxInt { + return r, fmt.Errorf("string length cannot be represented on 32-bit platform: %d", l64) + } + l = int(l64) + p = l // +8 + if l <= maxMediumStringLen { + return r, fmt.Errorf("non-canonical (huge) string format for length: %d", l) + } + } + + if len(r) < l { + return r, io.ErrUnexpectedEOF + } + + *dst = string(r[:l]) + + padding := paddingLen(p) + if len(r) < l+padding { + return r, io.ErrUnexpectedEOF + } + for i := 0; i < padding; i++ { + if r[l+i] != 0 { + return r, errBadPadding + } + } + return r[l+padding:], nil +} + +func StringReadBytes(r []byte, dst *[]byte) ([]byte, error) { + if len(r) == 0 { + return r, io.ErrUnexpectedEOF + } + b0 := r[0] + + var l int + var p int + switch { + case b0 <= tinyStringLen: + l = int(b0) + r = r[1:] + p = l + 1 + case b0 == mediumStringMarker: + if len(r) < 4 { + return r, io.ErrUnexpectedEOF + } + l = (int(r[3]) << 16) + (int(r[2]) << 8) + (int(r[1]) << 0) + r = r[4:] + p = l // +4 + if l <= tinyStringLen { + return r, fmt.Errorf("non-canonical (medium) string format for length: %d", l) + } + default: // hugeStringMarker + if len(r) < 8 { + return r, io.ErrUnexpectedEOF + } + l64 := (uint64(r[7]) << 48) + (uint64(r[6]) << 40) + (uint64(r[5]) << 32) + (uint64(r[4]) << 24) + (uint64(r[3]) << 16) + (uint64(r[2]) << 8) + (uint64(r[1]) << 0) + r = r[8:] + if l64 > math.MaxInt { + return r, fmt.Errorf("string length cannot be represented as int: %d", l64) + } + l = int(l64) + p = l // +8 + if l <= maxMediumStringLen { + return r, fmt.Errorf("non-canonical (huge) string format for length: %d", l) + } + } + + if l > 0 { + if len(r) < l { + return r, io.ErrUnexpectedEOF + } + // Allocate only after we know there is enough bytes in reader + if cap(*dst) < l { + *dst = make([]byte, l) + } else { + *dst = (*dst)[:l] + } + copy(*dst, r) + } else { + *dst = (*dst)[:0] + } + padding := paddingLen(p) + if len(r) < l+padding { + return r, io.ErrUnexpectedEOF + } + for i := 0; i < padding; i++ { + if r[l+i] != 0 { + return r, errBadPadding + } + } + return r[l+padding:], nil +} + +func NatPeekTag(r []byte) (uint32, error) { + if len(r) < 4 { + return 0, io.ErrUnexpectedEOF + } + return binary.LittleEndian.Uint32(r), nil +} + +func NatReadTag(r []byte) (uint32, []byte, error) { + if len(r) < 4 { + return 0, r, io.ErrUnexpectedEOF + } + return binary.LittleEndian.Uint32(r), r[4:], nil +} + +func NatReadExactTag(r []byte, tag uint32) ([]byte, error) { + if len(r) < 4 { + return r, io.ErrUnexpectedEOF + } + if t := binary.LittleEndian.Uint32(r); t != tag { + return r, fmt.Errorf("read tag #%08x instead of #%08x", t, tag) + } + return r[4:], nil +} + +func paddingLen(l int) int { + return int(-uint(l) % 4) +} + +func StringWrite(w []byte, v string) []byte { + l := int64(len(v)) + var p int64 + switch { + case l <= tinyStringLen: + w = append(w, byte(l)) + p = l + 1 + case l <= maxMediumStringLen: + w = append(w, mediumStringMarker, byte(l), byte(l>>8), byte(l>>16)) + p = l // +4 + default: + if l > maxHugeStringLen { // for correctness only, we do not expect strings so huge + l = maxHugeStringLen + v = v[:l] + } + w = append(w, hugeStringMarker, byte(l), byte(l>>8), byte(l>>16), byte(l>>24), byte(l>>32), byte(l>>40), byte(l>>48)) + p = l // +8 + } + w = append(w, v...) + + // w is sometimes slice of byte array, so we do not want optimization to always append 3 bytes, then resize. + switch uint64(p) % 4 { + case 1: + w = append(w, 0, 0, 0) + case 2: + w = append(w, 0, 0) + case 3: + w = append(w, 0) + } + return w +} + +func StringWriteBytes(w []byte, v []byte) []byte { + l := int64(len(v)) + var p int64 + switch { + case l <= tinyStringLen: + w = append(w, byte(l)) + p = l + 1 + case l <= maxMediumStringLen: + w = append(w, mediumStringMarker, byte(l), byte(l>>8), byte(l>>16)) + p = l // +4 + default: + if l > maxHugeStringLen { // for correctness only, we do not expect strings so huge + l = maxHugeStringLen + v = v[:l] + } + w = append(w, hugeStringMarker, byte(l), byte(l>>8), byte(l>>16), byte(l>>24), byte(l>>32), byte(l>>40), byte(l>>48)) + p = l // +8 + } + w = append(w, v...) + + // w is sometimes slice of byte array, so we do not want optimization to always append 3 bytes, then resize. + switch uint64(p) % 4 { + case 1: + w = append(w, 0, 0, 0) + case 2: + w = append(w, 0, 0) + case 3: + w = append(w, 0) + } + return w +} + +func JSONWriteBool(w []byte, v bool) []byte { + return append(w, strconv.FormatBool(v)...) +} + +func JSONWriteByte(w []byte, v byte) []byte { + return strconv.AppendUint(w, uint64(v), 10) +} + +func JSONWriteUint32(w []byte, v uint32) []byte { + return strconv.AppendUint(w, uint64(v), 10) +} + +func JSONWriteInt32(w []byte, v int32) []byte { + return strconv.AppendInt(w, int64(v), 10) +} + +func JSONWriteUint64(w []byte, v uint64) []byte { + return strconv.AppendUint(w, v, 10) +} + +func JSONWriteInt64(w []byte, v int64) []byte { + return strconv.AppendInt(w, v, 10) +} + +func jsonWriteFloatSpecial(w []byte, v float64) ([]byte, bool) { + if math.IsNaN(v) { + return append(w, "\"NaN\""...), true + } + if math.IsInf(v, 1) { + return append(w, "\"+Inf\""...), true + } + if math.IsInf(v, -1) { + return append(w, "\"-Inf\""...), true + } + return w, false +} + +func JSONWriteFloat32(w []byte, v float32) []byte { + if ws, ok := jsonWriteFloatSpecial(w, float64(v)); ok { + return ws + } + return strconv.AppendFloat(w, float64(v), 'f', -1, 32) +} + +func JSONWriteFloat64(w []byte, v float64) []byte { + if ws, ok := jsonWriteFloatSpecial(w, v); ok { + return ws + } + return strconv.AppendFloat(w, v, 'f', -1, 64) +} + +func JSONAddCommaIfNeeded(w []byte) []byte { // Never called on empty buffer, so panic is ok + lastChar := w[len(w)-1] + if lastChar != '{' && lastChar != '[' { + return append(w, ',') + } + return w +} + +// JSON string escaping is below, keep in sync with go/src/encoding/json/encode.go + +const hex = "0123456789abcdef" + +var safeSet = [utf8.RuneSelf]bool{ + ' ': true, + '!': true, + '"': false, + '#': true, + '$': true, + '%': true, + '&': true, + '\'': true, + '(': true, + ')': true, + '*': true, + '+': true, + ',': true, + '-': true, + '.': true, + '/': true, + '0': true, + '1': true, + '2': true, + '3': true, + '4': true, + '5': true, + '6': true, + '7': true, + '8': true, + '9': true, + ':': true, + ';': true, + '<': true, + '=': true, + '>': true, + '?': true, + '@': true, + 'A': true, + 'B': true, + 'C': true, + 'D': true, + 'E': true, + 'F': true, + 'G': true, + 'H': true, + 'I': true, + 'J': true, + 'K': true, + 'L': true, + 'M': true, + 'N': true, + 'O': true, + 'P': true, + 'Q': true, + 'R': true, + 'S': true, + 'T': true, + 'U': true, + 'V': true, + 'W': true, + 'X': true, + 'Y': true, + 'Z': true, + '[': true, + '\\': false, + ']': true, + '^': true, + '_': true, + '\x60': true, + 'a': true, + 'b': true, + 'c': true, + 'd': true, + 'e': true, + 'f': true, + 'g': true, + 'h': true, + 'i': true, + 'j': true, + 'k': true, + 'l': true, + 'm': true, + 'n': true, + 'o': true, + 'p': true, + 'q': true, + 'r': true, + 's': true, + 't': true, + 'u': true, + 'v': true, + 'w': true, + 'x': true, + 'y': true, + 'z': true, + '{': true, + '|': true, + '}': true, + '~': true, + '\u007f': true, +} + +const ( + binaryJSONStringStart = "{\"base64\":\"" + binaryJSONStringEnd = "\"}" +) + +func alloc(buf []byte, size int) []byte { + if cap(buf) >= len(buf)+size { + return buf[:len(buf)+size] + } + return append(buf, make([]byte, size)...) +} + +// NOTE: keep in sync with stringBytes below. + +func JSONWriteString(w []byte, s string) []byte { + if !utf8.ValidString(s) { + w = append(w, binaryJSONStringStart...) + beforeAllocation := len(w) + w = alloc(w, base64.StdEncoding.EncodedLen(len(s))) + base64.StdEncoding.Encode(w[beforeAllocation:], []byte(s)) + return append(w, binaryJSONStringEnd...) + } + w = append(w, '"') + start := 0 + for i := 0; i < len(s); { + if b := s[i]; b < utf8.RuneSelf { + if safeSet[b] { + i++ + continue + } + if start < i { + w = append(w, s[start:i]...) + } + w = append(w, '\\') + switch b { + case '\\', '"': + w = append(w, b) + case '\n': + w = append(w, 'n') + case '\r': + w = append(w, 'r') + case '\t': + w = append(w, 't') + default: + // This encodes bytes < 0x20 except for \t, \n and \r. + // If escapeHTML is set, it also escapes <, >, and & + // because they can lead to security holes when + // user-controlled strings are rendered into JSON + // and served to some browsers. + w = append(w, "u00"...) + w = append(w, hex[b>>4]) + w = append(w, hex[b&0xF]) + } + i++ + start = i + continue + } + c, size := utf8.DecodeRuneInString(s[i:]) + if c == utf8.RuneError && size == 1 { + if start < i { + w = append(w, s[start:i]...) + } + w = append(w, "\\ufffd"...) + i += size + start = i + continue + } + // U+2028 is LINE SEPARATOR. + // U+2029 is PARAGRAPH SEPARATOR. + // They are both technically valid characters in JSON strings, + // but don't work in JSONP, which has to be evaluated as JavaScript, + // and can lead to security holes there. It is valid JSON to + // escape them, so we do so unconditionally. + // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion. + if c == '\u2028' || c == '\u2029' { + if start < i { + w = append(w, s[start:i]...) + } + w = append(w, "\\u202"...) + w = append(w, hex[c&0xF]) + i += size + start = i + continue + } + i += size + } + if start < len(s) { + w = append(w, s[start:]...) + } + return append(w, '"') +} + +// NOTE: keep in sync with string above. +func JSONWriteStringBytes(w []byte, s []byte) []byte { + if !utf8.Valid(s) { + w = append(w, binaryJSONStringStart...) + beforeAllocation := len(w) + w = alloc(w, base64.StdEncoding.EncodedLen(len(s))) + base64.StdEncoding.Encode(w[beforeAllocation:], s) + return append(w, binaryJSONStringEnd...) + } + w = append(w, '"') + start := 0 + for i := 0; i < len(s); { + if b := s[i]; b < utf8.RuneSelf { + if safeSet[b] { + i++ + continue + } + if start < i { + w = append(w, s[start:i]...) + } + w = append(w, '\\') + switch b { + case '\\', '"': + w = append(w, b) + case '\n': + w = append(w, 'n') + case '\r': + w = append(w, 'r') + case '\t': + w = append(w, 't') + default: + // This encodes bytes < 0x20 except for \t, \n and \r. + // If escapeHTML is set, it also escapes <, >, and & + // because they can lead to security holes when + // user-controlled strings are rendered into JSON + // and served to some browsers. + w = append(w, "u00"...) + w = append(w, hex[b>>4]) + w = append(w, hex[b&0xF]) + } + i++ + start = i + continue + } + c, size := utf8.DecodeRune(s[i:]) + if c == utf8.RuneError && size == 1 { + if start < i { + w = append(w, s[start:i]...) + } + w = append(w, "\\ufffd"...) + i += size + start = i + continue + } + // U+2028 is LINE SEPARATOR. + // U+2029 is PARAGRAPH SEPARATOR. + // They are both technically valid characters in JSON strings, + // but don't work in JSONP, which has to be evaluated as JavaScript, + // and can lead to security holes there. It is valid JSON to + // escape them, so we do so unconditionally. + // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion. + if c == '\u2028' || c == '\u2029' { + if start < i { + w = append(w, s[start:i]...) + } + w = append(w, "\\u202"...) + w = append(w, hex[c&0xF]) + i += size + start = i + continue + } + i += size + } + if start < len(s) { + w = append(w, s[start:]...) + } + return append(w, '"') +} + +type Rand interface { + Uint32() uint32 + Int31() int32 + Int63() int64 + NormFloat64() float64 +} + +type RandGenerator struct { + maxDepth uint32 + curDepth uint32 + r Rand + + SizeHandler func(generatedValue uint32) uint32 + FieldMaskHandler func(generatedValue uint32, bitMask uint32) uint32 +} + +type RandgeneratorContext struct { + SizeHandler func(generatedValue uint32) uint32 + FieldMaskHandler func(generatedValue uint32, bitMask uint32) uint32 +} + +func NewRandGenerator(r Rand) *RandGenerator { + const minDepth = 2 + const maxDepth = 5 + return &RandGenerator{ + maxDepth: (r.Uint32() % (maxDepth - minDepth + 1)) + minDepth, + curDepth: 0, + r: r, + + SizeHandler: func(generatedValue uint32) uint32 { + return generatedValue + }, + FieldMaskHandler: func(generatedValue uint32, bitMask uint32) uint32 { + return generatedValue + }, + } +} + +func NewRandGeneratorWithContext(r Rand, ctx RandgeneratorContext) *RandGenerator { + rand := NewRandGenerator(r) + if ctx.SizeHandler != nil { + rand.SizeHandler = ctx.SizeHandler + } + if ctx.FieldMaskHandler != nil { + rand.FieldMaskHandler = ctx.FieldMaskHandler + } + return rand +} + +func (rg *RandGenerator) IncreaseDepth() { + if rg.curDepth != rg.maxDepth { + rg.curDepth += 1 + } +} + +func (rg *RandGenerator) DecreaseDepth() { + if rg.curDepth != 0 { + rg.curDepth -= 1 + } +} + +func (rg *RandGenerator) LimitValue(value uint32) uint32 { + const limit = 1024 + value &= limit - 1 + return value +} + +func RandomUint(rg *RandGenerator) uint32 { + if rg.curDepth >= rg.maxDepth { + return 0 + } + const probabilityBits = 20 + const sourceMask = 1<>probabilityBits)&0b1 + } else if categoryBits < w3to4 { + bitMask = 3 + (source>>probabilityBits)&0b1 + } else if categoryBits < w5to8 { + bitMask = 5 + (source>>probabilityBits)&0b11 + } else if categoryBits < w9to16 { + bitMask = 9 + (source>>probabilityBits)&0b111 + } else if categoryBits < w17to24 { + bitMask = 17 + (source>>probabilityBits)&0b111 + } else if categoryBits < w25to32 { + bitMask = 25 + (source>>probabilityBits)&0b111 + } + + bitMask = (1 << bitMask) - 1 + + return rg.r.Uint32() & bitMask +} + +func RandomSize(rg *RandGenerator) uint32 { + return rg.SizeHandler(rg.LimitValue(RandomUint(rg))) +} + +func RandomFieldMask(rg *RandGenerator, bitMask uint32) uint32 { + source := RandomUint(rg) + sourceIndex := 0 + value := uint32(0) + for i := 0; i < 32; i++ { + if bitMask&(1< math.MaxInt { + return r, 0, fmt.Errorf("string length cannot be represented as an int: %d", l64) + } + // we allow non-canonical length to speed up some rare implementations + r = r[9:] + return r, int(l64), nil + } +} + +func TL2WriteSize(w []byte, l int) []byte { + switch { + case l < mediumStringMarker: + w = append(w, byte(l)) + case l < mediumStringMarker+(1<<16): + w = append(w, mediumStringMarker) + w = binary.LittleEndian.AppendUint16(w, uint16(l-mediumStringMarker)) + default: + if int(uint64(l)) != l { // >64-bit platform + panic("TL2 string len does not fit huge format") + } + w = append(w, hugeStringMarker) + w = binary.LittleEndian.AppendUint64(w, uint64(l)) + } + return w +} + +func TL2ReadSize(r []byte, l *int) (_ []byte, err error) { + r, *l, err = TL2ParseSize(r) + return r, err +} + +// w have at least 9 bytes length +func TL2PutSize(w []byte, l int) int { + switch { + case l < mediumStringMarker: + w[0] = byte(l) + return 1 + case l < mediumStringMarker+(1<<16): + w[0] = mediumStringMarker + binary.LittleEndian.PutUint16(w[1:], uint16(l-mediumStringMarker)) + return 3 + default: + if int(uint64(l)) != l { // >64-bit platform + panic("TL2 string len does not fit huge format") + } + w[0] = hugeStringMarker + binary.LittleEndian.PutUint64(w[1:], uint64(l)) + return 9 + } +} + +func TL2CalculateSize(l int) int { + switch { + case l < mediumStringMarker: + return 1 + case l < mediumStringMarker+(1<<16): + return 3 + default: + if int(uint64(l)) != l { // >64-bit platform + panic("TL2 string len does not fit huge format") + } + return 9 + } +} + +func StringWriteTL2(w []byte, v string) []byte { + w = TL2WriteSize(w, len(v)) + w = append(w, v...) + return w +} + +func StringWriteTL2Bytes(w []byte, v []byte) []byte { + w = TL2WriteSize(w, len(v)) + w = append(w, v...) + return w +} + +func StringReadTL2(r []byte, dst *string) (_ []byte, err error) { + var l int + if r, l, err = TL2ParseSize(r); err != nil { + return r, err + } + if len(r) < l { + return r, io.ErrUnexpectedEOF + } + *dst = string(r[:l]) + return r[l:], nil +} + +func StringReadTL2Bytes(r []byte, dst *[]byte) (_ []byte, err error) { + var l int + if r, l, err = TL2ParseSize(r); err != nil { + return r, err + } + if l > 0 { + if len(r) < l { + return r, io.ErrUnexpectedEOF + } + // Allocate only after we know there is enough bytes in reader + if cap(*dst) < l { + *dst = make([]byte, l) + } else { + *dst = (*dst)[:l] + } + copy(*dst, r) + } else { + *dst = (*dst)[:0] + } + return r[l:], nil +} + +func Uint64Read(r []byte, dst *uint64) ([]byte, error) { + if len(r) < 8 { + return r, io.ErrUnexpectedEOF + } + *dst = binary.LittleEndian.Uint64(r) + return r[8:], nil +} + +func Uint64Write(w []byte, v uint64) []byte { + return nat64Write(w, v) +} + +// TODO - remove after all generated code updated +func ByteWriteTL2(w []byte, b byte) []byte { + return ByteWrite(w, b) +} + +func ByteWrite(w []byte, b byte) []byte { + w = append(w, b) + return w +} + +// TODO - remove after all generated code updated +func ByteReadTL2(r []byte, b *byte) ([]byte, error) { + return ByteRead(r, b) +} + +func ByteRead(r []byte, b *byte) ([]byte, error) { + if len(r) == 0 { + return r, io.ErrUnexpectedEOF + } + *b = r[0] + return r[1:], nil +} + +func ByteBoolWriteTL2(w []byte, b bool) []byte { + if b { + w = append(w, 1) + } else { + w = append(w, 0) + } + return w +} + +func ByteBoolReadTL2(r []byte, b *bool) (_ []byte, err error) { + var byt byte + if r, err = ByteRead(r, &byt); err != nil { + return r, err + } + if byt == 0 { + *b = false + } else { + *b = true + } + return r, nil +} + +func MaybeBoolWriteTL2(w []byte, b bool) []byte { + if b { + w = append(w, 2, 1<<0+1<<1, 1) + } else { + w = append(w, 2, 1<<0, 1) + } + return w +} + +func SkipSizedValue(r []byte) (_ []byte, err error) { + var l int + if r, l, err = TL2ParseSize(r); err != nil { + return r, err + } + if len(r) < l { + return r, TL2Error("not enough data to skip: expected %d, got %d", l, len(r)) + } + r = r[l:] + return r, err +} + +func SkipFixedSizedValue(r []byte, l int) (_ []byte, err error) { + if l < 0 { + return r, TL2Error("can skip only non negative number of elements") + } + if len(r) < l { + return r, TL2Error("not enough data to skip: expected %d, got %d", l, len(r)) + } + r = r[l:] + return r, err +} + +func VectorBitContentWriteTL2(w []byte, vec []bool) []byte { + blockOffset := 0 + for ; blockOffset+8 <= len(vec); blockOffset += 8 { + var block byte + for j := 0; j < 8; j++ { + if vec[blockOffset+j] { + block |= (1 << j) + } + } + w = append(w, block) + } + if blockOffset < len(vec) { + var block byte + for j := 0; j < len(vec)-blockOffset; j++ { + if vec[blockOffset+j] { + block |= (1 << j) + } + } + w = append(w, block) + } + return w +} + +func VectorBitContentReadTL2(w []byte, vec []bool) (_ []byte, err error) { + blockOffset := 0 + for ; blockOffset+8 <= len(vec); blockOffset += 8 { + var block byte + if w, err = ByteRead(w, &block); err != nil { + return w, err + } + for j := 0; j < 8; j++ { + vec[blockOffset+j] = (block & (1 << j)) != 0 + } + } + if blockOffset < len(vec) { + var block byte + if w, err = ByteRead(w, &block); err != nil { + return w, err + } + for j := 0; j < len(vec)-blockOffset; j++ { + vec[blockOffset+j] = (block & (1 << j)) != 0 + } + } + return w, nil +} diff --git a/internal/speed/speed_tl/constants/constants.go b/internal/speed/speed_tl/constants/constants.go new file mode 100644 index 000000000..14a3f8684 --- /dev/null +++ b/internal/speed/speed_tl/constants/constants.go @@ -0,0 +1,20 @@ +// Code generated by tl2gen; DO NOT EDIT. +package constants + +const ( + MemcacheLongvalue = 0x09729c42 // memcache.longvalue + MemcacheLongvalueWithTime = 0x01dcd5d5 // memcache.longvalueWithTime + MemcacheNotFound = 0x32c42422 // memcache.not_found + MemcacheStrvalue = 0xa6bebb1a // memcache.strvalue + MemcacheStrvalueWithDelay = 0x1bbf7044 // memcache.strvalueWithDelay + MemcacheStrvalueWithTime = 0xa064c821 // memcache.strvalueWithTime + MemcacheValues = 0xc894cef8 // memcache.values + PartialPoint = 0xbfa57042 // partialPoint + PartialPoints = 0x0d7f74de // partialPoints + Point = 0x8ec1a27e // point + Points = 0xebf9dd56 // points + UnionPointError = 0xa8dbfd23 // unionPointError + UnionPointValue = 0xbee8f76b // unionPointValue + UnionPoints = 0xa8495345 // unionPoints + Vector = 0x1cb5c415 // vector +) diff --git a/internal/speed/speed_tl/factory/factory.go b/internal/speed/speed_tl/factory/factory.go new file mode 100644 index 000000000..aaeb0d76d --- /dev/null +++ b/internal/speed/speed_tl/factory/factory.go @@ -0,0 +1,62 @@ +// Code generated by tl2gen; DO NOT EDIT. +package factory + +// factory contains both metadata all types and all generated code for all types. +// you want to import factory only where absolutely necessary, and never into common code. + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/internal" + "github.com/VKCOM/tl/internal/speed/speed_tl/internal/metainternal" + "github.com/VKCOM/tl/internal/speed/speed_tl/meta" // force import to call meta init first +) + +func CreateFunction(tag uint32) meta.Function { + item := meta.FactoryItemByTLTag(tag) + if item == nil || !item.IsFunction() { + return nil + } + return item.CreateFunction() +} + +func CreateObject(tag uint32) meta.Object { + item := meta.FactoryItemByTLTag(tag) + if item == nil { + return nil + } + return item.CreateObject() +} + +func CreateFunctionFromName(name string) meta.Function { + item := meta.FactoryItemByTLName(name) + if item == nil || !item.IsFunction() { + return nil + } + return item.CreateFunction() +} + +func CreateObjectFromName(name string) meta.Object { + item := meta.FactoryItemByTLName(name) + if item == nil { + return nil + } + return item.CreateObject() +} + +func init() { + metainternal.SetGlobalFactoryCreateForObject("memcache.longvalue", func() metainternal.Object { return new(internal.MemcacheLongvalue) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.longvalueWithTime", func() metainternal.Object { return new(internal.MemcacheLongvalueWithTime) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.not_found", func() metainternal.Object { return new(internal.MemcacheNotFound) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.strvalue", func() metainternal.Object { return new(internal.MemcacheStrvalue) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.strvalueWithDelay", func() metainternal.Object { return new(internal.MemcacheStrvalueWithDelay) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.strvalueWithTime", func() metainternal.Object { return new(internal.MemcacheStrvalueWithTime) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.Value", func() metainternal.Object { return new(internal.MemcacheValue) }) + metainternal.SetGlobalFactoryCreateForObject("memcache.values", func() metainternal.Object { return new(internal.MemcacheValues) }) + metainternal.SetGlobalFactoryCreateForObject("partialPoint", func() metainternal.Object { return new(internal.PartialPoint) }) + metainternal.SetGlobalFactoryCreateForObject("partialPoints", func() metainternal.Object { return new(internal.PartialPoints) }) + metainternal.SetGlobalFactoryCreateForObject("point", func() metainternal.Object { return new(internal.Point) }) + metainternal.SetGlobalFactoryCreateForObject("points", func() metainternal.Object { return new(internal.Points) }) + metainternal.SetGlobalFactoryCreateForObject("UnionPoint", func() metainternal.Object { return new(internal.UnionPoint) }) + metainternal.SetGlobalFactoryCreateForObject("unionPointError", func() metainternal.Object { return new(internal.UnionPointError) }) + metainternal.SetGlobalFactoryCreateForObject("unionPointValue", func() metainternal.Object { return new(internal.UnionPointValue) }) + metainternal.SetGlobalFactoryCreateForObject("unionPoints", func() metainternal.Object { return new(internal.UnionPoints) }) +} diff --git a/internal/speed/speed_tl/internal/a_tlgen_helpers_code.go b/internal/speed/speed_tl/internal/a_tlgen_helpers_code.go new file mode 100644 index 000000000..9951bc92a --- /dev/null +++ b/internal/speed/speed_tl/internal/a_tlgen_helpers_code.go @@ -0,0 +1,464 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "errors" + "fmt" + "strconv" + + "github.com/mailru/easyjson/jlexer" +) + +type UnionElement struct { + TLTag uint32 + TLName string + TLString string +} + +func Unused[T any](_ T) {} // suppress var not used errors + +func ErrorClientWrite(typeName string, err error) error { + return fmt.Errorf("failed to serialize %s request: %w", typeName, err) +} + +func ErrorClientDo(typeName string, network string, actorID int64, address string, err error) error { + return fmt.Errorf("%s request to %s://%d@%s failed: %w", typeName, network, actorID, address, err) +} + +func ErrorClientReadResult(typeName string, network string, actorID int64, address string, err error) error { + return fmt.Errorf("failed to deserialize %s response from %s://%d@%s: %w", typeName, network, actorID, address, err) +} + +func ErrorServerHandle(typeName string, err error) error { + return fmt.Errorf("failed to handle %s: %w", typeName, err) +} + +func ErrorServerRead(typeName string, err error) error { + return fmt.Errorf("failed to deserialize %s request: %w", typeName, err) +} + +func ErrorServerWriteResult(typeName string, err error) error { + return fmt.Errorf("failed to serialize %s response: %w", typeName, err) +} + +func ErrorInvalidEnumTag(typeName string, tag uint32) error { + return fmt.Errorf("invalid enum %q tag: 0x%x", typeName, tag) +} + +func ErrorInvalidUnionTag(typeName string, tag uint32) error { + return fmt.Errorf("invalid union %q tag: 0x%x", typeName, tag) +} + +func ErrorInvalidUnionIndex(typeName string, index int) error { + return fmt.Errorf("invalid TL2 union %q index: %d", typeName, index) +} + +func ErrorWrongSequenceLength(typeName string, actual int, expected uint32) error { + return fmt.Errorf("wrong sequence %q length: %d expected: %d", typeName, actual, expected) +} + +func ErrorInvalidUnionTagJSON(typeName string, tag string) error { + return fmt.Errorf("invalid union %q tag: %q", typeName, tag) +} + +func ErrorInvalidUnionLegacyTagJSON(typeName string, tag string) error { + return fmt.Errorf("legacy union %q tag %q, please remove suffix", typeName, tag) +} + +func ErrorInvalidJSON(typeName string, msg string) error { + return fmt.Errorf("invalid json for type %q - %s", typeName, msg) +} + +func ErrorInvalidJSONWithDuplicatingKeys(typeName string, field string) error { + return fmt.Errorf("invalid json for type %q: %q repeats several times", typeName, field) +} + +func ErrorTL2SerializersNotGenerated(typeName string) error { + return fmt.Errorf("serializers for TL2 were not generated for type %q", typeName) +} + +func ErrorInvalidJSONExcessElement(typeName string, key string) error { + return fmt.Errorf("invalid json object key %q", key) +} + +// returns unsafe string, so do not store it anywhere +func Json2ReadUnion(typeName string, in *jlexer.Lexer) (string, []byte, error) { + if in == nil { + return "", nil, ErrorInvalidJSON(typeName, "expected json object or string") + } + if in.CurrentToken() == jlexer.TokenString { + return in.UnsafeString(), nil, nil + } + + var valueFound bool + var valueSlice []byte + + var typeFound bool + var typeValue string + + in.Delim('{') + if !in.Ok() { + return "", nil, in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if valueFound { + return "", nil, ErrorInvalidJSONWithDuplicatingKeys(typeName, "value") + } + valueSlice = in.Raw() + valueFound = true + case "type": + if typeFound { + return "", nil, ErrorInvalidJSONWithDuplicatingKeys(typeName, "type") + } + typeValue = in.UnsafeString() + typeFound = true + default: + return "", nil, ErrorInvalidJSON(typeName, "unexpected field '"+key+"' in union") + } + + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return "", nil, in.Error() + } + + if !typeFound { + return "", nil, ErrorInvalidJSON(typeName, "field 'type' is absent") + } + + return typeValue, valueSlice, nil +} + +func Json2ReadMaybe(typeName string, in *jlexer.Lexer) (bool, []byte, error) { + if in == nil { + return false, nil, nil + } + var valueFound bool + var valueSlice []byte + + var okFound bool + var okValue bool + + in.Delim('{') + if !in.Ok() { + return false, nil, ErrorInvalidJSON(typeName, "expected json object") + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if valueFound { + return false, nil, ErrorInvalidJSONWithDuplicatingKeys(typeName, "value") + } + valueSlice = in.Raw() + valueFound = true + case "ok": + if okFound { + return false, nil, ErrorInvalidJSONWithDuplicatingKeys(typeName, "ok") + } + okValue = in.Bool() + okFound = true + default: + return false, nil, ErrorInvalidJSON(typeName, "unexpected field '"+key+"' in maybe") + } + + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return false, nil, in.Error() + } + + if okFound && !okValue && valueSlice != nil { + return false, nil, ErrorInvalidJSON(typeName, "field 'ok' is false but field 'value' is presented in maybe") + } + if !okFound && valueSlice != nil { + okValue = true + } + return okValue, valueSlice, nil +} + +func Json2ReadBool(in *jlexer.Lexer, dst *bool) error { + if in == nil { + *dst = false + return nil + } + *dst = in.Bool() + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadString(in *jlexer.Lexer, dst *string) error { + if in == nil { + *dst = "" + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + *dst = in.String() + case jlexer.TokenDelim: + var findValue = false + + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "base64": + if findValue { + return errors.New("base64 repeats several times") + } + *dst = string(in.Bytes()) + findValue = true + default: + return errors.New("unexpected field '" + key + "'") + } + + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + + if !findValue { + return errors.New("field base64 is absent") + } + default: + return errors.New("invalid json for string") + } + return nil +} + +func Json2ReadStringBytes(in *jlexer.Lexer, dst *[]byte) error { + if in == nil { + *dst = nil + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + *dst = append((*dst)[:0], in.String()...) + case jlexer.TokenDelim: + var findValue = false + + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "base64": + if findValue { + return errors.New("field base64 repeats several times") + } + *dst = in.Bytes() + findValue = true + default: + return errors.New("unexpected field '" + key + "'") + } + + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + + if !findValue { + return errors.New("field base64 is absent") + } + default: + return errors.New("invalid json for string") + } + return nil +} + +func Json2ReadByte(in *jlexer.Lexer, dst *byte) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseUint(src, 10, 8) + if err != nil { + return err + } + *dst = byte(value) + case jlexer.TokenNumber: + *dst = in.Uint8() + default: + return errors.New("invalid json for byte") + } + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadUint32(in *jlexer.Lexer, dst *uint32) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseUint(src, 10, 32) + if err != nil { + return err + } + *dst = uint32(value) + case jlexer.TokenNumber: + *dst = in.Uint32() + default: + return errors.New("invalid json for uint32") + } + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadInt32(in *jlexer.Lexer, dst *int32) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseInt(src, 10, 32) + if err != nil { + return err + } + *dst = int32(value) + case jlexer.TokenNumber: + *dst = in.Int32() + default: + return errors.New("invalid json for int32") + } + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadInt64(in *jlexer.Lexer, dst *int64) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseInt(src, 10, 64) + if err != nil { + return err + } + *dst = value + case jlexer.TokenNumber: + *dst = in.Int64() + default: + return errors.New("invalid json for int64") + } + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadUint64(in *jlexer.Lexer, dst *uint64) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseUint(src, 10, 64) + if err != nil { + return err + } + *dst = value + case jlexer.TokenNumber: + *dst = in.Uint64() + default: + return errors.New("invalid json for uint64") + } + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadFloat32(in *jlexer.Lexer, dst *float32) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseFloat(src, 32) + if err != nil { + return err + } + *dst = float32(value) + case jlexer.TokenNumber: + *dst = in.Float32() + default: + return errors.New("invalid json for float32") + } + if !in.Ok() { + return in.Error() + } + return nil +} + +func Json2ReadFloat64(in *jlexer.Lexer, dst *float64) error { + if in == nil { + *dst = 0 + return nil + } + + switch in.CurrentToken() { + case jlexer.TokenString: + src := in.UnsafeString() + value, err := strconv.ParseFloat(src, 64) + if err != nil { + return err + } + *dst = value + case jlexer.TokenNumber: + *dst = in.Float64() + default: + return errors.New("invalid json for float64") + } + if !in.Ok() { + return in.Error() + } + return nil +} diff --git a/internal/speed/speed_tl/internal/bool.go b/internal/speed/speed_tl/internal/bool.go new file mode 100644 index 000000000..81b43a22e --- /dev/null +++ b/internal/speed/speed_tl/internal/bool.go @@ -0,0 +1,16 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +func BoolReadTL1Boxed(w []byte, v *bool) ([]byte, error) { + return w, basictl.TL2Error("not implemented for tl2 type") +} + +func BoolWriteTL1Boxed(w []byte, v bool) []byte { + panic(basictl.TL2Error("not implemented for tl2 type")) +} diff --git a/internal/speed/speed_tl/internal/memcache.value.go b/internal/speed/speed_tl/internal/memcache.value.go new file mode 100644 index 000000000..ef150b2bb --- /dev/null +++ b/internal/speed/speed_tl/internal/memcache.value.go @@ -0,0 +1,2397 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +func BuiltinVectorMemcacheValueReadTL1(w []byte, vec *[]MemcacheValue) (_ []byte, err error) { + var l uint32 + if w, err = basictl.NatRead(w, &l); err != nil { + return w, err + } + if err = basictl.CheckLengthSanity(w, l, 4); err != nil { + return w, err + } + if uint32(cap(*vec)) < l { + *vec = make([]MemcacheValue, l) + } else { + *vec = (*vec)[:l] + } + for i := range *vec { + if w, err = (*vec)[i].ReadTL1Boxed(w); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinVectorMemcacheValueWriteTL1(w []byte, vec []MemcacheValue) []byte { + w = basictl.NatWrite(w, uint32(len(vec))) + for _, elem := range vec { + w = elem.WriteTL1Boxed(w) + } + return w +} + +func BuiltinVectorMemcacheValueCalculateLayout(sizes []int, optimizeEmpty bool, vec *[]MemcacheValue) ([]int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 + } + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 0 + var sz int + + currentSize += basictl.TL2CalculateSize(len(*vec)) + for i := 0; i < len(*vec); i++ { + sizes, sz = (*vec)[i].CalculateLayout(sizes, false) + currentSize += sz + } + sizes[sizePosition] = currentSize + currentSize += basictl.TL2CalculateSize(currentSize) + Unused(sz) + return sizes, currentSize +} + +func BuiltinVectorMemcacheValueInternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool, vec *[]MemcacheValue) ([]byte, []int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 + } + currentSize := sizes[0] + sizes = sizes[1:] + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + w = basictl.TL2WriteSize(w, len(*vec)) + + var sz int + for i := 0; i < len(*vec); i++ { + w, sizes, _ = (*vec)[i].InternalWriteTL2(w, sizes, false) + } + Unused(sz) + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + return w, sizes, currentSize +} + +func BuiltinVectorMemcacheValueInternalReadTL2(r []byte, vec *[]MemcacheValue) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + elementCount := 0 + if currentSize != 0 { + if currentR, elementCount, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if elementCount > len(currentR) { + return r, basictl.TL2ElementCountError(elementCount, currentR) + } + } + + if cap(*vec) < elementCount { + *vec = make([]MemcacheValue, elementCount) + } + *vec = (*vec)[:elementCount] + for i := 0; i < elementCount; i++ { + if currentR, err = (*vec)[i].InternalReadTL2(currentR); err != nil { + return currentR, err + } + } + return r, nil +} + +func BuiltinVectorMemcacheValueReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer, vec *[]MemcacheValue) error { + *vec = (*vec)[:cap(*vec)] + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return ErrorInvalidJSON("[]MemcacheValue", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if len(*vec) <= index { + var newValue MemcacheValue + *vec = append(*vec, newValue) + *vec = (*vec)[:cap(*vec)] + } + if err := (*vec)[index].ReadJSONGeneral(jctx, in); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return ErrorInvalidJSON("[]MemcacheValue", "expected json array's end") + } + } + *vec = (*vec)[:index] + return nil +} + +func BuiltinVectorMemcacheValueWriteJSON(w []byte, vec []MemcacheValue) []byte { + return BuiltinVectorMemcacheValueWriteJSONOpt(nil, w, vec) +} +func BuiltinVectorMemcacheValueWriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte, vec []MemcacheValue) []byte { + w = append(w, '[') + for _, elem := range vec { + w = basictl.JSONAddCommaIfNeeded(w) + w = elem.WriteJSONOpt(jctx, w) + } + return append(w, ']') +} + +func (item MemcacheLongvalue) AsUnion() MemcacheValue { + var ret MemcacheValue + ret.SetLongvalue(item) + return ret +} + +type MemcacheLongvalue struct { + Value int64 + Flags int32 +} + +func (MemcacheLongvalue) TLName() string { return "memcache.longvalue" } +func (MemcacheLongvalue) TLTag() uint32 { return 0x09729c42 } + +func (item *MemcacheLongvalue) Reset() { + item.Value = 0 + item.Flags = 0 +} + +func (item *MemcacheLongvalue) ReadTL1(w []byte) (_ []byte, err error) { + if w, err = basictl.LongRead(w, &item.Value); err != nil { + return w, err + } + return basictl.IntRead(w, &item.Flags) +} + +func (item *MemcacheLongvalue) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheLongvalue) WriteTL1(w []byte) []byte { + w = basictl.LongWrite(w, item.Value) + w = basictl.IntWrite(w, item.Flags) + return w +} + +func (item *MemcacheLongvalue) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x09729c42); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheLongvalue) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheLongvalue) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x09729c42) + return item.WriteTL1(w) +} + +func (item MemcacheLongvalue) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheLongvalue) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheLongvalue) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuePresented bool + var propFlagsPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if propValuePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.longvalue", "value") + } + propValuePresented = true + if err := Json2ReadInt64(in, &item.Value); err != nil { + return err + } + case "flags": + if propFlagsPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.longvalue", "flags") + } + propFlagsPresented = true + if err := Json2ReadInt32(in, &item.Flags); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("memcache.longvalue", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuePresented { + item.Value = 0 + } + if !propFlagsPresented { + item.Flags = 0 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheLongvalue) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheLongvalue) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheLongvalue) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValue := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + w = basictl.JSONWriteInt64(w, item.Value) + if !(item.Value != 0) { + w = w[:backupIndexValue] + } + backupIndexFlags := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"flags":`...) + w = basictl.JSONWriteInt32(w, item.Flags) + if !(item.Flags != 0) { + w = w[:backupIndexFlags] + } + return append(w, '}') +} + +func (item *MemcacheLongvalue) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheLongvalue) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.longvalue", err.Error()) + } + return nil +} + +func (item *MemcacheLongvalue) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 3382994936) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + // add constructor No for union type in case of non first option + currentSize += basictl.TL2CalculateSize(2) + lastUsedByte = currentSize + if item.Value != 0 { + currentSize += 8 + lastUsedByte = currentSize + } + if item.Flags != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *MemcacheLongvalue) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 3382994936 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + w = basictl.TL2WriteSize(w, 2) + currentBlock |= 1 + if item.Value != 0 { + w = basictl.LongWrite(w, item.Value) + currentBlock |= 2 + } + if item.Flags != 0 { + w = basictl.IntWrite(w, item.Flags) + currentBlock |= 4 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *MemcacheLongvalue) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheLongvalue) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + if block&2 != 0 { + if currentR, err = basictl.LongRead(currentR, &item.Value); err != nil { + return currentR, err + } + } else { + item.Value = 0 + } + if block&4 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.Flags); err != nil { + return currentR, err + } + } else { + item.Flags = 0 + } + Unused(currentR) + return r, nil +} + +func (item *MemcacheLongvalue) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 2 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 2) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +func (item MemcacheLongvalueWithTime) AsUnion() MemcacheValue { + var ret MemcacheValue + ret.SetLongvalueWithTime(item) + return ret +} + +type MemcacheLongvalueWithTime struct { + Value int64 + Flags int32 + ModificationTime int32 +} + +func (MemcacheLongvalueWithTime) TLName() string { return "memcache.longvalueWithTime" } +func (MemcacheLongvalueWithTime) TLTag() uint32 { return 0x01dcd5d5 } + +func (item *MemcacheLongvalueWithTime) Reset() { + item.Value = 0 + item.Flags = 0 + item.ModificationTime = 0 +} + +func (item *MemcacheLongvalueWithTime) ReadTL1(w []byte) (_ []byte, err error) { + if w, err = basictl.LongRead(w, &item.Value); err != nil { + return w, err + } + if w, err = basictl.IntRead(w, &item.Flags); err != nil { + return w, err + } + return basictl.IntRead(w, &item.ModificationTime) +} + +func (item *MemcacheLongvalueWithTime) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheLongvalueWithTime) WriteTL1(w []byte) []byte { + w = basictl.LongWrite(w, item.Value) + w = basictl.IntWrite(w, item.Flags) + w = basictl.IntWrite(w, item.ModificationTime) + return w +} + +func (item *MemcacheLongvalueWithTime) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x01dcd5d5); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheLongvalueWithTime) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheLongvalueWithTime) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x01dcd5d5) + return item.WriteTL1(w) +} + +func (item MemcacheLongvalueWithTime) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheLongvalueWithTime) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheLongvalueWithTime) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuePresented bool + var propFlagsPresented bool + var propModificationTimePresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if propValuePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.longvalueWithTime", "value") + } + propValuePresented = true + if err := Json2ReadInt64(in, &item.Value); err != nil { + return err + } + case "flags": + if propFlagsPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.longvalueWithTime", "flags") + } + propFlagsPresented = true + if err := Json2ReadInt32(in, &item.Flags); err != nil { + return err + } + case "modificationTime": + if propModificationTimePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.longvalueWithTime", "modificationTime") + } + propModificationTimePresented = true + if err := Json2ReadInt32(in, &item.ModificationTime); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("memcache.longvalueWithTime", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuePresented { + item.Value = 0 + } + if !propFlagsPresented { + item.Flags = 0 + } + if !propModificationTimePresented { + item.ModificationTime = 0 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheLongvalueWithTime) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheLongvalueWithTime) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheLongvalueWithTime) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValue := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + w = basictl.JSONWriteInt64(w, item.Value) + if !(item.Value != 0) { + w = w[:backupIndexValue] + } + backupIndexFlags := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"flags":`...) + w = basictl.JSONWriteInt32(w, item.Flags) + if !(item.Flags != 0) { + w = w[:backupIndexFlags] + } + backupIndexModificationTime := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"modificationTime":`...) + w = basictl.JSONWriteInt32(w, item.ModificationTime) + if !(item.ModificationTime != 0) { + w = w[:backupIndexModificationTime] + } + return append(w, '}') +} + +func (item *MemcacheLongvalueWithTime) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheLongvalueWithTime) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.longvalueWithTime", err.Error()) + } + return nil +} + +func (item *MemcacheLongvalueWithTime) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 3130132128) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + // add constructor No for union type in case of non first option + currentSize += basictl.TL2CalculateSize(4) + lastUsedByte = currentSize + if item.Value != 0 { + currentSize += 8 + lastUsedByte = currentSize + } + if item.Flags != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.ModificationTime != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *MemcacheLongvalueWithTime) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 3130132128 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + w = basictl.TL2WriteSize(w, 4) + currentBlock |= 1 + if item.Value != 0 { + w = basictl.LongWrite(w, item.Value) + currentBlock |= 2 + } + if item.Flags != 0 { + w = basictl.IntWrite(w, item.Flags) + currentBlock |= 4 + } + if item.ModificationTime != 0 { + w = basictl.IntWrite(w, item.ModificationTime) + currentBlock |= 8 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *MemcacheLongvalueWithTime) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheLongvalueWithTime) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + if block&2 != 0 { + if currentR, err = basictl.LongRead(currentR, &item.Value); err != nil { + return currentR, err + } + } else { + item.Value = 0 + } + if block&4 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.Flags); err != nil { + return currentR, err + } + } else { + item.Flags = 0 + } + if block&8 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.ModificationTime); err != nil { + return currentR, err + } + } else { + item.ModificationTime = 0 + } + Unused(currentR) + return r, nil +} + +func (item *MemcacheLongvalueWithTime) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 4 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 4) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +func (item MemcacheNotFound) AsUnion() MemcacheValue { + var ret MemcacheValue + ret.SetNotFound() + return ret +} + +type MemcacheNotFound struct { +} + +func (MemcacheNotFound) TLName() string { return "memcache.not_found" } +func (MemcacheNotFound) TLTag() uint32 { return 0x32c42422 } + +func (item *MemcacheNotFound) Reset() {} + +func (item *MemcacheNotFound) ReadTL1(w []byte) (_ []byte, err error) { return w, nil } + +func (item *MemcacheNotFound) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheNotFound) WriteTL1(w []byte) []byte { + return w +} + +func (item *MemcacheNotFound) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x32c42422); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheNotFound) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheNotFound) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x32c42422) + return item.WriteTL1(w) +} + +func (item MemcacheNotFound) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheNotFound) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheNotFound) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + return ErrorInvalidJSON("memcache.not_found", "this object can't have properties") + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheNotFound) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheNotFound) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheNotFound) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + return append(w, '}') +} + +func (item *MemcacheNotFound) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheNotFound) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.not_found", err.Error()) + } + return nil +} + +func (item *MemcacheNotFound) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 +} + +func (item *MemcacheNotFound) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 +} + +func (item *MemcacheNotFound) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheNotFound) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + Unused(currentR) + return r, nil +} + +func (item *MemcacheNotFound) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 0 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 0) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +func (item MemcacheStrvalue) AsUnion() MemcacheValue { + var ret MemcacheValue + ret.SetStrvalue(item) + return ret +} + +type MemcacheStrvalue struct { + Value string + Flags int32 +} + +func (MemcacheStrvalue) TLName() string { return "memcache.strvalue" } +func (MemcacheStrvalue) TLTag() uint32 { return 0xa6bebb1a } + +func (item *MemcacheStrvalue) Reset() { + item.Value = "" + item.Flags = 0 +} + +func (item *MemcacheStrvalue) ReadTL1(w []byte) (_ []byte, err error) { + if w, err = basictl.StringRead(w, &item.Value); err != nil { + return w, err + } + return basictl.IntRead(w, &item.Flags) +} + +func (item *MemcacheStrvalue) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheStrvalue) WriteTL1(w []byte) []byte { + w = basictl.StringWrite(w, item.Value) + w = basictl.IntWrite(w, item.Flags) + return w +} + +func (item *MemcacheStrvalue) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xa6bebb1a); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheStrvalue) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheStrvalue) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xa6bebb1a) + return item.WriteTL1(w) +} + +func (item MemcacheStrvalue) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheStrvalue) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheStrvalue) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuePresented bool + var propFlagsPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if propValuePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalue", "value") + } + propValuePresented = true + if err := Json2ReadString(in, &item.Value); err != nil { + return err + } + case "flags": + if propFlagsPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalue", "flags") + } + propFlagsPresented = true + if err := Json2ReadInt32(in, &item.Flags); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("memcache.strvalue", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuePresented { + item.Value = "" + } + if !propFlagsPresented { + item.Flags = 0 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheStrvalue) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheStrvalue) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheStrvalue) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValue := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + w = basictl.JSONWriteString(w, item.Value) + if !(len(item.Value) != 0) { + w = w[:backupIndexValue] + } + backupIndexFlags := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"flags":`...) + w = basictl.JSONWriteInt32(w, item.Flags) + if !(item.Flags != 0) { + w = w[:backupIndexFlags] + } + return append(w, '}') +} + +func (item *MemcacheStrvalue) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheStrvalue) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.strvalue", err.Error()) + } + return nil +} + +func (item *MemcacheStrvalue) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 4135603527) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + // add constructor No for union type in case of non first option + currentSize += basictl.TL2CalculateSize(1) + lastUsedByte = currentSize + if len(item.Value) != 0 { + currentSize += basictl.TL2CalculateSize(len(item.Value)) + len(item.Value) + lastUsedByte = currentSize + } + if item.Flags != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *MemcacheStrvalue) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 4135603527 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + w = basictl.TL2WriteSize(w, 1) + currentBlock |= 1 + if len(item.Value) != 0 { + w = basictl.StringWriteTL2(w, item.Value) + currentBlock |= 2 + } + if item.Flags != 0 { + w = basictl.IntWrite(w, item.Flags) + currentBlock |= 4 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *MemcacheStrvalue) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheStrvalue) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + if block&2 != 0 { + if currentR, err = basictl.StringReadTL2(currentR, &item.Value); err != nil { + return currentR, err + } + } else { + item.Value = "" + } + if block&4 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.Flags); err != nil { + return currentR, err + } + } else { + item.Flags = 0 + } + Unused(currentR) + return r, nil +} + +func (item *MemcacheStrvalue) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 1 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 1) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +func (item MemcacheStrvalueWithDelay) AsUnion() MemcacheValue { + var ret MemcacheValue + ret.SetStrvalueWithDelay(item) + return ret +} + +type MemcacheStrvalueWithDelay struct { + Value string + Flags int32 + Delay int32 +} + +func (MemcacheStrvalueWithDelay) TLName() string { return "memcache.strvalueWithDelay" } +func (MemcacheStrvalueWithDelay) TLTag() uint32 { return 0x1bbf7044 } + +func (item *MemcacheStrvalueWithDelay) Reset() { + item.Value = "" + item.Flags = 0 + item.Delay = 0 +} + +func (item *MemcacheStrvalueWithDelay) ReadTL1(w []byte) (_ []byte, err error) { + if w, err = basictl.StringRead(w, &item.Value); err != nil { + return w, err + } + if w, err = basictl.IntRead(w, &item.Flags); err != nil { + return w, err + } + return basictl.IntRead(w, &item.Delay) +} + +func (item *MemcacheStrvalueWithDelay) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheStrvalueWithDelay) WriteTL1(w []byte) []byte { + w = basictl.StringWrite(w, item.Value) + w = basictl.IntWrite(w, item.Flags) + w = basictl.IntWrite(w, item.Delay) + return w +} + +func (item *MemcacheStrvalueWithDelay) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x1bbf7044); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheStrvalueWithDelay) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheStrvalueWithDelay) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x1bbf7044) + return item.WriteTL1(w) +} + +func (item MemcacheStrvalueWithDelay) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheStrvalueWithDelay) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheStrvalueWithDelay) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuePresented bool + var propFlagsPresented bool + var propDelayPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if propValuePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalueWithDelay", "value") + } + propValuePresented = true + if err := Json2ReadString(in, &item.Value); err != nil { + return err + } + case "flags": + if propFlagsPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalueWithDelay", "flags") + } + propFlagsPresented = true + if err := Json2ReadInt32(in, &item.Flags); err != nil { + return err + } + case "delay": + if propDelayPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalueWithDelay", "delay") + } + propDelayPresented = true + if err := Json2ReadInt32(in, &item.Delay); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("memcache.strvalueWithDelay", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuePresented { + item.Value = "" + } + if !propFlagsPresented { + item.Flags = 0 + } + if !propDelayPresented { + item.Delay = 0 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheStrvalueWithDelay) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheStrvalueWithDelay) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheStrvalueWithDelay) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValue := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + w = basictl.JSONWriteString(w, item.Value) + if !(len(item.Value) != 0) { + w = w[:backupIndexValue] + } + backupIndexFlags := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"flags":`...) + w = basictl.JSONWriteInt32(w, item.Flags) + if !(item.Flags != 0) { + w = w[:backupIndexFlags] + } + backupIndexDelay := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"delay":`...) + w = basictl.JSONWriteInt32(w, item.Delay) + if !(item.Delay != 0) { + w = w[:backupIndexDelay] + } + return append(w, '}') +} + +func (item *MemcacheStrvalueWithDelay) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheStrvalueWithDelay) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.strvalueWithDelay", err.Error()) + } + return nil +} + +func (item *MemcacheStrvalueWithDelay) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 4232367265) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + // add constructor No for union type in case of non first option + currentSize += basictl.TL2CalculateSize(5) + lastUsedByte = currentSize + if len(item.Value) != 0 { + currentSize += basictl.TL2CalculateSize(len(item.Value)) + len(item.Value) + lastUsedByte = currentSize + } + if item.Flags != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.Delay != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *MemcacheStrvalueWithDelay) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 4232367265 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + w = basictl.TL2WriteSize(w, 5) + currentBlock |= 1 + if len(item.Value) != 0 { + w = basictl.StringWriteTL2(w, item.Value) + currentBlock |= 2 + } + if item.Flags != 0 { + w = basictl.IntWrite(w, item.Flags) + currentBlock |= 4 + } + if item.Delay != 0 { + w = basictl.IntWrite(w, item.Delay) + currentBlock |= 8 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *MemcacheStrvalueWithDelay) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheStrvalueWithDelay) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + if block&2 != 0 { + if currentR, err = basictl.StringReadTL2(currentR, &item.Value); err != nil { + return currentR, err + } + } else { + item.Value = "" + } + if block&4 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.Flags); err != nil { + return currentR, err + } + } else { + item.Flags = 0 + } + if block&8 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.Delay); err != nil { + return currentR, err + } + } else { + item.Delay = 0 + } + Unused(currentR) + return r, nil +} + +func (item *MemcacheStrvalueWithDelay) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 5 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 5) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +func (item MemcacheStrvalueWithTime) AsUnion() MemcacheValue { + var ret MemcacheValue + ret.SetStrvalueWithTime(item) + return ret +} + +type MemcacheStrvalueWithTime struct { + Value string + Flags int32 + ModificationTime int32 +} + +func (MemcacheStrvalueWithTime) TLName() string { return "memcache.strvalueWithTime" } +func (MemcacheStrvalueWithTime) TLTag() uint32 { return 0xa064c821 } + +func (item *MemcacheStrvalueWithTime) Reset() { + item.Value = "" + item.Flags = 0 + item.ModificationTime = 0 +} + +func (item *MemcacheStrvalueWithTime) ReadTL1(w []byte) (_ []byte, err error) { + if w, err = basictl.StringRead(w, &item.Value); err != nil { + return w, err + } + if w, err = basictl.IntRead(w, &item.Flags); err != nil { + return w, err + } + return basictl.IntRead(w, &item.ModificationTime) +} + +func (item *MemcacheStrvalueWithTime) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheStrvalueWithTime) WriteTL1(w []byte) []byte { + w = basictl.StringWrite(w, item.Value) + w = basictl.IntWrite(w, item.Flags) + w = basictl.IntWrite(w, item.ModificationTime) + return w +} + +func (item *MemcacheStrvalueWithTime) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xa064c821); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheStrvalueWithTime) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheStrvalueWithTime) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xa064c821) + return item.WriteTL1(w) +} + +func (item MemcacheStrvalueWithTime) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheStrvalueWithTime) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheStrvalueWithTime) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuePresented bool + var propFlagsPresented bool + var propModificationTimePresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "value": + if propValuePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalueWithTime", "value") + } + propValuePresented = true + if err := Json2ReadString(in, &item.Value); err != nil { + return err + } + case "flags": + if propFlagsPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalueWithTime", "flags") + } + propFlagsPresented = true + if err := Json2ReadInt32(in, &item.Flags); err != nil { + return err + } + case "modificationTime": + if propModificationTimePresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.strvalueWithTime", "modificationTime") + } + propModificationTimePresented = true + if err := Json2ReadInt32(in, &item.ModificationTime); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("memcache.strvalueWithTime", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuePresented { + item.Value = "" + } + if !propFlagsPresented { + item.Flags = 0 + } + if !propModificationTimePresented { + item.ModificationTime = 0 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheStrvalueWithTime) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheStrvalueWithTime) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheStrvalueWithTime) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValue := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"value":`...) + w = basictl.JSONWriteString(w, item.Value) + if !(len(item.Value) != 0) { + w = w[:backupIndexValue] + } + backupIndexFlags := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"flags":`...) + w = basictl.JSONWriteInt32(w, item.Flags) + if !(item.Flags != 0) { + w = w[:backupIndexFlags] + } + backupIndexModificationTime := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"modificationTime":`...) + w = basictl.JSONWriteInt32(w, item.ModificationTime) + if !(item.ModificationTime != 0) { + w = w[:backupIndexModificationTime] + } + return append(w, '}') +} + +func (item *MemcacheStrvalueWithTime) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheStrvalueWithTime) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.strvalueWithTime", err.Error()) + } + return nil +} + +func (item *MemcacheStrvalueWithTime) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 3228951779) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + // add constructor No for union type in case of non first option + currentSize += basictl.TL2CalculateSize(3) + lastUsedByte = currentSize + if len(item.Value) != 0 { + currentSize += basictl.TL2CalculateSize(len(item.Value)) + len(item.Value) + lastUsedByte = currentSize + } + if item.Flags != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.ModificationTime != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *MemcacheStrvalueWithTime) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 3228951779 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + w = basictl.TL2WriteSize(w, 3) + currentBlock |= 1 + if len(item.Value) != 0 { + w = basictl.StringWriteTL2(w, item.Value) + currentBlock |= 2 + } + if item.Flags != 0 { + w = basictl.IntWrite(w, item.Flags) + currentBlock |= 4 + } + if item.ModificationTime != 0 { + w = basictl.IntWrite(w, item.ModificationTime) + currentBlock |= 8 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *MemcacheStrvalueWithTime) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheStrvalueWithTime) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + if block&2 != 0 { + if currentR, err = basictl.StringReadTL2(currentR, &item.Value); err != nil { + return currentR, err + } + } else { + item.Value = "" + } + if block&4 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.Flags); err != nil { + return currentR, err + } + } else { + item.Flags = 0 + } + if block&8 != 0 { + if currentR, err = basictl.IntRead(currentR, &item.ModificationTime); err != nil { + return currentR, err + } + } else { + item.ModificationTime = 0 + } + Unused(currentR) + return r, nil +} + +func (item *MemcacheStrvalueWithTime) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 3 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 3) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +var _MemcacheValue = [6]UnionElement{ + {TLTag: 0x32c42422, TLName: "memcache.not_found", TLString: "memcache.not_found#32c42422"}, + {TLTag: 0xa6bebb1a, TLName: "memcache.strvalue", TLString: "memcache.strvalue#a6bebb1a"}, + {TLTag: 0x09729c42, TLName: "memcache.longvalue", TLString: "memcache.longvalue#09729c42"}, + {TLTag: 0xa064c821, TLName: "memcache.strvalueWithTime", TLString: "memcache.strvalueWithTime#a064c821"}, + {TLTag: 0x01dcd5d5, TLName: "memcache.longvalueWithTime", TLString: "memcache.longvalueWithTime#01dcd5d5"}, + {TLTag: 0x1bbf7044, TLName: "memcache.strvalueWithDelay", TLString: "memcache.strvalueWithDelay#1bbf7044"}, +} + +type MemcacheValue struct { + valueStrvalue MemcacheStrvalue + valueLongvalue MemcacheLongvalue + valueStrvalueWithTime MemcacheStrvalueWithTime + valueLongvalueWithTime MemcacheLongvalueWithTime + valueStrvalueWithDelay MemcacheStrvalueWithDelay + index int +} + +func (item MemcacheValue) TLName() string { return _MemcacheValue[item.index].TLName } +func (item MemcacheValue) TLTag() uint32 { return _MemcacheValue[item.index].TLTag } + +func (item *MemcacheValue) Reset() { item.index = 0 } + +func (item *MemcacheValue) IsNotFound() bool { return item.index == 0 } + +func (item *MemcacheValue) AsNotFound() (MemcacheNotFound, bool) { + var value MemcacheNotFound + return value, item.index == 0 +} +func (item *MemcacheValue) ResetToNotFound() { item.index = 0 } +func (item *MemcacheValue) SetNotFound() { item.index = 0 } + +func (item *MemcacheValue) IsStrvalue() bool { return item.index == 1 } + +func (item *MemcacheValue) AsStrvalue() (*MemcacheStrvalue, bool) { + if item.index != 1 { + return nil, false + } + return &item.valueStrvalue, true +} +func (item *MemcacheValue) ResetToStrvalue() *MemcacheStrvalue { + item.index = 1 + item.valueStrvalue.Reset() + return &item.valueStrvalue +} +func (item *MemcacheValue) SetStrvalue(value MemcacheStrvalue) { + item.index = 1 + item.valueStrvalue = value +} + +func (item *MemcacheValue) IsLongvalue() bool { return item.index == 2 } + +func (item *MemcacheValue) AsLongvalue() (*MemcacheLongvalue, bool) { + if item.index != 2 { + return nil, false + } + return &item.valueLongvalue, true +} +func (item *MemcacheValue) ResetToLongvalue() *MemcacheLongvalue { + item.index = 2 + item.valueLongvalue.Reset() + return &item.valueLongvalue +} +func (item *MemcacheValue) SetLongvalue(value MemcacheLongvalue) { + item.index = 2 + item.valueLongvalue = value +} + +func (item *MemcacheValue) IsStrvalueWithTime() bool { return item.index == 3 } + +func (item *MemcacheValue) AsStrvalueWithTime() (*MemcacheStrvalueWithTime, bool) { + if item.index != 3 { + return nil, false + } + return &item.valueStrvalueWithTime, true +} +func (item *MemcacheValue) ResetToStrvalueWithTime() *MemcacheStrvalueWithTime { + item.index = 3 + item.valueStrvalueWithTime.Reset() + return &item.valueStrvalueWithTime +} +func (item *MemcacheValue) SetStrvalueWithTime(value MemcacheStrvalueWithTime) { + item.index = 3 + item.valueStrvalueWithTime = value +} + +func (item *MemcacheValue) IsLongvalueWithTime() bool { return item.index == 4 } + +func (item *MemcacheValue) AsLongvalueWithTime() (*MemcacheLongvalueWithTime, bool) { + if item.index != 4 { + return nil, false + } + return &item.valueLongvalueWithTime, true +} +func (item *MemcacheValue) ResetToLongvalueWithTime() *MemcacheLongvalueWithTime { + item.index = 4 + item.valueLongvalueWithTime.Reset() + return &item.valueLongvalueWithTime +} +func (item *MemcacheValue) SetLongvalueWithTime(value MemcacheLongvalueWithTime) { + item.index = 4 + item.valueLongvalueWithTime = value +} + +func (item *MemcacheValue) IsStrvalueWithDelay() bool { return item.index == 5 } + +func (item *MemcacheValue) AsStrvalueWithDelay() (*MemcacheStrvalueWithDelay, bool) { + if item.index != 5 { + return nil, false + } + return &item.valueStrvalueWithDelay, true +} +func (item *MemcacheValue) ResetToStrvalueWithDelay() *MemcacheStrvalueWithDelay { + item.index = 5 + item.valueStrvalueWithDelay.Reset() + return &item.valueStrvalueWithDelay +} +func (item *MemcacheValue) SetStrvalueWithDelay(value MemcacheStrvalueWithDelay) { + item.index = 5 + item.valueStrvalueWithDelay = value +} + +func (item *MemcacheValue) ReadTL1(w []byte) (_ []byte, err error) { + return item.ReadTL1Boxed(w) +} + +func (item *MemcacheValue) ReadTL1Boxed(w []byte) (_ []byte, err error) { + var tag uint32 + if w, err = basictl.NatRead(w, &tag); err != nil { + return w, err + } + switch tag { + case 0x32c42422: + item.index = 0 + return w, nil + case 0xa6bebb1a: + item.index = 1 + return item.valueStrvalue.ReadTL1(w) + case 0x09729c42: + item.index = 2 + return item.valueLongvalue.ReadTL1(w) + case 0xa064c821: + item.index = 3 + return item.valueStrvalueWithTime.ReadTL1(w) + case 0x01dcd5d5: + item.index = 4 + return item.valueLongvalueWithTime.ReadTL1(w) + case 0x1bbf7044: + item.index = 5 + return item.valueStrvalueWithDelay.ReadTL1(w) + default: + return w, ErrorInvalidUnionTag("memcache.Value", tag) + } +} + +func (item *MemcacheValue) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1BoxedGeneral(w) +} + +func (item *MemcacheValue) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheValue) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, _MemcacheValue[item.index].TLTag) + switch item.index { + case 0: + return w + case 1: + w = item.valueStrvalue.WriteTL1(w) + case 2: + w = item.valueLongvalue.WriteTL1(w) + case 3: + w = item.valueStrvalueWithTime.WriteTL1(w) + case 4: + w = item.valueLongvalueWithTime.WriteTL1(w) + case 5: + w = item.valueStrvalueWithDelay.WriteTL1(w) + } + return w +} + +func (item *MemcacheValue) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + + switch item.index { + case 1: + return item.valueStrvalue.CalculateLayout(sizes, optimizeEmpty) + case 2: + return item.valueLongvalue.CalculateLayout(sizes, optimizeEmpty) + case 3: + return item.valueStrvalueWithTime.CalculateLayout(sizes, optimizeEmpty) + case 4: + return item.valueLongvalueWithTime.CalculateLayout(sizes, optimizeEmpty) + case 5: + return item.valueStrvalueWithDelay.CalculateLayout(sizes, optimizeEmpty) + } + if item.index == 0 { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 + } + bodySize := 1 + basictl.TL2CalculateSize(item.index) + return sizes, 1 + bodySize +} + +func (item *MemcacheValue) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + + switch item.index { + case 1: + return item.valueStrvalue.InternalWriteTL2(w, sizes, optimizeEmpty) + case 2: + return item.valueLongvalue.InternalWriteTL2(w, sizes, optimizeEmpty) + case 3: + return item.valueStrvalueWithTime.InternalWriteTL2(w, sizes, optimizeEmpty) + case 4: + return item.valueLongvalueWithTime.InternalWriteTL2(w, sizes, optimizeEmpty) + case 5: + return item.valueStrvalueWithDelay.InternalWriteTL2(w, sizes, optimizeEmpty) + } + if item.index == 0 { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 + } + bodySize := 1 + basictl.TL2CalculateSize(item.index) + w = append(w, byte(bodySize)) + w = append(w, 1) + w = basictl.TL2WriteSize(w, item.index) + return w, sizes, 1 + bodySize +} + +func (item *MemcacheValue) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + item.index = 0 + if (block & 1) != 0 { + if currentR, item.index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if item.index >= 6 { + return r, ErrorInvalidUnionIndex("memcache.Value", item.index) + } + } + switch item.index { + case 1: + if currentR, err = item.valueStrvalue.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + case 2: + if currentR, err = item.valueLongvalue.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + case 3: + if currentR, err = item.valueStrvalueWithTime.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + case 4: + if currentR, err = item.valueLongvalueWithTime.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + case 5: + if currentR, err = item.valueStrvalueWithDelay.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + } + Unused(currentR) + return r, nil +} +func (item *MemcacheValue) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheValue) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) ([]byte, error) { + return item.InternalReadTL2(r) +} + +func (item *MemcacheValue) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheValue) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + _tag, _value, err := Json2ReadUnion("memcache.Value", in) + if err != nil { + return err + } + switch _tag { + case "not_found", "memcache.not_found#32c42422", "memcache.not_found", "#32c42422": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "memcache.not_found#32c42422" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "memcache.not_found#32c42422") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#32c42422" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "#32c42422") + } + item.index = 0 + case "strvalue", "memcache.strvalue#a6bebb1a", "memcache.strvalue", "#a6bebb1a": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "memcache.strvalue#a6bebb1a" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "memcache.strvalue#a6bebb1a") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#a6bebb1a" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "#a6bebb1a") + } + item.index = 1 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueStrvalue.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + case "longvalue", "memcache.longvalue#09729c42", "memcache.longvalue", "#09729c42": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "memcache.longvalue#09729c42" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "memcache.longvalue#09729c42") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#09729c42" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "#09729c42") + } + item.index = 2 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueLongvalue.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + case "strvalueWithTime", "memcache.strvalueWithTime#a064c821", "memcache.strvalueWithTime", "#a064c821": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "memcache.strvalueWithTime#a064c821" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "memcache.strvalueWithTime#a064c821") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#a064c821" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "#a064c821") + } + item.index = 3 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueStrvalueWithTime.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + case "longvalueWithTime", "memcache.longvalueWithTime#01dcd5d5", "memcache.longvalueWithTime", "#01dcd5d5": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "memcache.longvalueWithTime#01dcd5d5" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "memcache.longvalueWithTime#01dcd5d5") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#01dcd5d5" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "#01dcd5d5") + } + item.index = 4 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueLongvalueWithTime.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + case "strvalueWithDelay", "memcache.strvalueWithDelay#1bbf7044", "memcache.strvalueWithDelay", "#1bbf7044": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "memcache.strvalueWithDelay#1bbf7044" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "memcache.strvalueWithDelay#1bbf7044") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#1bbf7044" { + return ErrorInvalidUnionLegacyTagJSON("memcache.Value", "#1bbf7044") + } + item.index = 5 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueStrvalueWithDelay.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + default: + return ErrorInvalidUnionTagJSON("memcache.Value", _tag) + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheValue) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) ([]byte, error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheValue) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheValue) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + switch item.index { + case 0: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"not_found"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"memcache.not_found#32c42422"`...) + } else { + w = append(w, `{"type":"memcache.not_found"`...) + } + } + return append(w, '}') + case 1: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"strvalue"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"memcache.strvalue#a6bebb1a"`...) + } else { + w = append(w, `{"type":"memcache.strvalue"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueStrvalue.WriteJSONOpt(jctx, w) + return append(w, '}') + case 2: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"longvalue"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"memcache.longvalue#09729c42"`...) + } else { + w = append(w, `{"type":"memcache.longvalue"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueLongvalue.WriteJSONOpt(jctx, w) + return append(w, '}') + case 3: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"strvalueWithTime"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"memcache.strvalueWithTime#a064c821"`...) + } else { + w = append(w, `{"type":"memcache.strvalueWithTime"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueStrvalueWithTime.WriteJSONOpt(jctx, w) + return append(w, '}') + case 4: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"longvalueWithTime"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"memcache.longvalueWithTime#01dcd5d5"`...) + } else { + w = append(w, `{"type":"memcache.longvalueWithTime"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueLongvalueWithTime.WriteJSONOpt(jctx, w) + return append(w, '}') + case 5: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"strvalueWithDelay"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"memcache.strvalueWithDelay#1bbf7044"`...) + } else { + w = append(w, `{"type":"memcache.strvalueWithDelay"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueStrvalueWithDelay.WriteJSONOpt(jctx, w) + return append(w, '}') + default: // Impossible due to panic above + return w + } +} + +func (item MemcacheValue) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheValue) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheValue) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.Value", err.Error()) + } + return nil +} diff --git a/internal/speed/speed_tl/internal/memcache.values.go b/internal/speed/speed_tl/internal/memcache.values.go new file mode 100644 index 000000000..06645e85b --- /dev/null +++ b/internal/speed/speed_tl/internal/memcache.values.go @@ -0,0 +1,244 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +type MemcacheValues struct { + Values []MemcacheValue +} + +func (MemcacheValues) TLName() string { return "memcache.values" } +func (MemcacheValues) TLTag() uint32 { return 0xc894cef8 } + +func (item *MemcacheValues) Reset() { + item.Values = item.Values[:0] +} + +func (item *MemcacheValues) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorMemcacheValueReadTL1(w, &item.Values) +} + +func (item *MemcacheValues) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *MemcacheValues) WriteTL1(w []byte) []byte { + w = BuiltinVectorMemcacheValueWriteTL1(w, item.Values) + return w +} + +func (item *MemcacheValues) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xc894cef8); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *MemcacheValues) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *MemcacheValues) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xc894cef8) + return item.WriteTL1(w) +} + +func (item MemcacheValues) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *MemcacheValues) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *MemcacheValues) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuesPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "values": + if propValuesPresented { + return ErrorInvalidJSONWithDuplicatingKeys("memcache.values", "values") + } + propValuesPresented = true + if err := BuiltinVectorMemcacheValueReadJSONGeneral(jctx, in, &item.Values); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("memcache.values", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuesPresented { + item.Values = item.Values[:0] + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *MemcacheValues) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *MemcacheValues) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *MemcacheValues) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValues := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"values":`...) + w = BuiltinVectorMemcacheValueWriteJSONOpt(jctx, w, item.Values) + if !(len(item.Values) != 0) { + w = w[:backupIndexValues] + } + return append(w, '}') +} + +func (item *MemcacheValues) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *MemcacheValues) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("memcache.values", err.Error()) + } + return nil +} + +func (item *MemcacheValues) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 3532069701) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if sizes, sz = BuiltinVectorMemcacheValueCalculateLayout(sizes, true, &item.Values); sz != 0 { + currentSize += sz + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *MemcacheValues) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 3532069701 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if w, sizes, sz = BuiltinVectorMemcacheValueInternalWriteTL2(w, sizes, true, &item.Values); sz != 0 { + currentBlock |= 2 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *MemcacheValues) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *MemcacheValues) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return currentR, err + } + // read No of constructor + if block&1 != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return currentR, err + } + if index != 0 { + return r, ErrorInvalidUnionIndex("memcache.values", index) + } + } + if block&2 != 0 { + if currentR, err = BuiltinVectorMemcacheValueInternalReadTL2(currentR, &item.Values); err != nil { + return currentR, err + } + } else { + item.Values = item.Values[:0] + } + Unused(currentR) + return r, nil +} + +func (item *MemcacheValues) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/internal/metainternal/metainternal.go b/internal/speed/speed_tl/internal/metainternal/metainternal.go new file mode 100644 index 000000000..5db07c36c --- /dev/null +++ b/internal/speed/speed_tl/internal/metainternal/metainternal.go @@ -0,0 +1,300 @@ +// Code generated by tl2gen; DO NOT EDIT. +package metainternal + +import ( + "fmt" + + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" + "github.com/VKCOM/tl/internal/speed/speed_tl/internal" +) + +// We can create only types which have zero type arguments and zero nat arguments +type Object interface { + TLName() string // returns type's TL name. For union, returns constructor name depending on actual union value + TLTag() uint32 // returns type's TL tag. For union, returns constructor tag depending on actual union value + String() string // returns type's representation for debugging (JSON for now) + + ReadTL1(w []byte) ([]byte, error) // reads type's bare TL representation by consuming bytes from the start of w and returns remaining bytes, plus error + ReadTL1Boxed(w []byte) ([]byte, error) // same as Read, but reads/checks TLTag first (this method is general version of Write, use it only when you are working with interface) + WriteTL1General(w []byte) ([]byte, error) // same as Write, but has common signature (with error) for all objects, so can be called through interface + WriteTL1BoxedGeneral(w []byte) ([]byte, error) // same as WriteBoxed, but has common signature (with error) for all objects, so can be called through interface + + MarshalJSON() ([]byte, error) // returns type's JSON representation, plus error + UnmarshalJSON([]byte) error // reads type's JSON representation + + ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error + // like MarshalJSON, but appends to w and returns it + // pass empty basictl.JSONWriteContext{} if you do not know which options you need + WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) ([]byte, error) + + ReadTL2(r []byte, tctx *basictl.TL2ReadContext) ([]byte, error) + WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte +} + +type Function interface { + Object + + // jctx is for options controlling transcoding short-long version during Long ID and legacyTypeNames->newTypeNames transition + // pass nil if you do not know which options you need + ReadResultTL1WriteResultJSON(jctx *basictl.JSONWriteContext, r []byte, w []byte) ([]byte, []byte, error) // combination of ReadResult(r) + WriteResultJSON(w). Returns new r, new w, plus error + ReadResultJSONWriteResultTL1(jctx *basictl.JSONReadContext, r []byte, w []byte) ([]byte, []byte, error) // combination of ReadResultJSON(r) + WriteResult(w). Returns new r, new w, plus error + + ReadResultTL1WriteResultTL2(tctx *basictl.TL2WriteContext, r []byte, w []byte) (_ []byte, _ []byte, err error) + ReadResultTL2WriteResultTL1(tctx *basictl.TL2ReadContext, r []byte, w []byte) (_ []byte, _ []byte, err error) + + ReadResultTL2WriteResultJSON(tctx *basictl.TL2ReadContext, jctx *basictl.JSONWriteContext, r []byte, w []byte) (_ []byte, _ []byte, err error) + ReadResultJSONWriteResultTL2(jctx *basictl.JSONReadContext, tctx *basictl.TL2WriteContext, r []byte, w []byte) (_ []byte, _ []byte, err error) +} + +type TLItem interface { + TLTag() uint32 + TLName() string + // true if has TL1 code generated + HasTL1() bool + // true if has TL2 code generated + HasTL2() bool + CreateObject() Object + // used in TL generator tests only, do not use in product code + CreateObjectBytes() Object + + IsFunction() bool + CreateFunction() Function + // used in TL generator tests only, do not use in product code + CreateFunctionBytes() Function + HasUnionTypesInResult() bool + HasUnionTypesInArguments() bool + // For transcoding short-long version during Long ID transition + HasFunctionLong() bool + CreateFunctionLong() Function + + // Annotations + AnnotationAny() bool + AnnotationInternal() bool + AnnotationKphp() bool + AnnotationRead() bool + AnnotationReadwrite() bool + AnnotationWrite() bool +} + +type TLItemImpl struct { + Tag uint32 + Annotations uint32 + Name string + + HaTL1 bool + HaTL2 bool + + ResultTypeContainsUnionTypes bool + ArgumentsTypesContainUnionTypes bool + + // either CrObject != nil or CrFunction != nil for object/function respectively + // also, CrFunctionLong can be != nil if there is long adapter (legacy to be removed soon) + // also, CrObjectBytes, CrFunctionBytes, CrFunctionLongBytes + // can be != nil independently, if factory_bytes is imported + CrFunction func() Function + CrFunctionLong func() Function + CrObject func() Object + CrFunctionBytes func() Function + CrFunctionLongBytes func() Function + CrObjectBytes func() Object +} + +func (item TLItemImpl) TLTag() uint32 { return item.Tag } +func (item TLItemImpl) TLName() string { return item.Name } + +// true for TL1-originated types +func (item TLItemImpl) HasTL1() bool { return item.HaTL1 } + +// true for TL2-originated types and for TL1-originated types if in TL2 generation whitelist +func (item TLItemImpl) HasTL2() bool { return item.HaTL2 } +func (item TLItemImpl) CreateObject() Object { + if item.CrFunction != nil { + return item.CrFunction() + } + return item.CrObject() +} + +// used in TL generator tests only, do not use in product code +func (item TLItemImpl) CreateObjectBytes() Object { + if item.CrFunctionBytes != nil { + return item.CrFunctionBytes() + } + if item.CrFunction != nil { + return item.CrFunction() + } + if item.CrObjectBytes != nil { + return item.CrObjectBytes() + } + return item.CrObject() +} + +func (item TLItemImpl) IsFunction() bool { return item.CrFunction != nil } +func (item TLItemImpl) CreateFunction() Function { return item.CrFunction() } + +// used in TL generator tests only, do not use in product code +func (item TLItemImpl) CreateFunctionBytes() Function { + if item.CrFunctionBytes != nil { + return item.CrFunctionBytes() + } + return item.CrFunction() +} + +func (item TLItemImpl) HasUnionTypesInResult() bool { return item.ResultTypeContainsUnionTypes } +func (item TLItemImpl) HasUnionTypesInArguments() bool { return item.ArgumentsTypesContainUnionTypes } + +// For transcoding short-long version during Long ID transition +func (item TLItemImpl) HasFunctionLong() bool { return item.CrFunctionLong != nil } +func (item TLItemImpl) CreateFunctionLong() Function { return item.CrFunctionLong() } + +// we simplify interface by commenting this method no one yet needs. +// hopefully it will be removed together with long adapters code +// func (item TLItemImpl) CreateFunctionLongBytes() Function { +// if item.CrFunctionLongBytes != nil { +// return item.CrFunctionLongBytes() +// } +// return item.CrFunctionLong() +// } + +// Annotations +func (item TLItemImpl) AnnotationAny() bool { return item.Annotations&0x1 != 0 } +func (item TLItemImpl) AnnotationInternal() bool { return item.Annotations&0x2 != 0 } +func (item TLItemImpl) AnnotationKphp() bool { return item.Annotations&0x4 != 0 } +func (item TLItemImpl) AnnotationRead() bool { return item.Annotations&0x8 != 0 } +func (item TLItemImpl) AnnotationReadwrite() bool { return item.Annotations&0x10 != 0 } +func (item TLItemImpl) AnnotationWrite() bool { return item.Annotations&0x20 != 0 } + +// TLItemImpl serves as a single type for all TL1 enum values +func (item *TLItemImpl) Reset() {} +func (item *TLItemImpl) ReadTL1(w []byte) ([]byte, error) { return w, nil } +func (item *TLItemImpl) ReadTL1Boxed(w []byte) ([]byte, error) { + return basictl.NatReadExactTag(w, item.Tag) +} +func (item *TLItemImpl) WriteTL1General(w []byte) ([]byte, error) { return w, nil } +func (item *TLItemImpl) WriteTL1BoxedGeneral(w []byte) ([]byte, error) { + return basictl.NatWrite(w, item.Tag), nil +} +func (item TLItemImpl) String() string { + return string(item.WriteJSON(nil)) +} +func (item *TLItemImpl) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + return internal.ErrorInvalidJSONExcessElement(item.Name, in.UnsafeFieldName(true)) + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + return nil +} +func (item *TLItemImpl) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSON(w), nil +} +func (item *TLItemImpl) WriteJSON(w []byte) []byte { + w = append(w, '{') + return append(w, '}') +} +func (item *TLItemImpl) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} +func (item *TLItemImpl) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return internal.ErrorInvalidJSON(item.Name, err.Error()) + } + return nil +} +func (item *TLItemImpl) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) ([]byte, error) { + return r, nil +} +func (item *TLItemImpl) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + return w +} + +var ItemsOrdered []TLItem + +var ItemsByTag = map[uint32]*TLItemImpl{} + +var ItemsByName = map[string]*TLItemImpl{} + +// called by factory init code +func SetGlobalFactoryCreateForFunction(name string, createFunction func() Function, createFunctionLong func() Function) { + item := ItemsByName[name] + if item == nil || item.CrFunction == nil { // only replace !nil createFunction + panic(fmt.Sprintf("factory cannot find function %s to set", name)) + } + item.CrFunction = createFunction + item.CrFunctionLong = createFunctionLong +} + +// called by factory init code +func SetGlobalFactoryCreateForObject(name string, createObject func() Object) { + item := ItemsByName[name] + if item == nil || item.CrObject == nil { // only replace !nil createObject + panic(fmt.Sprintf("factory cannot find object %s to set", name)) + } + item.CrObject = createObject +} + +// called by factory init code +func SetGlobalFactoryCreateForEnumElement(name string) { + item := ItemsByName[name] + if item == nil || item.CrObject == nil { // only replace !nil createObject + panic(fmt.Sprintf("factory cannot find enum %s to set", name)) + } + item.CrObject = func() Object { return item } +} + +// called by factory init code +func SetGlobalFactoryCreateForFunctionBytes(name string, createFunctionBytes func() Function, createFunctionLongBytes func() Function) { + item := ItemsByName[name] + if item == nil || item.CrFunction == nil { // only replace !nil createFunction + panic(fmt.Sprintf("factory cannot find function %s to set", name)) + } + item.CrFunctionBytes = createFunctionBytes + item.CrFunctionLongBytes = createFunctionLongBytes +} + +// Do not call directly, called by factory init code +func SetGlobalFactoryCreateForObjectBytes(name string, createObjectBytes func() Object) { + item := ItemsByName[name] + if item == nil || item.CrObject == nil { // only replace !nil createObject + panic(fmt.Sprintf("factory cannot find object %s to set", name)) + } + item.CrObjectBytes = createObjectBytes +} + +func pleaseImportFactoryObject() Object { + panic("factory functions are not linked to reduce code bloat, please import 'gen/factory' instead of 'gen/meta'.") +} + +func pleaseImportFactoryFunction() Function { + panic("factory functions are not linked to reduce code bloat, please import 'gen/factory' instead of 'gen/meta'.") +} + +func FillObject(item *TLItemImpl) { + if _, ok := ItemsByName[item.Name]; ok { + return // meta and metamini can both add the same item + } + ItemsOrdered = append(ItemsOrdered, item) + ItemsByName[item.Name] = item + if item.Tag != 0 { + ItemsByTag[item.Tag] = item + } + item.CrObject = pleaseImportFactoryObject +} + +func FillFunction(item *TLItemImpl) { + if _, ok := ItemsByName[item.Name]; ok { + return // meta and metamini can both add the same item + } + ItemsOrdered = append(ItemsOrdered, item) + ItemsByName[item.Name] = item + if item.Tag != 0 { + ItemsByTag[item.Tag] = item + } + item.CrFunction = pleaseImportFactoryFunction +} diff --git a/internal/speed/speed_tl/internal/partialPoint.go b/internal/speed/speed_tl/internal/partialPoint.go new file mode 100644 index 000000000..f262d913e --- /dev/null +++ b/internal/speed/speed_tl/internal/partialPoint.go @@ -0,0 +1,625 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +func BuiltinVectorPartialPointBoxedRepairMasks(vec *[]PartialPoint) { + for i := range *vec { + (*vec)[i].RepairMasks() + } +} +func BuiltinVectorPartialPointBoxedReadTL1(w []byte, vec *[]PartialPoint) (_ []byte, err error) { + var l uint32 + if w, err = basictl.NatRead(w, &l); err != nil { + return w, err + } + if err = basictl.CheckLengthSanity(w, l, 4); err != nil { + return w, err + } + if uint32(cap(*vec)) < l { + *vec = make([]PartialPoint, l) + } else { + *vec = (*vec)[:l] + } + for i := range *vec { + if w, err = (*vec)[i].ReadTL1Boxed(w); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinVectorPartialPointBoxedWriteTL1(w []byte, vec []PartialPoint) []byte { + w = basictl.NatWrite(w, uint32(len(vec))) + for _, elem := range vec { + w = elem.WriteTL1Boxed(w) + } + return w +} + +func BuiltinVectorPartialPointBoxedCalculateLayout(sizes []int, optimizeEmpty bool, vec *[]PartialPoint) ([]int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 + } + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 0 + var sz int + + currentSize += basictl.TL2CalculateSize(len(*vec)) + for i := 0; i < len(*vec); i++ { + sizes, sz = (*vec)[i].CalculateLayout(sizes, false) + currentSize += sz + } + sizes[sizePosition] = currentSize + currentSize += basictl.TL2CalculateSize(currentSize) + Unused(sz) + return sizes, currentSize +} + +func BuiltinVectorPartialPointBoxedInternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool, vec *[]PartialPoint) ([]byte, []int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 + } + currentSize := sizes[0] + sizes = sizes[1:] + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + w = basictl.TL2WriteSize(w, len(*vec)) + + var sz int + for i := 0; i < len(*vec); i++ { + w, sizes, _ = (*vec)[i].InternalWriteTL2(w, sizes, false) + } + Unused(sz) + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + return w, sizes, currentSize +} + +func BuiltinVectorPartialPointBoxedInternalReadTL2(r []byte, vec *[]PartialPoint) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + elementCount := 0 + if currentSize != 0 { + if currentR, elementCount, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if elementCount > len(currentR) { + return r, basictl.TL2ElementCountError(elementCount, currentR) + } + } + + if cap(*vec) < elementCount { + *vec = make([]PartialPoint, elementCount) + } + *vec = (*vec)[:elementCount] + for i := 0; i < elementCount; i++ { + if currentR, err = (*vec)[i].InternalReadTL2(currentR); err != nil { + return currentR, err + } + } + return r, nil +} + +func BuiltinVectorPartialPointBoxedReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer, vec *[]PartialPoint) error { + *vec = (*vec)[:cap(*vec)] + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return ErrorInvalidJSON("[]PartialPoint", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if len(*vec) <= index { + var newValue PartialPoint + *vec = append(*vec, newValue) + *vec = (*vec)[:cap(*vec)] + } + if err := (*vec)[index].ReadJSONGeneral(jctx, in); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return ErrorInvalidJSON("[]PartialPoint", "expected json array's end") + } + } + *vec = (*vec)[:index] + return nil +} + +func BuiltinVectorPartialPointBoxedWriteJSON(w []byte, vec []PartialPoint) []byte { + return BuiltinVectorPartialPointBoxedWriteJSONOpt(nil, w, vec) +} +func BuiltinVectorPartialPointBoxedWriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte, vec []PartialPoint) []byte { + w = append(w, '[') + for _, elem := range vec { + w = basictl.JSONAddCommaIfNeeded(w) + w = elem.WriteJSONOpt(jctx, w) + } + return append(w, ']') +} + +type PartialPoint struct { + Mask uint32 + X uint32 // Conditional: item.Mask.0 + Y uint32 // Conditional: item.Mask.1 + Z uint32 // Conditional: item.Mask.2 + tl2mask0 byte +} + +func (PartialPoint) TLName() string { return "partialPoint" } +func (PartialPoint) TLTag() uint32 { return 0xbfa57042 } + +func (item *PartialPoint) SetX(v uint32) { + item.X = v + item.Mask |= 1 << 0 + item.tl2mask0 |= 1 +} +func (item *PartialPoint) ClearX() { + item.X = 0 + item.Mask &^= 1 << 0 + item.tl2mask0 &^= 1 +} +func (item *PartialPoint) IsSetX() bool { return item.tl2mask0&1 != 0 } + +func (item *PartialPoint) SetY(v uint32) { + item.Y = v + item.Mask |= 1 << 1 + item.tl2mask0 |= 2 +} +func (item *PartialPoint) ClearY() { + item.Y = 0 + item.Mask &^= 1 << 1 + item.tl2mask0 &^= 2 +} +func (item *PartialPoint) IsSetY() bool { return item.tl2mask0&2 != 0 } + +func (item *PartialPoint) SetZ(v uint32) { + item.Z = v + item.Mask |= 1 << 2 + item.tl2mask0 |= 4 +} +func (item *PartialPoint) ClearZ() { + item.Z = 0 + item.Mask &^= 1 << 2 + item.tl2mask0 &^= 4 +} +func (item *PartialPoint) IsSetZ() bool { return item.tl2mask0&4 != 0 } + +func (item *PartialPoint) Reset() { + item.Mask = 0 + item.X = 0 + item.Y = 0 + item.Z = 0 + item.tl2mask0 = 0 +} + +func (item PartialPoint) RepairMasksValue() PartialPoint { + item.RepairMasks() + return item +} +func (item *PartialPoint) RepairMasks() { + item.tl2mask0 = 0 + if item.Mask&(1<<0) != 0 { + item.tl2mask0 |= 1 + } + if item.Mask&(1<<1) != 0 { + item.tl2mask0 |= 2 + } + if item.Mask&(1<<2) != 0 { + item.tl2mask0 |= 4 + } +} + +func (item *PartialPoint) ReadTL1(w []byte) (_ []byte, err error) { + item.tl2mask0 = 0 + if w, err = basictl.NatRead(w, &item.Mask); err != nil { + return w, err + } + if item.Mask&(1<<0) != 0 { + item.tl2mask0 |= 1 + if w, err = basictl.NatRead(w, &item.X); err != nil { + return w, err + } + } else { + item.X = 0 + } + if item.Mask&(1<<1) != 0 { + item.tl2mask0 |= 2 + if w, err = basictl.NatRead(w, &item.Y); err != nil { + return w, err + } + } else { + item.Y = 0 + } + if item.Mask&(1<<2) != 0 { + item.tl2mask0 |= 4 + if w, err = basictl.NatRead(w, &item.Z); err != nil { + return w, err + } + } else { + item.Z = 0 + } + return w, nil +} + +func (item *PartialPoint) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *PartialPoint) WriteTL1(w []byte) []byte { + w = basictl.NatWrite(w, item.Mask) + if item.Mask&(1<<0) != 0 { + w = basictl.NatWrite(w, item.X) + } + if item.Mask&(1<<1) != 0 { + w = basictl.NatWrite(w, item.Y) + } + if item.Mask&(1<<2) != 0 { + w = basictl.NatWrite(w, item.Z) + } + return w +} + +func (item *PartialPoint) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xbfa57042); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *PartialPoint) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *PartialPoint) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xbfa57042) + return item.WriteTL1(w) +} + +func (item PartialPoint) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *PartialPoint) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *PartialPoint) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + item.tl2mask0 = 0 + var propMaskPresented bool + var propXPresented bool + var propYPresented bool + var propZPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "mask": + if propMaskPresented { + return ErrorInvalidJSONWithDuplicatingKeys("partialPoint", "mask") + } + propMaskPresented = true + if err := Json2ReadUint32(in, &item.Mask); err != nil { + return err + } + case "x": + if propXPresented { + return ErrorInvalidJSONWithDuplicatingKeys("partialPoint", "x") + } + propXPresented = true + if err := Json2ReadUint32(in, &item.X); err != nil { + return err + } + item.tl2mask0 |= 1 + case "y": + if propYPresented { + return ErrorInvalidJSONWithDuplicatingKeys("partialPoint", "y") + } + propYPresented = true + if err := Json2ReadUint32(in, &item.Y); err != nil { + return err + } + item.tl2mask0 |= 2 + case "z": + if propZPresented { + return ErrorInvalidJSONWithDuplicatingKeys("partialPoint", "z") + } + propZPresented = true + if err := Json2ReadUint32(in, &item.Z); err != nil { + return err + } + item.tl2mask0 |= 4 + default: + return ErrorInvalidJSONExcessElement("partialPoint", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propMaskPresented { + item.Mask = 0 + } + if !propXPresented { + item.X = 0 + } + if !propYPresented { + item.Y = 0 + } + if !propZPresented { + item.Z = 0 + } + if !propXPresented && item.Mask&(1<<0) != 0 { + item.tl2mask0 |= 1 + } + if !propYPresented && item.Mask&(1<<1) != 0 { + item.tl2mask0 |= 2 + } + if !propZPresented && item.Mask&(1<<2) != 0 { + item.tl2mask0 |= 4 + } + if propXPresented { + item.Mask |= 1 << 0 + } + if propYPresented { + item.Mask |= 1 << 1 + } + if propZPresented { + item.Mask |= 1 << 2 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *PartialPoint) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *PartialPoint) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *PartialPoint) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexMask := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"mask":`...) + w = basictl.JSONWriteUint32(w, item.Mask) + if !(item.Mask != 0) { + w = w[:backupIndexMask] + } + if item.tl2mask0&1 != 0 { + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"x":`...) + w = basictl.JSONWriteUint32(w, item.X) + } + if item.tl2mask0&2 != 0 { + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"y":`...) + w = basictl.JSONWriteUint32(w, item.Y) + } + if item.tl2mask0&4 != 0 { + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"z":`...) + w = basictl.JSONWriteUint32(w, item.Z) + } + return append(w, '}') +} + +func (item *PartialPoint) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *PartialPoint) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("partialPoint", err.Error()) + } + return nil +} + +func (item *PartialPoint) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 2182843827) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if item.Mask != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.tl2mask0&1 != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.tl2mask0&2 != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.tl2mask0&4 != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *PartialPoint) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 2182843827 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if item.Mask != 0 { + w = basictl.NatWrite(w, item.Mask) + currentBlock |= 2 + } + if item.tl2mask0&1 != 0 { + w = basictl.NatWrite(w, item.X) + currentBlock |= 4 + } + if item.tl2mask0&2 != 0 { + w = basictl.NatWrite(w, item.Y) + currentBlock |= 8 + } + if item.tl2mask0&4 != 0 { + w = basictl.NatWrite(w, item.Z) + currentBlock |= 16 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *PartialPoint) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *PartialPoint) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return currentR, err + } + // read No of constructor + if block&1 != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return currentR, err + } + if index != 0 { + return r, ErrorInvalidUnionIndex("partialPoint", index) + } + } + item.tl2mask0 = 0 + if block&2 != 0 { + if currentR, err = basictl.NatRead(currentR, &item.Mask); err != nil { + return currentR, err + } + } else { + item.Mask = 0 + } + if block&4 != 0 { + item.tl2mask0 |= 1 + if currentR, err = basictl.NatRead(currentR, &item.X); err != nil { + return currentR, err + } + } else { + item.X = 0 + } + if block&8 != 0 { + item.tl2mask0 |= 2 + if currentR, err = basictl.NatRead(currentR, &item.Y); err != nil { + return currentR, err + } + } else { + item.Y = 0 + } + if block&16 != 0 { + item.tl2mask0 |= 4 + if currentR, err = basictl.NatRead(currentR, &item.Z); err != nil { + return currentR, err + } + } else { + item.Z = 0 + } + Unused(currentR) + return r, nil +} + +func (item *PartialPoint) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/internal/partialPoints.go b/internal/speed/speed_tl/internal/partialPoints.go new file mode 100644 index 000000000..3c08541af --- /dev/null +++ b/internal/speed/speed_tl/internal/partialPoints.go @@ -0,0 +1,252 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +type PartialPoints struct { + Values []PartialPoint +} + +func (PartialPoints) TLName() string { return "partialPoints" } +func (PartialPoints) TLTag() uint32 { return 0x0d7f74de } + +func (item *PartialPoints) Reset() { + item.Values = item.Values[:0] +} + +func (item PartialPoints) RepairMasksValue() PartialPoints { + item.RepairMasks() + return item +} +func (item *PartialPoints) RepairMasks() { + BuiltinVectorPartialPointBoxedRepairMasks(&item.Values) +} + +func (item *PartialPoints) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorPartialPointBoxedReadTL1(w, &item.Values) +} + +func (item *PartialPoints) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *PartialPoints) WriteTL1(w []byte) []byte { + w = BuiltinVectorPartialPointBoxedWriteTL1(w, item.Values) + return w +} + +func (item *PartialPoints) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x0d7f74de); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *PartialPoints) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *PartialPoints) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x0d7f74de) + return item.WriteTL1(w) +} + +func (item PartialPoints) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *PartialPoints) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *PartialPoints) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuesPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "values": + if propValuesPresented { + return ErrorInvalidJSONWithDuplicatingKeys("partialPoints", "values") + } + propValuesPresented = true + if err := BuiltinVectorPartialPointBoxedReadJSONGeneral(jctx, in, &item.Values); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("partialPoints", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuesPresented { + item.Values = item.Values[:0] + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *PartialPoints) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *PartialPoints) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *PartialPoints) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValues := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"values":`...) + w = BuiltinVectorPartialPointBoxedWriteJSONOpt(jctx, w, item.Values) + if !(len(item.Values) != 0) { + w = w[:backupIndexValues] + } + return append(w, '}') +} + +func (item *PartialPoints) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *PartialPoints) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("partialPoints", err.Error()) + } + return nil +} + +func (item *PartialPoints) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 1178964329) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if sizes, sz = BuiltinVectorPartialPointBoxedCalculateLayout(sizes, true, &item.Values); sz != 0 { + currentSize += sz + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *PartialPoints) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 1178964329 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if w, sizes, sz = BuiltinVectorPartialPointBoxedInternalWriteTL2(w, sizes, true, &item.Values); sz != 0 { + currentBlock |= 2 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *PartialPoints) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *PartialPoints) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return currentR, err + } + // read No of constructor + if block&1 != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return currentR, err + } + if index != 0 { + return r, ErrorInvalidUnionIndex("partialPoints", index) + } + } + if block&2 != 0 { + if currentR, err = BuiltinVectorPartialPointBoxedInternalReadTL2(currentR, &item.Values); err != nil { + return currentR, err + } + } else { + item.Values = item.Values[:0] + } + Unused(currentR) + return r, nil +} + +func (item *PartialPoints) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/internal/point.go b/internal/speed/speed_tl/internal/point.go new file mode 100644 index 000000000..4b6a4a65d --- /dev/null +++ b/internal/speed/speed_tl/internal/point.go @@ -0,0 +1,480 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +func BuiltinVectorPointBoxedReadTL1(w []byte, vec *[]Point) (_ []byte, err error) { + var l uint32 + if w, err = basictl.NatRead(w, &l); err != nil { + return w, err + } + if err = basictl.CheckLengthSanity(w, l, 4); err != nil { + return w, err + } + if uint32(cap(*vec)) < l { + *vec = make([]Point, l) + } else { + *vec = (*vec)[:l] + } + for i := range *vec { + if w, err = (*vec)[i].ReadTL1Boxed(w); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinVectorPointBoxedWriteTL1(w []byte, vec []Point) []byte { + w = basictl.NatWrite(w, uint32(len(vec))) + for _, elem := range vec { + w = elem.WriteTL1Boxed(w) + } + return w +} + +func BuiltinVectorPointBoxedCalculateLayout(sizes []int, optimizeEmpty bool, vec *[]Point) ([]int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 + } + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 0 + var sz int + + currentSize += basictl.TL2CalculateSize(len(*vec)) + for i := 0; i < len(*vec); i++ { + sizes, sz = (*vec)[i].CalculateLayout(sizes, false) + currentSize += sz + } + sizes[sizePosition] = currentSize + currentSize += basictl.TL2CalculateSize(currentSize) + Unused(sz) + return sizes, currentSize +} + +func BuiltinVectorPointBoxedInternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool, vec *[]Point) ([]byte, []int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 + } + currentSize := sizes[0] + sizes = sizes[1:] + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + w = basictl.TL2WriteSize(w, len(*vec)) + + var sz int + for i := 0; i < len(*vec); i++ { + w, sizes, _ = (*vec)[i].InternalWriteTL2(w, sizes, false) + } + Unused(sz) + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + return w, sizes, currentSize +} + +func BuiltinVectorPointBoxedInternalReadTL2(r []byte, vec *[]Point) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + elementCount := 0 + if currentSize != 0 { + if currentR, elementCount, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if elementCount > len(currentR) { + return r, basictl.TL2ElementCountError(elementCount, currentR) + } + } + + if cap(*vec) < elementCount { + *vec = make([]Point, elementCount) + } + *vec = (*vec)[:elementCount] + for i := 0; i < elementCount; i++ { + if currentR, err = (*vec)[i].InternalReadTL2(currentR); err != nil { + return currentR, err + } + } + return r, nil +} + +func BuiltinVectorPointBoxedReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer, vec *[]Point) error { + *vec = (*vec)[:cap(*vec)] + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return ErrorInvalidJSON("[]Point", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if len(*vec) <= index { + var newValue Point + *vec = append(*vec, newValue) + *vec = (*vec)[:cap(*vec)] + } + if err := (*vec)[index].ReadJSONGeneral(jctx, in); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return ErrorInvalidJSON("[]Point", "expected json array's end") + } + } + *vec = (*vec)[:index] + return nil +} + +func BuiltinVectorPointBoxedWriteJSON(w []byte, vec []Point) []byte { + return BuiltinVectorPointBoxedWriteJSONOpt(nil, w, vec) +} +func BuiltinVectorPointBoxedWriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte, vec []Point) []byte { + w = append(w, '[') + for _, elem := range vec { + w = basictl.JSONAddCommaIfNeeded(w) + w = elem.WriteJSONOpt(jctx, w) + } + return append(w, ']') +} + +type Point struct { + X uint32 + Y uint32 + Z uint32 +} + +func (Point) TLName() string { return "point" } +func (Point) TLTag() uint32 { return 0x8ec1a27e } + +func (item *Point) Reset() { + item.X = 0 + item.Y = 0 + item.Z = 0 +} + +func (item *Point) ReadTL1(w []byte) (_ []byte, err error) { + if w, err = basictl.NatRead(w, &item.X); err != nil { + return w, err + } + if w, err = basictl.NatRead(w, &item.Y); err != nil { + return w, err + } + return basictl.NatRead(w, &item.Z) +} + +func (item *Point) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *Point) WriteTL1(w []byte) []byte { + w = basictl.NatWrite(w, item.X) + w = basictl.NatWrite(w, item.Y) + w = basictl.NatWrite(w, item.Z) + return w +} + +func (item *Point) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x8ec1a27e); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *Point) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *Point) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x8ec1a27e) + return item.WriteTL1(w) +} + +func (item Point) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *Point) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *Point) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propXPresented bool + var propYPresented bool + var propZPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "x": + if propXPresented { + return ErrorInvalidJSONWithDuplicatingKeys("point", "x") + } + propXPresented = true + if err := Json2ReadUint32(in, &item.X); err != nil { + return err + } + case "y": + if propYPresented { + return ErrorInvalidJSONWithDuplicatingKeys("point", "y") + } + propYPresented = true + if err := Json2ReadUint32(in, &item.Y); err != nil { + return err + } + case "z": + if propZPresented { + return ErrorInvalidJSONWithDuplicatingKeys("point", "z") + } + propZPresented = true + if err := Json2ReadUint32(in, &item.Z); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("point", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propXPresented { + item.X = 0 + } + if !propYPresented { + item.Y = 0 + } + if !propZPresented { + item.Z = 0 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *Point) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *Point) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *Point) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexX := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"x":`...) + w = basictl.JSONWriteUint32(w, item.X) + if !(item.X != 0) { + w = w[:backupIndexX] + } + backupIndexY := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"y":`...) + w = basictl.JSONWriteUint32(w, item.Y) + if !(item.Y != 0) { + w = w[:backupIndexY] + } + backupIndexZ := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"z":`...) + w = basictl.JSONWriteUint32(w, item.Z) + if !(item.Z != 0) { + w = w[:backupIndexZ] + } + return append(w, '}') +} + +func (item *Point) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *Point) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("point", err.Error()) + } + return nil +} + +func (item *Point) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 616939567) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if item.X != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.Y != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.Z != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *Point) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 616939567 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if item.X != 0 { + w = basictl.NatWrite(w, item.X) + currentBlock |= 2 + } + if item.Y != 0 { + w = basictl.NatWrite(w, item.Y) + currentBlock |= 4 + } + if item.Z != 0 { + w = basictl.NatWrite(w, item.Z) + currentBlock |= 8 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *Point) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *Point) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return currentR, err + } + // read No of constructor + if block&1 != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return currentR, err + } + if index != 0 { + return r, ErrorInvalidUnionIndex("point", index) + } + } + if block&2 != 0 { + if currentR, err = basictl.NatRead(currentR, &item.X); err != nil { + return currentR, err + } + } else { + item.X = 0 + } + if block&4 != 0 { + if currentR, err = basictl.NatRead(currentR, &item.Y); err != nil { + return currentR, err + } + } else { + item.Y = 0 + } + if block&8 != 0 { + if currentR, err = basictl.NatRead(currentR, &item.Z); err != nil { + return currentR, err + } + } else { + item.Z = 0 + } + Unused(currentR) + return r, nil +} + +func (item *Point) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/internal/points.go b/internal/speed/speed_tl/internal/points.go new file mode 100644 index 000000000..c1a9e0d86 --- /dev/null +++ b/internal/speed/speed_tl/internal/points.go @@ -0,0 +1,244 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +type Points struct { + Values []Point +} + +func (Points) TLName() string { return "points" } +func (Points) TLTag() uint32 { return 0xebf9dd56 } + +func (item *Points) Reset() { + item.Values = item.Values[:0] +} + +func (item *Points) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorPointBoxedReadTL1(w, &item.Values) +} + +func (item *Points) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *Points) WriteTL1(w []byte) []byte { + w = BuiltinVectorPointBoxedWriteTL1(w, item.Values) + return w +} + +func (item *Points) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xebf9dd56); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *Points) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *Points) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xebf9dd56) + return item.WriteTL1(w) +} + +func (item Points) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *Points) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *Points) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuesPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "values": + if propValuesPresented { + return ErrorInvalidJSONWithDuplicatingKeys("points", "values") + } + propValuesPresented = true + if err := BuiltinVectorPointBoxedReadJSONGeneral(jctx, in, &item.Values); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("points", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuesPresented { + item.Values = item.Values[:0] + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *Points) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *Points) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *Points) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValues := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"values":`...) + w = BuiltinVectorPointBoxedWriteJSONOpt(jctx, w, item.Values) + if !(len(item.Values) != 0) { + w = w[:backupIndexValues] + } + return append(w, '}') +} + +func (item *Points) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *Points) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("points", err.Error()) + } + return nil +} + +func (item *Points) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 3802914423) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if sizes, sz = BuiltinVectorPointBoxedCalculateLayout(sizes, true, &item.Values); sz != 0 { + currentSize += sz + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *Points) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 3802914423 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if w, sizes, sz = BuiltinVectorPointBoxedInternalWriteTL2(w, sizes, true, &item.Values); sz != 0 { + currentBlock |= 2 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *Points) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *Points) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return currentR, err + } + // read No of constructor + if block&1 != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return currentR, err + } + if index != 0 { + return r, ErrorInvalidUnionIndex("points", index) + } + } + if block&2 != 0 { + if currentR, err = BuiltinVectorPointBoxedInternalReadTL2(currentR, &item.Values); err != nil { + return currentR, err + } + } else { + item.Values = item.Values[:0] + } + Unused(currentR) + return r, nil +} + +func (item *Points) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/internal/unionPoint.go b/internal/speed/speed_tl/internal/unionPoint.go new file mode 100644 index 000000000..9b511e667 --- /dev/null +++ b/internal/speed/speed_tl/internal/unionPoint.go @@ -0,0 +1,1183 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +func BuiltinVectorUnionPointRepairMasks(vec *[]UnionPoint) { + for i := range *vec { + (*vec)[i].RepairMasks() + } +} +func BuiltinVectorUnionPointReadTL1(w []byte, vec *[]UnionPoint) (_ []byte, err error) { + var l uint32 + if w, err = basictl.NatRead(w, &l); err != nil { + return w, err + } + if err = basictl.CheckLengthSanity(w, l, 4); err != nil { + return w, err + } + if uint32(cap(*vec)) < l { + *vec = make([]UnionPoint, l) + } else { + *vec = (*vec)[:l] + } + for i := range *vec { + if w, err = (*vec)[i].ReadTL1Boxed(w); err != nil { + return w, err + } + } + return w, nil +} + +func BuiltinVectorUnionPointWriteTL1(w []byte, vec []UnionPoint) []byte { + w = basictl.NatWrite(w, uint32(len(vec))) + for _, elem := range vec { + w = elem.WriteTL1Boxed(w) + } + return w +} + +func BuiltinVectorUnionPointCalculateLayout(sizes []int, optimizeEmpty bool, vec *[]UnionPoint) ([]int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 + } + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 0 + var sz int + + currentSize += basictl.TL2CalculateSize(len(*vec)) + for i := 0; i < len(*vec); i++ { + sizes, sz = (*vec)[i].CalculateLayout(sizes, false) + currentSize += sz + } + sizes[sizePosition] = currentSize + currentSize += basictl.TL2CalculateSize(currentSize) + Unused(sz) + return sizes, currentSize +} + +func BuiltinVectorUnionPointInternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool, vec *[]UnionPoint) ([]byte, []int, int) { + if len(*vec) == 0 { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 + } + currentSize := sizes[0] + sizes = sizes[1:] + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + w = basictl.TL2WriteSize(w, len(*vec)) + + var sz int + for i := 0; i < len(*vec); i++ { + w, sizes, _ = (*vec)[i].InternalWriteTL2(w, sizes, false) + } + Unused(sz) + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + return w, sizes, currentSize +} + +func BuiltinVectorUnionPointInternalReadTL2(r []byte, vec *[]UnionPoint) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + elementCount := 0 + if currentSize != 0 { + if currentR, elementCount, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if elementCount > len(currentR) { + return r, basictl.TL2ElementCountError(elementCount, currentR) + } + } + + if cap(*vec) < elementCount { + *vec = make([]UnionPoint, elementCount) + } + *vec = (*vec)[:elementCount] + for i := 0; i < elementCount; i++ { + if currentR, err = (*vec)[i].InternalReadTL2(currentR); err != nil { + return currentR, err + } + } + return r, nil +} + +func BuiltinVectorUnionPointReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer, vec *[]UnionPoint) error { + *vec = (*vec)[:cap(*vec)] + index := 0 + if in != nil { + in.Delim('[') + if !in.Ok() { + return ErrorInvalidJSON("[]UnionPoint", "expected json array") + } + for ; !in.IsDelim(']'); index++ { + if len(*vec) <= index { + var newValue UnionPoint + *vec = append(*vec, newValue) + *vec = (*vec)[:cap(*vec)] + } + if err := (*vec)[index].ReadJSONGeneral(jctx, in); err != nil { + return err + } + in.WantComma() + } + in.Delim(']') + if !in.Ok() { + return ErrorInvalidJSON("[]UnionPoint", "expected json array's end") + } + } + *vec = (*vec)[:index] + return nil +} + +func BuiltinVectorUnionPointWriteJSON(w []byte, vec []UnionPoint) []byte { + return BuiltinVectorUnionPointWriteJSONOpt(nil, w, vec) +} +func BuiltinVectorUnionPointWriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte, vec []UnionPoint) []byte { + w = append(w, '[') + for _, elem := range vec { + w = basictl.JSONAddCommaIfNeeded(w) + w = elem.WriteJSONOpt(jctx, w) + } + return append(w, ']') +} + +var _UnionPoint = [2]UnionElement{ + {TLTag: 0xbee8f76b, TLName: "unionPointValue", TLString: "unionPointValue#bee8f76b"}, + {TLTag: 0xa8dbfd23, TLName: "unionPointError", TLString: "unionPointError#a8dbfd23"}, +} + +type UnionPoint struct { + valueValue UnionPointValue + valueError UnionPointError + index int +} + +func (item UnionPoint) TLName() string { return _UnionPoint[item.index].TLName } +func (item UnionPoint) TLTag() uint32 { return _UnionPoint[item.index].TLTag } + +func (item *UnionPoint) Reset() { item.ResetToValue() } +func (item UnionPoint) RepairMasksValue() UnionPoint { + item.RepairMasks() + return item +} +func (item *UnionPoint) RepairMasks() { + item.valueValue.RepairMasks() +} + +func (item *UnionPoint) IsValue() bool { return item.index == 0 } + +func (item *UnionPoint) AsValue() (*UnionPointValue, bool) { + if item.index != 0 { + return nil, false + } + return &item.valueValue, true +} +func (item *UnionPoint) ResetToValue() *UnionPointValue { + item.index = 0 + item.valueValue.Reset() + return &item.valueValue +} +func (item *UnionPoint) SetValue(value UnionPointValue) { + item.index = 0 + item.valueValue = value +} + +func (item *UnionPoint) IsError() bool { return item.index == 1 } + +func (item *UnionPoint) AsError() (*UnionPointError, bool) { + if item.index != 1 { + return nil, false + } + return &item.valueError, true +} +func (item *UnionPoint) ResetToError() *UnionPointError { + item.index = 1 + item.valueError.Reset() + return &item.valueError +} +func (item *UnionPoint) SetError(value UnionPointError) { + item.index = 1 + item.valueError = value +} + +func (item *UnionPoint) ReadTL1(w []byte) (_ []byte, err error) { + return item.ReadTL1Boxed(w) +} + +func (item *UnionPoint) ReadTL1Boxed(w []byte) (_ []byte, err error) { + var tag uint32 + if w, err = basictl.NatRead(w, &tag); err != nil { + return w, err + } + switch tag { + case 0xbee8f76b: + item.index = 0 + return item.valueValue.ReadTL1(w) + case 0xa8dbfd23: + item.index = 1 + return item.valueError.ReadTL1(w) + default: + return w, ErrorInvalidUnionTag("UnionPoint", tag) + } +} + +func (item *UnionPoint) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1BoxedGeneral(w) +} + +func (item *UnionPoint) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *UnionPoint) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, _UnionPoint[item.index].TLTag) + switch item.index { + case 0: + w = item.valueValue.WriteTL1(w) + case 1: + w = item.valueError.WriteTL1(w) + } + return w +} + +func (item *UnionPoint) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + + switch item.index { + case 0: + return item.valueValue.CalculateLayout(sizes, optimizeEmpty) + case 1: + return item.valueError.CalculateLayout(sizes, optimizeEmpty) + } + if item.index == 0 { + if optimizeEmpty { + return sizes, 0 + } + return sizes, 1 + } + bodySize := 1 + basictl.TL2CalculateSize(item.index) + return sizes, 1 + bodySize +} + +func (item *UnionPoint) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + + switch item.index { + case 0: + return item.valueValue.InternalWriteTL2(w, sizes, optimizeEmpty) + case 1: + return item.valueError.InternalWriteTL2(w, sizes, optimizeEmpty) + } + if item.index == 0 { + if optimizeEmpty { + return w, sizes, 0 + } + w = append(w, 0) + return w, sizes, 1 + } + bodySize := 1 + basictl.TL2CalculateSize(item.index) + w = append(w, byte(bodySize)) + w = append(w, 1) + w = basictl.TL2WriteSize(w, item.index) + return w, sizes, 1 + bodySize +} + +func (item *UnionPoint) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + item.index = 0 + if (block & 1) != 0 { + if currentR, item.index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if item.index >= 2 { + return r, ErrorInvalidUnionIndex("UnionPoint", item.index) + } + } + switch item.index { + case 0: + if currentR, err = item.valueValue.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + case 1: + if currentR, err = item.valueError.InternalReadTL2(currentR, block); err != nil { + return currentR, err + } + } + Unused(currentR) + return r, nil +} +func (item *UnionPoint) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *UnionPoint) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) ([]byte, error) { + return item.InternalReadTL2(r) +} + +func (item *UnionPoint) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *UnionPoint) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + _tag, _value, err := Json2ReadUnion("UnionPoint", in) + if err != nil { + return err + } + switch _tag { + case "Value", "unionPointValue#bee8f76b", "unionPointValue", "#bee8f76b": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "unionPointValue#bee8f76b" { + return ErrorInvalidUnionLegacyTagJSON("UnionPoint", "unionPointValue#bee8f76b") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#bee8f76b" { + return ErrorInvalidUnionLegacyTagJSON("UnionPoint", "#bee8f76b") + } + item.index = 0 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueValue.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + case "Error", "unionPointError#a8dbfd23", "unionPointError", "#a8dbfd23": + if jctx != nil && !jctx.LegacyTypeNames && _tag == "unionPointError#a8dbfd23" { + return ErrorInvalidUnionLegacyTagJSON("UnionPoint", "unionPointError#a8dbfd23") + } + if jctx != nil && !jctx.LegacyTypeNames && _tag == "#a8dbfd23" { + return ErrorInvalidUnionLegacyTagJSON("UnionPoint", "#a8dbfd23") + } + item.index = 1 + var in2Pointer *basictl.JsonLexer + if _value != nil { + in2Pointer = &basictl.JsonLexer{Data: _value} + } + if err := item.valueError.ReadJSONGeneral(jctx, in2Pointer); err != nil { + return err + } + default: + return ErrorInvalidUnionTagJSON("UnionPoint", _tag) + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *UnionPoint) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) ([]byte, error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *UnionPoint) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *UnionPoint) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + switch item.index { + case 0: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"Value"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"unionPointValue#bee8f76b"`...) + } else { + w = append(w, `{"type":"unionPointValue"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueValue.WriteJSONOpt(jctx, w) + return append(w, '}') + case 1: + if jctx != nil && jctx.IsTL2 { + w = append(w, `{"type":"Error"`...) + } else { + if jctx != nil && jctx.LegacyTypeNames { + w = append(w, `{"type":"unionPointError#a8dbfd23"`...) + } else { + w = append(w, `{"type":"unionPointError"`...) + } + } + w = append(w, `,"value":`...) + w = item.valueError.WriteJSONOpt(jctx, w) + return append(w, '}') + default: // Impossible due to panic above + return w + } +} + +func (item UnionPoint) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *UnionPoint) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *UnionPoint) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("UnionPoint", err.Error()) + } + return nil +} + +func (item UnionPointError) AsUnion() UnionPoint { + var ret UnionPoint + ret.SetError(item) + return ret +} + +type UnionPointError struct { + Err string +} + +func (UnionPointError) TLName() string { return "unionPointError" } +func (UnionPointError) TLTag() uint32 { return 0xa8dbfd23 } + +func (item *UnionPointError) Reset() { + item.Err = "" +} + +func (item *UnionPointError) ReadTL1(w []byte) (_ []byte, err error) { + return basictl.StringRead(w, &item.Err) +} + +func (item *UnionPointError) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *UnionPointError) WriteTL1(w []byte) []byte { + w = basictl.StringWrite(w, item.Err) + return w +} + +func (item *UnionPointError) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xa8dbfd23); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *UnionPointError) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *UnionPointError) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xa8dbfd23) + return item.WriteTL1(w) +} + +func (item UnionPointError) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *UnionPointError) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *UnionPointError) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propErrPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "err": + if propErrPresented { + return ErrorInvalidJSONWithDuplicatingKeys("unionPointError", "err") + } + propErrPresented = true + if err := Json2ReadString(in, &item.Err); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("unionPointError", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propErrPresented { + item.Err = "" + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *UnionPointError) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *UnionPointError) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *UnionPointError) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexErr := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"err":`...) + w = basictl.JSONWriteString(w, item.Err) + if !(len(item.Err) != 0) { + w = w[:backupIndexErr] + } + return append(w, '}') +} + +func (item *UnionPointError) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *UnionPointError) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("unionPointError", err.Error()) + } + return nil +} + +func (item *UnionPointError) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 2471129417) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + // add constructor No for union type in case of non first option + currentSize += basictl.TL2CalculateSize(1) + lastUsedByte = currentSize + if len(item.Err) != 0 { + currentSize += basictl.TL2CalculateSize(len(item.Err)) + len(item.Err) + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *UnionPointError) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 2471129417 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + w = basictl.TL2WriteSize(w, 1) + currentBlock |= 1 + if len(item.Err) != 0 { + w = basictl.StringWriteTL2(w, item.Err) + currentBlock |= 2 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *UnionPointError) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *UnionPointError) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + if block&2 != 0 { + if currentR, err = basictl.StringReadTL2(currentR, &item.Err); err != nil { + return currentR, err + } + } else { + item.Err = "" + } + Unused(currentR) + return r, nil +} + +func (item *UnionPointError) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 1 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 1) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} + +func (item UnionPointValue) AsUnion() UnionPoint { + var ret UnionPoint + ret.SetValue(item) + return ret +} + +type UnionPointValue struct { + Mask uint32 + X uint32 // Conditional: item.Mask.0 + Y uint32 // Conditional: item.Mask.1 + Z uint32 // Conditional: item.Mask.2 + tl2mask0 byte +} + +func (UnionPointValue) TLName() string { return "unionPointValue" } +func (UnionPointValue) TLTag() uint32 { return 0xbee8f76b } + +func (item *UnionPointValue) SetX(v uint32) { + item.X = v + item.Mask |= 1 << 0 + item.tl2mask0 |= 1 +} +func (item *UnionPointValue) ClearX() { + item.X = 0 + item.Mask &^= 1 << 0 + item.tl2mask0 &^= 1 +} +func (item *UnionPointValue) IsSetX() bool { return item.tl2mask0&1 != 0 } + +func (item *UnionPointValue) SetY(v uint32) { + item.Y = v + item.Mask |= 1 << 1 + item.tl2mask0 |= 2 +} +func (item *UnionPointValue) ClearY() { + item.Y = 0 + item.Mask &^= 1 << 1 + item.tl2mask0 &^= 2 +} +func (item *UnionPointValue) IsSetY() bool { return item.tl2mask0&2 != 0 } + +func (item *UnionPointValue) SetZ(v uint32) { + item.Z = v + item.Mask |= 1 << 2 + item.tl2mask0 |= 4 +} +func (item *UnionPointValue) ClearZ() { + item.Z = 0 + item.Mask &^= 1 << 2 + item.tl2mask0 &^= 4 +} +func (item *UnionPointValue) IsSetZ() bool { return item.tl2mask0&4 != 0 } + +func (item *UnionPointValue) Reset() { + item.Mask = 0 + item.X = 0 + item.Y = 0 + item.Z = 0 + item.tl2mask0 = 0 +} + +func (item UnionPointValue) RepairMasksValue() UnionPointValue { + item.RepairMasks() + return item +} +func (item *UnionPointValue) RepairMasks() { + item.tl2mask0 = 0 + if item.Mask&(1<<0) != 0 { + item.tl2mask0 |= 1 + } + if item.Mask&(1<<1) != 0 { + item.tl2mask0 |= 2 + } + if item.Mask&(1<<2) != 0 { + item.tl2mask0 |= 4 + } +} + +func (item *UnionPointValue) ReadTL1(w []byte) (_ []byte, err error) { + item.tl2mask0 = 0 + if w, err = basictl.NatRead(w, &item.Mask); err != nil { + return w, err + } + if item.Mask&(1<<0) != 0 { + item.tl2mask0 |= 1 + if w, err = basictl.NatRead(w, &item.X); err != nil { + return w, err + } + } else { + item.X = 0 + } + if item.Mask&(1<<1) != 0 { + item.tl2mask0 |= 2 + if w, err = basictl.NatRead(w, &item.Y); err != nil { + return w, err + } + } else { + item.Y = 0 + } + if item.Mask&(1<<2) != 0 { + item.tl2mask0 |= 4 + if w, err = basictl.NatRead(w, &item.Z); err != nil { + return w, err + } + } else { + item.Z = 0 + } + return w, nil +} + +func (item *UnionPointValue) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *UnionPointValue) WriteTL1(w []byte) []byte { + w = basictl.NatWrite(w, item.Mask) + if item.Mask&(1<<0) != 0 { + w = basictl.NatWrite(w, item.X) + } + if item.Mask&(1<<1) != 0 { + w = basictl.NatWrite(w, item.Y) + } + if item.Mask&(1<<2) != 0 { + w = basictl.NatWrite(w, item.Z) + } + return w +} + +func (item *UnionPointValue) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xbee8f76b); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *UnionPointValue) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *UnionPointValue) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xbee8f76b) + return item.WriteTL1(w) +} + +func (item UnionPointValue) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *UnionPointValue) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *UnionPointValue) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + item.tl2mask0 = 0 + var propMaskPresented bool + var propXPresented bool + var propYPresented bool + var propZPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "mask": + if propMaskPresented { + return ErrorInvalidJSONWithDuplicatingKeys("unionPointValue", "mask") + } + propMaskPresented = true + if err := Json2ReadUint32(in, &item.Mask); err != nil { + return err + } + case "x": + if propXPresented { + return ErrorInvalidJSONWithDuplicatingKeys("unionPointValue", "x") + } + propXPresented = true + if err := Json2ReadUint32(in, &item.X); err != nil { + return err + } + item.tl2mask0 |= 1 + case "y": + if propYPresented { + return ErrorInvalidJSONWithDuplicatingKeys("unionPointValue", "y") + } + propYPresented = true + if err := Json2ReadUint32(in, &item.Y); err != nil { + return err + } + item.tl2mask0 |= 2 + case "z": + if propZPresented { + return ErrorInvalidJSONWithDuplicatingKeys("unionPointValue", "z") + } + propZPresented = true + if err := Json2ReadUint32(in, &item.Z); err != nil { + return err + } + item.tl2mask0 |= 4 + default: + return ErrorInvalidJSONExcessElement("unionPointValue", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propMaskPresented { + item.Mask = 0 + } + if !propXPresented { + item.X = 0 + } + if !propYPresented { + item.Y = 0 + } + if !propZPresented { + item.Z = 0 + } + if !propXPresented && item.Mask&(1<<0) != 0 { + item.tl2mask0 |= 1 + } + if !propYPresented && item.Mask&(1<<1) != 0 { + item.tl2mask0 |= 2 + } + if !propZPresented && item.Mask&(1<<2) != 0 { + item.tl2mask0 |= 4 + } + if propXPresented { + item.Mask |= 1 << 0 + } + if propYPresented { + item.Mask |= 1 << 1 + } + if propZPresented { + item.Mask |= 1 << 2 + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *UnionPointValue) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *UnionPointValue) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *UnionPointValue) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexMask := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"mask":`...) + w = basictl.JSONWriteUint32(w, item.Mask) + if !(item.Mask != 0) { + w = w[:backupIndexMask] + } + if item.tl2mask0&1 != 0 { + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"x":`...) + w = basictl.JSONWriteUint32(w, item.X) + } + if item.tl2mask0&2 != 0 { + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"y":`...) + w = basictl.JSONWriteUint32(w, item.Y) + } + if item.tl2mask0&4 != 0 { + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"z":`...) + w = basictl.JSONWriteUint32(w, item.Z) + } + return append(w, '}') +} + +func (item *UnionPointValue) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *UnionPointValue) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("unionPointValue", err.Error()) + } + return nil +} + +func (item *UnionPointValue) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 1766814431) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if item.Mask != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.tl2mask0&1 != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.tl2mask0&2 != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + if item.tl2mask0&4 != 0 { + currentSize += 4 + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *UnionPointValue) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 1766814431 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if item.Mask != 0 { + w = basictl.NatWrite(w, item.Mask) + currentBlock |= 2 + } + if item.tl2mask0&1 != 0 { + w = basictl.NatWrite(w, item.X) + currentBlock |= 4 + } + if item.tl2mask0&2 != 0 { + w = basictl.NatWrite(w, item.Y) + currentBlock |= 8 + } + if item.tl2mask0&4 != 0 { + w = basictl.NatWrite(w, item.Z) + currentBlock |= 16 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *UnionPointValue) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *UnionPointValue) InternalReadTL2(r []byte, block byte) (_ []byte, err error) { + currentR := r + item.tl2mask0 = 0 + if block&2 != 0 { + if currentR, err = basictl.NatRead(currentR, &item.Mask); err != nil { + return currentR, err + } + } else { + item.Mask = 0 + } + if block&4 != 0 { + item.tl2mask0 |= 1 + if currentR, err = basictl.NatRead(currentR, &item.X); err != nil { + return currentR, err + } + } else { + item.X = 0 + } + if block&8 != 0 { + item.tl2mask0 |= 2 + if currentR, err = basictl.NatRead(currentR, &item.Y); err != nil { + return currentR, err + } + } else { + item.Y = 0 + } + if block&16 != 0 { + item.tl2mask0 |= 4 + if currentR, err = basictl.NatRead(currentR, &item.Z); err != nil { + return currentR, err + } + } else { + item.Z = 0 + } + Unused(currentR) + return r, nil +} + +func (item *UnionPointValue) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return r, err + } + if (block & 1) != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return r, err + } + if index != 0 { + return r, basictl.TL2Error("unexpected constructor number %d, instead of %d", index, 0) + } + } + _, err = item.InternalReadTL2(currentR, block) + return r, err +} diff --git a/internal/speed/speed_tl/internal/unionPoints.go b/internal/speed/speed_tl/internal/unionPoints.go new file mode 100644 index 000000000..5b8aff113 --- /dev/null +++ b/internal/speed/speed_tl/internal/unionPoints.go @@ -0,0 +1,252 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +type UnionPoints struct { + Values []UnionPoint +} + +func (UnionPoints) TLName() string { return "unionPoints" } +func (UnionPoints) TLTag() uint32 { return 0xa8495345 } + +func (item *UnionPoints) Reset() { + item.Values = item.Values[:0] +} + +func (item UnionPoints) RepairMasksValue() UnionPoints { + item.RepairMasks() + return item +} +func (item *UnionPoints) RepairMasks() { + BuiltinVectorUnionPointRepairMasks(&item.Values) +} + +func (item *UnionPoints) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorUnionPointReadTL1(w, &item.Values) +} + +func (item *UnionPoints) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *UnionPoints) WriteTL1(w []byte) []byte { + w = BuiltinVectorUnionPointWriteTL1(w, item.Values) + return w +} + +func (item *UnionPoints) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0xa8495345); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *UnionPoints) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *UnionPoints) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0xa8495345) + return item.WriteTL1(w) +} + +func (item UnionPoints) String() string { + return string(item.WriteJSON(nil)) +} + +func (item *UnionPoints) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *UnionPoints) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + var propValuesPresented bool + if in != nil { + in.Delim('{') + if !in.Ok() { + return in.Error() + } + for !in.IsDelim('}') { + key := in.UnsafeFieldName(true) + in.WantColon() + switch key { + case "values": + if propValuesPresented { + return ErrorInvalidJSONWithDuplicatingKeys("unionPoints", "values") + } + propValuesPresented = true + if err := BuiltinVectorUnionPointReadJSONGeneral(jctx, in, &item.Values); err != nil { + return err + } + default: + return ErrorInvalidJSONExcessElement("unionPoints", key) + } + in.WantComma() + } + in.Delim('}') + if !in.Ok() { + return in.Error() + } + } + if !propValuesPresented { + item.Values = item.Values[:0] + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *UnionPoints) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *UnionPoints) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} +func (item *UnionPoints) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = append(w, '{') + backupIndexValues := len(w) + w = basictl.JSONAddCommaIfNeeded(w) + w = append(w, `"values":`...) + w = BuiltinVectorUnionPointWriteJSONOpt(jctx, w, item.Values) + if !(len(item.Values) != 0) { + w = w[:backupIndexValues] + } + return append(w, '}') +} + +func (item *UnionPoints) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *UnionPoints) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("unionPoints", err.Error()) + } + return nil +} + +func (item *UnionPoints) CalculateLayout(sizes []int, optimizeEmpty bool) ([]int, int) { + sizes = append(sizes, 2646024565) + sizePosition := len(sizes) + sizes = append(sizes, 0) + + currentSize := 1 + lastUsedByte := 0 + var sz int + + if sizes, sz = BuiltinVectorUnionPointCalculateLayout(sizes, true, &item.Values); sz != 0 { + currentSize += sz + lastUsedByte = currentSize + } + + if lastUsedByte < currentSize { + currentSize = lastUsedByte + } + sizes[sizePosition] = currentSize + if currentSize == 0 { + sizes = sizes[:sizePosition+1] + } + if !optimizeEmpty || currentSize != 0 { + currentSize += basictl.TL2CalculateSize(currentSize) + } + Unused(sz) + return sizes, currentSize +} + +func (item *UnionPoints) InternalWriteTL2(w []byte, sizes []int, optimizeEmpty bool) ([]byte, []int, int) { + if sizes[0] != 2646024565 { + panic("tl2: tag mismatch between calculate and write") + } + currentSize := sizes[1] + sizes = sizes[2:] + if optimizeEmpty && currentSize == 0 { + return w, sizes, 0 + } + w = basictl.TL2WriteSize(w, currentSize) + if currentSize == 0 { + return w, sizes, 1 + } + oldLen := len(w) + var sz int + var currentBlock byte + currentBlockPosition := len(w) + w = append(w, 0) + if w, sizes, sz = BuiltinVectorUnionPointInternalWriteTL2(w, sizes, true, &item.Values); sz != 0 { + currentBlock |= 2 + } + if currentBlockPosition < len(w) { + w[currentBlockPosition] = currentBlock + } + if len(w)-oldLen != currentSize { + panic("tl2: mismatch between calculate and write") + } + Unused(sz) + return w, sizes, 1 +} + +func (item *UnionPoints) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes, sizes2 []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + sizes, _ = item.CalculateLayout(sizes, false) + w, sizes2, _ = item.InternalWriteTL2(w, sizes, false) + if len(sizes2) != 0 { + panic("tl2: internal write did not consume all size data") + } + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *UnionPoints) InternalReadTL2(r []byte) (_ []byte, err error) { + currentSize := 0 + if r, currentSize, err = basictl.TL2ParseSize(r); err != nil { + return r, err + } + if currentSize == 0 { + item.Reset() + return r, nil + } + if len(r) < currentSize { + return r, basictl.TL2Error("not enough data: expected %d, got %d", currentSize, len(r)) + } + + currentR := r[:currentSize] + r = r[currentSize:] + + var block byte + if currentR, err = basictl.ByteRead(currentR, &block); err != nil { + return currentR, err + } + // read No of constructor + if block&1 != 0 { + var index int + if currentR, index, err = basictl.TL2ParseSize(currentR); err != nil { + return currentR, err + } + if index != 0 { + return r, ErrorInvalidUnionIndex("unionPoints", index) + } + } + if block&2 != 0 { + if currentR, err = BuiltinVectorUnionPointInternalReadTL2(currentR, &item.Values); err != nil { + return currentR, err + } + } else { + item.Values = item.Values[:0] + } + Unused(currentR) + return r, nil +} + +func (item *UnionPoints) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/internal/vector.go b/internal/speed/speed_tl/internal/vector.go new file mode 100644 index 000000000..903d01b6b --- /dev/null +++ b/internal/speed/speed_tl/internal/vector.go @@ -0,0 +1,464 @@ +// Code generated by tl2gen; DO NOT EDIT. +package internal + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" +) + +var _ = basictl.NatWrite + +type VectorMemcacheValue []MemcacheValue + +func (item *VectorMemcacheValue) ptr() *[]MemcacheValue { return (*[]MemcacheValue)(item) } + +func (VectorMemcacheValue) TLName() string { return "vector" } +func (VectorMemcacheValue) TLTag() uint32 { return 0x1cb5c415 } + +func (item *VectorMemcacheValue) Reset() { + *item.ptr() = (*item.ptr())[:0] +} + +func (item *VectorMemcacheValue) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorMemcacheValueReadTL1(w, item.ptr()) +} + +func (item *VectorMemcacheValue) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *VectorMemcacheValue) WriteTL1(w []byte) []byte { + w = BuiltinVectorMemcacheValueWriteTL1(w, *item.ptr()) + return w +} + +func (item *VectorMemcacheValue) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x1cb5c415); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *VectorMemcacheValue) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *VectorMemcacheValue) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x1cb5c415) + return item.WriteTL1(w) +} + +func (item VectorMemcacheValue) String() string { + return string(item.WriteJSON(nil)) +} +func (item *VectorMemcacheValue) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *VectorMemcacheValue) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + if err := BuiltinVectorMemcacheValueReadJSONGeneral(jctx, in, item.ptr()); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *VectorMemcacheValue) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *VectorMemcacheValue) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} + +func (item *VectorMemcacheValue) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = BuiltinVectorMemcacheValueWriteJSONOpt(jctx, w, *item.ptr()) + return w +} +func (item *VectorMemcacheValue) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *VectorMemcacheValue) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("vector", err.Error()) + } + return nil +} + +func (item *VectorMemcacheValue) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + var sz int + var currentSize int + sizes, sz = BuiltinVectorMemcacheValueCalculateLayout(sizes, false, item.ptr()) + currentSize += sz + w, sizes, _ = BuiltinVectorMemcacheValueInternalWriteTL2(w, sizes, false, item.ptr()) + + Unused(currentSize) + Unused(sz) + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *VectorMemcacheValue) InternalReadTL2(r []byte) (_ []byte, err error) { + if r, err = BuiltinVectorMemcacheValueInternalReadTL2(r, item.ptr()); err != nil { + return r, err + } + return r, nil +} + +func (item *VectorMemcacheValue) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} + +type VectorPartialPointBoxed []PartialPoint + +func (item *VectorPartialPointBoxed) ptr() *[]PartialPoint { return (*[]PartialPoint)(item) } + +func (VectorPartialPointBoxed) TLName() string { return "vector" } +func (VectorPartialPointBoxed) TLTag() uint32 { return 0x1cb5c415 } + +func (item *VectorPartialPointBoxed) Reset() { + *item.ptr() = (*item.ptr())[:0] +} + +func (item VectorPartialPointBoxed) RepairMasksValue() VectorPartialPointBoxed { + item.RepairMasks() + return item +} +func (item *VectorPartialPointBoxed) RepairMasks() { + BuiltinVectorPartialPointBoxedRepairMasks(item.ptr()) +} + +func (item *VectorPartialPointBoxed) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorPartialPointBoxedReadTL1(w, item.ptr()) +} + +func (item *VectorPartialPointBoxed) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *VectorPartialPointBoxed) WriteTL1(w []byte) []byte { + w = BuiltinVectorPartialPointBoxedWriteTL1(w, *item.ptr()) + return w +} + +func (item *VectorPartialPointBoxed) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x1cb5c415); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *VectorPartialPointBoxed) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *VectorPartialPointBoxed) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x1cb5c415) + return item.WriteTL1(w) +} + +func (item VectorPartialPointBoxed) String() string { + return string(item.WriteJSON(nil)) +} +func (item *VectorPartialPointBoxed) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *VectorPartialPointBoxed) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + if err := BuiltinVectorPartialPointBoxedReadJSONGeneral(jctx, in, item.ptr()); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *VectorPartialPointBoxed) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *VectorPartialPointBoxed) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} + +func (item *VectorPartialPointBoxed) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = BuiltinVectorPartialPointBoxedWriteJSONOpt(jctx, w, *item.ptr()) + return w +} +func (item *VectorPartialPointBoxed) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *VectorPartialPointBoxed) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("vector", err.Error()) + } + return nil +} + +func (item *VectorPartialPointBoxed) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + var sz int + var currentSize int + sizes, sz = BuiltinVectorPartialPointBoxedCalculateLayout(sizes, false, item.ptr()) + currentSize += sz + w, sizes, _ = BuiltinVectorPartialPointBoxedInternalWriteTL2(w, sizes, false, item.ptr()) + + Unused(currentSize) + Unused(sz) + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *VectorPartialPointBoxed) InternalReadTL2(r []byte) (_ []byte, err error) { + if r, err = BuiltinVectorPartialPointBoxedInternalReadTL2(r, item.ptr()); err != nil { + return r, err + } + return r, nil +} + +func (item *VectorPartialPointBoxed) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} + +type VectorPointBoxed []Point + +func (item *VectorPointBoxed) ptr() *[]Point { return (*[]Point)(item) } + +func (VectorPointBoxed) TLName() string { return "vector" } +func (VectorPointBoxed) TLTag() uint32 { return 0x1cb5c415 } + +func (item *VectorPointBoxed) Reset() { + *item.ptr() = (*item.ptr())[:0] +} + +func (item *VectorPointBoxed) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorPointBoxedReadTL1(w, item.ptr()) +} + +func (item *VectorPointBoxed) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *VectorPointBoxed) WriteTL1(w []byte) []byte { + w = BuiltinVectorPointBoxedWriteTL1(w, *item.ptr()) + return w +} + +func (item *VectorPointBoxed) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x1cb5c415); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *VectorPointBoxed) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *VectorPointBoxed) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x1cb5c415) + return item.WriteTL1(w) +} + +func (item VectorPointBoxed) String() string { + return string(item.WriteJSON(nil)) +} +func (item *VectorPointBoxed) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *VectorPointBoxed) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + if err := BuiltinVectorPointBoxedReadJSONGeneral(jctx, in, item.ptr()); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *VectorPointBoxed) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *VectorPointBoxed) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} + +func (item *VectorPointBoxed) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = BuiltinVectorPointBoxedWriteJSONOpt(jctx, w, *item.ptr()) + return w +} +func (item *VectorPointBoxed) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *VectorPointBoxed) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("vector", err.Error()) + } + return nil +} + +func (item *VectorPointBoxed) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + var sz int + var currentSize int + sizes, sz = BuiltinVectorPointBoxedCalculateLayout(sizes, false, item.ptr()) + currentSize += sz + w, sizes, _ = BuiltinVectorPointBoxedInternalWriteTL2(w, sizes, false, item.ptr()) + + Unused(currentSize) + Unused(sz) + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *VectorPointBoxed) InternalReadTL2(r []byte) (_ []byte, err error) { + if r, err = BuiltinVectorPointBoxedInternalReadTL2(r, item.ptr()); err != nil { + return r, err + } + return r, nil +} + +func (item *VectorPointBoxed) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} + +type VectorUnionPoint []UnionPoint + +func (item *VectorUnionPoint) ptr() *[]UnionPoint { return (*[]UnionPoint)(item) } + +func (VectorUnionPoint) TLName() string { return "vector" } +func (VectorUnionPoint) TLTag() uint32 { return 0x1cb5c415 } + +func (item *VectorUnionPoint) Reset() { + *item.ptr() = (*item.ptr())[:0] +} + +func (item VectorUnionPoint) RepairMasksValue() VectorUnionPoint { + item.RepairMasks() + return item +} +func (item *VectorUnionPoint) RepairMasks() { + BuiltinVectorUnionPointRepairMasks(item.ptr()) +} + +func (item *VectorUnionPoint) ReadTL1(w []byte) (_ []byte, err error) { + return BuiltinVectorUnionPointReadTL1(w, item.ptr()) +} + +func (item *VectorUnionPoint) WriteTL1General(w []byte) (_ []byte, err error) { + return item.WriteTL1(w), nil +} + +func (item *VectorUnionPoint) WriteTL1(w []byte) []byte { + w = BuiltinVectorUnionPointWriteTL1(w, *item.ptr()) + return w +} + +func (item *VectorUnionPoint) ReadTL1Boxed(w []byte) (_ []byte, err error) { + if w, err = basictl.NatReadExactTag(w, 0x1cb5c415); err != nil { + return w, err + } + return item.ReadTL1(w) +} + +func (item *VectorUnionPoint) WriteTL1BoxedGeneral(w []byte) (_ []byte, err error) { + return item.WriteTL1Boxed(w), nil +} + +func (item *VectorUnionPoint) WriteTL1Boxed(w []byte) []byte { + w = basictl.NatWrite(w, 0x1cb5c415) + return item.WriteTL1(w) +} + +func (item VectorUnionPoint) String() string { + return string(item.WriteJSON(nil)) +} +func (item *VectorUnionPoint) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: legacyTypeNames} + return item.ReadJSONGeneral(&jctx, in) +} + +func (item *VectorUnionPoint) ReadJSONGeneral(jctx *basictl.JSONReadContext, in *basictl.JsonLexer) error { + if err := BuiltinVectorUnionPointReadJSONGeneral(jctx, in, item.ptr()); err != nil { + return err + } + return nil +} + +// This method is general version of WriteJSON, use it instead! +func (item *VectorUnionPoint) WriteJSONGeneral(jctx *basictl.JSONWriteContext, w []byte) (_ []byte, err error) { + return item.WriteJSONOpt(jctx, w), nil +} + +func (item *VectorUnionPoint) WriteJSON(w []byte) []byte { + return item.WriteJSONOpt(nil, w) +} + +func (item *VectorUnionPoint) WriteJSONOpt(jctx *basictl.JSONWriteContext, w []byte) []byte { + w = BuiltinVectorUnionPointWriteJSONOpt(jctx, w, *item.ptr()) + return w +} +func (item *VectorUnionPoint) MarshalJSON() ([]byte, error) { + return item.WriteJSON(nil), nil +} + +func (item *VectorUnionPoint) UnmarshalJSON(b []byte) error { + jctx := basictl.JSONReadContext{LegacyTypeNames: true} + if err := item.ReadJSONGeneral(&jctx, &basictl.JsonLexer{Data: b}); err != nil { + return ErrorInvalidJSON("vector", err.Error()) + } + return nil +} + +func (item *VectorUnionPoint) WriteTL2(w []byte, tctx *basictl.TL2WriteContext) []byte { + var sizes []int + if tctx != nil { + sizes = tctx.SizeBuffer[:0] + } + var sz int + var currentSize int + sizes, sz = BuiltinVectorUnionPointCalculateLayout(sizes, false, item.ptr()) + currentSize += sz + w, sizes, _ = BuiltinVectorUnionPointInternalWriteTL2(w, sizes, false, item.ptr()) + + Unused(currentSize) + Unused(sz) + if tctx != nil { + tctx.SizeBuffer = sizes + } + return w +} + +func (item *VectorUnionPoint) InternalReadTL2(r []byte) (_ []byte, err error) { + if r, err = BuiltinVectorUnionPointInternalReadTL2(r, item.ptr()); err != nil { + return r, err + } + return r, nil +} + +func (item *VectorUnionPoint) ReadTL2(r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return item.InternalReadTL2(r) +} diff --git a/internal/speed/speed_tl/meta/meta.go b/internal/speed/speed_tl/meta/meta.go new file mode 100644 index 000000000..d2fe11c18 --- /dev/null +++ b/internal/speed/speed_tl/meta/meta.go @@ -0,0 +1,79 @@ +// Code generated by tl2gen; DO NOT EDIT. +package meta + +// meta contains all types, and changes when any of them changes +// You probably want to import metamini instead. + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/internal/metainternal" +) + +func SchemaGenerator() string { return "(devel)" } +func SchemaURL() string { return "" } +func SchemaCommit() string { return "" } +func SchemaTimestamp() uint32 { return 0 } + +type Object = metainternal.Object +type Function = metainternal.Function +type TLItem = metainternal.TLItem + +// deterministic order, depends on order of package init() +// we see no benefits in sorting this. +func GetAllTLItems() []TLItem { + return metainternal.ItemsOrdered +} + +// for quick one-liners +func GetTLName(tag uint32, notFoundName string) string { + if item := FactoryItemByTLTag(tag); item != nil { + return item.TLName() + } + return notFoundName +} + +func FactoryItemByTLTag(tag uint32) TLItem { + if item, ok := metainternal.ItemsByTag[tag]; ok { + return item + } + return nil +} + +func FactoryItemByTLName(name string) TLItem { + if item, ok := metainternal.ItemsByName[name]; ok { + return item + } + return nil +} + +func init() { + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.longvalue", Tag: 0x09729c42, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.longvalueWithTime", Tag: 0x01dcd5d5, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.not_found", Tag: 0x32c42422, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.strvalue", Tag: 0xa6bebb1a, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.strvalueWithDelay", Tag: 0x1bbf7044, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.strvalueWithTime", Tag: 0xa064c821, HaTL1: true, HaTL2: true}) + metainternal.FillObject(&metainternal.TLItemImpl{Name: "memcache.Value", HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "memcache.values", Tag: 0xc894cef8, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "partialPoint", Tag: 0xbfa57042, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "partialPoints", Tag: 0x0d7f74de, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "point", Tag: 0x8ec1a27e, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "points", Tag: 0xebf9dd56, HaTL1: true, HaTL2: true}) + metainternal.FillObject(&metainternal.TLItemImpl{Name: "UnionPoint", HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "unionPointError", Tag: 0xa8dbfd23, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "unionPointValue", Tag: 0xbee8f76b, HaTL1: true, HaTL2: true}) + metainternal.FillObject( + &metainternal.TLItemImpl{Name: "unionPoints", Tag: 0xa8495345, HaTL1: true, HaTL2: true}) +} diff --git a/internal/speed/speed_tl/tl/tl.go b/internal/speed/speed_tl/tl/tl.go new file mode 100644 index 000000000..59c4d3a43 --- /dev/null +++ b/internal/speed/speed_tl/tl/tl.go @@ -0,0 +1,20 @@ +// Code generated by tl2gen; DO NOT EDIT. +package tl + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/internal" +) + +type ( + PartialPoint = internal.PartialPoint + PartialPoints = internal.PartialPoints + Point = internal.Point + Points = internal.Points + UnionPoint = internal.UnionPoint + UnionPointError = internal.UnionPointError + UnionPointValue = internal.UnionPointValue + UnionPoints = internal.UnionPoints + VectorPartialPointBoxed = internal.VectorPartialPointBoxed + VectorPointBoxed = internal.VectorPointBoxed + VectorUnionPoint = internal.VectorUnionPoint +) diff --git a/internal/speed/speed_tl/tlmemcache/tlmemcache.go b/internal/speed/speed_tl/tlmemcache/tlmemcache.go new file mode 100644 index 000000000..58ab9b54a --- /dev/null +++ b/internal/speed/speed_tl/tlmemcache/tlmemcache.go @@ -0,0 +1,18 @@ +// Code generated by tl2gen; DO NOT EDIT. +package tlmemcache + +import ( + "github.com/VKCOM/tl/internal/speed/speed_tl/internal" +) + +type ( + Longvalue = internal.MemcacheLongvalue + LongvalueWithTime = internal.MemcacheLongvalueWithTime + NotFound = internal.MemcacheNotFound + Strvalue = internal.MemcacheStrvalue + StrvalueWithDelay = internal.MemcacheStrvalueWithDelay + StrvalueWithTime = internal.MemcacheStrvalueWithTime + Value = internal.MemcacheValue + Values = internal.MemcacheValues + VectorValue = internal.VectorMemcacheValue +) diff --git a/internal/speed/tl_protobuf_read_test.go b/internal/speed/tl_protobuf_read_test.go new file mode 100644 index 000000000..b7aef5894 --- /dev/null +++ b/internal/speed/tl_protobuf_read_test.go @@ -0,0 +1,333 @@ +package speed + +import ( + "slices" + "testing" + + "github.com/VKCOM/tl/internal/speed/speed_proto_fast/pb_fast" + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" + "github.com/VKCOM/tl/internal/speed/speed_tl/tl" + tlmem "github.com/VKCOM/tl/internal/speed/speed_tl/tlmemcache" + "google.golang.org/protobuf/encoding/protowire" +) + +func BenchmarkPointsReadTLGen(b *testing.B) { + values, buf := prepareTLPointssBuffer() + for _, v := range values { + buf = v.WriteTL1(buf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tl.Points + buf2, err = p.ReadTL1(buf2) + if err != nil { + b.Fatalf("bad") + } + if !slices.Equal(p.Values, v.Values) { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkPointsReadTL2Gen(b *testing.B) { + values, buf := prepareTLPointssBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tl.Points + buf2, err = p.ReadTL2(buf2, nil) + if err != nil { + b.Fatalf("bad") + } + if !slices.Equal(p.Values, v.Values) { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkPointsReadProtoFastGen(b *testing.B) { + values, buf := prepareProtoPointssBuffer() + for _, v := range values { + tmpBuf, err := v.Marshal() + if err != nil { + b.Fatalf("bad") + } + buf = protowire.AppendBytes(buf, tmpBuf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for j, v := range values { + var err error + var p pb_fast.PointsPB + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = p.Unmarshal(str) + if err != nil { + b.Fatalf("bad") + } + + _ = j + _ = v + //if !compareProtoPoints(&p, &v) { + // b.Fatalf("bad %d", j) + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func compareProtoPoints(a, b *pb_fast.PointsPB) bool { + ap := a.Points + bp := b.Points + + if len(ap) != len(bp) { + return false + } + + for i := 0; i < len(ap); i++ { + pa := ap[i] + pb := bp[i] + + // repeated message в Go обычно []*PointPB, поэтому учитываем nil + if pa == nil || pb == nil { + if pa != pb { + return false + } + continue + } + + if pa.X != pb.X || pa.Y != pb.Y || pa.Z != pb.Z { + return false + } + } + + return true +} + +func BenchmarkMemcacheValueReadTLGen(b *testing.B) { + values, buf := prepareTLMemValuesBuffer() + for _, v := range values { + buf = v.WriteTL1Boxed(buf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tlmem.Value + buf2, err = p.ReadTL1(buf2) + if err != nil { + b.Fatalf("bad") + } + if p != v { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkMemcacheValueReadTL2Gen(b *testing.B) { + values, buf := prepareTLMemValuesBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tlmem.Value + buf2, err = p.ReadTL2(buf2, nil) + if err != nil { + b.Fatalf("bad") + } + if p != v { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkMemcacheValueReadProtoFastGen(b *testing.B) { + values, buf := prepareProtoMemValuesBuffer() + for _, v := range values { + tmpBuf, err := v.Marshal() + if err != nil { + b.Fatalf("bad") + } + buf = protowire.AppendBytes(buf, tmpBuf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for j, v := range values { + var err error + var p pb_fast.Value + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = p.Unmarshal(str) + if err != nil { + b.Fatalf("bad") + } + + _ = j + _ = v + //if !compareProtoPoints(&p, &v) { + // b.Fatalf("bad %d", j) + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkMemcacheValuesReadTLGen(b *testing.B) { + values, buf := prepareTLMemValuessBuffer() + for _, v := range values { + buf = v.WriteTL1(buf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tlmem.Values + buf2, err = p.ReadTL1(buf2) + if err != nil { + b.Fatalf("bad") + } + if !slices.Equal(p.Values, v.Values) { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkMemcacheValuesReadTL2Gen(b *testing.B) { + values, buf := prepareTLMemValuessBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for _, v := range values { + var err error + var p tlmem.Values + buf2, err = p.ReadTL2(buf2, nil) + if err != nil { + b.Fatalf("bad") + } + if !slices.Equal(p.Values, v.Values) { + b.Fatalf("bad") + } + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} + +func BenchmarkMemcacheValuesReadProtoFastGen(b *testing.B) { + values, buf := prepareProtoMemValuessBuffer() + for _, v := range values { + tmpBuf, err := v.Marshal() + if err != nil { + b.Fatalf("bad") + } + buf = protowire.AppendBytes(buf, tmpBuf) + } + b.ReportAllocs() + b.ResetTimer() + finish := b.N / len(values) + for i := 0; i < finish; i++ { + buf2 := buf + for j, v := range values { + var err error + var p pb_fast.Values + str, n := protowire.ConsumeBytes(buf2) + if n < 0 { + b.Fatalf("bad") + } + buf2 = buf2[n:] + err = p.Unmarshal(str) + if err != nil { + b.Fatalf("bad") + } + + _ = j + _ = v + //if !compareProtoPoints(&p, &v) { + // b.Fatalf("bad %d", j) + //} + } + if len(buf2) != 0 { + b.Fatalf("bad") + } + } + printSizes(b, int64(len(buf))*int64(finish)) +} diff --git a/internal/speed/tl_protobuf_test.go b/internal/speed/tl_protobuf_test.go new file mode 100644 index 000000000..671eccaab --- /dev/null +++ b/internal/speed/tl_protobuf_test.go @@ -0,0 +1,734 @@ +package speed + +import ( + "strings" + "testing" + + "github.com/VKCOM/tl/internal/speed/speed_proto_fast/pb_fast" + "github.com/VKCOM/tl/internal/speed/speed_tl/basictl" + "github.com/VKCOM/tl/internal/speed/speed_tl/tl" + tlmem "github.com/VKCOM/tl/internal/speed/speed_tl/tlmemcache" +) + +func BenchmarkPointsWriteGen(b *testing.B) { + values, buf := prepareTLPointssBuffer() + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL1(buf) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkPointsWriteTL2Gen(b *testing.B) { + values, buf := prepareTLPointssBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkPointsWriteProtobufFastGen(b *testing.B) { + values, buf := prepareProtoPointssBuffer() + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for vIndex := range values { + s := values[vIndex].Size() + pointer := len(buf) + buf = append(buf, make([]byte, s)...) + + _, err := values[vIndex].MarshalToSizedBuffer(buf[pointer:]) + if err != nil { + b.Fatal(err) + } + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkMemcacheValueWriteGen(b *testing.B) { + values, buf := prepareTLMemValuesBuffer() + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL1Boxed(buf) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkMemcacheValueWriteTL2Gen(b *testing.B) { + values, buf := prepareTLMemValuesBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkMemcacheValueWriteProtobufFastGen(b *testing.B) { + values, buf := prepareProtoMemValuesBuffer() + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for vIndex := range values { + s := values[vIndex].Size() + pointer := len(buf) + buf = append(buf, make([]byte, s)...) + + _, err := values[vIndex].MarshalToSizedBuffer(buf[pointer:]) + if err != nil { + b.Fatal(err) + } + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkMemcacheValuesWriteGen(b *testing.B) { + values, buf := prepareTLMemValuessBuffer() + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL1(buf) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkMemcacheValuesWriteTL2Gen(b *testing.B) { + values, buf := prepareTLMemValuessBuffer() + ctx := basictl.TL2WriteContext{SizeBuffer: make([]int, 1000)} + + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for _, v := range values { + buf = v.WriteTL2(buf, &ctx) + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkMemcacheValuesWriteProtobufFastGen(b *testing.B) { + values, buf := prepareProtoMemValuessBuffer() + b.ReportAllocs() + b.ResetTimer() + var total int64 + finish := b.N / len(values) + for i := 0; i < finish; i++ { + for vIndex := range values { + s := values[vIndex].Size() + pointer := len(buf) + buf = append(buf, make([]byte, s)...) + + _, err := values[vIndex].MarshalToSizedBuffer(buf[pointer:]) + if err != nil { + b.Fatal(err) + } + } + if len(buf) > bufferSize/2 { + total += int64(len(buf)) + buf = buf[:0] + } + } + printSizes(b, total+int64(len(buf))) +} + +func BenchmarkNewPoint(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.Point, pb_fast.PointPB](b, benchDataGenerator[tl.Point, pb_fast.PointPB]{ + GenerateSamples: func() []tl.Point { + ps, _, _ := prepareTLPointsBuffer() + return ps + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: func(p tl.Point) pb_fast.PointPB { + return pb_fast.PointPB{X: p.X, Y: p.Y, Z: p.Z} + }, + + TLProvider: TLData[tl.Point]{ + WriteTL1Boxed: func(x *tl.Point, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.Point, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.Point, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.Point, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.PointPB]{ + Size: func(x *pb_fast.PointPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.PointPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.PointPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.PointPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func BenchmarkNewPoints(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.Points, pb_fast.PointsPB](b, benchDataGenerator[tl.Points, pb_fast.PointsPB]{ + GenerateSamples: func() []tl.Points { + ps, _ := prepareTLPointssBuffer() + return ps + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: func(points tl.Points) pb_fast.PointsPB { + pbb := pb_fast.PointsPB{Points: make([]*pb_fast.PointPB, len(points.Values))} + for i, p := range points.Values { + pbb.Points[i] = &pb_fast.PointPB{X: p.X, Y: p.Y, Z: p.Z} + } + return pbb + }, + + TLProvider: TLData[tl.Points]{ + WriteTL1Boxed: func(x *tl.Points, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.Points, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.Points, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.Points, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.PointsPB]{ + Size: func(x *pb_fast.PointsPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.PointsPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.PointsPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.PointsPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func BenchmarkNewMemcacheValue(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tlmem.Value, pb_fast.Value](b, benchDataGenerator[tlmem.Value, pb_fast.Value]{ + GenerateSamples: func() []tlmem.Value { + ps, _ := prepareTLMemValuesBuffer() + return ps + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: mapTLMemcacheValueToProto, + + TLProvider: TLData[tlmem.Value]{ + WriteTL1Boxed: func(x *tlmem.Value, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tlmem.Value, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tlmem.Value, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tlmem.Value, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.Value]{ + Size: func(x *pb_fast.Value) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.Value, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.Value) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.Value, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func BenchmarkNewMemcacheValues(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tlmem.Values, pb_fast.Values](b, benchDataGenerator[tlmem.Values, pb_fast.Values]{ + GenerateSamples: func() []tlmem.Values { + ps, _ := prepareTLMemValuessBuffer() + return ps + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: func(values tlmem.Values) pb_fast.Values { + r := pb_fast.Values{Values: make([]*pb_fast.Value, len(values.Values))} + + for i, value := range values.Values { + vv := mapTLMemcacheValueToProto(value) + r.Values[i] = &vv + } + + return r + }, + + TLProvider: TLData[tlmem.Values]{ + WriteTL1Boxed: func(x *tlmem.Values, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tlmem.Values, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tlmem.Values, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tlmem.Values, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.Values]{ + Size: func(x *pb_fast.Values) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.Values, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.Values) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.Values, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func makePartialPoints(ps []tl.Point, defaultMask uint32, compact bool) []tl.PartialPoint { + pps := make([]tl.PartialPoint, len(ps)) + for i, p := range ps { + pp := tl.PartialPoint{} + pp.X = p.X + pp.Y = p.Y + pp.Z = p.Z + + pp.Mask = uint32((i*107+31)%8) ^ defaultMask + + if compact { + if pp.X == 0 { + pp.Mask &^= 1 << 0 + } + if pp.Y == 0 { + pp.Mask &^= 1 << 1 + } + if pp.Z == 0 { + pp.Mask &^= 1 << 2 + } + } + + pps[i] = pp + } + + return pps +} + +func makePartialPointPB(p tl.PartialPoint) pb_fast.PartialPointPB { + return pb_fast.PartialPointPB{Mask: p.Mask, X: p.X, Y: p.Y, Z: p.Z} +} + +func BenchmarkNewPartialPoint(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.PartialPoint, pb_fast.PartialPointPB](b, benchDataGenerator[tl.PartialPoint, pb_fast.PartialPointPB]{ + GenerateSamples: func() []tl.PartialPoint { + ps, _, _ := prepareTLPointsBuffer() + return makePartialPoints(ps, 0, false) + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: makePartialPointPB, + + TLProvider: TLData[tl.PartialPoint]{ + WriteTL1Boxed: func(x *tl.PartialPoint, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.PartialPoint, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.PartialPoint, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.PartialPoint, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.PartialPointPB]{ + Size: func(x *pb_fast.PartialPointPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.PartialPointPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.PartialPointPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.PartialPointPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func BenchmarkNewPartialPoints(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.PartialPoints, pb_fast.PartialPointsPB](b, benchDataGenerator[tl.PartialPoints, pb_fast.PartialPointsPB]{ + GenerateSamples: func() []tl.PartialPoints { + ps, _ := prepareTLPointssBuffer() + pss := make([]tl.PartialPoints, len(ps)) + for i, po := range ps { + pss[i] = tl.PartialPoints{Values: makePartialPoints(po.Values, uint32((i*73)+31)%8, false)} + } + return pss + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: func(p tl.PartialPoints) pb_fast.PartialPointsPB { + pbb := pb_fast.PartialPointsPB{Points: make([]*pb_fast.PartialPointPB, 0)} + for _, value := range p.Values { + pb := makePartialPointPB(value) + pbb.Points = append(pbb.Points, &pb) + } + return pbb + }, + + TLProvider: TLData[tl.PartialPoints]{ + WriteTL1Boxed: func(x *tl.PartialPoints, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.PartialPoints, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.PartialPoints, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.PartialPoints, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.PartialPointsPB]{ + Size: func(x *pb_fast.PartialPointsPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.PartialPointsPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.PartialPointsPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.PartialPointsPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func BenchmarkNewPartialPointsCompact(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.PartialPoints, pb_fast.PartialPointsPB](b, benchDataGenerator[tl.PartialPoints, pb_fast.PartialPointsPB]{ + GenerateSamples: func() []tl.PartialPoints { + ps, _ := prepareTLPointssBuffer() + pss := make([]tl.PartialPoints, len(ps)) + for i, po := range ps { + pss[i] = tl.PartialPoints{Values: makePartialPoints(po.Values, uint32((i*73)+31)%8, true)} + } + return pss + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: func(p tl.PartialPoints) pb_fast.PartialPointsPB { + pbb := pb_fast.PartialPointsPB{Points: make([]*pb_fast.PartialPointPB, 0)} + for _, value := range p.Values { + pb := makePartialPointPB(value) + pbb.Points = append(pbb.Points, &pb) + } + return pbb + }, + + TLProvider: TLData[tl.PartialPoints]{ + WriteTL1Boxed: func(x *tl.PartialPoints, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.PartialPoints, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.PartialPoints, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.PartialPoints, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.PartialPointsPB]{ + Size: func(x *pb_fast.PartialPointsPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.PartialPointsPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.PartialPointsPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.PartialPointsPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func makeUnionPoints(ps []tl.PartialPoint, shift int) []tl.UnionPoint { + ups := make([]tl.UnionPoint, len(ps)) + for i, p := range ps { + // random as i can + rValue := (i*79 + 89) % 313 + if rValue < 313/5 { + ups[i].SetError(tl.UnionPointError{Err: strings.Repeat("a", rValue)}) + } else { + ups[i].SetValue(tl.UnionPointValue{ + Mask: p.Mask, + X: p.X, + Y: p.Y, + Z: p.Z, + }) + } + } + + return ups +} + +func makeUnionPointPB(up tl.UnionPoint) pb_fast.UnionPointPB { + switch { + case up.IsValue(): + v, _ := up.AsValue() + return pb_fast.UnionPointPB{Kind: &pb_fast.UnionPointPB_Value{Value: &pb_fast.UnionPointValuePB{ + Mask: v.Mask, + X: v.X, + Y: v.Y, + Z: v.Z, + }}} + default: + v, _ := up.AsError() + return pb_fast.UnionPointPB{Kind: &pb_fast.UnionPointPB_Error{Error: &pb_fast.UnionPointErrorPB{ + Err: v.Err, + }}} + } +} + +func BenchmarkNewUnionPoint(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.UnionPoint, pb_fast.UnionPointPB](b, benchDataGenerator[tl.UnionPoint, pb_fast.UnionPointPB]{ + GenerateSamples: func() []tl.UnionPoint { + ps, _, _ := prepareTLPointsBuffer() + return makeUnionPoints(makePartialPoints(ps, 0, false), 0) + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: makeUnionPointPB, + + TLProvider: TLData[tl.UnionPoint]{ + WriteTL1Boxed: func(x *tl.UnionPoint, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.UnionPoint, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.UnionPoint, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.UnionPoint, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.UnionPointPB]{ + Size: func(x *pb_fast.UnionPointPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.UnionPointPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.UnionPointPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.UnionPointPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +} + +func BenchmarkNewUnionPoints(b *testing.B) { + buffer_ := make([]byte, 0, bufferSize) + + benchBase[tl.UnionPoints, pb_fast.UnionPointsPB](b, benchDataGenerator[tl.UnionPoints, pb_fast.UnionPointsPB]{ + GenerateSamples: func() []tl.UnionPoints { + ps, _ := prepareTLPointssBuffer() + pss := make([]tl.UnionPoints, len(ps)) + for i, po := range ps { + pss[i] = tl.UnionPoints{Values: makeUnionPoints(makePartialPoints(po.Values, uint32((i*73)+31)%8, true), i)} + } + return pss + }, + GenerateBuffer: func() []byte { + return buffer_ + }, + MapSample: func(p tl.UnionPoints) pb_fast.UnionPointsPB { + pbb := pb_fast.UnionPointsPB{Points: make([]*pb_fast.UnionPointPB, 0)} + for _, value := range p.Values { + pb := makeUnionPointPB(value) + pbb.Points = append(pbb.Points, &pb) + } + return pbb + }, + + TLProvider: TLData[tl.UnionPoints]{ + WriteTL1Boxed: func(x *tl.UnionPoints, buf []byte) []byte { + return x.WriteTL1Boxed(buf) + }, + ReadTL1Boxed: func(x *tl.UnionPoints, buf []byte) ([]byte, error) { + return x.ReadTL1Boxed(buf) + }, + WriteTL2: func(x *tl.UnionPoints, w []byte, tctx *basictl.TL2WriteContext) []byte { + return x.WriteTL2(w, tctx) + }, + ReadTL2: func(x *tl.UnionPoints, r []byte, tctx *basictl.TL2ReadContext) (_ []byte, err error) { + return x.ReadTL2(r, tctx) + }, + }, + + ProtoProvider: ProtoData[pb_fast.UnionPointsPB]{ + Size: func(x *pb_fast.UnionPointsPB) int { + return x.Size() + }, + MarshalToSizedBuffer: func(x *pb_fast.UnionPointsPB, dAtA []byte) (int, error) { + return x.MarshalToSizedBuffer(dAtA) + }, + Marshal: func(x *pb_fast.UnionPointsPB) ([]byte, error) { + return x.Marshal() + }, + Unmarshal: func(x *pb_fast.UnionPointsPB, dAtA []byte) error { + return x.Unmarshal(dAtA) + }, + }, + }) +}