From 950f63ed2ecb259c686d9a82fdbc7bcc96dcc523 Mon Sep 17 00:00:00 2001 From: srfrog Date: Fri, 21 Sep 2018 18:28:00 -0700 Subject: [PATCH 1/2] rename intern pkg to pb change all references to 'intern' to 'pb'. change gen.sh to use gogo/protobuf for code generation. update vendor with the working version of gogo/protobuf. [Ticket: X] --- algo/uidlist.go | 32 +- algo/uidlist_test.go | 64 +- conn/node.go | 12 +- conn/node_test.go | 4 +- conn/pool.go | 4 +- conn/raft_server.go | 16 +- dgraph/cmd/bulk/loader.go | 12 +- dgraph/cmd/bulk/mapper.go | 34 +- dgraph/cmd/bulk/reduce.go | 6 +- dgraph/cmd/bulk/schema.go | 24 +- dgraph/cmd/bulk/shuffle.go | 20 +- dgraph/cmd/live/batch.go | 6 +- dgraph/cmd/live/run.go | 2 +- dgraph/cmd/server/run.go | 2 +- dgraph/cmd/server/run_test.go | 8 +- dgraph/cmd/zero/assign.go | 18 +- dgraph/cmd/zero/http.go | 4 +- dgraph/cmd/zero/oracle.go | 50 +- dgraph/cmd/zero/raft.go | 26 +- dgraph/cmd/zero/run.go | 8 +- dgraph/cmd/zero/tablet.go | 24 +- dgraph/cmd/zero/telemetry.go | 4 +- dgraph/cmd/zero/zero.go | 70 +- dgraph/cmd/zero/zero_test.go | 6 +- edgraph/server.go | 10 +- gql/mutation.go | 28 +- gql/parser.go | 32 +- posting/index.go | 74 +- posting/index_test.go | 22 +- posting/list.go | 130 +- posting/list_test.go | 118 +- posting/lists.go | 4 +- posting/lru_test.go | 4 +- posting/mvcc.go | 14 +- posting/oracle.go | 4 +- protos/gen.sh | 2 +- protos/{internal.proto => pb.proto} | 2 +- protos/{intern/internal.pb.go => pb/pb.pb.go} | 4040 +++++++++++------ query/aggregator.go | 8 +- query/common_test.go | 42 +- query/groupby.go | 16 +- query/mutation.go | 32 +- query/query.go | 108 +- query/query0_test.go | 6 +- query/query1_test.go | 6 +- query/query2_test.go | 22 +- query/query3_test.go | 6 +- query/shortest.go | 56 +- schema/parse.go | 28 +- schema/parse_test.go | 62 +- schema/schema.go | 20 +- task/conversion.go | 12 +- types/facets/utils.go | 4 +- types/geofilter.go | 8 +- types/scalar_types.go | 28 +- types/sort.go | 10 +- types/sort_test.go | 6 +- vendor/github.com/gogo/protobuf/LICENSE | 5 +- .../github.com/gogo/protobuf/jsonpb/jsonpb.go | 792 +++- .../github.com/gogo/protobuf/proto/Makefile | 4 +- .../github.com/gogo/protobuf/proto/clone.go | 58 +- .../gogo/protobuf/proto/custom_gogo.go | 39 + .../github.com/gogo/protobuf/proto/decode.go | 784 +--- .../gogo/protobuf/proto/decode_gogo.go | 169 - .../github.com/gogo/protobuf/proto/discard.go | 350 ++ .../gogo/protobuf/proto/duration.go | 100 + .../gogo/protobuf/proto/duration_gogo.go | 49 + .../github.com/gogo/protobuf/proto/encode.go | 1190 +---- .../gogo/protobuf/proto/encode_gogo.go | 327 +- .../github.com/gogo/protobuf/proto/equal.go | 57 +- .../gogo/protobuf/proto/extensions.go | 479 +- .../gogo/protobuf/proto/extensions_gogo.go | 198 +- vendor/github.com/gogo/protobuf/proto/lib.go | 97 +- .../gogo/protobuf/proto/lib_gogo.go | 14 +- .../gogo/protobuf/proto/message_set.go | 104 +- .../gogo/protobuf/proto/pointer_reflect.go | 592 +-- .../protobuf/proto/pointer_reflect_gogo.go | 59 + .../gogo/protobuf/proto/pointer_unsafe.go | 364 +- .../protobuf/proto/pointer_unsafe_gogo.go | 86 +- .../gogo/protobuf/proto/properties.go | 515 +-- .../gogo/protobuf/proto/properties_gogo.go | 40 +- .../gogo/protobuf/proto/skip_gogo.go | 6 +- .../gogo/protobuf/proto/table_marshal.go | 2803 ++++++++++++ .../gogo/protobuf/proto/table_marshal_gogo.go | 388 ++ .../gogo/protobuf/proto/table_merge.go | 657 +++ .../gogo/protobuf/proto/table_unmarshal.go | 2058 +++++++++ .../protobuf/proto/table_unmarshal_gogo.go | 385 ++ vendor/github.com/gogo/protobuf/proto/text.go | 275 +- .../gogo/protobuf/proto/text_gogo.go | 12 +- .../gogo/protobuf/proto/text_parser.go | 278 +- .../gogo/protobuf/proto/timestamp.go | 113 + .../gogo/protobuf/proto/timestamp_gogo.go | 49 + .../gogo/protobuf/sortkeys/sortkeys.go | 101 + vendor/github.com/gogo/protobuf/types/any.go | 140 + .../github.com/gogo/protobuf/types/any.pb.go | 703 +++ .../github.com/gogo/protobuf/types/api.pb.go | 2067 +++++++++ vendor/github.com/gogo/protobuf/types/doc.go | 35 + .../gogo/protobuf/types/duration.go | 100 + .../gogo/protobuf/types/duration.pb.go | 537 +++ .../gogo/protobuf/types/duration_gogo.go | 100 + .../gogo/protobuf/types/empty.pb.go | 480 ++ .../gogo/protobuf/types/field_mask.pb.go | 769 ++++ .../gogo/protobuf/types/protosize.go | 34 + .../gogo/protobuf/types/source_context.pb.go | 538 +++ .../gogo/protobuf/types/struct.pb.go | 1986 ++++++++ .../gogo/protobuf/types/timestamp.go | 132 + .../gogo/protobuf/types/timestamp.pb.go | 555 +++ .../gogo/protobuf/types/timestamp_gogo.go | 94 + .../github.com/gogo/protobuf/types/type.pb.go | 3243 +++++++++++++ .../gogo/protobuf/types/wrappers.pb.go | 2668 +++++++++++ vendor/vendor.json | 24 +- worker/draft.go | 44 +- worker/draft_test.go | 10 +- worker/export.go | 50 +- worker/export_test.go | 48 +- worker/groups.go | 66 +- worker/mutation.go | 90 +- worker/mutation_test.go | 74 +- worker/predicate.go | 16 +- worker/predicate_move.go | 26 +- worker/predicate_test.go | 18 +- worker/schema.go | 26 +- worker/sort.go | 52 +- worker/stream_lists.go | 22 +- worker/stream_lists_test.go | 12 +- worker/stringfilter.go | 6 +- worker/task.go | 104 +- worker/trigram.go | 12 +- worker/worker.go | 10 +- worker/worker_test.go | 60 +- x/histogram.go | 2 +- x/x.go | 2 +- xidmap/xidmap.go | 12 +- 133 files changed, 27725 insertions(+), 6259 deletions(-) rename protos/{internal.proto => pb.proto} (99%) rename protos/{intern/internal.pb.go => pb/pb.pb.go} (71%) create mode 100644 vendor/github.com/gogo/protobuf/proto/custom_gogo.go delete mode 100644 vendor/github.com/gogo/protobuf/proto/decode_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/discard.go create mode 100644 vendor/github.com/gogo/protobuf/proto/duration.go create mode 100644 vendor/github.com/gogo/protobuf/proto/duration_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/table_marshal.go create mode 100644 vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/table_merge.go create mode 100644 vendor/github.com/gogo/protobuf/proto/table_unmarshal.go create mode 100644 vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/timestamp.go create mode 100644 vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/sortkeys/sortkeys.go create mode 100644 vendor/github.com/gogo/protobuf/types/any.go create mode 100644 vendor/github.com/gogo/protobuf/types/any.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/api.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/doc.go create mode 100644 vendor/github.com/gogo/protobuf/types/duration.go create mode 100644 vendor/github.com/gogo/protobuf/types/duration.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/duration_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/types/empty.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/field_mask.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/protosize.go create mode 100644 vendor/github.com/gogo/protobuf/types/source_context.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/struct.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/timestamp.go create mode 100644 vendor/github.com/gogo/protobuf/types/timestamp.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/timestamp_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/types/type.pb.go create mode 100644 vendor/github.com/gogo/protobuf/types/wrappers.pb.go diff --git a/algo/uidlist.go b/algo/uidlist.go index 48b6df31bda..633c484adeb 100644 --- a/algo/uidlist.go +++ b/algo/uidlist.go @@ -12,13 +12,13 @@ import ( "sort" "github.com/dgraph-io/dgraph/bp128" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" ) const jump = 32 // Jump size in InsersectWithJump. // ApplyFilter applies a filter to our UIDList. -func ApplyFilter(u *intern.List, f func(uint64, int) bool) { +func ApplyFilter(u *pb.List, f func(uint64, int) bool) { out := u.Uids[:0] for i, uid := range u.Uids { if f(uid, i) { @@ -28,7 +28,7 @@ func ApplyFilter(u *intern.List, f func(uint64, int) bool) { u.Uids = out } -func IntersectCompressedWith(u []byte, afterUID uint64, v, o *intern.List) { +func IntersectCompressedWith(u []byte, afterUID uint64, v, o *pb.List) { var bi bp128.BPackIterator bi.Init(u, afterUID) n := bi.Length() - bi.StartIdx() @@ -120,7 +120,7 @@ func IntersectCompressedWithBin(bi *bp128.BPackIterator, q []uint64, o *[]uint64 // IntersectWith intersects u with v. The update is made to o. // u, v should be sorted. -func IntersectWith(u, v, o *intern.List) { +func IntersectWith(u, v, o *pb.List) { n := len(u.Uids) m := len(v.Uids) @@ -261,13 +261,13 @@ func binIntersect(d, q []uint64, final *[]uint64) { } type listInfo struct { - l *intern.List + l *pb.List length int } -func IntersectSorted(lists []*intern.List) *intern.List { +func IntersectSorted(lists []*pb.List) *pb.List { if len(lists) == 0 { - return &intern.List{} + return &pb.List{} } ls := make([]listInfo, 0, len(lists)) for _, list := range lists { @@ -280,7 +280,7 @@ func IntersectSorted(lists []*intern.List) *intern.List { sort.Slice(ls, func(i, j int) bool { return ls[i].length < ls[j].length }) - out := &intern.List{Uids: make([]uint64, ls[0].length)} + out := &pb.List{Uids: make([]uint64, ls[0].length)} if len(ls) == 1 { copy(out.Uids, ls[0].l.Uids) return out @@ -299,9 +299,9 @@ func IntersectSorted(lists []*intern.List) *intern.List { return out } -func Difference(u, v *intern.List) *intern.List { +func Difference(u, v *pb.List) *pb.List { if u == nil || v == nil { - return &intern.List{Uids: make([]uint64, 0)} + return &pb.List{Uids: make([]uint64, 0)} } n := len(u.Uids) m := len(v.Uids) @@ -327,13 +327,13 @@ func Difference(u, v *intern.List) *intern.List { out = append(out, u.Uids[i]) i++ } - return &intern.List{Uids: out} + return &pb.List{Uids: out} } // MergeSorted merges sorted lists. -func MergeSorted(lists []*intern.List) *intern.List { +func MergeSorted(lists []*pb.List) *pb.List { if len(lists) == 0 { - return new(intern.List) + return new(pb.List) } h := &uint64Heap{} @@ -377,12 +377,12 @@ func MergeSorted(lists []*intern.List) *intern.List { heap.Fix(h, 0) // Faster than Pop() followed by Push(). } } - return &intern.List{Uids: output} + return &pb.List{Uids: output} } // IndexOf performs a binary search on the uids slice and returns the index at // which it finds the uid, else returns -1 -func IndexOf(u *intern.List, uid uint64) int { +func IndexOf(u *pb.List, uid uint64) int { i := sort.Search(len(u.Uids), func(i int) bool { return u.Uids[i] >= uid }) if i < len(u.Uids) && u.Uids[i] == uid { return i @@ -391,7 +391,7 @@ func IndexOf(u *intern.List, uid uint64) int { } // ToUintsListForTest converts to list of uints for testing purpose only. -func ToUintsListForTest(ul []*intern.List) [][]uint64 { +func ToUintsListForTest(ul []*pb.List) [][]uint64 { out := make([][]uint64, 0, len(ul)) for _, u := range ul { out = append(out, u.Uids) diff --git a/algo/uidlist_test.go b/algo/uidlist_test.go index 931e4a6df3d..7464a3de727 100644 --- a/algo/uidlist_test.go +++ b/algo/uidlist_test.go @@ -14,23 +14,23 @@ import ( "testing" "github.com/dgraph-io/dgraph/bp128" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" ) -func newList(data []uint64) *intern.List { - return &intern.List{data} +func newList(data []uint64) *pb.List { + return &pb.List{data} } func TestMergeSorted1(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{55}), } require.Equal(t, MergeSorted(input).Uids, []uint64{55}) } func TestMergeSorted2(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 3, 6, 8, 10}), newList([]uint64{2, 4, 5, 7, 15}), } @@ -39,7 +39,7 @@ func TestMergeSorted2(t *testing.T) { } func TestMergeSorted3(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 3, 6, 8, 10}), newList([]uint64{}), } @@ -47,7 +47,7 @@ func TestMergeSorted3(t *testing.T) { } func TestMergeSorted4(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{}), newList([]uint64{1, 3, 6, 8, 10}), } @@ -55,7 +55,7 @@ func TestMergeSorted4(t *testing.T) { } func TestMergeSorted5(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{}), newList([]uint64{}), } @@ -63,7 +63,7 @@ func TestMergeSorted5(t *testing.T) { } func TestMergeSorted6(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{11, 13, 16, 18, 20}), newList([]uint64{12, 14, 15, 15, 16, 16, 17, 25}), newList([]uint64{1, 2}), @@ -73,7 +73,7 @@ func TestMergeSorted6(t *testing.T) { } func TestMergeSorted7(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{5, 6, 7}), newList([]uint64{3, 4}), newList([]uint64{1, 2}), @@ -83,19 +83,19 @@ func TestMergeSorted7(t *testing.T) { } func TestMergeSorted8(t *testing.T) { - input := []*intern.List{} + input := []*pb.List{} require.Empty(t, MergeSorted(input).Uids) } func TestMergeSorted9(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 1, 1}), } require.Equal(t, MergeSorted(input).Uids, []uint64{1}) } func TestMergeSorted10(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3, 3, 6}), newList([]uint64{4, 8, 9}), } @@ -103,7 +103,7 @@ func TestMergeSorted10(t *testing.T) { } func TestIntersectSorted1(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{2, 3, 4, 5}), } @@ -111,26 +111,26 @@ func TestIntersectSorted1(t *testing.T) { } func TestIntersectSorted2(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), } require.Equal(t, IntersectSorted(input).Uids, []uint64{1, 2, 3}) } func TestIntersectSorted3(t *testing.T) { - input := []*intern.List{} + input := []*pb.List{} require.Empty(t, IntersectSorted(input).Uids) } func TestIntersectSorted4(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{100, 101}), } require.Equal(t, IntersectSorted(input).Uids, []uint64{100, 101}) } func TestIntersectSorted5(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{2, 3, 4, 5}), newList([]uint64{4, 5, 6}), @@ -139,7 +139,7 @@ func TestIntersectSorted5(t *testing.T) { } func TestIntersectSorted6(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{10, 12, 13}), newList([]uint64{2, 3, 4, 13}), newList([]uint64{4, 5, 6}), @@ -148,7 +148,7 @@ func TestIntersectSorted6(t *testing.T) { } func TestDiffSorted1(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{1}), } @@ -157,7 +157,7 @@ func TestDiffSorted1(t *testing.T) { } func TestDiffSorted2(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{2}), } @@ -166,7 +166,7 @@ func TestDiffSorted2(t *testing.T) { } func TestDiffSorted3(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{3}), } @@ -175,7 +175,7 @@ func TestDiffSorted3(t *testing.T) { } func TestDiffSorted4(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{}), } @@ -184,7 +184,7 @@ func TestDiffSorted4(t *testing.T) { } func TestDiffSorted5(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{}), newList([]uint64{1, 2}), } @@ -193,7 +193,7 @@ func TestDiffSorted5(t *testing.T) { } func TestSubSorted1(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{1, 2, 3}), newList([]uint64{2, 3, 4, 5}), } @@ -202,7 +202,7 @@ func TestSubSorted1(t *testing.T) { } func TestSubSorted6(t *testing.T) { - input := []*intern.List{ + input := []*pb.List{ newList([]uint64{10, 12, 13}), newList([]uint64{2, 3, 4, 13}), } @@ -290,8 +290,8 @@ func BenchmarkListIntersectRandom(b *testing.B) { u := newList(u1) v := newList(v1) - dst1 := &intern.List{} - dst2 := &intern.List{} + dst1 := &pb.List{} + dst2 := &pb.List{} compressedUids := bp128.DeltaPack(u1) b.Run(fmt.Sprintf(":size=%d:overlap=%.2f:", arrSz, overlap), @@ -353,10 +353,10 @@ func BenchmarkListIntersectRatio(b *testing.B) { sort.Slice(u1, func(i, j int) bool { return u1[i] < u1[j] }) sort.Slice(v1, func(i, j int) bool { return v1[i] < v1[j] }) - u := &intern.List{u1} - v := &intern.List{v1} - dst1 := &intern.List{} - dst2 := &intern.List{} + u := &pb.List{u1} + v := &pb.List{v1} + dst1 := &pb.List{} + dst2 := &pb.List{} compressedUids := bp128.DeltaPack(v1) fmt.Printf("len: %d, compressed: %d, bytes/int: %f\n", diff --git a/conn/node.go b/conn/node.go index d6f0a6065fd..4b57d10a81a 100644 --- a/conn/node.go +++ b/conn/node.go @@ -20,7 +20,7 @@ import ( "github.com/coreos/etcd/raft/raftpb" "github.com/dgraph-io/badger/y" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" @@ -51,7 +51,7 @@ type Node struct { peers map[uint64]string confChanges map[uint64]chan error messages chan sendmsg - RaftContext *intern.RaftContext + RaftContext *pb.RaftContext Store *raftwal.DiskStorage Rand *rand.Rand @@ -62,7 +62,7 @@ type Node struct { Applied x.WaterMark } -func NewNode(rc *intern.RaftContext, store *raftwal.DiskStorage) *Node { +func NewNode(rc *pb.RaftContext, store *raftwal.DiskStorage) *Node { snap, err := store.Snapshot() x.Check(err) @@ -332,9 +332,9 @@ func (n *Node) doSendMessage(pool *Pool, data []byte) { client := pool.Get() - c := intern.NewRaftClient(client) + c := pb.NewRaftClient(client) p := &api.Payload{Data: data} - batch := &intern.RaftBatch{ + batch := &pb.RaftBatch{ Context: n.RaftContext, Payload: p, } @@ -415,7 +415,7 @@ func (n *Node) proposeConfChange(ctx context.Context, pb raftpb.ConfChange) erro func (n *Node) AddToCluster(ctx context.Context, pid uint64) error { addr, ok := n.Peer(pid) x.AssertTruef(ok, "Unable to find conn pool for peer: %d", pid) - rc := &intern.RaftContext{ + rc := &pb.RaftContext{ Addr: addr, Group: n.RaftContext.Group, Id: pid, diff --git a/conn/node_test.go b/conn/node_test.go index d4d275cb984..f7980569774 100644 --- a/conn/node_test.go +++ b/conn/node_test.go @@ -12,7 +12,7 @@ import ( "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" "github.com/dgraph-io/badger" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/stretchr/testify/require" "golang.org/x/net/context" @@ -61,7 +61,7 @@ func TestProposal(t *testing.T) { require.NoError(t, err) store := raftwal.Init(db, 0, 0) - rc := &intern.RaftContext{Id: 1} + rc := &pb.RaftContext{Id: 1} n := NewNode(rc, store) peers := []raft.Peer{{ID: n.Id}} diff --git a/conn/pool.go b/conn/pool.go index 79e4925ff45..113718a322a 100644 --- a/conn/pool.go +++ b/conn/pool.go @@ -16,7 +16,7 @@ import ( "time" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "google.golang.org/grpc" @@ -150,7 +150,7 @@ func (p *Pool) UpdateHealthStatus(printError bool) error { query.Data = make([]byte, 10) x.Check2(rand.Read(query.Data)) - c := intern.NewRaftClient(conn) + c := pb.NewRaftClient(conn) resp, err := c.Echo(context.Background(), query) if err == nil { x.AssertTruef(bytes.Equal(resp.Data, query.Data), diff --git a/conn/raft_server.go b/conn/raft_server.go index e780a634578..f9516c43639 100644 --- a/conn/raft_server.go +++ b/conn/raft_server.go @@ -15,7 +15,7 @@ import ( "github.com/coreos/etcd/raft/raftpb" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -110,27 +110,27 @@ type RaftServer struct { Node *Node } -func (w *RaftServer) IsPeer(ctx context.Context, rc *intern.RaftContext) (*intern.PeerResponse, +func (w *RaftServer) IsPeer(ctx context.Context, rc *pb.RaftContext) (*pb.PeerResponse, error) { node := w.GetNode() if node == nil || node.Raft() == nil { - return &intern.PeerResponse{}, ErrNoNode + return &pb.PeerResponse{}, ErrNoNode } if node._confState == nil { - return &intern.PeerResponse{}, nil + return &pb.PeerResponse{}, nil } for _, raftIdx := range node._confState.Nodes { if rc.Id == raftIdx { - return &intern.PeerResponse{Status: true}, nil + return &pb.PeerResponse{Status: true}, nil } } - return &intern.PeerResponse{}, nil + return &pb.PeerResponse{}, nil } func (w *RaftServer) JoinCluster(ctx context.Context, - rc *intern.RaftContext) (*api.Payload, error) { + rc *pb.RaftContext) (*api.Payload, error) { if ctx.Err() != nil { return &api.Payload{}, ctx.Err() } @@ -168,7 +168,7 @@ func (w *RaftServer) JoinCluster(ctx context.Context, } func (w *RaftServer) RaftMessage(ctx context.Context, - batch *intern.RaftBatch) (*api.Payload, error) { + batch *pb.RaftBatch) (*api.Payload, error) { if ctx.Err() != nil { return &api.Payload{}, ctx.Err() } diff --git a/dgraph/cmd/bulk/loader.go b/dgraph/cmd/bulk/loader.go index 922b042b746..60596d17144 100644 --- a/dgraph/cmd/bulk/loader.go +++ b/dgraph/cmd/bulk/loader.go @@ -24,7 +24,7 @@ import ( "github.com/dgraph-io/badger" bo "github.com/dgraph-io/badger/options" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/dgraph/xidmap" @@ -102,10 +102,10 @@ func newLoader(opt options) *loader { } func getWriteTimestamp(zero *grpc.ClientConn) uint64 { - client := intern.NewZeroClient(zero) + client := pb.NewZeroClient(zero) for { ctx, cancel := context.WithTimeout(context.Background(), time.Second) - ts, err := client.Timestamps(ctx, &intern.Num{Val: 1}) + ts, err := client.Timestamps(ctx, &pb.Num{Val: 1}) cancel() if err == nil { return ts.GetStartId() @@ -115,7 +115,7 @@ func getWriteTimestamp(zero *grpc.ClientConn) uint64 { } } -func readSchema(filename string) []*intern.SchemaUpdate { +func readSchema(filename string) []*pb.SchemaUpdate { f, err := os.Open(filename) x.Check(err) defer f.Close() @@ -180,7 +180,7 @@ func findRDFFiles(dir string) []string { } type uidRangeResponse struct { - uids *intern.AssignedIds + uids *pb.AssignedIds err error } @@ -269,7 +269,7 @@ func (ld *loader) mapStage() { type shuffleOutput struct { db *badger.DB - mapEntries []*intern.MapEntry + mapEntries []*pb.MapEntry } func (ld *loader) reduceStage() { diff --git a/dgraph/cmd/bulk/mapper.go b/dgraph/cmd/bulk/mapper.go index 09abd560e72..d4020abe75c 100644 --- a/dgraph/cmd/bulk/mapper.go +++ b/dgraph/cmd/bulk/mapper.go @@ -24,7 +24,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/rdf" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" @@ -54,7 +54,7 @@ func newMapper(st *state) *mapper { } } -func less(lhs, rhs *intern.MapEntry) bool { +func less(lhs, rhs *pb.MapEntry) bool { if keyCmp := bytes.Compare(lhs.Key, rhs.Key); keyCmp != 0 { return keyCmp < 0 } @@ -73,12 +73,12 @@ func (m *mapper) writeMapEntriesToFile(entriesBuf []byte, shardIdx int) { defer m.shards[shardIdx].mu.Unlock() // Locked by caller. buf := entriesBuf - var entries []*intern.MapEntry + var entries []*pb.MapEntry for len(buf) > 0 { sz, n := binary.Uvarint(buf) x.AssertTrue(n > 0) buf = buf[n:] - me := new(intern.MapEntry) + me := new(pb.MapEntry) x.Check(proto.Unmarshal(buf[:sz], me)) buf = buf[sz:] entries = append(entries, me) @@ -151,13 +151,13 @@ func (m *mapper) run() { } } -func (m *mapper) addMapEntry(key []byte, p *intern.Posting, shard int) { +func (m *mapper) addMapEntry(key []byte, p *pb.Posting, shard int) { atomic.AddInt64(&m.prog.mapEdgeCount, 1) - me := &intern.MapEntry{ + me := &pb.MapEntry{ Key: key, } - if p.PostingType != intern.Posting_REF || len(p.Facets) > 0 { + if p.PostingType != pb.Posting_REF || len(p.Facets) > 0 { me.Posting = p } else { me.Uid = p.Uid @@ -188,7 +188,7 @@ func (m *mapper) processRDF(rdfLine string) error { func (m *mapper) processNQuad(nq gql.NQuad) { sid := m.lookupUid(nq.GetSubject()) var oid uint64 - var de *intern.DirectedEdge + var de *pb.DirectedEdge if nq.GetObjectValue() == nil { oid = m.lookupUid(nq.GetObjectId()) de = nq.CreateUidEdge(sid, oid) @@ -245,18 +245,18 @@ func parseNQuad(line string) (gql.NQuad, error) { return gql.NQuad{NQuad: &nq}, nil } -func (m *mapper) createPredicatePosting(predicate string) *intern.Posting { +func (m *mapper) createPredicatePosting(predicate string) *pb.Posting { fp := farm.Fingerprint64([]byte(predicate)) - return &intern.Posting{ + return &pb.Posting{ Uid: fp, Value: []byte(predicate), - ValType: intern.Posting_DEFAULT, - PostingType: intern.Posting_VALUE, + ValType: pb.Posting_DEFAULT, + PostingType: pb.Posting_VALUE, } } func (m *mapper) createPostings(nq gql.NQuad, - de *intern.DirectedEdge) (*intern.Posting, *intern.Posting) { + de *pb.DirectedEdge) (*pb.Posting, *pb.Posting) { m.schema.validateType(de, nq.ObjectValue == nil) @@ -274,7 +274,7 @@ func (m *mapper) createPostings(nq gql.NQuad, p.Facets = nq.Facets // Early exit for no reverse edge. - if sch.GetDirective() != intern.SchemaUpdate_REVERSE { + if sch.GetDirective() != pb.SchemaUpdate_REVERSE { return p, nil } @@ -289,7 +289,7 @@ func (m *mapper) createPostings(nq gql.NQuad, return p, rp } -func (m *mapper) addIndexMapEntries(nq gql.NQuad, de *intern.DirectedEdge) { +func (m *mapper) addIndexMapEntries(nq gql.NQuad, de *pb.DirectedEdge) { if nq.GetObjectValue() == nil { return // Cannot index UIDs } @@ -322,9 +322,9 @@ func (m *mapper) addIndexMapEntries(nq gql.NQuad, de *intern.DirectedEdge) { for _, t := range toks { m.addMapEntry( x.IndexKey(nq.Predicate, t), - &intern.Posting{ + &pb.Posting{ Uid: de.GetEntity(), - PostingType: intern.Posting_REF, + PostingType: pb.Posting_REF, }, m.state.shards.shardFor(nq.Predicate), ) diff --git a/dgraph/cmd/bulk/reduce.go b/dgraph/cmd/bulk/reduce.go index 7e4d071e5d9..723a63000d1 100644 --- a/dgraph/cmd/bulk/reduce.go +++ b/dgraph/cmd/bulk/reduce.go @@ -13,7 +13,7 @@ import ( "github.com/dgraph-io/dgraph/bp128" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -43,7 +43,7 @@ func (r *reducer) run() { func (r *reducer) reduce(job shuffleOutput) { var currentKey []byte var uids []uint64 - pl := new(intern.PostingList) + pl := new(pb.PostingList) txn := job.db.NewTransactionAt(r.state.writeTs, true) outputPostingList := func() { @@ -52,7 +52,7 @@ func (r *reducer) reduce(job shuffleOutput) { // For a UID-only posting list, the badger value is a delta packed UID // list. The UserMeta indicates to treat the value as a delta packed // list when the value is read by dgraph. For a value posting list, - // the full intern.Posting type is used (which intern.y contains the + // the full pb.Posting type is used (which pb.y contains the // delta packed UID list). meta := posting.BitCompletePosting if len(pl.Postings) == 0 { diff --git a/dgraph/cmd/bulk/schema.go b/dgraph/cmd/bulk/schema.go index f45313eb586..25647e95df1 100644 --- a/dgraph/cmd/bulk/schema.go +++ b/dgraph/cmd/bulk/schema.go @@ -15,30 +15,30 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" wk "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" ) type schemaStore struct { sync.RWMutex - m map[string]*intern.SchemaUpdate + m map[string]*pb.SchemaUpdate *state } -func newSchemaStore(initial []*intern.SchemaUpdate, opt options, state *state) *schemaStore { +func newSchemaStore(initial []*pb.SchemaUpdate, opt options, state *state) *schemaStore { s := &schemaStore{ - m: map[string]*intern.SchemaUpdate{ - "_predicate_": &intern.SchemaUpdate{ - ValueType: intern.Posting_STRING, + m: map[string]*pb.SchemaUpdate{ + "_predicate_": &pb.SchemaUpdate{ + ValueType: pb.Posting_STRING, List: true, }, }, state: state, } if opt.StoreXids { - s.m["xid"] = &intern.SchemaUpdate{ - ValueType: intern.Posting_STRING, + s.m["xid"] = &pb.SchemaUpdate{ + ValueType: pb.Posting_STRING, Tokenizer: []string{"hash"}, } } @@ -53,15 +53,15 @@ func newSchemaStore(initial []*intern.SchemaUpdate, opt options, state *state) * return s } -func (s *schemaStore) getSchema(pred string) *intern.SchemaUpdate { +func (s *schemaStore) getSchema(pred string) *pb.SchemaUpdate { s.RLock() defer s.RUnlock() return s.m[pred] } -func (s *schemaStore) validateType(de *intern.DirectedEdge, objectIsUID bool) { +func (s *schemaStore) validateType(de *pb.DirectedEdge, objectIsUID bool) { if objectIsUID { - de.ValueType = intern.Posting_UID + de.ValueType = pb.Posting_UID } s.RLock() @@ -71,7 +71,7 @@ func (s *schemaStore) validateType(de *intern.DirectedEdge, objectIsUID bool) { s.Lock() sch, ok = s.m[de.Attr] if !ok { - sch = &intern.SchemaUpdate{ValueType: de.ValueType} + sch = &pb.SchemaUpdate{ValueType: de.ValueType} s.m[de.Attr] = sch } s.Unlock() diff --git a/dgraph/cmd/bulk/shuffle.go b/dgraph/cmd/bulk/shuffle.go index 1193ef0ecf4..3363505894e 100644 --- a/dgraph/cmd/bulk/shuffle.go +++ b/dgraph/cmd/bulk/shuffle.go @@ -18,7 +18,7 @@ import ( "github.com/dgraph-io/badger" bo "github.com/dgraph-io/badger/options" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/gogo/protobuf/proto" ) @@ -38,9 +38,9 @@ func (s *shuffler) run() { thr.Start() go func(shardId int, db *badger.DB) { mapFiles := filenamesInTree(shardDirs[shardId]) - shuffleInputChs := make([]chan *intern.MapEntry, len(mapFiles)) + shuffleInputChs := make([]chan *pb.MapEntry, len(mapFiles)) for i, mapFile := range mapFiles { - shuffleInputChs[i] = make(chan *intern.MapEntry, 1000) + shuffleInputChs[i] = make(chan *pb.MapEntry, 1000) go readMapOutput(mapFile, shuffleInputChs[i]) } @@ -66,7 +66,7 @@ func (s *shuffler) createBadger(i int) *badger.DB { return db } -func readMapOutput(filename string, mapEntryCh chan<- *intern.MapEntry) { +func readMapOutput(filename string, mapEntryCh chan<- *pb.MapEntry) { fd, err := os.Open(filename) x.Check(err) defer fd.Close() @@ -90,14 +90,14 @@ func readMapOutput(filename string, mapEntryCh chan<- *intern.MapEntry) { } x.Check2(io.ReadFull(r, unmarshalBuf[:sz])) - me := new(intern.MapEntry) + me := new(pb.MapEntry) x.Check(proto.Unmarshal(unmarshalBuf[:sz], me)) mapEntryCh <- me } close(mapEntryCh) } -func (s *shuffler) shufflePostings(mapEntryChs []chan *intern.MapEntry, ci *countIndexer) { +func (s *shuffler) shufflePostings(mapEntryChs []chan *pb.MapEntry, ci *countIndexer) { var ph postingHeap for _, ch := range mapEntryChs { heap.Push(&ph, heapNode{mapEntry: <-ch, ch: ch}) @@ -105,7 +105,7 @@ func (s *shuffler) shufflePostings(mapEntryChs []chan *intern.MapEntry, ci *coun const batchSize = 1000 const batchAlloc = batchSize * 11 / 10 - batch := make([]*intern.MapEntry, 0, batchAlloc) + batch := make([]*pb.MapEntry, 0, batchAlloc) var prevKey []byte var plistLen int for len(ph.nodes) > 0 { @@ -127,7 +127,7 @@ func (s *shuffler) shufflePostings(mapEntryChs []chan *intern.MapEntry, ci *coun if len(batch) >= batchSize && bytes.Compare(prevKey, me.Key) != 0 { s.output <- shuffleOutput{mapEntries: batch, db: ci.db} NumQueuedReduceJobs.Add(1) - batch = make([]*intern.MapEntry, 0, batchAlloc) + batch = make([]*pb.MapEntry, 0, batchAlloc) } prevKey = me.Key batch = append(batch, me) @@ -143,8 +143,8 @@ func (s *shuffler) shufflePostings(mapEntryChs []chan *intern.MapEntry, ci *coun } type heapNode struct { - mapEntry *intern.MapEntry - ch <-chan *intern.MapEntry + mapEntry *pb.MapEntry + ch <-chan *pb.MapEntry } type postingHeap struct { diff --git a/dgraph/cmd/live/batch.go b/dgraph/cmd/live/batch.go index 9954760e86a..d6202ad2bdc 100644 --- a/dgraph/cmd/live/batch.go +++ b/dgraph/cmd/live/batch.go @@ -24,7 +24,7 @@ import ( "github.com/dgraph-io/dgo" "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgo/y" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/dgraph/xidmap" ) @@ -53,7 +53,7 @@ var defaultOptions = batchMutationOptions{ } type uidProvider struct { - zero intern.ZeroClient + zero pb.ZeroClient ctx context.Context } @@ -87,7 +87,7 @@ type loader struct { func (p *uidProvider) ReserveUidRange() (start, end uint64, err error) { factor := time.Second for { - assignedIds, err := p.zero.AssignUids(context.Background(), &intern.Num{Val: 1000}) + assignedIds, err := p.zero.AssignUids(context.Background(), &pb.Num{Val: 1000}) if err == nil { return assignedIds.StartId, assignedIds.EndId, nil } diff --git a/dgraph/cmd/live/run.go b/dgraph/cmd/live/run.go index ee1795fd559..5c28341e8a2 100644 --- a/dgraph/cmd/live/run.go +++ b/dgraph/cmd/live/run.go @@ -95,7 +95,7 @@ func readLine(r *bufio.Reader, buf *bytes.Buffer) error { var err error for isPrefix && err == nil { var line []byte - // The returned line is an intern.buffer in bufio and is only + // The returned line is an pb.buffer in bufio and is only // valid until the next call to ReadLine. It needs to be copied // over to our own buffer. line, isPrefix, err = r.ReadLine() diff --git a/dgraph/cmd/server/run.go b/dgraph/cmd/server/run.go index 9e6e54744b7..1563f003e41 100644 --- a/dgraph/cmd/server/run.go +++ b/dgraph/cmd/server/run.go @@ -218,7 +218,7 @@ func serveHTTP(l net.Listener, wg *sync.WaitGroup) { } func setupServer() { - go worker.RunServer(bindall) // For intern.communication. + go worker.RunServer(bindall) // For pb.communication. laddr := "localhost" if bindall { diff --git a/dgraph/cmd/server/run_test.go b/dgraph/cmd/server/run_test.go index 725a4fcf9c6..88ca6bcb910 100644 --- a/dgraph/cmd/server/run_test.go +++ b/dgraph/cmd/server/run_test.go @@ -26,7 +26,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/query" "github.com/dgraph-io/dgraph/schema" ) @@ -59,7 +59,7 @@ func (c *raftServer) RaftMessage(ctx context.Context, in *api.Payload) (*api.Pay return &api.Payload{}, nil } -func (c *raftServer) JoinCluster(ctx context.Context, in *intern.RaftContext) (*api.Payload, error) { +func (c *raftServer) JoinCluster(ctx context.Context, in *pb.RaftContext) (*api.Payload, error) { return &api.Payload{}, nil } @@ -1430,8 +1430,8 @@ func TestMain(m *testing.M) { if err != nil { log.Fatal(err) } - zc := intern.NewZeroClient(conn) - if _, err := zc.AssignUids(context.Background(), &intern.Num{Val: 1e6}); err != nil { + zc := pb.NewZeroClient(conn) + if _, err := zc.AssignUids(context.Background(), &pb.Num{Val: 1e6}); err != nil { log.Fatal(err) } diff --git a/dgraph/cmd/zero/assign.go b/dgraph/cmd/zero/assign.go index 881c48597e4..a27b4b506ed 100644 --- a/dgraph/cmd/zero/assign.go +++ b/dgraph/cmd/zero/assign.go @@ -12,14 +12,14 @@ import ( "golang.org/x/net/context" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" ) var ( - emptyNum intern.Num - emptyAssignedIds intern.AssignedIds + emptyNum pb.Num + emptyAssignedIds pb.AssignedIds ) const ( @@ -54,7 +54,7 @@ var servedFromMemory = errors.New("Lease was served from memory.") // This function is triggered by an RPC call. We ensure that only leader can assign new UIDs, // so we can tackle any collisions that might happen with the leasemanager // In essence, we just want one server to be handing out new uids. -func (s *Server) lease(ctx context.Context, num *intern.Num, txn bool) (*intern.AssignedIds, error) { +func (s *Server) lease(ctx context.Context, num *pb.Num, txn bool) (*pb.AssignedIds, error) { node := s.Node // TODO: Fix when we move to linearizable reads, need to check if we are the leader, might be // based on leader leases. If this node gets partitioned and unless checkquorum is enabled, this @@ -82,7 +82,7 @@ func (s *Server) lease(ctx context.Context, num *intern.Num, txn bool) (*intern. s.readOnlyTs, s.nextTxnTs) } if s.readOnlyTs > 0 && s.readOnlyTs == s.nextTxnTs-1 { - return &intern.AssignedIds{ReadOnly: s.readOnlyTs}, servedFromMemory + return &pb.AssignedIds{ReadOnly: s.readOnlyTs}, servedFromMemory } } // We couldn't service it. So, let's request an extra timestamp for @@ -103,7 +103,7 @@ func (s *Server) lease(ctx context.Context, num *intern.Num, txn bool) (*intern. } var maxLease, available uint64 - var proposal intern.ZeroProposal + var proposal pb.ZeroProposal // Calculate how many ids do we have available in memory, before we need to // renew our lease. @@ -125,7 +125,7 @@ func (s *Server) lease(ctx context.Context, num *intern.Num, txn bool) (*intern. } } - out := &intern.AssignedIds{} + out := &pb.AssignedIds{} if txn { if num.Val > 0 { out.StartId = s.nextTxnTs @@ -148,7 +148,7 @@ func (s *Server) lease(ctx context.Context, num *intern.Num, txn bool) (*intern. // AssignUids is used to assign new uids by communicating with the leader of the RAFT group // responsible for handing out uids. -func (s *Server) AssignUids(ctx context.Context, num *intern.Num) (*intern.AssignedIds, error) { +func (s *Server) AssignUids(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error) { if ctx.Err() != nil { return &emptyAssignedIds, ctx.Err() } @@ -166,7 +166,7 @@ func (s *Server) AssignUids(ctx context.Context, num *intern.Num) (*intern.Assig if pl == nil { err = x.Errorf("No healthy connection found to Leader of group zero") } else { - zc := intern.NewZeroClient(pl.Get()) + zc := pb.NewZeroClient(pl.Get()) reply, err = zc.AssignUids(ctx, num) } c <- err diff --git a/dgraph/cmd/zero/http.go b/dgraph/cmd/zero/http.go index 19ddaa19071..55dab4b9ea0 100644 --- a/dgraph/cmd/zero/http.go +++ b/dgraph/cmd/zero/http.go @@ -17,7 +17,7 @@ import ( "sync" "time" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/gogo/protobuf/jsonpb" ) @@ -56,7 +56,7 @@ func (st *state) assignUids(w http.ResponseWriter, r *http.Request) { if !ok { return } - num := &intern.Num{Val: uint64(val)} + num := &pb.Num{Val: uint64(val)} ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() ids, err := st.zero.AssignUids(ctx, num) diff --git a/dgraph/cmd/zero/oracle.go b/dgraph/cmd/zero/oracle.go index bc7ce2bd681..59f0583966f 100644 --- a/dgraph/cmd/zero/oracle.go +++ b/dgraph/cmd/zero/oracle.go @@ -14,7 +14,7 @@ import ( "time" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "golang.org/x/net/context" @@ -36,8 +36,8 @@ type Oracle struct { tmax uint64 // All transactions with startTs < startTxnTs return true for hasConflict. startTxnTs uint64 - subscribers map[int]chan *intern.OracleDelta - updates chan *intern.OracleDelta + subscribers map[int]chan *pb.OracleDelta + updates chan *pb.OracleDelta doneUntil x.WaterMark syncMarks []syncMark } @@ -45,8 +45,8 @@ type Oracle struct { func (o *Oracle) Init() { o.commits = make(map[uint64]uint64) o.keyCommit = make(map[string]uint64) - o.subscribers = make(map[int]chan *intern.OracleDelta) - o.updates = make(chan *intern.OracleDelta, 100000) // Keeping 1 second worth of updates. + o.subscribers = make(map[int]chan *pb.OracleDelta) + o.updates = make(chan *pb.OracleDelta, 100000) // Keeping 1 second worth of updates. o.doneUntil.Init() go o.sendDeltasToSubscribers() } @@ -107,24 +107,24 @@ func (o *Oracle) commit(src *api.TxnContext) error { return nil } -func sortTxns(delta *intern.OracleDelta) { +func sortTxns(delta *pb.OracleDelta) { sort.Slice(delta.Txns, func(i, j int) bool { return delta.Txns[i].CommitTs < delta.Txns[j].CommitTs }) } -func (o *Oracle) currentState() *intern.OracleDelta { +func (o *Oracle) currentState() *pb.OracleDelta { o.AssertRLock() - resp := &intern.OracleDelta{} + resp := &pb.OracleDelta{} for start, commit := range o.commits { resp.Txns = append(resp.Txns, - &intern.TxnStatus{StartTs: start, CommitTs: commit}) + &pb.TxnStatus{StartTs: start, CommitTs: commit}) } resp.MaxAssigned = o.maxAssigned return resp } -func (o *Oracle) newSubscriber() (<-chan *intern.OracleDelta, int) { +func (o *Oracle) newSubscriber() (<-chan *pb.OracleDelta, int) { o.Lock() defer o.Unlock() var id int @@ -134,7 +134,7 @@ func (o *Oracle) newSubscriber() (<-chan *intern.OracleDelta, int) { break } } - ch := make(chan *intern.OracleDelta, 1000) + ch := make(chan *pb.OracleDelta, 1000) ch <- o.currentState() // Queue up the full state as the first entry. o.subscribers[id] = ch return ch, id @@ -147,7 +147,7 @@ func (o *Oracle) removeSubscriber(id int) { } func (o *Oracle) sendDeltasToSubscribers() { - delta := &intern.OracleDelta{} + delta := &pb.OracleDelta{} for { update, open := <-o.updates if !open { @@ -177,7 +177,7 @@ func (o *Oracle) sendDeltasToSubscribers() { } } o.Unlock() - delta = &intern.OracleDelta{} + delta = &pb.OracleDelta{} } } @@ -199,8 +199,8 @@ func (o *Oracle) updateCommitStatusHelper(index uint64, src *api.TxnContext) boo func (o *Oracle) updateCommitStatus(index uint64, src *api.TxnContext) { // TODO: We should check if the tablet is in read-only status here. if o.updateCommitStatusHelper(index, src) { - delta := new(intern.OracleDelta) - delta.Txns = append(delta.Txns, &intern.TxnStatus{ + delta := new(pb.OracleDelta) + delta.Txns = append(delta.Txns, &pb.TxnStatus{ StartTs: src.StartTs, CommitTs: o.commitTs(src.StartTs), }) @@ -214,12 +214,12 @@ func (o *Oracle) commitTs(startTs uint64) uint64 { return o.commits[startTs] } -func (o *Oracle) storePending(ids *intern.AssignedIds) { +func (o *Oracle) storePending(ids *pb.AssignedIds) { // Wait to finish up processing everything before start id. max := x.Max(ids.EndId, ids.ReadOnly) o.doneUntil.WaitForMark(context.Background(), max) // Now send it out to updates. - o.updates <- &intern.OracleDelta{MaxAssigned: max} + o.updates <- &pb.OracleDelta{MaxAssigned: max} o.Lock() defer o.Unlock() @@ -237,7 +237,7 @@ var errConflict = errors.New("Transaction conflict") // proposeTxn proposes a txn update, and then updates src to reflect the state // of the commit after proposal is run. func (s *Server) proposeTxn(ctx context.Context, src *api.TxnContext) error { - var zp intern.ZeroProposal + var zp pb.ZeroProposal zp.Txn = &api.TxnContext{ StartTs: src.StartTs, CommitTs: src.CommitTs, @@ -303,7 +303,7 @@ func (s *Server) commit(ctx context.Context, src *api.TxnContext) error { } } - num := intern.Num{Val: 1} + num := pb.Num{Val: 1} assigned, err := s.lease(ctx, &num, true) if err != nil { return err @@ -333,7 +333,7 @@ func (s *Server) CommitOrAbort(ctx context.Context, src *api.TxnContext) (*api.T var errClosed = errors.New("Streaming closed by Oracle.") var errNotLeader = errors.New("Node is no longer leader.") -func (s *Server) Oracle(unused *api.Payload, server intern.Zero_OracleServer) error { +func (s *Server) Oracle(unused *api.Payload, server pb.Zero_OracleServer) error { if !s.Node.AmLeader() { return errNotLeader } @@ -397,7 +397,7 @@ OUTER: x.Printf("No healthy connection found to leader of group %d\n", group) goto OUTER } - c := intern.NewWorkerClient(pl.Get()) + c := pb.NewWorkerClient(pl.Get()) num, err := c.PurgeTs(context.Background(), &api.Payload{}) if err != nil { x.Printf("Error while fetching minTs from group %d, err: %v\n", group, err) @@ -416,8 +416,8 @@ OUTER: } func (s *Server) TryAbort(ctx context.Context, - txns *intern.TxnTimestamps) (*intern.OracleDelta, error) { - delta := &intern.OracleDelta{} + txns *pb.TxnTimestamps) (*pb.OracleDelta, error) { + delta := &pb.OracleDelta{} for _, startTs := range txns.Ts { // Do via proposals to avoid race tctx := &api.TxnContext{StartTs: startTs, Aborted: true} @@ -425,7 +425,7 @@ func (s *Server) TryAbort(ctx context.Context, return delta, err } // Txn should be aborted if not already committed. - delta.Txns = append(delta.Txns, &intern.TxnStatus{ + delta.Txns = append(delta.Txns, &pb.TxnStatus{ StartTs: startTs, CommitTs: s.orc.commitTs(startTs)}) } @@ -433,7 +433,7 @@ func (s *Server) TryAbort(ctx context.Context, } // Timestamps is used to assign startTs for a new transaction -func (s *Server) Timestamps(ctx context.Context, num *intern.Num) (*intern.AssignedIds, error) { +func (s *Server) Timestamps(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error) { if ctx.Err() != nil { return &emptyAssignedIds, ctx.Err() } diff --git a/dgraph/cmd/zero/raft.go b/dgraph/cmd/zero/raft.go index 99cfe17083d..570aeec5a5d 100644 --- a/dgraph/cmd/zero/raft.go +++ b/dgraph/cmd/zero/raft.go @@ -20,7 +20,7 @@ import ( "github.com/coreos/etcd/raft/raftpb" "github.com/dgraph-io/badger/y" "github.com/dgraph-io/dgraph/conn" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" "github.com/google/uuid" @@ -88,7 +88,7 @@ func (n *node) uniqueKey() string { var errInternalRetry = errors.New("Retry Raft proposal internally") -func (n *node) proposeAndWait(ctx context.Context, proposal *intern.ZeroProposal) error { +func (n *node) proposeAndWait(ctx context.Context, proposal *pb.ZeroProposal) error { if n.Raft() == nil { return x.Errorf("Raft isn't initialized yet.") } @@ -155,15 +155,15 @@ var ( errTabletAlreadyServed = errors.New("Tablet is already being served") ) -func newGroup() *intern.Group { - return &intern.Group{ - Members: make(map[uint64]*intern.Member), - Tablets: make(map[string]*intern.Tablet), +func newGroup() *pb.Group { + return &pb.Group{ + Members: make(map[uint64]*pb.Member), + Tablets: make(map[string]*pb.Tablet), } } func (n *node) applyProposal(e raftpb.Entry) (string, error) { - var p intern.ZeroProposal + var p pb.ZeroProposal // Raft commits empty entry on becoming a leader. if len(e.Data) == 0 { return p.Key, nil @@ -317,11 +317,11 @@ func (n *node) applyConfChange(e raftpb.Entry) { n.server.removeZero(cc.NodeID) } else if len(cc.Context) > 0 { - var rc intern.RaftContext + var rc pb.RaftContext x.Check(rc.Unmarshal(cc.Context)) go n.Connect(rc.Id, rc.Addr) - m := &intern.Member{Id: rc.Id, Addr: rc.Addr, GroupId: 0} + m := &pb.Member{Id: rc.Id, Addr: rc.Addr, GroupId: 0} for _, member := range n.server.membershipState().Removed { // It is not recommended to reuse RAFT ids. if member.GroupId == 0 && m.Id == member.Id { @@ -366,7 +366,7 @@ func (n *node) initAndStartNode() error { // It is important that we pick up the conf state here. n.SetConfState(&sp.Metadata.ConfState) - var state intern.MembershipState + var state pb.MembershipState x.Check(state.Unmarshal(sp.Data)) n.server.SetMembershipState(&state) for _, id := range sp.Metadata.ConfState.Nodes { @@ -383,7 +383,7 @@ func (n *node) initAndStartNode() error { } gconn := p.Get() - c := intern.NewRaftClient(gconn) + c := pb.NewRaftClient(gconn) err := errJoinCluster timeout := 8 * time.Second for i := 0; err != nil; i++ { @@ -423,7 +423,7 @@ func (n *node) initAndStartNode() error { // This is a new cluster. So, propose a new ID for the cluster. for { id := uuid.New().String() - err := n.proposeAndWait(context.Background(), &intern.ZeroProposal{Cid: id}) + err := n.proposeAndWait(context.Background(), &pb.ZeroProposal{Cid: id}) if err == nil { glog.Infof("CID set for cluster: %v", id) return @@ -526,7 +526,7 @@ func (n *node) Run() { n.SaveToStorage(rd.HardState, rd.Entries, rd.Snapshot) if !raft.IsEmptySnap(rd.Snapshot) { - var state intern.MembershipState + var state pb.MembershipState x.Check(state.Unmarshal(rd.Snapshot.Data)) n.server.SetMembershipState(&state) } diff --git a/dgraph/cmd/zero/run.go b/dgraph/cmd/zero/run.go index 74e3169f45c..74bc47a0d34 100644 --- a/dgraph/cmd/zero/run.go +++ b/dgraph/cmd/zero/run.go @@ -24,7 +24,7 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/dgraph/conn" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" "github.com/spf13/cobra" @@ -93,7 +93,7 @@ func (st *state) serveGRPC(l net.Listener, wg *sync.WaitGroup, store *raftwal.Di grpc.MaxSendMsgSize(x.GrpcMaxSize), grpc.MaxConcurrentStreams(1000)) - rc := intern.RaftContext{Id: opts.nodeId, Addr: opts.myAddr, Group: 0} + rc := pb.RaftContext{Id: opts.nodeId, Addr: opts.myAddr, Group: 0} m := conn.NewNode(&rc, store) st.rs = &conn.RaftServer{Node: m} @@ -102,8 +102,8 @@ func (st *state) serveGRPC(l net.Listener, wg *sync.WaitGroup, store *raftwal.Di st.zero.Init() st.node.server = st.zero - intern.RegisterZeroServer(s, st.zero) - intern.RegisterRaftServer(s, st.rs) + pb.RegisterZeroServer(s, st.zero) + pb.RegisterRaftServer(s, st.rs) go func() { defer wg.Done() diff --git a/dgraph/cmd/zero/tablet.go b/dgraph/cmd/zero/tablet.go index 642a650405d..ee197f1af7b 100644 --- a/dgraph/cmd/zero/tablet.go +++ b/dgraph/cmd/zero/tablet.go @@ -12,7 +12,7 @@ import ( "sort" "time" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" humanize "github.com/dustin/go-humanize" "golang.org/x/net/context" @@ -116,12 +116,12 @@ func (s *Server) runRecovery() { if s.state == nil { return } - var proposals []*intern.ZeroProposal + var proposals []*pb.ZeroProposal for _, group := range s.state.Groups { for _, tab := range group.Tablets { if tab.ReadOnly { - p := &intern.ZeroProposal{} - p.Tablet = &intern.Tablet{ + p := &pb.ZeroProposal{} + p.Tablet = &pb.Tablet{ GroupId: tab.GroupId, Predicate: tab.Predicate, Space: tab.Space, @@ -134,7 +134,7 @@ func (s *Server) runRecovery() { errCh := make(chan error) for _, pr := range proposals { - go func(pr *intern.ZeroProposal) { + go func(pr *pb.ZeroProposal) { errCh <- s.Node.proposeAndWait(context.Background(), pr) }(pr) } @@ -226,8 +226,8 @@ func (s *Server) moveTablet(ctx context.Context, predicate string, srcGroup uint stab := s.ServingTablet(predicate) x.AssertTrue(stab != nil) - p := &intern.ZeroProposal{} - p.Tablet = &intern.Tablet{ + p := &pb.ZeroProposal{} + p.Tablet = &pb.Tablet{ GroupId: srcGroup, Predicate: predicate, Space: stab.Space, @@ -246,8 +246,8 @@ func (s *Server) movePredicateHelper(ctx context.Context, predicate string, srcG stab := s.ServingTablet(predicate) x.AssertTrue(stab != nil) // Propose that predicate in read only - p := &intern.ZeroProposal{} - p.Tablet = &intern.Tablet{ + p := &pb.ZeroProposal{} + p.Tablet = &pb.Tablet{ GroupId: srcGroup, Predicate: predicate, Space: stab.Space, @@ -262,8 +262,8 @@ func (s *Server) movePredicateHelper(ctx context.Context, predicate string, srcG return x.Errorf("No healthy connection found to leader of group %d", srcGroup) } - c := intern.NewWorkerClient(pl.Get()) - in := &intern.MovePredicatePayload{ + c := pb.NewWorkerClient(pl.Get()) + in := &pb.MovePredicatePayload{ Predicate: predicate, State: s.membershipState(), SourceGroupId: srcGroup, @@ -274,7 +274,7 @@ func (s *Server) movePredicateHelper(ctx context.Context, predicate string, srcG } // Propose that predicate is served by dstGroup in RW. - p.Tablet = &intern.Tablet{ + p.Tablet = &pb.Tablet{ GroupId: dstGroup, Predicate: predicate, Space: stab.Space, diff --git a/dgraph/cmd/zero/telemetry.go b/dgraph/cmd/zero/telemetry.go index 01b150dc28e..57c8f6cae01 100644 --- a/dgraph/cmd/zero/telemetry.go +++ b/dgraph/cmd/zero/telemetry.go @@ -14,7 +14,7 @@ import ( "net/http" "runtime" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/golang/glog" ) @@ -35,7 +35,7 @@ type Telemetry struct { var keenUrl = "https://api.keen.io/3.0/projects/5b809dfac9e77c0001783ad0/events" -func newTelemetry(ms *intern.MembershipState) *Telemetry { +func newTelemetry(ms *pb.MembershipState) *Telemetry { if len(ms.Cid) == 0 { glog.V(2).Infoln("No CID found yet") return nil diff --git a/dgraph/cmd/zero/zero.go b/dgraph/cmd/zero/zero.go index a6cf1f2025b..322b50e6300 100644 --- a/dgraph/cmd/zero/zero.go +++ b/dgraph/cmd/zero/zero.go @@ -16,15 +16,15 @@ import ( "golang.org/x/net/context" "github.com/dgraph-io/dgraph/conn" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/gogo/protobuf/proto" "github.com/golang/glog" ) var ( - emptyMembershipState intern.MembershipState - emptyConnectionState intern.ConnectionState + emptyMembershipState pb.MembershipState + emptyConnectionState pb.ConnectionState errInvalidId = errors.New("Invalid server id") errInvalidAddress = errors.New("Invalid address") errEmptyPredicate = errors.New("Empty predicate") @@ -43,7 +43,7 @@ type Server struct { orc *Oracle NumReplicas int - state *intern.MembershipState + state *pb.MembershipState nextLeaseId uint64 nextTxnTs uint64 @@ -63,9 +63,9 @@ func (s *Server) Init() { s.orc = &Oracle{} s.orc.Init() - s.state = &intern.MembershipState{ - Groups: make(map[uint32]*intern.Group), - Zeros: make(map[uint64]*intern.Member), + s.state = &pb.MembershipState{ + Groups: make(map[uint32]*pb.Group), + Zeros: make(map[uint64]*pb.Member), } s.nextLeaseId = 1 s.nextTxnTs = 1 @@ -120,7 +120,7 @@ func (s *Server) leaderChangeChannel() chan struct{} { return s.leaderChangeCh } -func (s *Server) member(addr string) *intern.Member { +func (s *Server) member(addr string) *pb.Member { s.AssertRLock() for _, m := range s.state.Zeros { if m.Addr == addr { @@ -143,7 +143,7 @@ func (s *Server) Leader(gid uint32) *conn.Pool { if s.state == nil { return nil } - var members map[uint64]*intern.Member + var members map[uint64]*pb.Member if gid == 0 { members = s.state.Zeros } else { @@ -192,15 +192,15 @@ func (s *Server) hasLeader(gid uint32) bool { return false } -func (s *Server) SetMembershipState(state *intern.MembershipState) { +func (s *Server) SetMembershipState(state *pb.MembershipState) { s.Lock() defer s.Unlock() s.state = state if state.Zeros == nil { - state.Zeros = make(map[uint64]*intern.Member) + state.Zeros = make(map[uint64]*pb.Member) } if state.Groups == nil { - state.Groups = make(map[uint32]*intern.Group) + state.Groups = make(map[uint32]*pb.Group) } // Create connections to all members. for _, g := range state.Groups { @@ -208,7 +208,7 @@ func (s *Server) SetMembershipState(state *intern.MembershipState) { conn.Get().Connect(m.Addr) } if g.Tablets == nil { - g.Tablets = make(map[string]*intern.Tablet) + g.Tablets = make(map[string]*pb.Tablet) } } s.nextGroup = uint32(len(state.Groups) + 1) @@ -220,13 +220,13 @@ func (s *Server) MarshalMembershipState() ([]byte, error) { return s.state.Marshal() } -func (s *Server) membershipState() *intern.MembershipState { +func (s *Server) membershipState() *pb.MembershipState { s.RLock() defer s.RUnlock() - return proto.Clone(s.state).(*intern.MembershipState) + return proto.Clone(s.state).(*pb.MembershipState) } -func (s *Server) storeZero(m *intern.Member) { +func (s *Server) storeZero(m *pb.Member) { s.Lock() defer s.Unlock() @@ -259,7 +259,7 @@ func (s *Server) removeZero(nodeId uint64) { } // ServingTablet returns the Tablet called tablet. -func (s *Server) ServingTablet(tablet string) *intern.Tablet { +func (s *Server) ServingTablet(tablet string) *pb.Tablet { s.RLock() defer s.RUnlock() @@ -273,7 +273,7 @@ func (s *Server) ServingTablet(tablet string) *intern.Tablet { return nil } -func (s *Server) servingTablet(tablet string) *intern.Tablet { +func (s *Server) servingTablet(tablet string) *pb.Tablet { s.AssertRLock() for _, group := range s.state.Groups { @@ -286,8 +286,8 @@ func (s *Server) servingTablet(tablet string) *intern.Tablet { return nil } -func (s *Server) createProposals(dst *intern.Group) ([]*intern.ZeroProposal, error) { - var res []*intern.ZeroProposal +func (s *Server) createProposals(dst *pb.Group) ([]*pb.ZeroProposal, error) { + var res []*pb.ZeroProposal if len(dst.Members) > 1 { return res, errInvalidQuery } @@ -307,7 +307,7 @@ func (s *Server) createProposals(dst *intern.Group) ([]*intern.ZeroProposal, err if srcMember.Addr != dstMember.Addr || srcMember.Leader != dstMember.Leader { - proposal := &intern.ZeroProposal{ + proposal := &pb.ZeroProposal{ Member: dstMember, } res = append(res, proposal) @@ -332,7 +332,7 @@ func (s *Server) createProposals(dst *intern.Group) ([]*intern.ZeroProposal, err d := float64(dstTablet.Space) if dstTablet.Remove || (s == 0 && d > 0) || (s > 0 && math.Abs(d/s-1) > 0.1) { dstTablet.Force = false - proposal := &intern.ZeroProposal{ + proposal := &pb.ZeroProposal{ Tablet: dstTablet, } res = append(res, proposal) @@ -346,8 +346,8 @@ func (s *Server) removeNode(ctx context.Context, nodeId uint64, groupId uint32) if groupId == 0 { return s.Node.ProposePeerRemoval(ctx, nodeId) } - zp := &intern.ZeroProposal{} - zp.Member = &intern.Member{Id: nodeId, GroupId: groupId, AmDead: true} + zp := &pb.ZeroProposal{} + zp.Member = &pb.Member{Id: nodeId, GroupId: groupId, AmDead: true} if _, ok := s.state.Groups[groupId]; !ok { return x.Errorf("No group with groupId %d found", groupId) } @@ -359,7 +359,7 @@ func (s *Server) removeNode(ctx context.Context, nodeId uint64, groupId uint32) // Connect is used to connect the very first time with group zero. func (s *Server) Connect(ctx context.Context, - m *intern.Member) (resp *intern.ConnectionState, err error) { + m *pb.Member) (resp *pb.ConnectionState, err error) { // Ensures that connect requests are always serialized s.connectLock.Lock() defer s.connectLock.Unlock() @@ -374,7 +374,7 @@ func (s *Server) Connect(ctx context.Context, // This request only wants to access the membership state, and nothing else. Most likely // from our clients. ms, err := s.latestMembershipState(ctx) - cs := &intern.ConnectionState{ + cs := &pb.ConnectionState{ State: ms, MaxPending: s.orc.MaxPending(), } @@ -408,11 +408,11 @@ func (s *Server) Connect(ctx context.Context, // Create a connection and check validity of the address by doing an Echo. conn.Get().Connect(m.Addr) - createProposal := func() *intern.ZeroProposal { + createProposal := func() *pb.ZeroProposal { s.Lock() defer s.Unlock() - proposal := new(intern.ZeroProposal) + proposal := new(pb.ZeroProposal) // Check if we already have this member. for _, group := range s.state.Groups { if _, has := group.Members[m.Id]; has { @@ -468,7 +468,7 @@ func (s *Server) Connect(ctx context.Context, return &emptyConnectionState, err } } - resp = &intern.ConnectionState{ + resp = &pb.ConnectionState{ State: s.membershipState(), Member: m, } @@ -476,7 +476,7 @@ func (s *Server) Connect(ctx context.Context, } func (s *Server) ShouldServe( - ctx context.Context, tablet *intern.Tablet) (resp *intern.Tablet, err error) { + ctx context.Context, tablet *pb.Tablet) (resp *pb.Tablet, err error) { if len(tablet.Predicate) == 0 { return resp, errEmptyPredicate } @@ -494,7 +494,7 @@ func (s *Server) ShouldServe( } // Set the tablet to be served by this server's group. - var proposal intern.ZeroProposal + var proposal pb.ZeroProposal // Multiple Groups might be assigned to same tablet, so during proposal we will check again. tablet.Force = false proposal.Tablet = tablet @@ -506,7 +506,7 @@ func (s *Server) ShouldServe( return tab, nil } -func (s *Server) receiveUpdates(stream intern.Zero_UpdateServer) error { +func (s *Server) receiveUpdates(stream pb.Zero_UpdateServer) error { for { group, err := stream.Recv() // Due to closeSend on client Side @@ -528,7 +528,7 @@ func (s *Server) receiveUpdates(stream intern.Zero_UpdateServer) error { errCh := make(chan error) for _, pr := range proposals { - go func(pr *intern.ZeroProposal) { + go func(pr *pb.ZeroProposal) { errCh <- s.Node.proposeAndWait(context.Background(), pr) }(pr) } @@ -543,7 +543,7 @@ func (s *Server) receiveUpdates(stream intern.Zero_UpdateServer) error { } } -func (s *Server) Update(stream intern.Zero_UpdateServer) error { +func (s *Server) Update(stream pb.Zero_UpdateServer) error { che := make(chan error, 1) // Server side cancellation can only be done by existing the handler // since Recv is blocking we need to run it in a goroutine. @@ -599,7 +599,7 @@ func (s *Server) Update(stream intern.Zero_UpdateServer) error { } } -func (s *Server) latestMembershipState(ctx context.Context) (*intern.MembershipState, error) { +func (s *Server) latestMembershipState(ctx context.Context) (*pb.MembershipState, error) { if err := s.Node.WaitLinearizableRead(ctx); err != nil { return nil, err } diff --git a/dgraph/cmd/zero/zero_test.go b/dgraph/cmd/zero/zero_test.go index 70818c3d760..965a2ab2148 100644 --- a/dgraph/cmd/zero/zero_test.go +++ b/dgraph/cmd/zero/zero_test.go @@ -11,14 +11,14 @@ import ( "context" "testing" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" ) func TestRemoveNode(t *testing.T) { server := &Server{ - state: &intern.MembershipState{ - Groups: map[uint32]*intern.Group{1: {Members: map[uint64]*intern.Member{}}}, + state: &pb.MembershipState{ + Groups: map[uint32]*pb.Group{1: {Members: map[uint64]*pb.Member{}}}, }, } ctx := context.Background() diff --git a/edgraph/server.go b/edgraph/server.go index fb32b1585d5..9e8e86e5fcb 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -29,7 +29,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgo/y" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/query" "github.com/dgraph-io/dgraph/rdf" "github.com/dgraph-io/dgraph/schema" @@ -197,7 +197,7 @@ func (s *ServerState) fillTimestampRequests() { } // Generate the request. - num := &intern.Num{} + num := &pb.Num{} for _, r := range reqs { if r.readOnly { num.ReadOnly = true @@ -273,7 +273,7 @@ func (s *Server) Alter(ctx context.Context, op *api.Operation) (*api.Payload, er // StartTs is not needed if the predicate to be dropped lies on this server but is required // if it lies on some other machine. Let's get it for safety. - m := &intern.Mutations{StartTs: State.getTimestamp(false)} + m := &pb.Mutations{StartTs: State.getTimestamp(false)} if op.DropAll { m.DropAll = true _, err := query.ApplyMutations(ctx, m) @@ -290,7 +290,7 @@ func (s *Server) Alter(ctx context.Context, op *api.Operation) (*api.Payload, er if err != nil { return empty, err } - edges := []*intern.DirectedEdge{edge} + edges := []*pb.DirectedEdge{edge} m.Edges = edges _, err = query.ApplyMutations(ctx, m) return empty, err @@ -360,7 +360,7 @@ func (s *Server) Mutate(ctx context.Context, mu *api.Mutation) (resp *api.Assign return resp, err } - m := &intern.Mutations{ + m := &pb.Mutations{ Edges: edges, StartTs: mu.StartTs, } diff --git a/gql/mutation.go b/gql/mutation.go index b279460c7ce..ee1600a67ed 100644 --- a/gql/mutation.go +++ b/gql/mutation.go @@ -13,7 +13,7 @@ import ( "strconv" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" ) @@ -106,13 +106,13 @@ func toUid(subject string, newToUid map[string]uint64) (uid uint64, err error) { return 0, x.Errorf("uid not found/generated for xid %s\n", subject) } -var emptyEdge intern.DirectedEdge +var emptyEdge pb.DirectedEdge -func (nq NQuad) createEdge(subjectUid uint64, newToUid map[string]uint64) (*intern.DirectedEdge, error) { +func (nq NQuad) createEdge(subjectUid uint64, newToUid map[string]uint64) (*pb.DirectedEdge, error) { var err error var objectUid uint64 - out := &intern.DirectedEdge{ + out := &pb.DirectedEdge{ Entity: subjectUid, Attr: nq.Predicate, Label: nq.Label, @@ -138,8 +138,8 @@ func (nq NQuad) createEdge(subjectUid uint64, newToUid map[string]uint64) (*inte return out, nil } -func (nq NQuad) createEdgePrototype(subjectUid uint64) *intern.DirectedEdge { - return &intern.DirectedEdge{ +func (nq NQuad) createEdgePrototype(subjectUid uint64) *pb.DirectedEdge { + return &pb.DirectedEdge{ Entity: subjectUid, Attr: nq.Predicate, Label: nq.Label, @@ -148,13 +148,13 @@ func (nq NQuad) createEdgePrototype(subjectUid uint64) *intern.DirectedEdge { } } -func (nq NQuad) CreateUidEdge(subjectUid uint64, objectUid uint64) *intern.DirectedEdge { +func (nq NQuad) CreateUidEdge(subjectUid uint64, objectUid uint64) *pb.DirectedEdge { out := nq.createEdgePrototype(subjectUid) out.ValueId = objectUid return out } -func (nq NQuad) CreateValueEdge(subjectUid uint64) (*intern.DirectedEdge, error) { +func (nq NQuad) CreateValueEdge(subjectUid uint64) (*pb.DirectedEdge, error) { var err error out := nq.createEdgePrototype(subjectUid) @@ -164,12 +164,12 @@ func (nq NQuad) CreateValueEdge(subjectUid uint64) (*intern.DirectedEdge, error) return out, nil } -func (nq NQuad) ToDeletePredEdge() (*intern.DirectedEdge, error) { +func (nq NQuad) ToDeletePredEdge() (*pb.DirectedEdge, error) { if nq.Subject != x.Star && nq.ObjectValue.String() != x.Star { return &emptyEdge, x.Errorf("Subject and object both should be *. Got: %+v", nq) } - out := &intern.DirectedEdge{ + out := &pb.DirectedEdge{ // This along with edge.ObjectValue == x.Star would indicate // that we want to delete the predicate. Entity: 0, @@ -177,7 +177,7 @@ func (nq NQuad) ToDeletePredEdge() (*intern.DirectedEdge, error) { Label: nq.Label, Lang: nq.Lang, Facets: nq.Facets, - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } if err := copyValue(out, nq); err != nil { @@ -188,8 +188,8 @@ func (nq NQuad) ToDeletePredEdge() (*intern.DirectedEdge, error) { // ToEdgeUsing determines the UIDs for the provided XIDs and populates the // xidToUid map. -func (nq NQuad) ToEdgeUsing(newToUid map[string]uint64) (*intern.DirectedEdge, error) { - var edge *intern.DirectedEdge +func (nq NQuad) ToEdgeUsing(newToUid map[string]uint64) (*pb.DirectedEdge, error) { + var edge *pb.DirectedEdge sUid, err := toUid(nq.Subject, newToUid) if err != nil { return nil, err @@ -220,7 +220,7 @@ func (nq NQuad) ToEdgeUsing(newToUid map[string]uint64) (*intern.DirectedEdge, e return edge, nil } -func copyValue(out *intern.DirectedEdge, nq NQuad) error { +func copyValue(out *pb.DirectedEdge, nq NQuad) error { var err error var t types.TypeID if out.Value, t, err = byteVal(nq); err != nil { diff --git a/gql/parser.go b/gql/parser.go index d8bacfb8f48..67d899beb0d 100644 --- a/gql/parser.go +++ b/gql/parser.go @@ -15,7 +15,7 @@ import ( "strings" "github.com/dgraph-io/dgraph/lex" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -25,7 +25,7 @@ const ( ) // GraphQuery stores the parsed Query in a tree format. This gets converted to -// intern.y used query.SubGraph before processing the query. +// pb.y used query.SubGraph before processing the query. type GraphQuery struct { UID []uint64 Attr string @@ -41,7 +41,7 @@ type GraphQuery struct { Args map[string]string // Query can have multiple sort parameters. - Order []*intern.Order + Order []*pb.Order Children []*GraphQuery Filter *FilterTree MathExp *MathTree @@ -50,7 +50,7 @@ type GraphQuery struct { RecurseArgs RecurseArgs Cascade bool IgnoreReflex bool - Facets *intern.FacetParams + Facets *pb.FacetParams FacetsFilter *FilterTree GroupbyAttrs []GroupByAttr FacetVar map[string]string @@ -449,7 +449,7 @@ type Vars struct { type Result struct { Query []*GraphQuery QueryVars []*Vars - Schema *intern.SchemaRequest + Schema *pb.SchemaRequest } // Parse initializes and runs the lexer. It also constructs the GraphQuery subgraph @@ -865,7 +865,7 @@ func parseListItemNames(it *lex.ItemIterator) ([]string, error) { } // parses till rightround is found -func parseSchemaPredicates(it *lex.ItemIterator, s *intern.SchemaRequest) error { +func parseSchemaPredicates(it *lex.ItemIterator, s *pb.SchemaRequest) error { // pred should be followed by colon it.Next() item := it.Item() @@ -901,7 +901,7 @@ func parseSchemaPredicates(it *lex.ItemIterator, s *intern.SchemaRequest) error } // parses till rightcurl is found -func parseSchemaFields(it *lex.ItemIterator, s *intern.SchemaRequest) error { +func parseSchemaFields(it *lex.ItemIterator, s *pb.SchemaRequest) error { for it.Next() { item := it.Item() switch item.Typ { @@ -916,8 +916,8 @@ func parseSchemaFields(it *lex.ItemIterator, s *intern.SchemaRequest) error { return x.Errorf("Invalid schema block.") } -func getSchema(it *lex.ItemIterator) (*intern.SchemaRequest, error) { - var s intern.SchemaRequest +func getSchema(it *lex.ItemIterator) (*pb.SchemaRequest, error) { + var s pb.SchemaRequest leftRoundSeen := false for it.Next() { item := it.Item() @@ -1582,7 +1582,7 @@ L: } type facetRes struct { - f *intern.FacetParams + f *pb.FacetParams ft *FilterTree vmap map[string]string facetOrder string @@ -1677,7 +1677,7 @@ func tryParseFacetList(it *lex.ItemIterator) (res facetRes, parseOk bool, err er // Skip past '(' if _, ok := tryParseItemType(it, itemLeftRound); !ok { it.Restore(savePos) - var facets intern.FacetParams + var facets pb.FacetParams facets.AllKeys = true res.f = &facets res.vmap = make(map[string]string) @@ -1685,7 +1685,7 @@ func tryParseFacetList(it *lex.ItemIterator) (res facetRes, parseOk bool, err er } facetVar := make(map[string]string) - var facets intern.FacetParams + var facets pb.FacetParams var orderdesc bool var orderkey string @@ -1713,7 +1713,7 @@ func tryParseFacetList(it *lex.ItemIterator) (res facetRes, parseOk bool, err er } facetVar[facetItem.name] = facetItem.varName } - facets.Param = append(facets.Param, &intern.FacetParam{ + facets.Param = append(facets.Param, &pb.FacetParam{ Key: facetItem.name, Alias: facetItem.alias, }) @@ -2002,7 +2002,7 @@ func parseDirective(it *lex.ItemIterator, curp *GraphQuery) error { valid = false } it.Next() - // No directive is allowed on intern.subgraph like expand all, value variables. + // No directive is allowed on pb.subgraph like expand all, value variables. if !valid || curp == nil || curp.IsInternal { return x.Errorf("Invalid use of directive.") } @@ -2292,7 +2292,7 @@ func getRoot(it *lex.ItemIterator) (gq *GraphQuery, rerr error) { return nil, x.Errorf("Sorting by an attribute: [%s] can only be done once", val) } attr, langs := attrAndLang(val) - gq.Order = append(gq.Order, &intern.Order{attr, key == "orderdesc", langs}) + gq.Order = append(gq.Order, &pb.Order{attr, key == "orderdesc", langs}) order[val] = true continue } @@ -2692,7 +2692,7 @@ func godeep(it *lex.ItemIterator, gq *GraphQuery) error { return x.Errorf("Sorting by an attribute: [%s] can only be done once", p.Val) } attr, langs := attrAndLang(p.Val) - curp.Order = append(curp.Order, &intern.Order{attr, p.Key == "orderdesc", langs}) + curp.Order = append(curp.Order, &pb.Order{attr, p.Key == "orderdesc", langs}) order[p.Val] = true continue } diff --git a/posting/index.go b/posting/index.go index 0c6131fc25a..b2ff3a8584f 100644 --- a/posting/index.go +++ b/posting/index.go @@ -19,7 +19,7 @@ import ( "github.com/dgraph-io/badger" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" @@ -80,8 +80,8 @@ func indexTokens(attr, lang string, src types.Val) ([]string, error) { // addIndexMutations adds mutation(s) for a single term, to maintain index. // t represents the original uid -> value edge. // TODO - See if we need to pass op as argument as t should already have Op. -func (txn *Txn) addIndexMutations(ctx context.Context, t *intern.DirectedEdge, p types.Val, - op intern.DirectedEdge_Op) error { +func (txn *Txn) addIndexMutations(ctx context.Context, t *pb.DirectedEdge, p types.Val, + op pb.DirectedEdge_Op) error { attr := t.Attr uid := t.Entity x.AssertTrue(uid != 0) @@ -93,7 +93,7 @@ func (txn *Txn) addIndexMutations(ctx context.Context, t *intern.DirectedEdge, p } // Create a value token -> uid edge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: uid, Attr: attr, Op: op, @@ -107,7 +107,7 @@ func (txn *Txn) addIndexMutations(ctx context.Context, t *intern.DirectedEdge, p return nil } -func (txn *Txn) addIndexMutation(ctx context.Context, edge *intern.DirectedEdge, +func (txn *Txn) addIndexMutation(ctx context.Context, edge *pb.DirectedEdge, token string) error { key := x.IndexKey(edge.Attr, token) @@ -146,7 +146,7 @@ type countParams struct { } func (txn *Txn) addReverseMutationHelper(ctx context.Context, plist *List, - hasCountIndex bool, edge *intern.DirectedEdge) (countParams, error) { + hasCountIndex bool, edge *pb.DirectedEdge) (countParams, error) { countBefore, countAfter := 0, 0 plist.Lock() defer plist.Unlock() @@ -175,7 +175,7 @@ func (txn *Txn) addReverseMutationHelper(ctx context.Context, plist *List, return emptyCountParams, nil } -func (txn *Txn) addReverseMutation(ctx context.Context, t *intern.DirectedEdge) error { +func (txn *Txn) addReverseMutation(ctx context.Context, t *pb.DirectedEdge) error { key := x.ReverseKey(t.Attr, t.ValueId) plist, err := Get(key) if err != nil { @@ -183,7 +183,7 @@ func (txn *Txn) addReverseMutation(ctx context.Context, t *intern.DirectedEdge) } x.AssertTrue(plist != nil) - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Entity: t.ValueId, ValueId: t.Entity, Attr: t.Attr, @@ -210,12 +210,12 @@ func (txn *Txn) addReverseMutation(ctx context.Context, t *intern.DirectedEdge) return nil } -func (l *List) handleDeleteAll(ctx context.Context, t *intern.DirectedEdge, +func (l *List) handleDeleteAll(ctx context.Context, t *pb.DirectedEdge, txn *Txn) error { isReversed := schema.State().IsReversed(t.Attr) isIndexed := schema.State().IsIndexed(t.Attr) hasCount := schema.State().HasCount(t.Attr) - delEdge := &intern.DirectedEdge{ + delEdge := &pb.DirectedEdge{ Attr: t.Attr, Op: t.Op, Entity: t.Entity, @@ -223,7 +223,7 @@ func (l *List) handleDeleteAll(ctx context.Context, t *intern.DirectedEdge, // To calculate length of posting list. Used for deletion of count index. var plen int var iterErr error - l.Iterate(txn.StartTs, 0, func(p *intern.Posting) bool { + l.Iterate(txn.StartTs, 0, func(p *pb.Posting) bool { plen++ if isReversed { // Delete reverse edge for each posting. @@ -239,7 +239,7 @@ func (l *List) handleDeleteAll(ctx context.Context, t *intern.DirectedEdge, Tid: types.TypeID(p.ValType), Value: p.Value, } - if err := txn.addIndexMutations(ctx, t, p, intern.DirectedEdge_DEL); err != nil { + if err := txn.addIndexMutations(ctx, t, p, pb.DirectedEdge_DEL); err != nil { iterErr = err return false } @@ -267,7 +267,7 @@ func (l *List) handleDeleteAll(ctx context.Context, t *intern.DirectedEdge, return l.addMutation(ctx, txn, t) } -func (txn *Txn) addCountMutation(ctx context.Context, t *intern.DirectedEdge, count uint32, +func (txn *Txn) addCountMutation(ctx context.Context, t *pb.DirectedEdge, count uint32, reverse bool) error { key := x.CountKey(t.Attr, count, reverse) plist, err := Get(key) @@ -290,10 +290,10 @@ func (txn *Txn) addCountMutation(ctx context.Context, t *intern.DirectedEdge, co } func (txn *Txn) updateCount(ctx context.Context, params countParams) error { - edge := intern.DirectedEdge{ + edge := pb.DirectedEdge{ ValueId: params.entity, Attr: params.attr, - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } if err := txn.addCountMutation(ctx, &edge, uint32(params.countBefore), params.reverse); err != nil { @@ -301,7 +301,7 @@ func (txn *Txn) updateCount(ctx context.Context, params countParams) error { } if params.countAfter > 0 { - edge.Op = intern.DirectedEdge_SET + edge.Op = pb.DirectedEdge_SET if err := txn.addCountMutation(ctx, &edge, uint32(params.countAfter), params.reverse); err != nil { return err @@ -311,7 +311,7 @@ func (txn *Txn) updateCount(ctx context.Context, params countParams) error { } func (txn *Txn) addMutationHelper(ctx context.Context, l *List, doUpdateIndex bool, - hasCountIndex bool, t *intern.DirectedEdge) (types.Val, bool, countParams, error) { + hasCountIndex bool, t *pb.DirectedEdge) (types.Val, bool, countParams, error) { var val types.Val var found bool var err error @@ -359,14 +359,14 @@ func (txn *Txn) addMutationHelper(ctx context.Context, l *List, doUpdateIndex bo // AddMutationWithIndex is AddMutation with support for indexing. It also // supports reverse edges. -func (l *List) AddMutationWithIndex(ctx context.Context, t *intern.DirectedEdge, +func (l *List) AddMutationWithIndex(ctx context.Context, t *pb.DirectedEdge, txn *Txn) error { if len(t.Attr) == 0 { return x.Errorf("Predicate cannot be empty for edge with subject: [%v], object: [%v]"+ " and value: [%v]", t.Entity, t.ValueId, t.Value) } - if t.Op == intern.DirectedEdge_DEL && string(t.Value) == x.Star { + if t.Op == pb.DirectedEdge_DEL && string(t.Value) == x.Star { return l.handleDeleteAll(ctx, t, txn) } @@ -385,16 +385,16 @@ func (l *List) AddMutationWithIndex(ctx context.Context, t *intern.DirectedEdge, if doUpdateIndex { // Exact matches. if found && val.Value != nil { - if err := txn.addIndexMutations(ctx, t, val, intern.DirectedEdge_DEL); err != nil { + if err := txn.addIndexMutations(ctx, t, val, pb.DirectedEdge_DEL); err != nil { return err } } - if t.Op == intern.DirectedEdge_SET { + if t.Op == pb.DirectedEdge_SET { p := types.Val{ Tid: types.TypeID(t.ValueType), Value: t.Value, } - if err := txn.addIndexMutations(ctx, t, p, intern.DirectedEdge_SET); err != nil { + if err := txn.addIndexMutations(ctx, t, p, pb.DirectedEdge_SET); err != nil { return err } } @@ -510,10 +510,10 @@ func rebuildCountIndex(ctx context.Context, attr string, reverse bool, errCh cha txn := &Txn{StartTs: startTs} for it := range ch { l := it.list - t := &intern.DirectedEdge{ + t := &pb.DirectedEdge{ ValueId: it.uid, Attr: attr, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } len := l.Length(txn.StartTs, 0) if len == -1 { @@ -625,13 +625,13 @@ func RebuildReverseEdges(ctx context.Context, attr string, startTs uint64) error // Helper function - Add reverse entries for values in posting list addReversePostings := func(uid uint64, pl *List, txn *Txn) { - edge := intern.DirectedEdge{Attr: attr, Entity: uid} + edge := pb.DirectedEdge{Attr: attr, Entity: uid} var err error - pl.Iterate(txn.StartTs, 0, func(pp *intern.Posting) bool { + pl.Iterate(txn.StartTs, 0, func(pp *pb.Posting) bool { puid := pp.Uid // Add reverse entries based on p. edge.ValueId = puid - edge.Op = intern.DirectedEdge_SET + edge.Op = pb.DirectedEdge_SET edge.Facets = pp.Facets edge.Label = pp.Label err = txn.addReverseMutation(ctx, &edge) @@ -730,8 +730,8 @@ func RebuildListType(ctx context.Context, attr string, startTs uint64) error { defer it.Close() rewriteValuePostings := func(pl *List, txn *Txn) error { - var mpost *intern.Posting - pl.Iterate(txn.StartTs, 0, func(p *intern.Posting) bool { + var mpost *pb.Posting + pl.Iterate(txn.StartTs, 0, func(p *pb.Posting) bool { // We only want to modify the untagged value. There could be other values with a // lang tag. if p.Uid == math.MaxUint64 { @@ -742,10 +742,10 @@ func RebuildListType(ctx context.Context, attr string, startTs uint64) error { }) if mpost != nil { // Delete the old edge corresponding to ValueId math.MaxUint64 - t := &intern.DirectedEdge{ + t := &pb.DirectedEdge{ ValueId: mpost.Uid, Attr: attr, - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } if err := pl.AddMutation(ctx, txn, t); err != nil { @@ -753,11 +753,11 @@ func RebuildListType(ctx context.Context, attr string, startTs uint64) error { } // Add the new edge with the fingerprinted value id. - newEdge := &intern.DirectedEdge{ + newEdge := &pb.DirectedEdge{ Attr: attr, Value: mpost.Value, ValueType: mpost.ValType, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, Label: mpost.Label, Facets: mpost.Facets, } @@ -830,18 +830,18 @@ func RebuildIndex(ctx context.Context, attr string, startTs uint64) error { // Helper function - Add index entries for values in posting list addPostingsToIndex := func(uid uint64, pl *List, txn *Txn) { - edge := intern.DirectedEdge{Attr: attr, Entity: uid} + edge := pb.DirectedEdge{Attr: attr, Entity: uid} var err error - pl.Iterate(txn.StartTs, 0, func(p *intern.Posting) bool { + pl.Iterate(txn.StartTs, 0, func(p *pb.Posting) bool { // Add index entries based on p. val := types.Val{ Value: p.Value, Tid: types.TypeID(p.ValType), } - err = txn.addIndexMutations(ctx, &edge, val, intern.DirectedEdge_SET) + err = txn.addIndexMutations(ctx, &edge, val, pb.DirectedEdge_SET) for err == ErrRetry { time.Sleep(10 * time.Millisecond) - err = txn.addIndexMutations(ctx, &edge, val, intern.DirectedEdge_SET) + err = txn.addIndexMutations(ctx, &edge, val, pb.DirectedEdge_SET) } if err != nil { x.Printf("Error while adding index mutation: %v\n", err) diff --git a/posting/index_test.go b/posting/index_test.go index 11e003eb541..3cd400806fa 100644 --- a/posting/index_test.go +++ b/posting/index_test.go @@ -17,7 +17,7 @@ import ( "github.com/dgraph-io/badger" "github.com/stretchr/testify/require" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" @@ -100,12 +100,12 @@ func TestIndexingInvalidLang(t *testing.T) { require.Error(t, err) } -func addMutation(t *testing.T, l *List, edge *intern.DirectedEdge, op uint32, +func addMutation(t *testing.T, l *List, edge *pb.DirectedEdge, op uint32, startTs uint64, commitTs uint64, index bool) { if op == Del { - edge.Op = intern.DirectedEdge_DEL + edge.Op = pb.DirectedEdge_DEL } else if op == Set { - edge.Op = intern.DirectedEdge_SET + edge.Op = pb.DirectedEdge_SET } else { x.Fatalf("Unhandled op: %v", op) } @@ -140,7 +140,7 @@ func TestTokensTable(t *testing.T) { require.NoError(t, err) lcache.PutIfMissing(string(l.key), l) - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("david"), Label: "testing", Attr: "name", @@ -186,12 +186,12 @@ func tokensForTest(attr string) []string { // addEdgeToValue adds edge without indexing. func addEdgeToValue(t *testing.T, attr string, src uint64, value string, startTs, commitTs uint64) { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(value), Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } l, err := Get(x.DataKey(attr, src)) require.NoError(t, err) @@ -202,12 +202,12 @@ func addEdgeToValue(t *testing.T, attr string, src uint64, // addEdgeToUID adds uid edge with reverse edge func addEdgeToUID(t *testing.T, attr string, src uint64, dst uint64, startTs, commitTs uint64) { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: dst, Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } l, err := Get(x.DataKey(attr, src)) require.NoError(t, err) @@ -218,12 +218,12 @@ func addEdgeToUID(t *testing.T, attr string, src uint64, // addEdgeToUID adds uid edge with reverse edge func addReverseEdge(t *testing.T, attr string, src uint64, dst uint64, startTs, commitTs uint64) { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: dst, Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } txn := Txn{ StartTs: startTs, diff --git a/posting/list.go b/posting/list.go index 95b5998e67d..823c48d7b49 100644 --- a/posting/list.go +++ b/posting/list.go @@ -27,7 +27,7 @@ import ( "github.com/dgraph-io/dgo/y" "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/bp128" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" @@ -42,8 +42,8 @@ var ( ErrNoValue = fmt.Errorf("No value found") ErrInvalidTxn = fmt.Errorf("Invalid transaction") errUncommitted = fmt.Errorf("Posting List has uncommitted data") - emptyPosting = &intern.Posting{} - emptyList = &intern.PostingList{} + emptyPosting = &pb.Posting{} + emptyList = &pb.PostingList{} ) const ( @@ -62,8 +62,8 @@ const ( type List struct { x.SafeMutex key []byte - plist *intern.PostingList - mutationMap map[uint64]*intern.PostingList + plist *pb.PostingList + mutationMap map[uint64]*pb.PostingList minTs uint64 // commit timestamp of immutable layer, reject reads before this ts. commitTs uint64 // last commitTs of this pl deleteMe int32 // Using atomic for this, to avoid expensive SetForDeletion operation. @@ -84,8 +84,8 @@ func (l *List) calculateSize() int32 { } type PIterator struct { - pl *intern.PostingList - uidPosting *intern.Posting + pl *pb.PostingList + uidPosting *pb.Posting pidx int // index of postings plen int valid bool @@ -95,9 +95,9 @@ type PIterator struct { offset int } -func (it *PIterator) Init(pl *intern.PostingList, afterUid uint64) { +func (it *PIterator) Init(pl *pb.PostingList, afterUid uint64) { it.pl = pl - it.uidPosting = &intern.Posting{} + it.uidPosting = &pb.Posting{} it.bi.Init(pl.Uids, afterUid) it.plen = len(pl.Postings) it.uids = it.bi.Uids() @@ -128,7 +128,7 @@ func (it *PIterator) Valid() bool { return it.valid } -func (it *PIterator) Posting() *intern.Posting { +func (it *PIterator) Posting() *pb.Posting { uid := it.uids[it.offset] for it.pidx < it.plen { @@ -145,17 +145,17 @@ func (it *PIterator) Posting() *intern.Posting { } // ListOptions is used in List.Uids (in posting) to customize our output list of -// UIDs, for each posting list. It should be intern.to this package. +// UIDs, for each posting list. It should be pb.to this package. type ListOptions struct { ReadTs uint64 - AfterUID uint64 // Any UID returned must be after this value. - Intersect *intern.List // Intersect results with this list of UIDs. + AfterUID uint64 // Any UID returned must be after this value. + Intersect *pb.List // Intersect results with this list of UIDs. } // samePosting tells whether this is same posting depending upon operation of new posting. // if operation is Del, we ignore facets and only care about uid and value. // otherwise we match everything. -func samePosting(oldp *intern.Posting, newp *intern.Posting) bool { +func samePosting(oldp *pb.Posting, newp *pb.Posting) bool { if oldp.Uid != newp.Uid { return false } @@ -182,29 +182,29 @@ func samePosting(oldp *intern.Posting, newp *intern.Posting) bool { return facets.SameFacets(oldp.Facets, newp.Facets) } -func NewPosting(t *intern.DirectedEdge) *intern.Posting { +func NewPosting(t *pb.DirectedEdge) *pb.Posting { var op uint32 - if t.Op == intern.DirectedEdge_SET { + if t.Op == pb.DirectedEdge_SET { op = Set - } else if t.Op == intern.DirectedEdge_DEL { + } else if t.Op == pb.DirectedEdge_DEL { op = Del } else { x.Fatalf("Unhandled operation: %+v", t) } - var postingType intern.Posting_PostingType + var postingType pb.Posting_PostingType if len(t.Lang) > 0 { - postingType = intern.Posting_VALUE_LANG + postingType = pb.Posting_VALUE_LANG } else if t.ValueId == 0 { - postingType = intern.Posting_VALUE + postingType = pb.Posting_VALUE } else { - postingType = intern.Posting_REF + postingType = pb.Posting_REF } - return &intern.Posting{ + return &pb.Posting{ Uid: t.ValueId, Value: t.Value, - ValType: intern.Posting_ValType(t.ValueType), + ValType: pb.Posting_ValType(t.ValueType), PostingType: postingType, LangTag: []byte(t.Lang), Label: t.Label, @@ -237,18 +237,18 @@ func (l *List) SetForDeletion() bool { return true } -func hasDeleteAll(mpost *intern.Posting) bool { +func hasDeleteAll(mpost *pb.Posting) bool { return mpost.Op == Del && bytes.Equal(mpost.Value, []byte(x.Star)) } // Ensure that you either abort the uncomitted postings or commit them before calling me. -func (l *List) updateMutationLayer(mpost *intern.Posting) { +func (l *List) updateMutationLayer(mpost *pb.Posting) { l.AssertLock() x.AssertTrue(mpost.Op == Set || mpost.Op == Del) // If we have a delete all, then we replace the map entry with just one. if hasDeleteAll(mpost) { - plist := &intern.PostingList{} + plist := &pb.PostingList{} plist.Postings = append(plist.Postings, mpost) l.mutationMap[mpost.StartTs] = plist return @@ -256,7 +256,7 @@ func (l *List) updateMutationLayer(mpost *intern.Posting) { plist, ok := l.mutationMap[mpost.StartTs] if !ok { - plist := &intern.PostingList{} + plist := &pb.PostingList{} plist.Postings = append(plist.Postings, mpost) l.mutationMap[mpost.StartTs] = plist return @@ -275,7 +275,7 @@ func (l *List) updateMutationLayer(mpost *intern.Posting) { // AddMutation adds mutation to mutation layers. Note that it does not write // anything to disk. Some other background routine will be responsible for merging // changes in mutation layers to BadgerDB. Returns whether any mutation happens. -func (l *List) AddMutation(ctx context.Context, txn *Txn, t *intern.DirectedEdge) error { +func (l *List) AddMutation(ctx context.Context, txn *Txn, t *pb.DirectedEdge) error { t1 := time.Now() l.Lock() if dur := time.Since(t1); dur > time.Millisecond { @@ -288,14 +288,14 @@ func (l *List) AddMutation(ctx context.Context, txn *Txn, t *intern.DirectedEdge } // TypeID returns the typeid of destination vertex -func TypeID(edge *intern.DirectedEdge) types.TypeID { +func TypeID(edge *pb.DirectedEdge) types.TypeID { if edge.ValueId != 0 { return types.UidID } return types.TypeID(edge.ValueType) } -func fingerprintEdge(t *intern.DirectedEdge) uint64 { +func fingerprintEdge(t *pb.DirectedEdge) uint64 { // There could be a collision if the user gives us a value with Lang = "en" and later gives // us a value = "en" for the same predicate. We would end up overwritting his older lang // value. @@ -316,7 +316,7 @@ func fingerprintEdge(t *intern.DirectedEdge) uint64 { return id } -func (l *List) addMutation(ctx context.Context, txn *Txn, t *intern.DirectedEdge) error { +func (l *List) addMutation(ctx context.Context, txn *Txn, t *pb.DirectedEdge) error { if atomic.LoadInt32(&l.deleteMe) == 1 { if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("DELETEME set to true. Temporary error.") @@ -366,7 +366,7 @@ func (l *List) addMutation(ctx context.Context, txn *Txn, t *intern.DirectedEdge mpost := NewPosting(t) mpost.StartTs = txn.StartTs - if mpost.PostingType != intern.Posting_REF { + if mpost.PostingType != pb.Posting_REF { t.ValueId = fingerprintEdge(t) mpost.Uid = t.ValueId } @@ -448,12 +448,12 @@ func (l *List) commitMutation(startTs, commitTs uint64) error { // The function will loop until either the Posting List is fully iterated, or you return a false // in the provided function, which will indicate to the function to break out of the iteration. // -// pl.Iterate(func(p *intern.Posting) bool { +// pl.Iterate(func(p *pb.Posting) bool { // // Use posting p // return true // to continue iteration. // return false // to break iteration. // }) -func (l *List) Iterate(readTs uint64, afterUid uint64, f func(obj *intern.Posting) bool) error { +func (l *List) Iterate(readTs uint64, afterUid uint64, f func(obj *pb.Posting) bool) error { l.RLock() defer l.RUnlock() return l.iterate(readTs, afterUid, f) @@ -474,7 +474,7 @@ func (l *List) Conflicts(readTs uint64) []uint64 { return conflicts } -func (l *List) pickPostings(readTs uint64) (*intern.PostingList, []*intern.Posting) { +func (l *List) pickPostings(readTs uint64) (*pb.PostingList, []*pb.Posting) { // This function would return zero ts for entries above readTs. effective := func(start, commit uint64) uint64 { if commit > 0 && commit <= readTs { @@ -490,7 +490,7 @@ func (l *List) pickPostings(readTs uint64) (*intern.PostingList, []*intern.Posti // First pick up the postings. var deleteBelow uint64 - var posts []*intern.Posting + var posts []*pb.Posting for startTs, plist := range l.mutationMap { // Pick up the transactions which are either committed, or the one which is ME. effectiveTs := effective(startTs, plist.Commit) @@ -536,7 +536,7 @@ func (l *List) pickPostings(readTs uint64) (*intern.PostingList, []*intern.Posti return storedList, posts } -func (l *List) iterate(readTs uint64, afterUid uint64, f func(obj *intern.Posting) bool) error { +func (l *List) iterate(readTs uint64, afterUid uint64, f func(obj *pb.Posting) bool) error { l.AssertRLock() plist, mposts := l.pickPostings(readTs) @@ -552,7 +552,7 @@ func (l *List) iterate(readTs uint64, afterUid uint64, f func(obj *intern.Postin }) } - var mp, pp *intern.Posting + var mp, pp *pb.Posting cont := true var pitr PIterator pitr.Init(plist, afterUid) @@ -611,7 +611,7 @@ func (l *List) IsEmpty() bool { func (l *List) length(readTs, afterUid uint64) int { l.AssertRLock() count := 0 - err := l.iterate(readTs, afterUid, func(p *intern.Posting) bool { + err := l.iterate(readTs, afterUid, func(p *pb.Posting) bool { count++ return true }) @@ -639,14 +639,14 @@ func doAsyncWrite(commitTs uint64, key []byte, data []byte, meta byte, f func(er } } -func (l *List) MarshalToKv() (*intern.KV, error) { +func (l *List) MarshalToKv() (*pb.KV, error) { l.Lock() defer l.Unlock() if err := l.rollup(); err != nil { return nil, err } - kv := &intern.KV{} + kv := &pb.KV{} kv.Version = l.minTs kv.Key = l.key val, meta := marshalPostingList(l.plist) @@ -655,7 +655,7 @@ func (l *List) MarshalToKv() (*intern.KV, error) { return kv, nil } -func marshalPostingList(plist *intern.PostingList) (data []byte, meta byte) { +func marshalPostingList(plist *pb.PostingList) (data []byte, meta byte) { if len(plist.Uids) == 0 { data = nil meta |= BitEmptyPosting @@ -675,13 +675,13 @@ func marshalPostingList(plist *intern.PostingList) (data []byte, meta byte) { // into immutable layer. func (l *List) rollup() error { l.AssertLock() - final := new(intern.PostingList) + final := new(pb.PostingList) var bp bp128.BPackEncoder buf := make([]uint64, 0, bp128.BlockSize) // Pick all committed entries x.AssertTrue(l.minTs <= l.commitTs) - err := l.iterate(l.commitTs, 0, func(p *intern.Posting) bool { + err := l.iterate(l.commitTs, 0, func(p *pb.Posting) bool { // iterate already takes care of not returning entries whose commitTs is above l.commitTs. // So, we don't need to do any filtering here. In fact, doing filtering here could result // in a bug. @@ -692,7 +692,7 @@ func (l *List) rollup() error { } // We want to add the posting if it has facets or has a value. - if p.Facets != nil || p.PostingType != intern.Posting_REF || len(p.Label) != 0 { + if p.Facets != nil || p.PostingType != pb.Posting_REF || len(p.Label) != 0 { // I think it's okay to take the pointer from the iterator, because we have a lock // over List; which won't be released until final has been marshalled. Thus, the // underlying data wouldn't be changed. @@ -814,7 +814,7 @@ func (l *List) syncIfDirty(delFromCache bool) (committed bool, err error) { } // Copies the val if it's uid only posting, be careful -func UnmarshalOrCopy(val []byte, metadata byte, pl *intern.PostingList) { +func UnmarshalOrCopy(val []byte, metadata byte, pl *pb.PostingList) { if metadata == BitUidPosting { buf := make([]byte, len(val)) copy(buf, val) @@ -827,12 +827,12 @@ func UnmarshalOrCopy(val []byte, metadata byte, pl *intern.PostingList) { // Uids returns the UIDs given some query params. // We have to apply the filtering before applying (offset, count). // WARNING: Calling this function just to get Uids is expensive -func (l *List) Uids(opt ListOptions) (*intern.List, error) { +func (l *List) Uids(opt ListOptions) (*pb.List, error) { // Pre-assign length to make it faster. l.RLock() // Use approximate length for initial capacity. res := make([]uint64, 0, len(l.mutationMap)+bp128.NumIntegers(l.plist.Uids)) - out := &intern.List{} + out := &pb.List{} if len(l.mutationMap) == 0 && opt.Intersect != nil { if opt.ReadTs < l.minTs { l.RUnlock() @@ -843,8 +843,8 @@ func (l *List) Uids(opt ListOptions) (*intern.List, error) { return out, nil } - err := l.iterate(opt.ReadTs, opt.AfterUID, func(p *intern.Posting) bool { - if p.PostingType == intern.Posting_REF { + err := l.iterate(opt.ReadTs, opt.AfterUID, func(p *pb.Posting) bool { + if p.PostingType == pb.Posting_REF { res = append(res, p.Uid) } return true @@ -864,12 +864,12 @@ func (l *List) Uids(opt ListOptions) (*intern.List, error) { // Postings calls postFn with the postings that are common with // uids in the opt ListOptions. -func (l *List) Postings(opt ListOptions, postFn func(*intern.Posting) bool) error { +func (l *List) Postings(opt ListOptions, postFn func(*pb.Posting) bool) error { l.RLock() defer l.RUnlock() - return l.iterate(opt.ReadTs, opt.AfterUID, func(p *intern.Posting) bool { - if p.PostingType != intern.Posting_REF { + return l.iterate(opt.ReadTs, opt.AfterUID, func(p *pb.Posting) bool { + if p.PostingType != pb.Posting_REF { return true } return postFn(p) @@ -881,7 +881,7 @@ func (l *List) AllUntaggedValues(readTs uint64) ([]types.Val, error) { defer l.RUnlock() var vals []types.Val - err := l.iterate(readTs, 0, func(p *intern.Posting) bool { + err := l.iterate(readTs, 0, func(p *pb.Posting) bool { if len(p.LangTag) == 0 { vals = append(vals, types.Val{ Tid: types.TypeID(p.ValType), @@ -898,7 +898,7 @@ func (l *List) AllValues(readTs uint64) ([]types.Val, error) { defer l.RUnlock() var vals []types.Val - err := l.iterate(readTs, 0, func(p *intern.Posting) bool { + err := l.iterate(readTs, 0, func(p *pb.Posting) bool { vals = append(vals, types.Val{ Tid: types.TypeID(p.ValType), Value: p.Value, @@ -914,7 +914,7 @@ func (l *List) GetLangTags(readTs uint64) ([]string, error) { defer l.RUnlock() var tags []string - err := l.iterate(readTs, 0, func(p *intern.Posting) bool { + err := l.iterate(readTs, 0, func(p *pb.Posting) bool { tags = append(tags, string(p.LangTag)) return true }) @@ -951,7 +951,7 @@ func (l *List) ValueFor(readTs uint64, langs []string) (rval types.Val, rerr err return valueToTypesVal(p), nil } -func (l *List) postingFor(readTs uint64, langs []string) (p *intern.Posting, rerr error) { +func (l *List) postingFor(readTs uint64, langs []string) (p *pb.Posting, rerr error) { l.AssertRLock() // Avoid recursive locking by asserting a lock here. return l.postingForLangs(readTs, langs) } @@ -966,7 +966,7 @@ func (l *List) ValueForTag(readTs uint64, tag string) (rval types.Val, rerr erro return valueToTypesVal(p), nil } -func valueToTypesVal(p *intern.Posting) (rval types.Val) { +func valueToTypesVal(p *pb.Posting) (rval types.Val) { // This is ok because we dont modify the value of a Posting. We create a newPosting // and add it to the PostingList to do a set. rval.Value = p.Value @@ -974,7 +974,7 @@ func valueToTypesVal(p *intern.Posting) (rval types.Val) { return } -func (l *List) postingForLangs(readTs uint64, langs []string) (pos *intern.Posting, rerr error) { +func (l *List) postingForLangs(readTs uint64, langs []string) (pos *pb.Posting, rerr error) { l.AssertRLock() any := false @@ -1002,8 +1002,8 @@ func (l *List) postingForLangs(readTs uint64, langs []string) (pos *intern.Posti var found bool // last resort - return value with smallest lang Uid if any { - err := l.iterate(readTs, 0, func(p *intern.Posting) bool { - if p.PostingType == intern.Posting_VALUE_LANG { + err := l.iterate(readTs, 0, func(p *pb.Posting) bool { + if p.PostingType == pb.Posting_VALUE_LANG { pos = p found = true return false @@ -1022,7 +1022,7 @@ func (l *List) postingForLangs(readTs uint64, langs []string) (pos *intern.Posti return pos, ErrNoValue } -func (l *List) postingForTag(readTs uint64, tag string) (p *intern.Posting, rerr error) { +func (l *List) postingForTag(readTs uint64, tag string) (p *pb.Posting, rerr error) { l.AssertRLock() uid := farm.Fingerprint64([]byte(tag)) found, p, err := l.findPosting(readTs, uid) @@ -1046,9 +1046,9 @@ func (l *List) findValue(readTs, uid uint64) (rval types.Val, found bool, err er return valueToTypesVal(p), true, nil } -func (l *List) findPosting(readTs uint64, uid uint64) (found bool, pos *intern.Posting, err error) { +func (l *List) findPosting(readTs uint64, uid uint64) (found bool, pos *pb.Posting, err error) { // Iterate starts iterating after the given argument, so we pass uid - 1 - err = l.iterate(readTs, uid-1, func(p *intern.Posting) bool { + err = l.iterate(readTs, uid-1, func(p *pb.Posting) bool { if p.Uid == uid { pos = p found = true @@ -1060,7 +1060,7 @@ func (l *List) findPosting(readTs uint64, uid uint64) (found bool, pos *intern.P } // Facets gives facets for the posting representing value. -func (l *List) Facets(readTs uint64, param *intern.FacetParams, langs []string) (fs []*api.Facet, +func (l *List) Facets(readTs uint64, param *pb.FacetParams, langs []string) (fs []*api.Facet, ferr error) { l.RLock() defer l.RUnlock() diff --git a/posting/list_test.go b/posting/list_test.go index 680521123f4..2d0cae1973f 100644 --- a/posting/list_test.go +++ b/posting/list_test.go @@ -19,12 +19,12 @@ import ( "github.com/dgraph-io/badger" "github.com/stretchr/testify/require" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" ) -func (l *List) PostingList() *intern.PostingList { +func (l *List) PostingList() *pb.PostingList { l.RLock() defer l.RUnlock() return l.plist @@ -32,7 +32,7 @@ func (l *List) PostingList() *intern.PostingList { func listToArray(t *testing.T, afterUid uint64, l *List, readTs uint64) []uint64 { out := make([]uint64, 0, 10) - l.Iterate(readTs, afterUid, func(p *intern.Posting) bool { + l.Iterate(readTs, afterUid, func(p *pb.Posting) bool { out = append(out, p.Uid) return true }) @@ -48,11 +48,11 @@ func checkUids(t *testing.T, l *List, uids []uint64, readTs uint64) { } } -func addMutationHelper(t *testing.T, l *List, edge *intern.DirectedEdge, op uint32, txn *Txn) { +func addMutationHelper(t *testing.T, l *List, edge *pb.DirectedEdge, op uint32, txn *Txn) { if op == Del { - edge.Op = intern.DirectedEdge_DEL + edge.Op = pb.DirectedEdge_DEL } else if op == Set { - edge.Op = intern.DirectedEdge_SET + edge.Op = pb.DirectedEdge_SET } else { x.Fatalf("Unhandled op: %v", op) } @@ -67,7 +67,7 @@ func TestAddMutation(t *testing.T) { require.NoError(t, err) txn := &Txn{StartTs: uint64(1)} - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 9, Label: "testing", } @@ -116,8 +116,8 @@ func TestAddMutation(t *testing.T) { checkUids(t, dl, uids, 3) } -func getFirst(l *List, readTs uint64) (res intern.Posting) { - l.Iterate(readTs, 0, func(p *intern.Posting) bool { +func getFirst(l *List, readTs uint64) (res pb.Posting) { + l.Iterate(readTs, 0, func(p *pb.Posting) bool { res = *p return false }) @@ -135,7 +135,7 @@ func TestAddMutation_Value(t *testing.T) { key := x.DataKey("value", 10) ol, err := getNew(key, ps) require.NoError(t, err) - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("oh hey there"), Label: "new-testing", } @@ -162,7 +162,7 @@ func TestAddMutation_jchiu1(t *testing.T) { require.NoError(t, err) // Set value to cars and merge to BadgerDB. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -179,7 +179,7 @@ func TestAddMutation_jchiu1(t *testing.T) { txn = &Txn{StartTs: 3} // Set value to newcars, but don't merge yet. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("newcars"), Label: "jchiu", } @@ -188,7 +188,7 @@ func TestAddMutation_jchiu1(t *testing.T) { checkValue(t, ol, "newcars", txn.StartTs) // Set value to someothercars, but don't merge yet. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("someothercars"), Label: "jchiu", } @@ -197,7 +197,7 @@ func TestAddMutation_jchiu1(t *testing.T) { checkValue(t, ol, "someothercars", txn.StartTs) // Set value back to the committed value cars, but don't merge yet. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -213,16 +213,16 @@ func TestAddMutation_DelSet(t *testing.T) { // DO sp*, don't commit // Del a value cars and but don't merge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(x.Star), - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } txn := &Txn{StartTs: 1} err = ol.AddMutation(context.Background(), txn, edge) require.NoError(t, err) // Set value to newcars, commit it - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("newcars"), } txn = &Txn{StartTs: 2} @@ -237,7 +237,7 @@ func TestAddMutation_DelRead(t *testing.T) { require.NoError(t, err) // Set value to newcars, and commit it - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("newcars"), } txn := &Txn{StartTs: 1} @@ -248,9 +248,9 @@ func TestAddMutation_DelRead(t *testing.T) { // DO sp*, don't commit // Del a value cars and but don't merge. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte(x.Star), - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } txn = &Txn{StartTs: 3} err = ol.AddMutation(context.Background(), txn, edge) @@ -276,7 +276,7 @@ func TestAddMutation_jchiu2(t *testing.T) { require.NoError(t, err) // Del a value cars and but don't merge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -285,7 +285,7 @@ func TestAddMutation_jchiu2(t *testing.T) { require.EqualValues(t, 0, ol.Length(txn.StartTs, 0)) // Set value to newcars, but don't merge yet. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("newcars"), Label: "jchiu", } @@ -300,7 +300,7 @@ func TestAddMutation_jchiu2_Commit(t *testing.T) { require.NoError(t, err) // Del a value cars and but don't merge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -310,7 +310,7 @@ func TestAddMutation_jchiu2_Commit(t *testing.T) { require.EqualValues(t, 0, ol.Length(uint64(3), 0)) // Set value to newcars, but don't merge yet. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("newcars"), Label: "jchiu", } @@ -327,7 +327,7 @@ func TestAddMutation_jchiu3(t *testing.T) { require.NoError(t, err) // Set value to cars and merge to BadgerDB. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -342,7 +342,7 @@ func TestAddMutation_jchiu3(t *testing.T) { checkValue(t, ol, "cars", uint64(3)) // Del a value cars and but don't merge. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -351,7 +351,7 @@ func TestAddMutation_jchiu3(t *testing.T) { require.Equal(t, 0, ol.Length(txn.StartTs, 0)) // Set value to newcars, but don't merge yet. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("newcars"), Label: "jchiu", } @@ -360,7 +360,7 @@ func TestAddMutation_jchiu3(t *testing.T) { checkValue(t, ol, "newcars", txn.StartTs) // Del a value newcars and but don't merge. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("newcars"), Label: "jchiu", } @@ -374,7 +374,7 @@ func TestAddMutation_mrjn1(t *testing.T) { require.NoError(t, err) // Set a value cars and merge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -387,7 +387,7 @@ func TestAddMutation_mrjn1(t *testing.T) { // Delete the previously committed value cars. But don't merge. txn = &Txn{StartTs: 2} - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -396,7 +396,7 @@ func TestAddMutation_mrjn1(t *testing.T) { // Do this again to cover Del, muid == curUid, inPlist test case. // Delete the previously committed value cars. But don't merge. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -405,7 +405,7 @@ func TestAddMutation_mrjn1(t *testing.T) { // Set the value again to cover Set, muid == curUid, inPlist test case. // Set the previously committed value cars. But don't merge. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -413,7 +413,7 @@ func TestAddMutation_mrjn1(t *testing.T) { checkValue(t, ol, "cars", txn.StartTs) // Delete it again, just for fun. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("cars"), Label: "jchiu", } @@ -428,7 +428,7 @@ func TestMillion(t *testing.T) { var commits int N := int(1e6) for i := 2; i <= N; i += 2 { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: uint64(i), } txn := Txn{StartTs: uint64(i)} @@ -453,9 +453,9 @@ func TestAddMutation_mrjn2(t *testing.T) { require.NoError(t, err) var readTs uint64 for readTs = 1; readTs < 10; readTs++ { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: readTs, - ValueType: intern.Posting_INT, + ValueType: pb.Posting_INT, } txn := &Txn{StartTs: readTs} addMutationHelper(t, ol, edge, Set, txn) @@ -476,18 +476,18 @@ func TestAddMutation_mrjn2(t *testing.T) { require.EqualValues(t, 3, ol.Length(15, 0)) // The three commits. { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(x.Star), - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } txn := &Txn{StartTs: 7} err := ol.AddMutation(ctx, txn, edge) require.NoError(t, err) // Add edge just to test that the deletion still happens. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ ValueId: 7, - ValueType: intern.Posting_INT, + ValueType: pb.Posting_INT, } err = ol.AddMutation(ctx, txn, edge) require.NoError(t, err) @@ -500,9 +500,9 @@ func TestAddMutation_mrjn2(t *testing.T) { require.EqualValues(t, 2, ol.Length(15, 0)) // Only one commit should be found. } { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(x.Star), - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } txn := &Txn{StartTs: 5} err := ol.AddMutation(ctx, txn, edge) @@ -532,13 +532,13 @@ func TestAddMutation_gru(t *testing.T) { { // Set two tag ids and merge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 0x2b693088816b04b7, Label: "gru", } txn := &Txn{StartTs: 1} addMutationHelper(t, ol, edge, Set, txn) - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ ValueId: 0x29bf442b48a772e0, Label: "gru", } @@ -550,13 +550,13 @@ func TestAddMutation_gru(t *testing.T) { } { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 0x38dec821d2ac3a79, Label: "gru", } txn := &Txn{StartTs: 3} addMutationHelper(t, ol, edge, Set, txn) - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ ValueId: 0x2b693088816b04b7, Label: "gru", } @@ -575,13 +575,13 @@ func TestAddMutation_gru2(t *testing.T) { { // Set two tag ids and merge. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 0x02, Label: "gru", } txn := &Txn{StartTs: 1} addMutationHelper(t, ol, edge, Set, txn) - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ ValueId: 0x03, Label: "gru", } @@ -595,19 +595,19 @@ func TestAddMutation_gru2(t *testing.T) { { // Lets set a new tag and delete the two older ones. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 0x02, Label: "gru", } txn := &Txn{StartTs: 3} addMutationHelper(t, ol, edge, Del, txn) - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ ValueId: 0x03, Label: "gru", } addMutationHelper(t, ol, edge, Del, txn) - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ ValueId: 0x04, Label: "gru", } @@ -630,7 +630,7 @@ func TestAddAndDelMutation(t *testing.T) { // Set and callSyncIfDirty { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 0x02, Label: "gru", } @@ -644,7 +644,7 @@ func TestAddAndDelMutation(t *testing.T) { // Delete and callSyncIfDirty { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 0x02, Label: "gru", } @@ -667,7 +667,7 @@ func TestAfterUIDCount(t *testing.T) { ol, err := getNew(key, ps) require.NoError(t, err) // Set value to cars and merge to BadgerDB. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Label: "jchiu", } @@ -742,7 +742,7 @@ func TestAfterUIDCount2(t *testing.T) { require.NoError(t, err) // Set value to cars and merge to BadgerDB. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Label: "jchiu", } @@ -772,7 +772,7 @@ func TestDelete(t *testing.T) { require.NoError(t, err) // Set value to cars and merge to BadgerDB. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Label: "jchiu", } @@ -799,7 +799,7 @@ func TestAfterUIDCountWithCommit(t *testing.T) { require.NoError(t, err) // Set value to cars and merge to BadgerDB. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Label: "jchiu", } @@ -914,10 +914,10 @@ func BenchmarkAddMutations(b *testing.B) { b.Error(err) return } - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: uint64(rand.Intn(b.N) + 1), Label: "testing", - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } txn := &Txn{StartTs: 1} if err = l.AddMutation(ctx, txn, edge); err != nil { diff --git a/posting/lists.go b/posting/lists.go index 333ea663b09..87bfa5b1037 100644 --- a/posting/lists.go +++ b/posting/lists.go @@ -26,7 +26,7 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/badger/y" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -54,7 +54,7 @@ const ( func init() { x.AddInit(func() { h := md5.New() - pl := intern.PostingList{ + pl := pb.PostingList{ Checksum: h.Sum(nil), } var err error diff --git a/posting/lru_test.go b/posting/lru_test.go index e261c03a095..e4610b226c1 100644 --- a/posting/lru_test.go +++ b/posting/lru_test.go @@ -21,13 +21,13 @@ import ( "sync" "testing" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" ) func getPosting() *List { l := &List{ - plist: &intern.PostingList{}, + plist: &pb.PostingList{}, } return l } diff --git a/posting/mvcc.go b/posting/mvcc.go index 80f6058d0cd..7b23b82d3a5 100644 --- a/posting/mvcc.go +++ b/posting/mvcc.go @@ -16,7 +16,7 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" farm "github.com/dgryski/go-farm" ) @@ -137,7 +137,7 @@ func (tx *Txn) CommitToMemory(commitTs uint64) error { return nil } -func unmarshalOrCopy(plist *intern.PostingList, item *badger.Item) error { +func unmarshalOrCopy(plist *pb.PostingList, item *badger.Item) error { // It's delta val, err := item.Value() if err != nil { @@ -165,8 +165,8 @@ func unmarshalOrCopy(plist *intern.PostingList, item *badger.Item) error { func ReadPostingList(key []byte, it *badger.Iterator) (*List, error) { l := new(List) l.key = key - l.mutationMap = make(map[uint64]*intern.PostingList) - l.plist = new(intern.PostingList) + l.mutationMap = make(map[uint64]*pb.PostingList) + l.plist = new(pb.PostingList) // Iterates from highest Ts to lowest Ts for it.Valid() { @@ -196,7 +196,7 @@ func ReadPostingList(key []byte, it *badger.Iterator) (*List, error) { break } if item.UserMeta()&bitDeltaPosting > 0 { - pl := &intern.PostingList{} + pl := &pb.PostingList{} x.Check(pl.Unmarshal(val)) pl.Commit = item.Version() for _, mpost := range pl.Postings { @@ -219,8 +219,8 @@ func ReadPostingList(key []byte, it *badger.Iterator) (*List, error) { func getNew(key []byte, pstore *badger.DB) (*List, error) { l := new(List) l.key = key - l.mutationMap = make(map[uint64]*intern.PostingList) - l.plist = new(intern.PostingList) + l.mutationMap = make(map[uint64]*pb.PostingList) + l.plist = new(pb.PostingList) txn := pstore.NewTransactionAt(math.MaxUint64, false) defer txn.Discard() diff --git a/posting/oracle.go b/posting/oracle.go index 1d84a548bd9..adab6f679e8 100644 --- a/posting/oracle.go +++ b/posting/oracle.go @@ -13,7 +13,7 @@ import ( "sync" "time" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -152,7 +152,7 @@ func (o *oracle) WaitForTs(ctx context.Context, startTs uint64) error { } } -func (o *oracle) ProcessDelta(delta *intern.OracleDelta) { +func (o *oracle) ProcessDelta(delta *pb.OracleDelta) { o.Lock() defer o.Unlock() for _, txn := range delta.Txns { diff --git a/protos/gen.sh b/protos/gen.sh index 769ef5be2ea..a16b0738106 100755 --- a/protos/gen.sh +++ b/protos/gen.sh @@ -5,4 +5,4 @@ dgraph_io=${GOPATH-$HOME/go}/src/github.com/dgraph-io protos=$dgraph_io/dgraph/protos pushd $protos > /dev/null -protoc -I=$dgraph_io/dgo/protos -I=. --gofast_out=plugins=grpc,Mapi.proto=github.com/dgraph-io/dgo/protos/api:intern internal.proto +protoc -I=$dgraph_io/dgo/protos -I=. --gogofaster_out=plugins=grpc,Mapi.proto=github.com/dgraph-io/dgo/protos/api:pb pb.proto diff --git a/protos/internal.proto b/protos/pb.proto similarity index 99% rename from protos/internal.proto rename to protos/pb.proto index 4480a072db9..00540304794 100644 --- a/protos/internal.proto +++ b/protos/pb.proto @@ -22,7 +22,7 @@ syntax = "proto3"; -package intern; +package pb; import "api.proto"; diff --git a/protos/intern/internal.pb.go b/protos/pb/pb.pb.go similarity index 71% rename from protos/intern/internal.pb.go rename to protos/pb/pb.pb.go index 246620db3b9..4870eb41050 100644 --- a/protos/intern/internal.pb.go +++ b/protos/pb/pb.pb.go @@ -1,71 +1,19 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: internal.proto - -/* - Package intern is a generated protocol buffer package. - - It is generated from these files: - internal.proto - - It has these top-level messages: - List - TaskValue - SrcFunction - Query - ValueList - LangList - Result - Order - SortMessage - SortResult - RaftContext - Member - Group - ZeroProposal - MembershipState - ConnectionState - Tablet - DirectedEdge - Mutations - KeyValues - Snapshot - Proposal - KVS - KV - Posting - PostingList - FacetParam - FacetParams - Facets - FacetsList - Function - FilterTree - SchemaRequest - SchemaResult - SchemaUpdate - MapEntry - MovePredicatePayload - ExportPayload - TxnStatus - OracleDelta - TxnTimestamps - PeerResponse - RaftBatch - Num - AssignedIds - SnapshotMeta -*/ -package intern - -import proto "github.com/golang/protobuf/proto" +// source: pb.proto + +package pb + +import proto "github.com/gogo/protobuf/proto" import fmt "fmt" import math "math" import api "github.com/dgraph-io/dgo/protos/api" -import context "golang.org/x/net/context" -import grpc "google.golang.org/grpc" +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) -import binary "encoding/binary" +import encoding_binary "encoding/binary" import io "io" @@ -78,7 +26,7 @@ var _ = math.Inf // 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.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package type DirectedEdge_Op int32 @@ -99,7 +47,9 @@ var DirectedEdge_Op_value = map[string]int32{ func (x DirectedEdge_Op) String() string { return proto.EnumName(DirectedEdge_Op_name, int32(x)) } -func (DirectedEdge_Op) EnumDescriptor() ([]byte, []int) { return fileDescriptorInternal, []int{17, 0} } +func (DirectedEdge_Op) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{17, 0} +} type Posting_ValType int32 @@ -144,7 +94,9 @@ var Posting_ValType_value = map[string]int32{ func (x Posting_ValType) String() string { return proto.EnumName(Posting_ValType_name, int32(x)) } -func (Posting_ValType) EnumDescriptor() ([]byte, []int) { return fileDescriptorInternal, []int{24, 0} } +func (Posting_ValType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{24, 0} +} type Posting_PostingType int32 @@ -169,7 +121,7 @@ func (x Posting_PostingType) String() string { return proto.EnumName(Posting_PostingType_name, int32(x)) } func (Posting_PostingType) EnumDescriptor() ([]byte, []int) { - return fileDescriptorInternal, []int{24, 1} + return fileDescriptor_pb_03862279bc4bb7c1, []int{24, 1} } type SchemaUpdate_Directive int32 @@ -198,7 +150,7 @@ func (x SchemaUpdate_Directive) String() string { return proto.EnumName(SchemaUpdate_Directive_name, int32(x)) } func (SchemaUpdate_Directive) EnumDescriptor() ([]byte, []int) { - return fileDescriptorInternal, []int{34, 0} + return fileDescriptor_pb_03862279bc4bb7c1, []int{34, 0} } type ExportPayload_Status int32 @@ -227,17 +179,45 @@ func (x ExportPayload_Status) String() string { return proto.EnumName(ExportPayload_Status_name, int32(x)) } func (ExportPayload_Status) EnumDescriptor() ([]byte, []int) { - return fileDescriptorInternal, []int{37, 0} + return fileDescriptor_pb_03862279bc4bb7c1, []int{37, 0} } type List struct { Uids []uint64 `protobuf:"fixed64,1,rep,packed,name=uids" json:"uids,omitempty"` } -func (m *List) Reset() { *m = List{} } -func (m *List) String() string { return proto.CompactTextString(m) } -func (*List) ProtoMessage() {} -func (*List) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{0} } +func (m *List) Reset() { *m = List{} } +func (m *List) String() string { return proto.CompactTextString(m) } +func (*List) ProtoMessage() {} +func (*List) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{0} +} +func (m *List) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *List) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_List.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *List) XXX_Merge(src proto.Message) { + xxx_messageInfo_List.Merge(dst, src) +} +func (m *List) XXX_Size() int { + return m.Size() +} +func (m *List) XXX_DiscardUnknown() { + xxx_messageInfo_List.DiscardUnknown(m) +} + +var xxx_messageInfo_List proto.InternalMessageInfo func (m *List) GetUids() []uint64 { if m != nil { @@ -248,13 +228,41 @@ func (m *List) GetUids() []uint64 { type TaskValue struct { Val []byte `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` - ValType Posting_ValType `protobuf:"varint,2,opt,name=val_type,json=valType,proto3,enum=intern.Posting_ValType" json:"val_type,omitempty"` + ValType Posting_ValType `protobuf:"varint,2,opt,name=val_type,json=valType,proto3,enum=pb.Posting_ValType" json:"val_type,omitempty"` } -func (m *TaskValue) Reset() { *m = TaskValue{} } -func (m *TaskValue) String() string { return proto.CompactTextString(m) } -func (*TaskValue) ProtoMessage() {} -func (*TaskValue) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{1} } +func (m *TaskValue) Reset() { *m = TaskValue{} } +func (m *TaskValue) String() string { return proto.CompactTextString(m) } +func (*TaskValue) ProtoMessage() {} +func (*TaskValue) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{1} +} +func (m *TaskValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TaskValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TaskValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *TaskValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_TaskValue.Merge(dst, src) +} +func (m *TaskValue) XXX_Size() int { + return m.Size() +} +func (m *TaskValue) XXX_DiscardUnknown() { + xxx_messageInfo_TaskValue.DiscardUnknown(m) +} + +var xxx_messageInfo_TaskValue proto.InternalMessageInfo func (m *TaskValue) GetVal() []byte { if m != nil { @@ -276,10 +284,38 @@ type SrcFunction struct { IsCount bool `protobuf:"varint,4,opt,name=isCount,proto3" json:"isCount,omitempty"` } -func (m *SrcFunction) Reset() { *m = SrcFunction{} } -func (m *SrcFunction) String() string { return proto.CompactTextString(m) } -func (*SrcFunction) ProtoMessage() {} -func (*SrcFunction) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{2} } +func (m *SrcFunction) Reset() { *m = SrcFunction{} } +func (m *SrcFunction) String() string { return proto.CompactTextString(m) } +func (*SrcFunction) ProtoMessage() {} +func (*SrcFunction) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{2} +} +func (m *SrcFunction) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SrcFunction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SrcFunction.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SrcFunction) XXX_Merge(src proto.Message) { + xxx_messageInfo_SrcFunction.Merge(dst, src) +} +func (m *SrcFunction) XXX_Size() int { + return m.Size() +} +func (m *SrcFunction) XXX_DiscardUnknown() { + xxx_messageInfo_SrcFunction.DiscardUnknown(m) +} + +var xxx_messageInfo_SrcFunction proto.InternalMessageInfo func (m *SrcFunction) GetName() string { if m != nil { @@ -318,10 +354,38 @@ type Query struct { ReadTs uint64 `protobuf:"varint,13,opt,name=read_ts,json=readTs,proto3" json:"read_ts,omitempty"` } -func (m *Query) Reset() { *m = Query{} } -func (m *Query) String() string { return proto.CompactTextString(m) } -func (*Query) ProtoMessage() {} -func (*Query) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{3} } +func (m *Query) Reset() { *m = Query{} } +func (m *Query) String() string { return proto.CompactTextString(m) } +func (*Query) ProtoMessage() {} +func (*Query) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{3} +} +func (m *Query) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Query) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Query.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Query) XXX_Merge(src proto.Message) { + xxx_messageInfo_Query.Merge(dst, src) +} +func (m *Query) XXX_Size() int { + return m.Size() +} +func (m *Query) XXX_DiscardUnknown() { + xxx_messageInfo_Query.DiscardUnknown(m) +} + +var xxx_messageInfo_Query proto.InternalMessageInfo func (m *Query) GetAttr() string { if m != nil { @@ -404,10 +468,38 @@ type ValueList struct { Values []*TaskValue `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` } -func (m *ValueList) Reset() { *m = ValueList{} } -func (m *ValueList) String() string { return proto.CompactTextString(m) } -func (*ValueList) ProtoMessage() {} -func (*ValueList) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{4} } +func (m *ValueList) Reset() { *m = ValueList{} } +func (m *ValueList) String() string { return proto.CompactTextString(m) } +func (*ValueList) ProtoMessage() {} +func (*ValueList) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{4} +} +func (m *ValueList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValueList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValueList.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ValueList) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValueList.Merge(dst, src) +} +func (m *ValueList) XXX_Size() int { + return m.Size() +} +func (m *ValueList) XXX_DiscardUnknown() { + xxx_messageInfo_ValueList.DiscardUnknown(m) +} + +var xxx_messageInfo_ValueList proto.InternalMessageInfo func (m *ValueList) GetValues() []*TaskValue { if m != nil { @@ -420,10 +512,38 @@ type LangList struct { Lang []string `protobuf:"bytes,1,rep,name=lang" json:"lang,omitempty"` } -func (m *LangList) Reset() { *m = LangList{} } -func (m *LangList) String() string { return proto.CompactTextString(m) } -func (*LangList) ProtoMessage() {} -func (*LangList) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{5} } +func (m *LangList) Reset() { *m = LangList{} } +func (m *LangList) String() string { return proto.CompactTextString(m) } +func (*LangList) ProtoMessage() {} +func (*LangList) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{5} +} +func (m *LangList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LangList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LangList.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *LangList) XXX_Merge(src proto.Message) { + xxx_messageInfo_LangList.Merge(dst, src) +} +func (m *LangList) XXX_Size() int { + return m.Size() +} +func (m *LangList) XXX_DiscardUnknown() { + xxx_messageInfo_LangList.DiscardUnknown(m) +} + +var xxx_messageInfo_LangList proto.InternalMessageInfo func (m *LangList) GetLang() []string { if m != nil { @@ -442,10 +562,38 @@ type Result struct { List bool `protobuf:"varint,7,opt,name=list,proto3" json:"list,omitempty"` } -func (m *Result) Reset() { *m = Result{} } -func (m *Result) String() string { return proto.CompactTextString(m) } -func (*Result) ProtoMessage() {} -func (*Result) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{6} } +func (m *Result) Reset() { *m = Result{} } +func (m *Result) String() string { return proto.CompactTextString(m) } +func (*Result) ProtoMessage() {} +func (*Result) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{6} +} +func (m *Result) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Result.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Result) XXX_Merge(src proto.Message) { + xxx_messageInfo_Result.Merge(dst, src) +} +func (m *Result) XXX_Size() int { + return m.Size() +} +func (m *Result) XXX_DiscardUnknown() { + xxx_messageInfo_Result.DiscardUnknown(m) +} + +var xxx_messageInfo_Result proto.InternalMessageInfo func (m *Result) GetUidMatrix() []*List { if m != nil { @@ -502,10 +650,38 @@ type Order struct { Langs []string `protobuf:"bytes,3,rep,name=langs" json:"langs,omitempty"` } -func (m *Order) Reset() { *m = Order{} } -func (m *Order) String() string { return proto.CompactTextString(m) } -func (*Order) ProtoMessage() {} -func (*Order) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{7} } +func (m *Order) Reset() { *m = Order{} } +func (m *Order) String() string { return proto.CompactTextString(m) } +func (*Order) ProtoMessage() {} +func (*Order) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{7} +} +func (m *Order) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Order) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Order.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Order) XXX_Merge(src proto.Message) { + xxx_messageInfo_Order.Merge(dst, src) +} +func (m *Order) XXX_Size() int { + return m.Size() +} +func (m *Order) XXX_DiscardUnknown() { + xxx_messageInfo_Order.DiscardUnknown(m) +} + +var xxx_messageInfo_Order proto.InternalMessageInfo func (m *Order) GetAttr() string { if m != nil { @@ -536,10 +712,38 @@ type SortMessage struct { ReadTs uint64 `protobuf:"varint,13,opt,name=read_ts,json=readTs,proto3" json:"read_ts,omitempty"` } -func (m *SortMessage) Reset() { *m = SortMessage{} } -func (m *SortMessage) String() string { return proto.CompactTextString(m) } -func (*SortMessage) ProtoMessage() {} -func (*SortMessage) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{8} } +func (m *SortMessage) Reset() { *m = SortMessage{} } +func (m *SortMessage) String() string { return proto.CompactTextString(m) } +func (*SortMessage) ProtoMessage() {} +func (*SortMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{8} +} +func (m *SortMessage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SortMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SortMessage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SortMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_SortMessage.Merge(dst, src) +} +func (m *SortMessage) XXX_Size() int { + return m.Size() +} +func (m *SortMessage) XXX_DiscardUnknown() { + xxx_messageInfo_SortMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_SortMessage proto.InternalMessageInfo func (m *SortMessage) GetOrder() []*Order { if m != nil { @@ -580,10 +784,38 @@ type SortResult struct { UidMatrix []*List `protobuf:"bytes,1,rep,name=uid_matrix,json=uidMatrix" json:"uid_matrix,omitempty"` } -func (m *SortResult) Reset() { *m = SortResult{} } -func (m *SortResult) String() string { return proto.CompactTextString(m) } -func (*SortResult) ProtoMessage() {} -func (*SortResult) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{9} } +func (m *SortResult) Reset() { *m = SortResult{} } +func (m *SortResult) String() string { return proto.CompactTextString(m) } +func (*SortResult) ProtoMessage() {} +func (*SortResult) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{9} +} +func (m *SortResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SortResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SortResult.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SortResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_SortResult.Merge(dst, src) +} +func (m *SortResult) XXX_Size() int { + return m.Size() +} +func (m *SortResult) XXX_DiscardUnknown() { + xxx_messageInfo_SortResult.DiscardUnknown(m) +} + +var xxx_messageInfo_SortResult proto.InternalMessageInfo func (m *SortResult) GetUidMatrix() []*List { if m != nil { @@ -599,10 +831,38 @@ type RaftContext struct { SnapshotTs uint64 `protobuf:"varint,4,opt,name=snapshot_ts,json=snapshotTs,proto3" json:"snapshot_ts,omitempty"` } -func (m *RaftContext) Reset() { *m = RaftContext{} } -func (m *RaftContext) String() string { return proto.CompactTextString(m) } -func (*RaftContext) ProtoMessage() {} -func (*RaftContext) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{10} } +func (m *RaftContext) Reset() { *m = RaftContext{} } +func (m *RaftContext) String() string { return proto.CompactTextString(m) } +func (*RaftContext) ProtoMessage() {} +func (*RaftContext) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{10} +} +func (m *RaftContext) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RaftContext) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RaftContext.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *RaftContext) XXX_Merge(src proto.Message) { + xxx_messageInfo_RaftContext.Merge(dst, src) +} +func (m *RaftContext) XXX_Size() int { + return m.Size() +} +func (m *RaftContext) XXX_DiscardUnknown() { + xxx_messageInfo_RaftContext.DiscardUnknown(m) +} + +var xxx_messageInfo_RaftContext proto.InternalMessageInfo func (m *RaftContext) GetId() uint64 { if m != nil { @@ -645,10 +905,38 @@ type Member struct { ClusterInfoOnly bool `protobuf:"varint,13,opt,name=cluster_info_only,json=clusterInfoOnly,proto3" json:"cluster_info_only,omitempty"` } -func (m *Member) Reset() { *m = Member{} } -func (m *Member) String() string { return proto.CompactTextString(m) } -func (*Member) ProtoMessage() {} -func (*Member) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{11} } +func (m *Member) Reset() { *m = Member{} } +func (m *Member) String() string { return proto.CompactTextString(m) } +func (*Member) ProtoMessage() {} +func (*Member) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{11} +} +func (m *Member) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Member) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Member.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Member) XXX_Merge(src proto.Message) { + xxx_messageInfo_Member.Merge(dst, src) +} +func (m *Member) XXX_Size() int { + return m.Size() +} +func (m *Member) XXX_DiscardUnknown() { + xxx_messageInfo_Member.DiscardUnknown(m) +} + +var xxx_messageInfo_Member proto.InternalMessageInfo func (m *Member) GetId() uint64 { if m != nil { @@ -704,10 +992,38 @@ type Group struct { Tablets map[string]*Tablet `protobuf:"bytes,2,rep,name=tablets" json:"tablets,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"` } -func (m *Group) Reset() { *m = Group{} } -func (m *Group) String() string { return proto.CompactTextString(m) } -func (*Group) ProtoMessage() {} -func (*Group) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{12} } +func (m *Group) Reset() { *m = Group{} } +func (m *Group) String() string { return proto.CompactTextString(m) } +func (*Group) ProtoMessage() {} +func (*Group) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{12} +} +func (m *Group) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Group) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Group.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Group) XXX_Merge(src proto.Message) { + xxx_messageInfo_Group.Merge(dst, src) +} +func (m *Group) XXX_Size() int { + return m.Size() +} +func (m *Group) XXX_DiscardUnknown() { + xxx_messageInfo_Group.DiscardUnknown(m) +} + +var xxx_messageInfo_Group proto.InternalMessageInfo func (m *Group) GetMembers() map[uint64]*Member { if m != nil { @@ -734,10 +1050,38 @@ type ZeroProposal struct { Cid string `protobuf:"bytes,9,opt,name=cid,proto3" json:"cid,omitempty"` } -func (m *ZeroProposal) Reset() { *m = ZeroProposal{} } -func (m *ZeroProposal) String() string { return proto.CompactTextString(m) } -func (*ZeroProposal) ProtoMessage() {} -func (*ZeroProposal) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{13} } +func (m *ZeroProposal) Reset() { *m = ZeroProposal{} } +func (m *ZeroProposal) String() string { return proto.CompactTextString(m) } +func (*ZeroProposal) ProtoMessage() {} +func (*ZeroProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{13} +} +func (m *ZeroProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ZeroProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ZeroProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ZeroProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_ZeroProposal.Merge(dst, src) +} +func (m *ZeroProposal) XXX_Size() int { + return m.Size() +} +func (m *ZeroProposal) XXX_DiscardUnknown() { + xxx_messageInfo_ZeroProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_ZeroProposal proto.InternalMessageInfo func (m *ZeroProposal) GetMember() *Member { if m != nil { @@ -809,10 +1153,38 @@ type MembershipState struct { Cid string `protobuf:"bytes,8,opt,name=cid,proto3" json:"cid,omitempty"` } -func (m *MembershipState) Reset() { *m = MembershipState{} } -func (m *MembershipState) String() string { return proto.CompactTextString(m) } -func (*MembershipState) ProtoMessage() {} -func (*MembershipState) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{14} } +func (m *MembershipState) Reset() { *m = MembershipState{} } +func (m *MembershipState) String() string { return proto.CompactTextString(m) } +func (*MembershipState) ProtoMessage() {} +func (*MembershipState) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{14} +} +func (m *MembershipState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MembershipState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MembershipState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *MembershipState) XXX_Merge(src proto.Message) { + xxx_messageInfo_MembershipState.Merge(dst, src) +} +func (m *MembershipState) XXX_Size() int { + return m.Size() +} +func (m *MembershipState) XXX_DiscardUnknown() { + xxx_messageInfo_MembershipState.DiscardUnknown(m) +} + +var xxx_messageInfo_MembershipState proto.InternalMessageInfo func (m *MembershipState) GetCounter() uint64 { if m != nil { @@ -876,10 +1248,38 @@ type ConnectionState struct { MaxPending uint64 `protobuf:"varint,3,opt,name=max_pending,json=maxPending,proto3" json:"max_pending,omitempty"` } -func (m *ConnectionState) Reset() { *m = ConnectionState{} } -func (m *ConnectionState) String() string { return proto.CompactTextString(m) } -func (*ConnectionState) ProtoMessage() {} -func (*ConnectionState) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{15} } +func (m *ConnectionState) Reset() { *m = ConnectionState{} } +func (m *ConnectionState) String() string { return proto.CompactTextString(m) } +func (*ConnectionState) ProtoMessage() {} +func (*ConnectionState) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{15} +} +func (m *ConnectionState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConnectionState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConnectionState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ConnectionState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConnectionState.Merge(dst, src) +} +func (m *ConnectionState) XXX_Size() int { + return m.Size() +} +func (m *ConnectionState) XXX_DiscardUnknown() { + xxx_messageInfo_ConnectionState.DiscardUnknown(m) +} + +var xxx_messageInfo_ConnectionState proto.InternalMessageInfo func (m *ConnectionState) GetMember() *Member { if m != nil { @@ -911,10 +1311,38 @@ type Tablet struct { Remove bool `protobuf:"varint,8,opt,name=remove,proto3" json:"remove,omitempty"` } -func (m *Tablet) Reset() { *m = Tablet{} } -func (m *Tablet) String() string { return proto.CompactTextString(m) } -func (*Tablet) ProtoMessage() {} -func (*Tablet) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{16} } +func (m *Tablet) Reset() { *m = Tablet{} } +func (m *Tablet) String() string { return proto.CompactTextString(m) } +func (*Tablet) ProtoMessage() {} +func (*Tablet) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{16} +} +func (m *Tablet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Tablet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Tablet.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Tablet) XXX_Merge(src proto.Message) { + xxx_messageInfo_Tablet.Merge(dst, src) +} +func (m *Tablet) XXX_Size() int { + return m.Size() +} +func (m *Tablet) XXX_DiscardUnknown() { + xxx_messageInfo_Tablet.DiscardUnknown(m) +} + +var xxx_messageInfo_Tablet proto.InternalMessageInfo func (m *Tablet) GetGroupId() uint32 { if m != nil { @@ -962,18 +1390,46 @@ type DirectedEdge struct { Entity uint64 `protobuf:"fixed64,1,opt,name=entity,proto3" json:"entity,omitempty"` Attr string `protobuf:"bytes,2,opt,name=attr,proto3" json:"attr,omitempty"` Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` - ValueType Posting_ValType `protobuf:"varint,4,opt,name=value_type,json=valueType,proto3,enum=intern.Posting_ValType" json:"value_type,omitempty"` + ValueType Posting_ValType `protobuf:"varint,4,opt,name=value_type,json=valueType,proto3,enum=pb.Posting_ValType" json:"value_type,omitempty"` ValueId uint64 `protobuf:"fixed64,5,opt,name=value_id,json=valueId,proto3" json:"value_id,omitempty"` Label string `protobuf:"bytes,6,opt,name=label,proto3" json:"label,omitempty"` Lang string `protobuf:"bytes,7,opt,name=lang,proto3" json:"lang,omitempty"` - Op DirectedEdge_Op `protobuf:"varint,8,opt,name=op,proto3,enum=intern.DirectedEdge_Op" json:"op,omitempty"` + Op DirectedEdge_Op `protobuf:"varint,8,opt,name=op,proto3,enum=pb.DirectedEdge_Op" json:"op,omitempty"` Facets []*api.Facet `protobuf:"bytes,9,rep,name=facets" json:"facets,omitempty"` } -func (m *DirectedEdge) Reset() { *m = DirectedEdge{} } -func (m *DirectedEdge) String() string { return proto.CompactTextString(m) } -func (*DirectedEdge) ProtoMessage() {} -func (*DirectedEdge) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{17} } +func (m *DirectedEdge) Reset() { *m = DirectedEdge{} } +func (m *DirectedEdge) String() string { return proto.CompactTextString(m) } +func (*DirectedEdge) ProtoMessage() {} +func (*DirectedEdge) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{17} +} +func (m *DirectedEdge) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DirectedEdge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DirectedEdge.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *DirectedEdge) XXX_Merge(src proto.Message) { + xxx_messageInfo_DirectedEdge.Merge(dst, src) +} +func (m *DirectedEdge) XXX_Size() int { + return m.Size() +} +func (m *DirectedEdge) XXX_DiscardUnknown() { + xxx_messageInfo_DirectedEdge.DiscardUnknown(m) +} + +var xxx_messageInfo_DirectedEdge proto.InternalMessageInfo func (m *DirectedEdge) GetEntity() uint64 { if m != nil { @@ -1047,10 +1503,38 @@ type Mutations struct { IgnoreIndexConflict bool `protobuf:"varint,6,opt,name=ignore_index_conflict,json=ignoreIndexConflict,proto3" json:"ignore_index_conflict,omitempty"` } -func (m *Mutations) Reset() { *m = Mutations{} } -func (m *Mutations) String() string { return proto.CompactTextString(m) } -func (*Mutations) ProtoMessage() {} -func (*Mutations) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{18} } +func (m *Mutations) Reset() { *m = Mutations{} } +func (m *Mutations) String() string { return proto.CompactTextString(m) } +func (*Mutations) ProtoMessage() {} +func (*Mutations) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{18} +} +func (m *Mutations) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Mutations) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Mutations.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Mutations) XXX_Merge(src proto.Message) { + xxx_messageInfo_Mutations.Merge(dst, src) +} +func (m *Mutations) XXX_Size() int { + return m.Size() +} +func (m *Mutations) XXX_DiscardUnknown() { + xxx_messageInfo_Mutations.DiscardUnknown(m) +} + +var xxx_messageInfo_Mutations proto.InternalMessageInfo func (m *Mutations) GetGroupId() uint32 { if m != nil { @@ -1098,10 +1582,38 @@ type KeyValues struct { Kv []*KV `protobuf:"bytes,1,rep,name=kv" json:"kv,omitempty"` } -func (m *KeyValues) Reset() { *m = KeyValues{} } -func (m *KeyValues) String() string { return proto.CompactTextString(m) } -func (*KeyValues) ProtoMessage() {} -func (*KeyValues) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{19} } +func (m *KeyValues) Reset() { *m = KeyValues{} } +func (m *KeyValues) String() string { return proto.CompactTextString(m) } +func (*KeyValues) ProtoMessage() {} +func (*KeyValues) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{19} +} +func (m *KeyValues) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *KeyValues) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_KeyValues.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *KeyValues) XXX_Merge(src proto.Message) { + xxx_messageInfo_KeyValues.Merge(dst, src) +} +func (m *KeyValues) XXX_Size() int { + return m.Size() +} +func (m *KeyValues) XXX_DiscardUnknown() { + xxx_messageInfo_KeyValues.DiscardUnknown(m) +} + +var xxx_messageInfo_KeyValues proto.InternalMessageInfo func (m *KeyValues) GetKv() []*KV { if m != nil { @@ -1116,10 +1628,38 @@ type Snapshot struct { ReadTs uint64 `protobuf:"varint,3,opt,name=read_ts,json=readTs,proto3" json:"read_ts,omitempty"` } -func (m *Snapshot) Reset() { *m = Snapshot{} } -func (m *Snapshot) String() string { return proto.CompactTextString(m) } -func (*Snapshot) ProtoMessage() {} -func (*Snapshot) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{20} } +func (m *Snapshot) Reset() { *m = Snapshot{} } +func (m *Snapshot) String() string { return proto.CompactTextString(m) } +func (*Snapshot) ProtoMessage() {} +func (*Snapshot) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{20} +} +func (m *Snapshot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Snapshot.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Snapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_Snapshot.Merge(dst, src) +} +func (m *Snapshot) XXX_Size() int { + return m.Size() +} +func (m *Snapshot) XXX_DiscardUnknown() { + xxx_messageInfo_Snapshot.DiscardUnknown(m) +} + +var xxx_messageInfo_Snapshot proto.InternalMessageInfo func (m *Snapshot) GetContext() *RaftContext { if m != nil { @@ -1152,10 +1692,38 @@ type Proposal struct { Snapshot *Snapshot `protobuf:"bytes,9,opt,name=snapshot" json:"snapshot,omitempty"` } -func (m *Proposal) Reset() { *m = Proposal{} } -func (m *Proposal) String() string { return proto.CompactTextString(m) } -func (*Proposal) ProtoMessage() {} -func (*Proposal) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{21} } +func (m *Proposal) Reset() { *m = Proposal{} } +func (m *Proposal) String() string { return proto.CompactTextString(m) } +func (*Proposal) ProtoMessage() {} +func (*Proposal) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{21} +} +func (m *Proposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Proposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Proposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Proposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_Proposal.Merge(dst, src) +} +func (m *Proposal) XXX_Size() int { + return m.Size() +} +func (m *Proposal) XXX_DiscardUnknown() { + xxx_messageInfo_Proposal.DiscardUnknown(m) +} + +var xxx_messageInfo_Proposal proto.InternalMessageInfo func (m *Proposal) GetMutations() *Mutations { if m != nil { @@ -1210,10 +1778,38 @@ type KVS struct { Kv []*KV `protobuf:"bytes,1,rep,name=kv" json:"kv,omitempty"` } -func (m *KVS) Reset() { *m = KVS{} } -func (m *KVS) String() string { return proto.CompactTextString(m) } -func (*KVS) ProtoMessage() {} -func (*KVS) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{22} } +func (m *KVS) Reset() { *m = KVS{} } +func (m *KVS) String() string { return proto.CompactTextString(m) } +func (*KVS) ProtoMessage() {} +func (*KVS) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{22} +} +func (m *KVS) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *KVS) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_KVS.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *KVS) XXX_Merge(src proto.Message) { + xxx_messageInfo_KVS.Merge(dst, src) +} +func (m *KVS) XXX_Size() int { + return m.Size() +} +func (m *KVS) XXX_DiscardUnknown() { + xxx_messageInfo_KVS.DiscardUnknown(m) +} + +var xxx_messageInfo_KVS proto.InternalMessageInfo func (m *KVS) GetKv() []*KV { if m != nil { @@ -1229,10 +1825,38 @@ type KV struct { Version uint64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` } -func (m *KV) Reset() { *m = KV{} } -func (m *KV) String() string { return proto.CompactTextString(m) } -func (*KV) ProtoMessage() {} -func (*KV) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{23} } +func (m *KV) Reset() { *m = KV{} } +func (m *KV) String() string { return proto.CompactTextString(m) } +func (*KV) ProtoMessage() {} +func (*KV) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{23} +} +func (m *KV) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *KV) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_KV.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *KV) XXX_Merge(src proto.Message) { + xxx_messageInfo_KV.Merge(dst, src) +} +func (m *KV) XXX_Size() int { + return m.Size() +} +func (m *KV) XXX_DiscardUnknown() { + xxx_messageInfo_KV.DiscardUnknown(m) +} + +var xxx_messageInfo_KV proto.InternalMessageInfo func (m *KV) GetKey() []byte { if m != nil { @@ -1266,8 +1890,8 @@ func (m *KV) GetVersion() uint64 { type Posting struct { Uid uint64 `protobuf:"fixed64,1,opt,name=uid,proto3" json:"uid,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - ValType Posting_ValType `protobuf:"varint,3,opt,name=val_type,json=valType,proto3,enum=intern.Posting_ValType" json:"val_type,omitempty"` - PostingType Posting_PostingType `protobuf:"varint,4,opt,name=posting_type,json=postingType,proto3,enum=intern.Posting_PostingType" json:"posting_type,omitempty"` + ValType Posting_ValType `protobuf:"varint,3,opt,name=val_type,json=valType,proto3,enum=pb.Posting_ValType" json:"val_type,omitempty"` + PostingType Posting_PostingType `protobuf:"varint,4,opt,name=posting_type,json=postingType,proto3,enum=pb.Posting_PostingType" json:"posting_type,omitempty"` LangTag []byte `protobuf:"bytes,5,opt,name=lang_tag,json=langTag,proto3" json:"lang_tag,omitempty"` Label string `protobuf:"bytes,6,opt,name=label,proto3" json:"label,omitempty"` Facets []*api.Facet `protobuf:"bytes,9,rep,name=facets" json:"facets,omitempty"` @@ -1277,10 +1901,38 @@ type Posting struct { CommitTs uint64 `protobuf:"varint,14,opt,name=commit_ts,json=commitTs,proto3" json:"commit_ts,omitempty"` } -func (m *Posting) Reset() { *m = Posting{} } -func (m *Posting) String() string { return proto.CompactTextString(m) } -func (*Posting) ProtoMessage() {} -func (*Posting) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{24} } +func (m *Posting) Reset() { *m = Posting{} } +func (m *Posting) String() string { return proto.CompactTextString(m) } +func (*Posting) ProtoMessage() {} +func (*Posting) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{24} +} +func (m *Posting) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Posting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Posting.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Posting) XXX_Merge(src proto.Message) { + xxx_messageInfo_Posting.Merge(dst, src) +} +func (m *Posting) XXX_Size() int { + return m.Size() +} +func (m *Posting) XXX_DiscardUnknown() { + xxx_messageInfo_Posting.DiscardUnknown(m) +} + +var xxx_messageInfo_Posting proto.InternalMessageInfo func (m *Posting) GetUid() uint64 { if m != nil { @@ -1359,10 +2011,38 @@ type PostingList struct { Uids []byte `protobuf:"bytes,4,opt,name=uids,proto3" json:"uids,omitempty"` } -func (m *PostingList) Reset() { *m = PostingList{} } -func (m *PostingList) String() string { return proto.CompactTextString(m) } -func (*PostingList) ProtoMessage() {} -func (*PostingList) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{25} } +func (m *PostingList) Reset() { *m = PostingList{} } +func (m *PostingList) String() string { return proto.CompactTextString(m) } +func (*PostingList) ProtoMessage() {} +func (*PostingList) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{25} +} +func (m *PostingList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PostingList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PostingList.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *PostingList) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostingList.Merge(dst, src) +} +func (m *PostingList) XXX_Size() int { + return m.Size() +} +func (m *PostingList) XXX_DiscardUnknown() { + xxx_messageInfo_PostingList.DiscardUnknown(m) +} + +var xxx_messageInfo_PostingList proto.InternalMessageInfo func (m *PostingList) GetPostings() []*Posting { if m != nil { @@ -1389,18 +2069,46 @@ func (m *PostingList) GetUids() []byte { if m != nil { return m.Uids } - return nil + return nil +} + +type FacetParam struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Alias string `protobuf:"bytes,2,opt,name=alias,proto3" json:"alias,omitempty"` +} + +func (m *FacetParam) Reset() { *m = FacetParam{} } +func (m *FacetParam) String() string { return proto.CompactTextString(m) } +func (*FacetParam) ProtoMessage() {} +func (*FacetParam) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{26} +} +func (m *FacetParam) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FacetParam) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FacetParam.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } - -type FacetParam struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Alias string `protobuf:"bytes,2,opt,name=alias,proto3" json:"alias,omitempty"` +func (dst *FacetParam) XXX_Merge(src proto.Message) { + xxx_messageInfo_FacetParam.Merge(dst, src) +} +func (m *FacetParam) XXX_Size() int { + return m.Size() +} +func (m *FacetParam) XXX_DiscardUnknown() { + xxx_messageInfo_FacetParam.DiscardUnknown(m) } -func (m *FacetParam) Reset() { *m = FacetParam{} } -func (m *FacetParam) String() string { return proto.CompactTextString(m) } -func (*FacetParam) ProtoMessage() {} -func (*FacetParam) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{26} } +var xxx_messageInfo_FacetParam proto.InternalMessageInfo func (m *FacetParam) GetKey() string { if m != nil { @@ -1421,10 +2129,38 @@ type FacetParams struct { Param []*FacetParam `protobuf:"bytes,2,rep,name=param" json:"param,omitempty"` } -func (m *FacetParams) Reset() { *m = FacetParams{} } -func (m *FacetParams) String() string { return proto.CompactTextString(m) } -func (*FacetParams) ProtoMessage() {} -func (*FacetParams) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{27} } +func (m *FacetParams) Reset() { *m = FacetParams{} } +func (m *FacetParams) String() string { return proto.CompactTextString(m) } +func (*FacetParams) ProtoMessage() {} +func (*FacetParams) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{27} +} +func (m *FacetParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FacetParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FacetParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *FacetParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_FacetParams.Merge(dst, src) +} +func (m *FacetParams) XXX_Size() int { + return m.Size() +} +func (m *FacetParams) XXX_DiscardUnknown() { + xxx_messageInfo_FacetParams.DiscardUnknown(m) +} + +var xxx_messageInfo_FacetParams proto.InternalMessageInfo func (m *FacetParams) GetAllKeys() bool { if m != nil { @@ -1444,10 +2180,38 @@ type Facets struct { Facets []*api.Facet `protobuf:"bytes,1,rep,name=facets" json:"facets,omitempty"` } -func (m *Facets) Reset() { *m = Facets{} } -func (m *Facets) String() string { return proto.CompactTextString(m) } -func (*Facets) ProtoMessage() {} -func (*Facets) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{28} } +func (m *Facets) Reset() { *m = Facets{} } +func (m *Facets) String() string { return proto.CompactTextString(m) } +func (*Facets) ProtoMessage() {} +func (*Facets) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{28} +} +func (m *Facets) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Facets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Facets.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Facets) XXX_Merge(src proto.Message) { + xxx_messageInfo_Facets.Merge(dst, src) +} +func (m *Facets) XXX_Size() int { + return m.Size() +} +func (m *Facets) XXX_DiscardUnknown() { + xxx_messageInfo_Facets.DiscardUnknown(m) +} + +var xxx_messageInfo_Facets proto.InternalMessageInfo func (m *Facets) GetFacets() []*api.Facet { if m != nil { @@ -1460,10 +2224,38 @@ type FacetsList struct { FacetsList []*Facets `protobuf:"bytes,1,rep,name=facets_list,json=facetsList" json:"facets_list,omitempty"` } -func (m *FacetsList) Reset() { *m = FacetsList{} } -func (m *FacetsList) String() string { return proto.CompactTextString(m) } -func (*FacetsList) ProtoMessage() {} -func (*FacetsList) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{29} } +func (m *FacetsList) Reset() { *m = FacetsList{} } +func (m *FacetsList) String() string { return proto.CompactTextString(m) } +func (*FacetsList) ProtoMessage() {} +func (*FacetsList) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{29} +} +func (m *FacetsList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FacetsList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FacetsList.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *FacetsList) XXX_Merge(src proto.Message) { + xxx_messageInfo_FacetsList.Merge(dst, src) +} +func (m *FacetsList) XXX_Size() int { + return m.Size() +} +func (m *FacetsList) XXX_DiscardUnknown() { + xxx_messageInfo_FacetsList.DiscardUnknown(m) +} + +var xxx_messageInfo_FacetsList proto.InternalMessageInfo func (m *FacetsList) GetFacetsList() []*Facets { if m != nil { @@ -1478,10 +2270,38 @@ type Function struct { Args []string `protobuf:"bytes,3,rep,name=args" json:"args,omitempty"` } -func (m *Function) Reset() { *m = Function{} } -func (m *Function) String() string { return proto.CompactTextString(m) } -func (*Function) ProtoMessage() {} -func (*Function) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{30} } +func (m *Function) Reset() { *m = Function{} } +func (m *Function) String() string { return proto.CompactTextString(m) } +func (*Function) ProtoMessage() {} +func (*Function) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{30} +} +func (m *Function) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Function) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Function.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Function) XXX_Merge(src proto.Message) { + xxx_messageInfo_Function.Merge(dst, src) +} +func (m *Function) XXX_Size() int { + return m.Size() +} +func (m *Function) XXX_DiscardUnknown() { + xxx_messageInfo_Function.DiscardUnknown(m) +} + +var xxx_messageInfo_Function proto.InternalMessageInfo func (m *Function) GetName() string { if m != nil { @@ -1511,10 +2331,38 @@ type FilterTree struct { Func *Function `protobuf:"bytes,3,opt,name=func" json:"func,omitempty"` } -func (m *FilterTree) Reset() { *m = FilterTree{} } -func (m *FilterTree) String() string { return proto.CompactTextString(m) } -func (*FilterTree) ProtoMessage() {} -func (*FilterTree) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{31} } +func (m *FilterTree) Reset() { *m = FilterTree{} } +func (m *FilterTree) String() string { return proto.CompactTextString(m) } +func (*FilterTree) ProtoMessage() {} +func (*FilterTree) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{31} +} +func (m *FilterTree) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FilterTree) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FilterTree.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *FilterTree) XXX_Merge(src proto.Message) { + xxx_messageInfo_FilterTree.Merge(dst, src) +} +func (m *FilterTree) XXX_Size() int { + return m.Size() +} +func (m *FilterTree) XXX_DiscardUnknown() { + xxx_messageInfo_FilterTree.DiscardUnknown(m) +} + +var xxx_messageInfo_FilterTree proto.InternalMessageInfo func (m *FilterTree) GetOp() string { if m != nil { @@ -1545,10 +2393,38 @@ type SchemaRequest struct { Fields []string `protobuf:"bytes,3,rep,name=fields" json:"fields,omitempty"` } -func (m *SchemaRequest) Reset() { *m = SchemaRequest{} } -func (m *SchemaRequest) String() string { return proto.CompactTextString(m) } -func (*SchemaRequest) ProtoMessage() {} -func (*SchemaRequest) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{32} } +func (m *SchemaRequest) Reset() { *m = SchemaRequest{} } +func (m *SchemaRequest) String() string { return proto.CompactTextString(m) } +func (*SchemaRequest) ProtoMessage() {} +func (*SchemaRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{32} +} +func (m *SchemaRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SchemaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SchemaRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SchemaRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SchemaRequest.Merge(dst, src) +} +func (m *SchemaRequest) XXX_Size() int { + return m.Size() +} +func (m *SchemaRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SchemaRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SchemaRequest proto.InternalMessageInfo func (m *SchemaRequest) GetGroupId() uint32 { if m != nil { @@ -1575,10 +2451,38 @@ type SchemaResult struct { Schema []*api.SchemaNode `protobuf:"bytes,1,rep,name=schema" json:"schema,omitempty"` } -func (m *SchemaResult) Reset() { *m = SchemaResult{} } -func (m *SchemaResult) String() string { return proto.CompactTextString(m) } -func (*SchemaResult) ProtoMessage() {} -func (*SchemaResult) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{33} } +func (m *SchemaResult) Reset() { *m = SchemaResult{} } +func (m *SchemaResult) String() string { return proto.CompactTextString(m) } +func (*SchemaResult) ProtoMessage() {} +func (*SchemaResult) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{33} +} +func (m *SchemaResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SchemaResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SchemaResult.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SchemaResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_SchemaResult.Merge(dst, src) +} +func (m *SchemaResult) XXX_Size() int { + return m.Size() +} +func (m *SchemaResult) XXX_DiscardUnknown() { + xxx_messageInfo_SchemaResult.DiscardUnknown(m) +} + +var xxx_messageInfo_SchemaResult proto.InternalMessageInfo func (m *SchemaResult) GetSchema() []*api.SchemaNode { if m != nil { @@ -1589,8 +2493,8 @@ func (m *SchemaResult) GetSchema() []*api.SchemaNode { type SchemaUpdate struct { Predicate string `protobuf:"bytes,1,opt,name=predicate,proto3" json:"predicate,omitempty"` - ValueType Posting_ValType `protobuf:"varint,2,opt,name=value_type,json=valueType,proto3,enum=intern.Posting_ValType" json:"value_type,omitempty"` - Directive SchemaUpdate_Directive `protobuf:"varint,3,opt,name=directive,proto3,enum=intern.SchemaUpdate_Directive" json:"directive,omitempty"` + ValueType Posting_ValType `protobuf:"varint,2,opt,name=value_type,json=valueType,proto3,enum=pb.Posting_ValType" json:"value_type,omitempty"` + Directive SchemaUpdate_Directive `protobuf:"varint,3,opt,name=directive,proto3,enum=pb.SchemaUpdate_Directive" json:"directive,omitempty"` Tokenizer []string `protobuf:"bytes,4,rep,name=tokenizer" json:"tokenizer,omitempty"` Count bool `protobuf:"varint,5,opt,name=count,proto3" json:"count,omitempty"` List bool `protobuf:"varint,6,opt,name=list,proto3" json:"list,omitempty"` @@ -1598,10 +2502,38 @@ type SchemaUpdate struct { Lang bool `protobuf:"varint,9,opt,name=lang,proto3" json:"lang,omitempty"` } -func (m *SchemaUpdate) Reset() { *m = SchemaUpdate{} } -func (m *SchemaUpdate) String() string { return proto.CompactTextString(m) } -func (*SchemaUpdate) ProtoMessage() {} -func (*SchemaUpdate) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{34} } +func (m *SchemaUpdate) Reset() { *m = SchemaUpdate{} } +func (m *SchemaUpdate) String() string { return proto.CompactTextString(m) } +func (*SchemaUpdate) ProtoMessage() {} +func (*SchemaUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{34} +} +func (m *SchemaUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SchemaUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SchemaUpdate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SchemaUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_SchemaUpdate.Merge(dst, src) +} +func (m *SchemaUpdate) XXX_Size() int { + return m.Size() +} +func (m *SchemaUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_SchemaUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_SchemaUpdate proto.InternalMessageInfo func (m *SchemaUpdate) GetPredicate() string { if m != nil { @@ -1667,10 +2599,38 @@ type MapEntry struct { Posting *Posting `protobuf:"bytes,3,opt,name=posting" json:"posting,omitempty"` } -func (m *MapEntry) Reset() { *m = MapEntry{} } -func (m *MapEntry) String() string { return proto.CompactTextString(m) } -func (*MapEntry) ProtoMessage() {} -func (*MapEntry) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{35} } +func (m *MapEntry) Reset() { *m = MapEntry{} } +func (m *MapEntry) String() string { return proto.CompactTextString(m) } +func (*MapEntry) ProtoMessage() {} +func (*MapEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{35} +} +func (m *MapEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MapEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MapEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *MapEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_MapEntry.Merge(dst, src) +} +func (m *MapEntry) XXX_Size() int { + return m.Size() +} +func (m *MapEntry) XXX_DiscardUnknown() { + xxx_messageInfo_MapEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_MapEntry proto.InternalMessageInfo func (m *MapEntry) GetKey() []byte { if m != nil { @@ -1700,10 +2660,38 @@ type MovePredicatePayload struct { State *MembershipState `protobuf:"bytes,4,opt,name=state" json:"state,omitempty"` } -func (m *MovePredicatePayload) Reset() { *m = MovePredicatePayload{} } -func (m *MovePredicatePayload) String() string { return proto.CompactTextString(m) } -func (*MovePredicatePayload) ProtoMessage() {} -func (*MovePredicatePayload) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{36} } +func (m *MovePredicatePayload) Reset() { *m = MovePredicatePayload{} } +func (m *MovePredicatePayload) String() string { return proto.CompactTextString(m) } +func (*MovePredicatePayload) ProtoMessage() {} +func (*MovePredicatePayload) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{36} +} +func (m *MovePredicatePayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MovePredicatePayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MovePredicatePayload.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *MovePredicatePayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_MovePredicatePayload.Merge(dst, src) +} +func (m *MovePredicatePayload) XXX_Size() int { + return m.Size() +} +func (m *MovePredicatePayload) XXX_DiscardUnknown() { + xxx_messageInfo_MovePredicatePayload.DiscardUnknown(m) +} + +var xxx_messageInfo_MovePredicatePayload proto.InternalMessageInfo func (m *MovePredicatePayload) GetPredicate() string { if m != nil { @@ -1739,14 +2727,42 @@ func (m *MovePredicatePayload) GetState() *MembershipState { type ExportPayload struct { ReqId uint64 `protobuf:"varint,1,opt,name=req_id,json=reqId,proto3" json:"req_id,omitempty"` GroupId uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` - Status ExportPayload_Status `protobuf:"varint,3,opt,name=status,proto3,enum=intern.ExportPayload_Status" json:"status,omitempty"` + Status ExportPayload_Status `protobuf:"varint,3,opt,name=status,proto3,enum=pb.ExportPayload_Status" json:"status,omitempty"` ReadTs uint64 `protobuf:"varint,4,opt,name=read_ts,json=readTs,proto3" json:"read_ts,omitempty"` } -func (m *ExportPayload) Reset() { *m = ExportPayload{} } -func (m *ExportPayload) String() string { return proto.CompactTextString(m) } -func (*ExportPayload) ProtoMessage() {} -func (*ExportPayload) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{37} } +func (m *ExportPayload) Reset() { *m = ExportPayload{} } +func (m *ExportPayload) String() string { return proto.CompactTextString(m) } +func (*ExportPayload) ProtoMessage() {} +func (*ExportPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{37} +} +func (m *ExportPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExportPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExportPayload.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ExportPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExportPayload.Merge(dst, src) +} +func (m *ExportPayload) XXX_Size() int { + return m.Size() +} +func (m *ExportPayload) XXX_DiscardUnknown() { + xxx_messageInfo_ExportPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_ExportPayload proto.InternalMessageInfo func (m *ExportPayload) GetReqId() uint64 { if m != nil { @@ -1781,10 +2797,38 @@ type TxnStatus struct { CommitTs uint64 `protobuf:"varint,2,opt,name=commit_ts,json=commitTs,proto3" json:"commit_ts,omitempty"` } -func (m *TxnStatus) Reset() { *m = TxnStatus{} } -func (m *TxnStatus) String() string { return proto.CompactTextString(m) } -func (*TxnStatus) ProtoMessage() {} -func (*TxnStatus) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{38} } +func (m *TxnStatus) Reset() { *m = TxnStatus{} } +func (m *TxnStatus) String() string { return proto.CompactTextString(m) } +func (*TxnStatus) ProtoMessage() {} +func (*TxnStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{38} +} +func (m *TxnStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxnStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxnStatus.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *TxnStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxnStatus.Merge(dst, src) +} +func (m *TxnStatus) XXX_Size() int { + return m.Size() +} +func (m *TxnStatus) XXX_DiscardUnknown() { + xxx_messageInfo_TxnStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_TxnStatus proto.InternalMessageInfo func (m *TxnStatus) GetStartTs() uint64 { if m != nil { @@ -1805,10 +2849,38 @@ type OracleDelta struct { MaxAssigned uint64 `protobuf:"varint,2,opt,name=max_assigned,json=maxAssigned,proto3" json:"max_assigned,omitempty"` } -func (m *OracleDelta) Reset() { *m = OracleDelta{} } -func (m *OracleDelta) String() string { return proto.CompactTextString(m) } -func (*OracleDelta) ProtoMessage() {} -func (*OracleDelta) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{39} } +func (m *OracleDelta) Reset() { *m = OracleDelta{} } +func (m *OracleDelta) String() string { return proto.CompactTextString(m) } +func (*OracleDelta) ProtoMessage() {} +func (*OracleDelta) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{39} +} +func (m *OracleDelta) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleDelta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleDelta.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *OracleDelta) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleDelta.Merge(dst, src) +} +func (m *OracleDelta) XXX_Size() int { + return m.Size() +} +func (m *OracleDelta) XXX_DiscardUnknown() { + xxx_messageInfo_OracleDelta.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleDelta proto.InternalMessageInfo func (m *OracleDelta) GetTxns() []*TxnStatus { if m != nil { @@ -1828,10 +2900,38 @@ type TxnTimestamps struct { Ts []uint64 `protobuf:"varint,1,rep,packed,name=ts" json:"ts,omitempty"` } -func (m *TxnTimestamps) Reset() { *m = TxnTimestamps{} } -func (m *TxnTimestamps) String() string { return proto.CompactTextString(m) } -func (*TxnTimestamps) ProtoMessage() {} -func (*TxnTimestamps) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{40} } +func (m *TxnTimestamps) Reset() { *m = TxnTimestamps{} } +func (m *TxnTimestamps) String() string { return proto.CompactTextString(m) } +func (*TxnTimestamps) ProtoMessage() {} +func (*TxnTimestamps) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{40} +} +func (m *TxnTimestamps) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxnTimestamps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxnTimestamps.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *TxnTimestamps) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxnTimestamps.Merge(dst, src) +} +func (m *TxnTimestamps) XXX_Size() int { + return m.Size() +} +func (m *TxnTimestamps) XXX_DiscardUnknown() { + xxx_messageInfo_TxnTimestamps.DiscardUnknown(m) +} + +var xxx_messageInfo_TxnTimestamps proto.InternalMessageInfo func (m *TxnTimestamps) GetTs() []uint64 { if m != nil { @@ -1844,10 +2944,38 @@ type PeerResponse struct { Status bool `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` } -func (m *PeerResponse) Reset() { *m = PeerResponse{} } -func (m *PeerResponse) String() string { return proto.CompactTextString(m) } -func (*PeerResponse) ProtoMessage() {} -func (*PeerResponse) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{41} } +func (m *PeerResponse) Reset() { *m = PeerResponse{} } +func (m *PeerResponse) String() string { return proto.CompactTextString(m) } +func (*PeerResponse) ProtoMessage() {} +func (*PeerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{41} +} +func (m *PeerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PeerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PeerResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *PeerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PeerResponse.Merge(dst, src) +} +func (m *PeerResponse) XXX_Size() int { + return m.Size() +} +func (m *PeerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PeerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PeerResponse proto.InternalMessageInfo func (m *PeerResponse) GetStatus() bool { if m != nil { @@ -1861,10 +2989,38 @@ type RaftBatch struct { Payload *api.Payload `protobuf:"bytes,2,opt,name=payload" json:"payload,omitempty"` } -func (m *RaftBatch) Reset() { *m = RaftBatch{} } -func (m *RaftBatch) String() string { return proto.CompactTextString(m) } -func (*RaftBatch) ProtoMessage() {} -func (*RaftBatch) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{42} } +func (m *RaftBatch) Reset() { *m = RaftBatch{} } +func (m *RaftBatch) String() string { return proto.CompactTextString(m) } +func (*RaftBatch) ProtoMessage() {} +func (*RaftBatch) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{42} +} +func (m *RaftBatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RaftBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RaftBatch.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *RaftBatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_RaftBatch.Merge(dst, src) +} +func (m *RaftBatch) XXX_Size() int { + return m.Size() +} +func (m *RaftBatch) XXX_DiscardUnknown() { + xxx_messageInfo_RaftBatch.DiscardUnknown(m) +} + +var xxx_messageInfo_RaftBatch proto.InternalMessageInfo func (m *RaftBatch) GetContext() *RaftContext { if m != nil { @@ -1885,10 +3041,38 @@ type Num struct { ReadOnly bool `protobuf:"varint,2,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` } -func (m *Num) Reset() { *m = Num{} } -func (m *Num) String() string { return proto.CompactTextString(m) } -func (*Num) ProtoMessage() {} -func (*Num) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{43} } +func (m *Num) Reset() { *m = Num{} } +func (m *Num) String() string { return proto.CompactTextString(m) } +func (*Num) ProtoMessage() {} +func (*Num) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{43} +} +func (m *Num) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Num) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Num.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Num) XXX_Merge(src proto.Message) { + xxx_messageInfo_Num.Merge(dst, src) +} +func (m *Num) XXX_Size() int { + return m.Size() +} +func (m *Num) XXX_DiscardUnknown() { + xxx_messageInfo_Num.DiscardUnknown(m) +} + +var xxx_messageInfo_Num proto.InternalMessageInfo func (m *Num) GetVal() uint64 { if m != nil { @@ -1911,10 +3095,38 @@ type AssignedIds struct { ReadOnly uint64 `protobuf:"varint,5,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` } -func (m *AssignedIds) Reset() { *m = AssignedIds{} } -func (m *AssignedIds) String() string { return proto.CompactTextString(m) } -func (*AssignedIds) ProtoMessage() {} -func (*AssignedIds) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{44} } +func (m *AssignedIds) Reset() { *m = AssignedIds{} } +func (m *AssignedIds) String() string { return proto.CompactTextString(m) } +func (*AssignedIds) ProtoMessage() {} +func (*AssignedIds) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{44} +} +func (m *AssignedIds) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssignedIds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssignedIds.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *AssignedIds) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssignedIds.Merge(dst, src) +} +func (m *AssignedIds) XXX_Size() int { + return m.Size() +} +func (m *AssignedIds) XXX_DiscardUnknown() { + xxx_messageInfo_AssignedIds.DiscardUnknown(m) +} + +var xxx_messageInfo_AssignedIds proto.InternalMessageInfo func (m *AssignedIds) GetStartId() uint64 { if m != nil { @@ -1942,10 +3154,38 @@ type SnapshotMeta struct { GroupId uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` } -func (m *SnapshotMeta) Reset() { *m = SnapshotMeta{} } -func (m *SnapshotMeta) String() string { return proto.CompactTextString(m) } -func (*SnapshotMeta) ProtoMessage() {} -func (*SnapshotMeta) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{45} } +func (m *SnapshotMeta) Reset() { *m = SnapshotMeta{} } +func (m *SnapshotMeta) String() string { return proto.CompactTextString(m) } +func (*SnapshotMeta) ProtoMessage() {} +func (*SnapshotMeta) Descriptor() ([]byte, []int) { + return fileDescriptor_pb_03862279bc4bb7c1, []int{45} +} +func (m *SnapshotMeta) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotMeta.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SnapshotMeta) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotMeta.Merge(dst, src) +} +func (m *SnapshotMeta) XXX_Size() int { + return m.Size() +} +func (m *SnapshotMeta) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotMeta.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotMeta proto.InternalMessageInfo func (m *SnapshotMeta) GetClientTs() uint64 { if m != nil { @@ -1962,57 +3202,61 @@ func (m *SnapshotMeta) GetGroupId() uint32 { } func init() { - proto.RegisterType((*List)(nil), "intern.List") - proto.RegisterType((*TaskValue)(nil), "intern.TaskValue") - proto.RegisterType((*SrcFunction)(nil), "intern.SrcFunction") - proto.RegisterType((*Query)(nil), "intern.Query") - proto.RegisterType((*ValueList)(nil), "intern.ValueList") - proto.RegisterType((*LangList)(nil), "intern.LangList") - proto.RegisterType((*Result)(nil), "intern.Result") - proto.RegisterType((*Order)(nil), "intern.Order") - proto.RegisterType((*SortMessage)(nil), "intern.SortMessage") - proto.RegisterType((*SortResult)(nil), "intern.SortResult") - proto.RegisterType((*RaftContext)(nil), "intern.RaftContext") - proto.RegisterType((*Member)(nil), "intern.Member") - proto.RegisterType((*Group)(nil), "intern.Group") - proto.RegisterType((*ZeroProposal)(nil), "intern.ZeroProposal") - proto.RegisterType((*MembershipState)(nil), "intern.MembershipState") - proto.RegisterType((*ConnectionState)(nil), "intern.ConnectionState") - proto.RegisterType((*Tablet)(nil), "intern.Tablet") - proto.RegisterType((*DirectedEdge)(nil), "intern.DirectedEdge") - proto.RegisterType((*Mutations)(nil), "intern.Mutations") - proto.RegisterType((*KeyValues)(nil), "intern.KeyValues") - proto.RegisterType((*Snapshot)(nil), "intern.Snapshot") - proto.RegisterType((*Proposal)(nil), "intern.Proposal") - proto.RegisterType((*KVS)(nil), "intern.KVS") - proto.RegisterType((*KV)(nil), "intern.KV") - proto.RegisterType((*Posting)(nil), "intern.Posting") - proto.RegisterType((*PostingList)(nil), "intern.PostingList") - proto.RegisterType((*FacetParam)(nil), "intern.FacetParam") - proto.RegisterType((*FacetParams)(nil), "intern.FacetParams") - proto.RegisterType((*Facets)(nil), "intern.Facets") - proto.RegisterType((*FacetsList)(nil), "intern.FacetsList") - proto.RegisterType((*Function)(nil), "intern.Function") - proto.RegisterType((*FilterTree)(nil), "intern.FilterTree") - proto.RegisterType((*SchemaRequest)(nil), "intern.SchemaRequest") - proto.RegisterType((*SchemaResult)(nil), "intern.SchemaResult") - proto.RegisterType((*SchemaUpdate)(nil), "intern.SchemaUpdate") - proto.RegisterType((*MapEntry)(nil), "intern.MapEntry") - proto.RegisterType((*MovePredicatePayload)(nil), "intern.MovePredicatePayload") - proto.RegisterType((*ExportPayload)(nil), "intern.ExportPayload") - proto.RegisterType((*TxnStatus)(nil), "intern.TxnStatus") - proto.RegisterType((*OracleDelta)(nil), "intern.OracleDelta") - proto.RegisterType((*TxnTimestamps)(nil), "intern.TxnTimestamps") - proto.RegisterType((*PeerResponse)(nil), "intern.PeerResponse") - proto.RegisterType((*RaftBatch)(nil), "intern.RaftBatch") - proto.RegisterType((*Num)(nil), "intern.Num") - proto.RegisterType((*AssignedIds)(nil), "intern.AssignedIds") - proto.RegisterType((*SnapshotMeta)(nil), "intern.SnapshotMeta") - proto.RegisterEnum("intern.DirectedEdge_Op", DirectedEdge_Op_name, DirectedEdge_Op_value) - proto.RegisterEnum("intern.Posting_ValType", Posting_ValType_name, Posting_ValType_value) - proto.RegisterEnum("intern.Posting_PostingType", Posting_PostingType_name, Posting_PostingType_value) - proto.RegisterEnum("intern.SchemaUpdate_Directive", SchemaUpdate_Directive_name, SchemaUpdate_Directive_value) - proto.RegisterEnum("intern.ExportPayload_Status", ExportPayload_Status_name, ExportPayload_Status_value) + proto.RegisterType((*List)(nil), "pb.List") + proto.RegisterType((*TaskValue)(nil), "pb.TaskValue") + proto.RegisterType((*SrcFunction)(nil), "pb.SrcFunction") + proto.RegisterType((*Query)(nil), "pb.Query") + proto.RegisterType((*ValueList)(nil), "pb.ValueList") + proto.RegisterType((*LangList)(nil), "pb.LangList") + proto.RegisterType((*Result)(nil), "pb.Result") + proto.RegisterType((*Order)(nil), "pb.Order") + proto.RegisterType((*SortMessage)(nil), "pb.SortMessage") + proto.RegisterType((*SortResult)(nil), "pb.SortResult") + proto.RegisterType((*RaftContext)(nil), "pb.RaftContext") + proto.RegisterType((*Member)(nil), "pb.Member") + proto.RegisterType((*Group)(nil), "pb.Group") + proto.RegisterMapType((map[uint64]*Member)(nil), "pb.Group.MembersEntry") + proto.RegisterMapType((map[string]*Tablet)(nil), "pb.Group.TabletsEntry") + proto.RegisterType((*ZeroProposal)(nil), "pb.ZeroProposal") + proto.RegisterType((*MembershipState)(nil), "pb.MembershipState") + proto.RegisterMapType((map[uint32]*Group)(nil), "pb.MembershipState.GroupsEntry") + proto.RegisterMapType((map[uint64]*Member)(nil), "pb.MembershipState.ZerosEntry") + proto.RegisterType((*ConnectionState)(nil), "pb.ConnectionState") + proto.RegisterType((*Tablet)(nil), "pb.Tablet") + proto.RegisterType((*DirectedEdge)(nil), "pb.DirectedEdge") + proto.RegisterType((*Mutations)(nil), "pb.Mutations") + proto.RegisterType((*KeyValues)(nil), "pb.KeyValues") + proto.RegisterType((*Snapshot)(nil), "pb.Snapshot") + proto.RegisterType((*Proposal)(nil), "pb.Proposal") + proto.RegisterType((*KVS)(nil), "pb.KVS") + proto.RegisterType((*KV)(nil), "pb.KV") + proto.RegisterType((*Posting)(nil), "pb.Posting") + proto.RegisterType((*PostingList)(nil), "pb.PostingList") + proto.RegisterType((*FacetParam)(nil), "pb.FacetParam") + proto.RegisterType((*FacetParams)(nil), "pb.FacetParams") + proto.RegisterType((*Facets)(nil), "pb.Facets") + proto.RegisterType((*FacetsList)(nil), "pb.FacetsList") + proto.RegisterType((*Function)(nil), "pb.Function") + proto.RegisterType((*FilterTree)(nil), "pb.FilterTree") + proto.RegisterType((*SchemaRequest)(nil), "pb.SchemaRequest") + proto.RegisterType((*SchemaResult)(nil), "pb.SchemaResult") + proto.RegisterType((*SchemaUpdate)(nil), "pb.SchemaUpdate") + proto.RegisterType((*MapEntry)(nil), "pb.MapEntry") + proto.RegisterType((*MovePredicatePayload)(nil), "pb.MovePredicatePayload") + proto.RegisterType((*ExportPayload)(nil), "pb.ExportPayload") + proto.RegisterType((*TxnStatus)(nil), "pb.TxnStatus") + proto.RegisterType((*OracleDelta)(nil), "pb.OracleDelta") + proto.RegisterType((*TxnTimestamps)(nil), "pb.TxnTimestamps") + proto.RegisterType((*PeerResponse)(nil), "pb.PeerResponse") + proto.RegisterType((*RaftBatch)(nil), "pb.RaftBatch") + proto.RegisterType((*Num)(nil), "pb.Num") + proto.RegisterType((*AssignedIds)(nil), "pb.AssignedIds") + proto.RegisterType((*SnapshotMeta)(nil), "pb.SnapshotMeta") + proto.RegisterEnum("pb.DirectedEdge_Op", DirectedEdge_Op_name, DirectedEdge_Op_value) + proto.RegisterEnum("pb.Posting_ValType", Posting_ValType_name, Posting_ValType_value) + proto.RegisterEnum("pb.Posting_PostingType", Posting_PostingType_name, Posting_PostingType_value) + proto.RegisterEnum("pb.SchemaUpdate_Directive", SchemaUpdate_Directive_name, SchemaUpdate_Directive_value) + proto.RegisterEnum("pb.ExportPayload_Status", ExportPayload_Status_name, ExportPayload_Status_value) } // Reference imports to suppress errors if they are not otherwise used. @@ -2023,8 +3267,9 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for Raft service - +// RaftClient is the client API for Raft service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type RaftClient interface { Echo(ctx context.Context, in *api.Payload, opts ...grpc.CallOption) (*api.Payload, error) RaftMessage(ctx context.Context, in *RaftBatch, opts ...grpc.CallOption) (*api.Payload, error) @@ -2042,7 +3287,7 @@ func NewRaftClient(cc *grpc.ClientConn) RaftClient { func (c *raftClient) Echo(ctx context.Context, in *api.Payload, opts ...grpc.CallOption) (*api.Payload, error) { out := new(api.Payload) - err := grpc.Invoke(ctx, "/intern.Raft/Echo", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Raft/Echo", in, out, opts...) if err != nil { return nil, err } @@ -2051,7 +3296,7 @@ func (c *raftClient) Echo(ctx context.Context, in *api.Payload, opts ...grpc.Cal func (c *raftClient) RaftMessage(ctx context.Context, in *RaftBatch, opts ...grpc.CallOption) (*api.Payload, error) { out := new(api.Payload) - err := grpc.Invoke(ctx, "/intern.Raft/RaftMessage", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Raft/RaftMessage", in, out, opts...) if err != nil { return nil, err } @@ -2060,7 +3305,7 @@ func (c *raftClient) RaftMessage(ctx context.Context, in *RaftBatch, opts ...grp func (c *raftClient) JoinCluster(ctx context.Context, in *RaftContext, opts ...grpc.CallOption) (*api.Payload, error) { out := new(api.Payload) - err := grpc.Invoke(ctx, "/intern.Raft/JoinCluster", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Raft/JoinCluster", in, out, opts...) if err != nil { return nil, err } @@ -2069,15 +3314,14 @@ func (c *raftClient) JoinCluster(ctx context.Context, in *RaftContext, opts ...g func (c *raftClient) IsPeer(ctx context.Context, in *RaftContext, opts ...grpc.CallOption) (*PeerResponse, error) { out := new(PeerResponse) - err := grpc.Invoke(ctx, "/intern.Raft/IsPeer", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Raft/IsPeer", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for Raft service - +// RaftServer is the server API for Raft service. type RaftServer interface { Echo(context.Context, *api.Payload) (*api.Payload, error) RaftMessage(context.Context, *RaftBatch) (*api.Payload, error) @@ -2099,7 +3343,7 @@ func _Raft_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Raft/Echo", + FullMethod: "/pb.Raft/Echo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RaftServer).Echo(ctx, req.(*api.Payload)) @@ -2117,7 +3361,7 @@ func _Raft_RaftMessage_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Raft/RaftMessage", + FullMethod: "/pb.Raft/RaftMessage", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RaftServer).RaftMessage(ctx, req.(*RaftBatch)) @@ -2135,7 +3379,7 @@ func _Raft_JoinCluster_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Raft/JoinCluster", + FullMethod: "/pb.Raft/JoinCluster", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RaftServer).JoinCluster(ctx, req.(*RaftContext)) @@ -2153,7 +3397,7 @@ func _Raft_IsPeer_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Raft/IsPeer", + FullMethod: "/pb.Raft/IsPeer", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RaftServer).IsPeer(ctx, req.(*RaftContext)) @@ -2162,7 +3406,7 @@ func _Raft_IsPeer_Handler(srv interface{}, ctx context.Context, dec func(interfa } var _Raft_serviceDesc = grpc.ServiceDesc{ - ServiceName: "intern.Raft", + ServiceName: "pb.Raft", HandlerType: (*RaftServer)(nil), Methods: []grpc.MethodDesc{ { @@ -2183,11 +3427,12 @@ var _Raft_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "internal.proto", + Metadata: "pb.proto", } -// Client API for Zero service - +// ZeroClient is the client API for Zero service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type ZeroClient interface { Connect(ctx context.Context, in *Member, opts ...grpc.CallOption) (*ConnectionState, error) Update(ctx context.Context, opts ...grpc.CallOption) (Zero_UpdateClient, error) @@ -2209,7 +3454,7 @@ func NewZeroClient(cc *grpc.ClientConn) ZeroClient { func (c *zeroClient) Connect(ctx context.Context, in *Member, opts ...grpc.CallOption) (*ConnectionState, error) { out := new(ConnectionState) - err := grpc.Invoke(ctx, "/intern.Zero/Connect", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Zero/Connect", in, out, opts...) if err != nil { return nil, err } @@ -2217,7 +3462,7 @@ func (c *zeroClient) Connect(ctx context.Context, in *Member, opts ...grpc.CallO } func (c *zeroClient) Update(ctx context.Context, opts ...grpc.CallOption) (Zero_UpdateClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Zero_serviceDesc.Streams[0], c.cc, "/intern.Zero/Update", opts...) + stream, err := c.cc.NewStream(ctx, &_Zero_serviceDesc.Streams[0], "/pb.Zero/Update", opts...) if err != nil { return nil, err } @@ -2248,7 +3493,7 @@ func (x *zeroUpdateClient) Recv() (*MembershipState, error) { } func (c *zeroClient) Oracle(ctx context.Context, in *api.Payload, opts ...grpc.CallOption) (Zero_OracleClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Zero_serviceDesc.Streams[1], c.cc, "/intern.Zero/Oracle", opts...) + stream, err := c.cc.NewStream(ctx, &_Zero_serviceDesc.Streams[1], "/pb.Zero/Oracle", opts...) if err != nil { return nil, err } @@ -2281,7 +3526,7 @@ func (x *zeroOracleClient) Recv() (*OracleDelta, error) { func (c *zeroClient) ShouldServe(ctx context.Context, in *Tablet, opts ...grpc.CallOption) (*Tablet, error) { out := new(Tablet) - err := grpc.Invoke(ctx, "/intern.Zero/ShouldServe", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Zero/ShouldServe", in, out, opts...) if err != nil { return nil, err } @@ -2290,7 +3535,7 @@ func (c *zeroClient) ShouldServe(ctx context.Context, in *Tablet, opts ...grpc.C func (c *zeroClient) AssignUids(ctx context.Context, in *Num, opts ...grpc.CallOption) (*AssignedIds, error) { out := new(AssignedIds) - err := grpc.Invoke(ctx, "/intern.Zero/AssignUids", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Zero/AssignUids", in, out, opts...) if err != nil { return nil, err } @@ -2299,7 +3544,7 @@ func (c *zeroClient) AssignUids(ctx context.Context, in *Num, opts ...grpc.CallO func (c *zeroClient) Timestamps(ctx context.Context, in *Num, opts ...grpc.CallOption) (*AssignedIds, error) { out := new(AssignedIds) - err := grpc.Invoke(ctx, "/intern.Zero/Timestamps", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Zero/Timestamps", in, out, opts...) if err != nil { return nil, err } @@ -2308,7 +3553,7 @@ func (c *zeroClient) Timestamps(ctx context.Context, in *Num, opts ...grpc.CallO func (c *zeroClient) CommitOrAbort(ctx context.Context, in *api.TxnContext, opts ...grpc.CallOption) (*api.TxnContext, error) { out := new(api.TxnContext) - err := grpc.Invoke(ctx, "/intern.Zero/CommitOrAbort", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Zero/CommitOrAbort", in, out, opts...) if err != nil { return nil, err } @@ -2317,15 +3562,14 @@ func (c *zeroClient) CommitOrAbort(ctx context.Context, in *api.TxnContext, opts func (c *zeroClient) TryAbort(ctx context.Context, in *TxnTimestamps, opts ...grpc.CallOption) (*OracleDelta, error) { out := new(OracleDelta) - err := grpc.Invoke(ctx, "/intern.Zero/TryAbort", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Zero/TryAbort", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for Zero service - +// ZeroServer is the server API for Zero service. type ZeroServer interface { Connect(context.Context, *Member) (*ConnectionState, error) Update(Zero_UpdateServer) error @@ -2351,7 +3595,7 @@ func _Zero_Connect_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Zero/Connect", + FullMethod: "/pb.Zero/Connect", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ZeroServer).Connect(ctx, req.(*Member)) @@ -2416,7 +3660,7 @@ func _Zero_ShouldServe_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Zero/ShouldServe", + FullMethod: "/pb.Zero/ShouldServe", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ZeroServer).ShouldServe(ctx, req.(*Tablet)) @@ -2434,7 +3678,7 @@ func _Zero_AssignUids_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Zero/AssignUids", + FullMethod: "/pb.Zero/AssignUids", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ZeroServer).AssignUids(ctx, req.(*Num)) @@ -2452,7 +3696,7 @@ func _Zero_Timestamps_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Zero/Timestamps", + FullMethod: "/pb.Zero/Timestamps", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ZeroServer).Timestamps(ctx, req.(*Num)) @@ -2470,7 +3714,7 @@ func _Zero_CommitOrAbort_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Zero/CommitOrAbort", + FullMethod: "/pb.Zero/CommitOrAbort", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ZeroServer).CommitOrAbort(ctx, req.(*api.TxnContext)) @@ -2488,7 +3732,7 @@ func _Zero_TryAbort_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Zero/TryAbort", + FullMethod: "/pb.Zero/TryAbort", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ZeroServer).TryAbort(ctx, req.(*TxnTimestamps)) @@ -2497,7 +3741,7 @@ func _Zero_TryAbort_Handler(srv interface{}, ctx context.Context, dec func(inter } var _Zero_serviceDesc = grpc.ServiceDesc{ - ServiceName: "intern.Zero", + ServiceName: "pb.Zero", HandlerType: (*ZeroServer)(nil), Methods: []grpc.MethodDesc{ { @@ -2538,11 +3782,12 @@ var _Zero_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "internal.proto", + Metadata: "pb.proto", } -// Client API for Worker service - +// WorkerClient is the client API for Worker service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type WorkerClient interface { // Data serving RPCs. Mutate(ctx context.Context, in *Mutations, opts ...grpc.CallOption) (*api.TxnContext, error) @@ -2566,7 +3811,7 @@ func NewWorkerClient(cc *grpc.ClientConn) WorkerClient { func (c *workerClient) Mutate(ctx context.Context, in *Mutations, opts ...grpc.CallOption) (*api.TxnContext, error) { out := new(api.TxnContext) - err := grpc.Invoke(ctx, "/intern.Worker/Mutate", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/Mutate", in, out, opts...) if err != nil { return nil, err } @@ -2575,7 +3820,7 @@ func (c *workerClient) Mutate(ctx context.Context, in *Mutations, opts ...grpc.C func (c *workerClient) ServeTask(ctx context.Context, in *Query, opts ...grpc.CallOption) (*Result, error) { out := new(Result) - err := grpc.Invoke(ctx, "/intern.Worker/ServeTask", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/ServeTask", in, out, opts...) if err != nil { return nil, err } @@ -2583,7 +3828,7 @@ func (c *workerClient) ServeTask(ctx context.Context, in *Query, opts ...grpc.Ca } func (c *workerClient) StreamSnapshot(ctx context.Context, in *Snapshot, opts ...grpc.CallOption) (Worker_StreamSnapshotClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Worker_serviceDesc.Streams[0], c.cc, "/intern.Worker/StreamSnapshot", opts...) + stream, err := c.cc.NewStream(ctx, &_Worker_serviceDesc.Streams[0], "/pb.Worker/StreamSnapshot", opts...) if err != nil { return nil, err } @@ -2616,7 +3861,7 @@ func (x *workerStreamSnapshotClient) Recv() (*KVS, error) { func (c *workerClient) Sort(ctx context.Context, in *SortMessage, opts ...grpc.CallOption) (*SortResult, error) { out := new(SortResult) - err := grpc.Invoke(ctx, "/intern.Worker/Sort", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/Sort", in, out, opts...) if err != nil { return nil, err } @@ -2625,7 +3870,7 @@ func (c *workerClient) Sort(ctx context.Context, in *SortMessage, opts ...grpc.C func (c *workerClient) Schema(ctx context.Context, in *SchemaRequest, opts ...grpc.CallOption) (*SchemaResult, error) { out := new(SchemaResult) - err := grpc.Invoke(ctx, "/intern.Worker/Schema", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/Schema", in, out, opts...) if err != nil { return nil, err } @@ -2634,7 +3879,7 @@ func (c *workerClient) Schema(ctx context.Context, in *SchemaRequest, opts ...gr func (c *workerClient) PurgeTs(ctx context.Context, in *api.Payload, opts ...grpc.CallOption) (*Num, error) { out := new(Num) - err := grpc.Invoke(ctx, "/intern.Worker/PurgeTs", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/PurgeTs", in, out, opts...) if err != nil { return nil, err } @@ -2643,7 +3888,7 @@ func (c *workerClient) PurgeTs(ctx context.Context, in *api.Payload, opts ...grp func (c *workerClient) Export(ctx context.Context, in *ExportPayload, opts ...grpc.CallOption) (*ExportPayload, error) { out := new(ExportPayload) - err := grpc.Invoke(ctx, "/intern.Worker/Export", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/Export", in, out, opts...) if err != nil { return nil, err } @@ -2651,7 +3896,7 @@ func (c *workerClient) Export(ctx context.Context, in *ExportPayload, opts ...gr } func (c *workerClient) ReceivePredicate(ctx context.Context, opts ...grpc.CallOption) (Worker_ReceivePredicateClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Worker_serviceDesc.Streams[1], c.cc, "/intern.Worker/ReceivePredicate", opts...) + stream, err := c.cc.NewStream(ctx, &_Worker_serviceDesc.Streams[1], "/pb.Worker/ReceivePredicate", opts...) if err != nil { return nil, err } @@ -2686,15 +3931,14 @@ func (x *workerReceivePredicateClient) CloseAndRecv() (*api.Payload, error) { func (c *workerClient) MovePredicate(ctx context.Context, in *MovePredicatePayload, opts ...grpc.CallOption) (*api.Payload, error) { out := new(api.Payload) - err := grpc.Invoke(ctx, "/intern.Worker/MovePredicate", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/pb.Worker/MovePredicate", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for Worker service - +// WorkerServer is the server API for Worker service. type WorkerServer interface { // Data serving RPCs. Mutate(context.Context, *Mutations) (*api.TxnContext, error) @@ -2722,7 +3966,7 @@ func _Worker_Mutate_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/Mutate", + FullMethod: "/pb.Worker/Mutate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).Mutate(ctx, req.(*Mutations)) @@ -2740,7 +3984,7 @@ func _Worker_ServeTask_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/ServeTask", + FullMethod: "/pb.Worker/ServeTask", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).ServeTask(ctx, req.(*Query)) @@ -2779,7 +4023,7 @@ func _Worker_Sort_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/Sort", + FullMethod: "/pb.Worker/Sort", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).Sort(ctx, req.(*SortMessage)) @@ -2797,7 +4041,7 @@ func _Worker_Schema_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/Schema", + FullMethod: "/pb.Worker/Schema", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).Schema(ctx, req.(*SchemaRequest)) @@ -2815,7 +4059,7 @@ func _Worker_PurgeTs_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/PurgeTs", + FullMethod: "/pb.Worker/PurgeTs", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).PurgeTs(ctx, req.(*api.Payload)) @@ -2833,7 +4077,7 @@ func _Worker_Export_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/Export", + FullMethod: "/pb.Worker/Export", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).Export(ctx, req.(*ExportPayload)) @@ -2877,7 +4121,7 @@ func _Worker_MovePredicate_Handler(srv interface{}, ctx context.Context, dec fun } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/intern.Worker/MovePredicate", + FullMethod: "/pb.Worker/MovePredicate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WorkerServer).MovePredicate(ctx, req.(*MovePredicatePayload)) @@ -2886,7 +4130,7 @@ func _Worker_MovePredicate_Handler(srv interface{}, ctx context.Context, dec fun } var _Worker_serviceDesc = grpc.ServiceDesc{ - ServiceName: "intern.Worker", + ServiceName: "pb.Worker", HandlerType: (*WorkerServer)(nil), Methods: []grpc.MethodDesc{ { @@ -2930,7 +4174,7 @@ var _Worker_serviceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "internal.proto", + Metadata: "pb.proto", } func (m *List) Marshal() (dAtA []byte, err error) { @@ -2951,9 +4195,9 @@ func (m *List) MarshalTo(dAtA []byte) (int, error) { if len(m.Uids) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Uids)*8)) + i = encodeVarintPb(dAtA, i, uint64(len(m.Uids)*8)) for _, num := range m.Uids { - binary.LittleEndian.PutUint64(dAtA[i:], uint64(num)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(num)) i += 8 } } @@ -2978,13 +4222,13 @@ func (m *TaskValue) MarshalTo(dAtA []byte) (int, error) { if len(m.Val) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Val))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Val))) i += copy(dAtA[i:], m.Val) } if m.ValType != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ValType)) + i = encodeVarintPb(dAtA, i, uint64(m.ValType)) } return i, nil } @@ -3007,7 +4251,7 @@ func (m *SrcFunction) MarshalTo(dAtA []byte) (int, error) { if len(m.Name) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Name))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Name))) i += copy(dAtA[i:], m.Name) } if len(m.Args) > 0 { @@ -3056,7 +4300,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if len(m.Attr) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Attr))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Attr))) i += copy(dAtA[i:], m.Attr) } if len(m.Langs) > 0 { @@ -3077,7 +4321,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if m.AfterUid != 0 { dAtA[i] = 0x19 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.AfterUid)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.AfterUid)) i += 8 } if m.DoCount { @@ -3093,7 +4337,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if m.UidList != nil { dAtA[i] = 0x2a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.UidList.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.UidList.Size())) n1, err := m.UidList.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3103,7 +4347,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if m.SrcFunc != nil { dAtA[i] = 0x32 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.SrcFunc.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.SrcFunc.Size())) n2, err := m.SrcFunc.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3123,7 +4367,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if m.FacetParam != nil { dAtA[i] = 0x42 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.FacetParam.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.FacetParam.Size())) n3, err := m.FacetParam.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3133,7 +4377,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if m.FacetsFilter != nil { dAtA[i] = 0x4a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.FacetsFilter.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.FacetsFilter.Size())) n4, err := m.FacetsFilter.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3153,7 +4397,7 @@ func (m *Query) MarshalTo(dAtA []byte) (int, error) { if m.ReadTs != 0 { dAtA[i] = 0x68 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ReadTs)) + i = encodeVarintPb(dAtA, i, uint64(m.ReadTs)) } return i, nil } @@ -3177,7 +4421,7 @@ func (m *ValueList) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Values { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3240,7 +4484,7 @@ func (m *Result) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.UidMatrix { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3252,7 +4496,7 @@ func (m *Result) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.ValueMatrix { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3274,7 +4518,7 @@ func (m *Result) MarshalTo(dAtA []byte) (int, error) { } dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(j5)) + i = encodeVarintPb(dAtA, i, uint64(j5)) i += copy(dAtA[i:], dAtA6[:j5]) } if m.IntersectDest { @@ -3291,7 +4535,7 @@ func (m *Result) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.FacetMatrix { dAtA[i] = 0x2a i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3303,7 +4547,7 @@ func (m *Result) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.LangMatrix { dAtA[i] = 0x32 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3342,7 +4586,7 @@ func (m *Order) MarshalTo(dAtA []byte) (int, error) { if len(m.Attr) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Attr))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Attr))) i += copy(dAtA[i:], m.Attr) } if m.Desc { @@ -3392,7 +4636,7 @@ func (m *SortMessage) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Order { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3404,7 +4648,7 @@ func (m *SortMessage) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.UidMatrix { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3415,17 +4659,17 @@ func (m *SortMessage) MarshalTo(dAtA []byte) (int, error) { if m.Count != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Count)) + i = encodeVarintPb(dAtA, i, uint64(m.Count)) } if m.Offset != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Offset)) + i = encodeVarintPb(dAtA, i, uint64(m.Offset)) } if m.ReadTs != 0 { dAtA[i] = 0x68 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ReadTs)) + i = encodeVarintPb(dAtA, i, uint64(m.ReadTs)) } return i, nil } @@ -3449,7 +4693,7 @@ func (m *SortResult) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.UidMatrix { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3478,24 +4722,24 @@ func (m *RaftContext) MarshalTo(dAtA []byte) (int, error) { if m.Id != 0 { dAtA[i] = 0x9 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Id)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Id)) i += 8 } if m.Group != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Group)) + i = encodeVarintPb(dAtA, i, uint64(m.Group)) } if len(m.Addr) > 0 { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Addr))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Addr))) i += copy(dAtA[i:], m.Addr) } if m.SnapshotTs != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.SnapshotTs)) + i = encodeVarintPb(dAtA, i, uint64(m.SnapshotTs)) } return i, nil } @@ -3518,18 +4762,18 @@ func (m *Member) MarshalTo(dAtA []byte) (int, error) { if m.Id != 0 { dAtA[i] = 0x9 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Id)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Id)) i += 8 } if m.GroupId != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.GroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.GroupId)) } if len(m.Addr) > 0 { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Addr))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Addr))) i += copy(dAtA[i:], m.Addr) } if m.Leader { @@ -3555,7 +4799,7 @@ func (m *Member) MarshalTo(dAtA []byte) (int, error) { if m.LastUpdate != 0 { dAtA[i] = 0x30 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.LastUpdate)) + i = encodeVarintPb(dAtA, i, uint64(m.LastUpdate)) } if m.ClusterInfoOnly { dAtA[i] = 0x68 @@ -3593,17 +4837,17 @@ func (m *Group) MarshalTo(dAtA []byte) (int, error) { msgSize := 0 if v != nil { msgSize = v.Size() - msgSize += 1 + sovInternal(uint64(msgSize)) + msgSize += 1 + sovPb(uint64(msgSize)) } - mapSize := 1 + sovInternal(uint64(k)) + msgSize - i = encodeVarintInternal(dAtA, i, uint64(mapSize)) + mapSize := 1 + sovPb(uint64(k)) + msgSize + i = encodeVarintPb(dAtA, i, uint64(mapSize)) dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(k)) + i = encodeVarintPb(dAtA, i, uint64(k)) if v != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(v.Size())) + i = encodeVarintPb(dAtA, i, uint64(v.Size())) n7, err := v.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3620,18 +4864,18 @@ func (m *Group) MarshalTo(dAtA []byte) (int, error) { msgSize := 0 if v != nil { msgSize = v.Size() - msgSize += 1 + sovInternal(uint64(msgSize)) + msgSize += 1 + sovPb(uint64(msgSize)) } - mapSize := 1 + len(k) + sovInternal(uint64(len(k))) + msgSize - i = encodeVarintInternal(dAtA, i, uint64(mapSize)) + mapSize := 1 + len(k) + sovPb(uint64(len(k))) + msgSize + i = encodeVarintPb(dAtA, i, uint64(mapSize)) dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(k))) + i = encodeVarintPb(dAtA, i, uint64(len(k))) i += copy(dAtA[i:], k) if v != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(v.Size())) + i = encodeVarintPb(dAtA, i, uint64(v.Size())) n8, err := v.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3661,7 +4905,7 @@ func (m *ZeroProposal) MarshalTo(dAtA []byte) (int, error) { if m.Member != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Member.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Member.Size())) n9, err := m.Member.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3671,7 +4915,7 @@ func (m *ZeroProposal) MarshalTo(dAtA []byte) (int, error) { if m.Tablet != nil { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Tablet.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Tablet.Size())) n10, err := m.Tablet.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3681,22 +4925,22 @@ func (m *ZeroProposal) MarshalTo(dAtA []byte) (int, error) { if m.MaxLeaseId != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxLeaseId)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxLeaseId)) } if m.MaxTxnTs != 0 { dAtA[i] = 0x28 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxTxnTs)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxTxnTs)) } if m.MaxRaftId != 0 { dAtA[i] = 0x30 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxRaftId)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxRaftId)) } if m.Txn != nil { dAtA[i] = 0x3a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Txn.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Txn.Size())) n11, err := m.Txn.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3706,13 +4950,13 @@ func (m *ZeroProposal) MarshalTo(dAtA []byte) (int, error) { if len(m.Key) > 0 { dAtA[i] = 0x42 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Key))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Key))) i += copy(dAtA[i:], m.Key) } if len(m.Cid) > 0 { dAtA[i] = 0x4a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Cid))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Cid))) i += copy(dAtA[i:], m.Cid) } return i, nil @@ -3736,7 +4980,7 @@ func (m *MembershipState) MarshalTo(dAtA []byte) (int, error) { if m.Counter != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Counter)) + i = encodeVarintPb(dAtA, i, uint64(m.Counter)) } if len(m.Groups) > 0 { for k, _ := range m.Groups { @@ -3746,17 +4990,17 @@ func (m *MembershipState) MarshalTo(dAtA []byte) (int, error) { msgSize := 0 if v != nil { msgSize = v.Size() - msgSize += 1 + sovInternal(uint64(msgSize)) + msgSize += 1 + sovPb(uint64(msgSize)) } - mapSize := 1 + sovInternal(uint64(k)) + msgSize - i = encodeVarintInternal(dAtA, i, uint64(mapSize)) + mapSize := 1 + sovPb(uint64(k)) + msgSize + i = encodeVarintPb(dAtA, i, uint64(mapSize)) dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(k)) + i = encodeVarintPb(dAtA, i, uint64(k)) if v != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(v.Size())) + i = encodeVarintPb(dAtA, i, uint64(v.Size())) n12, err := v.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3773,17 +5017,17 @@ func (m *MembershipState) MarshalTo(dAtA []byte) (int, error) { msgSize := 0 if v != nil { msgSize = v.Size() - msgSize += 1 + sovInternal(uint64(msgSize)) + msgSize += 1 + sovPb(uint64(msgSize)) } - mapSize := 1 + sovInternal(uint64(k)) + msgSize - i = encodeVarintInternal(dAtA, i, uint64(mapSize)) + mapSize := 1 + sovPb(uint64(k)) + msgSize + i = encodeVarintPb(dAtA, i, uint64(mapSize)) dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(k)) + i = encodeVarintPb(dAtA, i, uint64(k)) if v != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(v.Size())) + i = encodeVarintPb(dAtA, i, uint64(v.Size())) n13, err := v.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3795,23 +5039,23 @@ func (m *MembershipState) MarshalTo(dAtA []byte) (int, error) { if m.MaxLeaseId != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxLeaseId)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxLeaseId)) } if m.MaxTxnTs != 0 { dAtA[i] = 0x28 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxTxnTs)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxTxnTs)) } if m.MaxRaftId != 0 { dAtA[i] = 0x30 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxRaftId)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxRaftId)) } if len(m.Removed) > 0 { for _, msg := range m.Removed { dAtA[i] = 0x3a i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3822,7 +5066,7 @@ func (m *MembershipState) MarshalTo(dAtA []byte) (int, error) { if len(m.Cid) > 0 { dAtA[i] = 0x42 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Cid))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Cid))) i += copy(dAtA[i:], m.Cid) } return i, nil @@ -3846,7 +5090,7 @@ func (m *ConnectionState) MarshalTo(dAtA []byte) (int, error) { if m.Member != nil { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Member.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Member.Size())) n14, err := m.Member.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3856,7 +5100,7 @@ func (m *ConnectionState) MarshalTo(dAtA []byte) (int, error) { if m.State != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.State.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.State.Size())) n15, err := m.State.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -3866,7 +5110,7 @@ func (m *ConnectionState) MarshalTo(dAtA []byte) (int, error) { if m.MaxPending != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxPending)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxPending)) } return i, nil } @@ -3889,12 +5133,12 @@ func (m *Tablet) MarshalTo(dAtA []byte) (int, error) { if m.GroupId != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.GroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.GroupId)) } if len(m.Predicate) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Predicate))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Predicate))) i += copy(dAtA[i:], m.Predicate) } if m.Force { @@ -3920,7 +5164,7 @@ func (m *Tablet) MarshalTo(dAtA []byte) (int, error) { if m.Space != 0 { dAtA[i] = 0x38 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Space)) + i = encodeVarintPb(dAtA, i, uint64(m.Space)) } if m.Remove { dAtA[i] = 0x40 @@ -3953,54 +5197,54 @@ func (m *DirectedEdge) MarshalTo(dAtA []byte) (int, error) { if m.Entity != 0 { dAtA[i] = 0x9 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Entity)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Entity)) i += 8 } if len(m.Attr) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Attr))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Attr))) i += copy(dAtA[i:], m.Attr) } if len(m.Value) > 0 { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Value))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Value))) i += copy(dAtA[i:], m.Value) } if m.ValueType != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ValueType)) + i = encodeVarintPb(dAtA, i, uint64(m.ValueType)) } if m.ValueId != 0 { dAtA[i] = 0x29 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.ValueId)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.ValueId)) i += 8 } if len(m.Label) > 0 { dAtA[i] = 0x32 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Label))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Label))) i += copy(dAtA[i:], m.Label) } if len(m.Lang) > 0 { dAtA[i] = 0x3a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Lang))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Lang))) i += copy(dAtA[i:], m.Lang) } if m.Op != 0 { dAtA[i] = 0x40 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Op)) + i = encodeVarintPb(dAtA, i, uint64(m.Op)) } if len(m.Facets) > 0 { for _, msg := range m.Facets { dAtA[i] = 0x4a i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4029,18 +5273,18 @@ func (m *Mutations) MarshalTo(dAtA []byte) (int, error) { if m.GroupId != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.GroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.GroupId)) } if m.StartTs != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.StartTs)) + i = encodeVarintPb(dAtA, i, uint64(m.StartTs)) } if len(m.Edges) > 0 { for _, msg := range m.Edges { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4052,7 +5296,7 @@ func (m *Mutations) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Schema { dAtA[i] = 0x22 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4102,7 +5346,7 @@ func (m *KeyValues) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Kv { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4131,7 +5375,7 @@ func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) { if m.Context != nil { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Context.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Context.Size())) n16, err := m.Context.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4141,12 +5385,12 @@ func (m *Snapshot) MarshalTo(dAtA []byte) (int, error) { if m.Index != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Index)) + i = encodeVarintPb(dAtA, i, uint64(m.Index)) } if m.ReadTs != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ReadTs)) + i = encodeVarintPb(dAtA, i, uint64(m.ReadTs)) } return i, nil } @@ -4169,7 +5413,7 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { if m.Mutations != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Mutations.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Mutations.Size())) n17, err := m.Mutations.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4180,7 +5424,7 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Kv { dAtA[i] = 0x22 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4191,7 +5435,7 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { if m.State != nil { dAtA[i] = 0x2a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.State.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.State.Size())) n18, err := m.State.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4201,19 +5445,19 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { if len(m.CleanPredicate) > 0 { dAtA[i] = 0x32 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.CleanPredicate))) + i = encodeVarintPb(dAtA, i, uint64(len(m.CleanPredicate))) i += copy(dAtA[i:], m.CleanPredicate) } if len(m.Key) > 0 { dAtA[i] = 0x3a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Key))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Key))) i += copy(dAtA[i:], m.Key) } if m.Delta != nil { dAtA[i] = 0x42 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Delta.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Delta.Size())) n19, err := m.Delta.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4223,7 +5467,7 @@ func (m *Proposal) MarshalTo(dAtA []byte) (int, error) { if m.Snapshot != nil { dAtA[i] = 0x4a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Snapshot.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Snapshot.Size())) n20, err := m.Snapshot.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4252,7 +5496,7 @@ func (m *KVS) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Kv { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4281,25 +5525,25 @@ func (m *KV) MarshalTo(dAtA []byte) (int, error) { if len(m.Key) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Key))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Key))) i += copy(dAtA[i:], m.Key) } if len(m.Val) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Val))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Val))) i += copy(dAtA[i:], m.Val) } if len(m.UserMeta) > 0 { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.UserMeta))) + i = encodeVarintPb(dAtA, i, uint64(len(m.UserMeta))) i += copy(dAtA[i:], m.UserMeta) } if m.Version != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Version)) + i = encodeVarintPb(dAtA, i, uint64(m.Version)) } return i, nil } @@ -4322,42 +5566,42 @@ func (m *Posting) MarshalTo(dAtA []byte) (int, error) { if m.Uid != 0 { dAtA[i] = 0x9 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Uid)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Uid)) i += 8 } if len(m.Value) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Value))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Value))) i += copy(dAtA[i:], m.Value) } if m.ValType != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ValType)) + i = encodeVarintPb(dAtA, i, uint64(m.ValType)) } if m.PostingType != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.PostingType)) + i = encodeVarintPb(dAtA, i, uint64(m.PostingType)) } if len(m.LangTag) > 0 { dAtA[i] = 0x2a i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.LangTag))) + i = encodeVarintPb(dAtA, i, uint64(len(m.LangTag))) i += copy(dAtA[i:], m.LangTag) } if len(m.Label) > 0 { dAtA[i] = 0x32 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Label))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Label))) i += copy(dAtA[i:], m.Label) } if len(m.Facets) > 0 { for _, msg := range m.Facets { dAtA[i] = 0x4a i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4368,17 +5612,17 @@ func (m *Posting) MarshalTo(dAtA []byte) (int, error) { if m.Op != 0 { dAtA[i] = 0x60 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Op)) + i = encodeVarintPb(dAtA, i, uint64(m.Op)) } if m.StartTs != 0 { dAtA[i] = 0x68 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.StartTs)) + i = encodeVarintPb(dAtA, i, uint64(m.StartTs)) } if m.CommitTs != 0 { dAtA[i] = 0x70 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.CommitTs)) + i = encodeVarintPb(dAtA, i, uint64(m.CommitTs)) } return i, nil } @@ -4402,7 +5646,7 @@ func (m *PostingList) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Postings { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4413,18 +5657,18 @@ func (m *PostingList) MarshalTo(dAtA []byte) (int, error) { if len(m.Checksum) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Checksum))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Checksum))) i += copy(dAtA[i:], m.Checksum) } if m.Commit != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Commit)) + i = encodeVarintPb(dAtA, i, uint64(m.Commit)) } if len(m.Uids) > 0 { dAtA[i] = 0x22 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Uids))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Uids))) i += copy(dAtA[i:], m.Uids) } return i, nil @@ -4448,13 +5692,13 @@ func (m *FacetParam) MarshalTo(dAtA []byte) (int, error) { if len(m.Key) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Key))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Key))) i += copy(dAtA[i:], m.Key) } if len(m.Alias) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Alias))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Alias))) i += copy(dAtA[i:], m.Alias) } return i, nil @@ -4489,7 +5733,7 @@ func (m *FacetParams) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Param { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4519,7 +5763,7 @@ func (m *Facets) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Facets { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4549,7 +5793,7 @@ func (m *FacetsList) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.FacetsList { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4578,13 +5822,13 @@ func (m *Function) MarshalTo(dAtA []byte) (int, error) { if len(m.Name) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Name))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Name))) i += copy(dAtA[i:], m.Name) } if len(m.Key) > 0 { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Key))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Key))) i += copy(dAtA[i:], m.Key) } if len(m.Args) > 0 { @@ -4623,14 +5867,14 @@ func (m *FilterTree) MarshalTo(dAtA []byte) (int, error) { if len(m.Op) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Op))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Op))) i += copy(dAtA[i:], m.Op) } if len(m.Children) > 0 { for _, msg := range m.Children { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4641,7 +5885,7 @@ func (m *FilterTree) MarshalTo(dAtA []byte) (int, error) { if m.Func != nil { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Func.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Func.Size())) n21, err := m.Func.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4669,7 +5913,7 @@ func (m *SchemaRequest) MarshalTo(dAtA []byte) (int, error) { if m.GroupId != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.GroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.GroupId)) } if len(m.Predicates) > 0 { for _, s := range m.Predicates { @@ -4723,7 +5967,7 @@ func (m *SchemaResult) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Schema { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4752,18 +5996,18 @@ func (m *SchemaUpdate) MarshalTo(dAtA []byte) (int, error) { if len(m.Predicate) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Predicate))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Predicate))) i += copy(dAtA[i:], m.Predicate) } if m.ValueType != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ValueType)) + i = encodeVarintPb(dAtA, i, uint64(m.ValueType)) } if m.Directive != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Directive)) + i = encodeVarintPb(dAtA, i, uint64(m.Directive)) } if len(m.Tokenizer) > 0 { for _, s := range m.Tokenizer { @@ -4841,19 +6085,19 @@ func (m *MapEntry) MarshalTo(dAtA []byte) (int, error) { if len(m.Key) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Key))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Key))) i += copy(dAtA[i:], m.Key) } if m.Uid != 0 { dAtA[i] = 0x11 i++ - binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Uid)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Uid)) i += 8 } if m.Posting != nil { dAtA[i] = 0x1a i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Posting.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Posting.Size())) n22, err := m.Posting.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4881,23 +6125,23 @@ func (m *MovePredicatePayload) MarshalTo(dAtA []byte) (int, error) { if len(m.Predicate) > 0 { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(len(m.Predicate))) + i = encodeVarintPb(dAtA, i, uint64(len(m.Predicate))) i += copy(dAtA[i:], m.Predicate) } if m.SourceGroupId != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.SourceGroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.SourceGroupId)) } if m.DestGroupId != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.DestGroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.DestGroupId)) } if m.State != nil { dAtA[i] = 0x22 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.State.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.State.Size())) n23, err := m.State.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -4925,22 +6169,22 @@ func (m *ExportPayload) MarshalTo(dAtA []byte) (int, error) { if m.ReqId != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ReqId)) + i = encodeVarintPb(dAtA, i, uint64(m.ReqId)) } if m.GroupId != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.GroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.GroupId)) } if m.Status != 0 { dAtA[i] = 0x18 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Status)) + i = encodeVarintPb(dAtA, i, uint64(m.Status)) } if m.ReadTs != 0 { dAtA[i] = 0x20 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ReadTs)) + i = encodeVarintPb(dAtA, i, uint64(m.ReadTs)) } return i, nil } @@ -4963,12 +6207,12 @@ func (m *TxnStatus) MarshalTo(dAtA []byte) (int, error) { if m.StartTs != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.StartTs)) + i = encodeVarintPb(dAtA, i, uint64(m.StartTs)) } if m.CommitTs != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.CommitTs)) + i = encodeVarintPb(dAtA, i, uint64(m.CommitTs)) } return i, nil } @@ -4992,7 +6236,7 @@ func (m *OracleDelta) MarshalTo(dAtA []byte) (int, error) { for _, msg := range m.Txns { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(msg.Size())) + i = encodeVarintPb(dAtA, i, uint64(msg.Size())) n, err := msg.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -5003,7 +6247,7 @@ func (m *OracleDelta) MarshalTo(dAtA []byte) (int, error) { if m.MaxAssigned != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.MaxAssigned)) + i = encodeVarintPb(dAtA, i, uint64(m.MaxAssigned)) } return i, nil } @@ -5037,7 +6281,7 @@ func (m *TxnTimestamps) MarshalTo(dAtA []byte) (int, error) { } dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(j24)) + i = encodeVarintPb(dAtA, i, uint64(j24)) i += copy(dAtA[i:], dAtA25[:j24]) } return i, nil @@ -5089,7 +6333,7 @@ func (m *RaftBatch) MarshalTo(dAtA []byte) (int, error) { if m.Context != nil { dAtA[i] = 0xa i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Context.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Context.Size())) n26, err := m.Context.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -5099,7 +6343,7 @@ func (m *RaftBatch) MarshalTo(dAtA []byte) (int, error) { if m.Payload != nil { dAtA[i] = 0x12 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Payload.Size())) + i = encodeVarintPb(dAtA, i, uint64(m.Payload.Size())) n27, err := m.Payload.MarshalTo(dAtA[i:]) if err != nil { return 0, err @@ -5127,7 +6371,7 @@ func (m *Num) MarshalTo(dAtA []byte) (int, error) { if m.Val != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.Val)) + i = encodeVarintPb(dAtA, i, uint64(m.Val)) } if m.ReadOnly { dAtA[i] = 0x10 @@ -5160,17 +6404,17 @@ func (m *AssignedIds) MarshalTo(dAtA []byte) (int, error) { if m.StartId != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.StartId)) + i = encodeVarintPb(dAtA, i, uint64(m.StartId)) } if m.EndId != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.EndId)) + i = encodeVarintPb(dAtA, i, uint64(m.EndId)) } if m.ReadOnly != 0 { dAtA[i] = 0x28 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ReadOnly)) + i = encodeVarintPb(dAtA, i, uint64(m.ReadOnly)) } return i, nil } @@ -5193,17 +6437,17 @@ func (m *SnapshotMeta) MarshalTo(dAtA []byte) (int, error) { if m.ClientTs != 0 { dAtA[i] = 0x8 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.ClientTs)) + i = encodeVarintPb(dAtA, i, uint64(m.ClientTs)) } if m.GroupId != 0 { dAtA[i] = 0x10 i++ - i = encodeVarintInternal(dAtA, i, uint64(m.GroupId)) + i = encodeVarintPb(dAtA, i, uint64(m.GroupId)) } return i, nil } -func encodeVarintInternal(dAtA []byte, offset int, v uint64) int { +func encodeVarintPb(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 @@ -5213,38 +6457,47 @@ func encodeVarintInternal(dAtA []byte, offset int, v uint64) int { return offset + 1 } func (m *List) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Uids) > 0 { - n += 1 + sovInternal(uint64(len(m.Uids)*8)) + len(m.Uids)*8 + n += 1 + sovPb(uint64(len(m.Uids)*8)) + len(m.Uids)*8 } return n } func (m *TaskValue) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Val) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.ValType != 0 { - n += 1 + sovInternal(uint64(m.ValType)) + n += 1 + sovPb(uint64(m.ValType)) } return n } func (m *SrcFunction) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Name) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if len(m.Args) > 0 { for _, s := range m.Args { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.IsCount { @@ -5254,16 +6507,19 @@ func (m *SrcFunction) Size() (n int) { } func (m *Query) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Attr) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if len(m.Langs) > 0 { for _, s := range m.Langs { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.AfterUid != 0 { @@ -5274,77 +6530,86 @@ func (m *Query) Size() (n int) { } if m.UidList != nil { l = m.UidList.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.SrcFunc != nil { l = m.SrcFunc.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Reverse { n += 2 } if m.FacetParam != nil { l = m.FacetParam.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.FacetsFilter != nil { l = m.FacetsFilter.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.ExpandAll { n += 2 } if m.ReadTs != 0 { - n += 1 + sovInternal(uint64(m.ReadTs)) + n += 1 + sovPb(uint64(m.ReadTs)) } return n } func (m *ValueList) 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 + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *LangList) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Lang) > 0 { for _, s := range m.Lang { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *Result) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.UidMatrix) > 0 { for _, e := range m.UidMatrix { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if len(m.ValueMatrix) > 0 { for _, e := range m.ValueMatrix { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if len(m.Counts) > 0 { l = 0 for _, e := range m.Counts { - l += sovInternal(uint64(e)) + l += sovPb(uint64(e)) } - n += 1 + sovInternal(uint64(l)) + l + n += 1 + sovPb(uint64(l)) + l } if m.IntersectDest { n += 2 @@ -5352,13 +6617,13 @@ func (m *Result) Size() (n int) { if len(m.FacetMatrix) > 0 { for _, e := range m.FacetMatrix { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if len(m.LangMatrix) > 0 { for _, e := range m.LangMatrix { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.List { @@ -5368,11 +6633,14 @@ func (m *Result) Size() (n int) { } func (m *Order) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Attr) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Desc { n += 2 @@ -5380,82 +6648,94 @@ func (m *Order) Size() (n int) { if len(m.Langs) > 0 { for _, s := range m.Langs { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *SortMessage) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Order) > 0 { for _, e := range m.Order { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if len(m.UidMatrix) > 0 { for _, e := range m.UidMatrix { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.Count != 0 { - n += 1 + sovInternal(uint64(m.Count)) + n += 1 + sovPb(uint64(m.Count)) } if m.Offset != 0 { - n += 1 + sovInternal(uint64(m.Offset)) + n += 1 + sovPb(uint64(m.Offset)) } if m.ReadTs != 0 { - n += 1 + sovInternal(uint64(m.ReadTs)) + n += 1 + sovPb(uint64(m.ReadTs)) } return n } func (m *SortResult) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.UidMatrix) > 0 { for _, e := range m.UidMatrix { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *RaftContext) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Id != 0 { n += 9 } if m.Group != 0 { - n += 1 + sovInternal(uint64(m.Group)) + n += 1 + sovPb(uint64(m.Group)) } l = len(m.Addr) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.SnapshotTs != 0 { - n += 1 + sovInternal(uint64(m.SnapshotTs)) + n += 1 + sovPb(uint64(m.SnapshotTs)) } return n } func (m *Member) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Id != 0 { n += 9 } if m.GroupId != 0 { - n += 1 + sovInternal(uint64(m.GroupId)) + n += 1 + sovPb(uint64(m.GroupId)) } l = len(m.Addr) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Leader { n += 2 @@ -5464,7 +6744,7 @@ func (m *Member) Size() (n int) { n += 2 } if m.LastUpdate != 0 { - n += 1 + sovInternal(uint64(m.LastUpdate)) + n += 1 + sovPb(uint64(m.LastUpdate)) } if m.ClusterInfoOnly { n += 2 @@ -5473,6 +6753,9 @@ func (m *Member) Size() (n int) { } func (m *Group) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Members) > 0 { @@ -5482,10 +6765,10 @@ func (m *Group) Size() (n int) { l = 0 if v != nil { l = v.Size() - l += 1 + sovInternal(uint64(l)) + l += 1 + sovPb(uint64(l)) } - mapEntrySize := 1 + sovInternal(uint64(k)) + l - n += mapEntrySize + 1 + sovInternal(uint64(mapEntrySize)) + mapEntrySize := 1 + sovPb(uint64(k)) + l + n += mapEntrySize + 1 + sovPb(uint64(mapEntrySize)) } } if len(m.Tablets) > 0 { @@ -5495,55 +6778,61 @@ func (m *Group) Size() (n int) { l = 0 if v != nil { l = v.Size() - l += 1 + sovInternal(uint64(l)) + l += 1 + sovPb(uint64(l)) } - mapEntrySize := 1 + len(k) + sovInternal(uint64(len(k))) + l - n += mapEntrySize + 1 + sovInternal(uint64(mapEntrySize)) + mapEntrySize := 1 + len(k) + sovPb(uint64(len(k))) + l + n += mapEntrySize + 1 + sovPb(uint64(mapEntrySize)) } } return n } func (m *ZeroProposal) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Member != nil { l = m.Member.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Tablet != nil { l = m.Tablet.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.MaxLeaseId != 0 { - n += 1 + sovInternal(uint64(m.MaxLeaseId)) + n += 1 + sovPb(uint64(m.MaxLeaseId)) } if m.MaxTxnTs != 0 { - n += 1 + sovInternal(uint64(m.MaxTxnTs)) + n += 1 + sovPb(uint64(m.MaxTxnTs)) } if m.MaxRaftId != 0 { - n += 1 + sovInternal(uint64(m.MaxRaftId)) + n += 1 + sovPb(uint64(m.MaxRaftId)) } if m.Txn != nil { l = m.Txn.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Key) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Cid) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *MembershipState) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Counter != 0 { - n += 1 + sovInternal(uint64(m.Counter)) + n += 1 + sovPb(uint64(m.Counter)) } if len(m.Groups) > 0 { for k, v := range m.Groups { @@ -5552,10 +6841,10 @@ func (m *MembershipState) Size() (n int) { l = 0 if v != nil { l = v.Size() - l += 1 + sovInternal(uint64(l)) + l += 1 + sovPb(uint64(l)) } - mapEntrySize := 1 + sovInternal(uint64(k)) + l - n += mapEntrySize + 1 + sovInternal(uint64(mapEntrySize)) + mapEntrySize := 1 + sovPb(uint64(k)) + l + n += mapEntrySize + 1 + sovPb(uint64(mapEntrySize)) } } if len(m.Zeros) > 0 { @@ -5565,60 +6854,66 @@ func (m *MembershipState) Size() (n int) { l = 0 if v != nil { l = v.Size() - l += 1 + sovInternal(uint64(l)) + l += 1 + sovPb(uint64(l)) } - mapEntrySize := 1 + sovInternal(uint64(k)) + l - n += mapEntrySize + 1 + sovInternal(uint64(mapEntrySize)) + mapEntrySize := 1 + sovPb(uint64(k)) + l + n += mapEntrySize + 1 + sovPb(uint64(mapEntrySize)) } } if m.MaxLeaseId != 0 { - n += 1 + sovInternal(uint64(m.MaxLeaseId)) + n += 1 + sovPb(uint64(m.MaxLeaseId)) } if m.MaxTxnTs != 0 { - n += 1 + sovInternal(uint64(m.MaxTxnTs)) + n += 1 + sovPb(uint64(m.MaxTxnTs)) } if m.MaxRaftId != 0 { - n += 1 + sovInternal(uint64(m.MaxRaftId)) + n += 1 + sovPb(uint64(m.MaxRaftId)) } if len(m.Removed) > 0 { for _, e := range m.Removed { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } l = len(m.Cid) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *ConnectionState) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Member != nil { l = m.Member.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.State != nil { l = m.State.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.MaxPending != 0 { - n += 1 + sovInternal(uint64(m.MaxPending)) + n += 1 + sovPb(uint64(m.MaxPending)) } return n } func (m *Tablet) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.GroupId != 0 { - n += 1 + sovInternal(uint64(m.GroupId)) + n += 1 + sovPb(uint64(m.GroupId)) } l = len(m.Predicate) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Force { n += 2 @@ -5627,7 +6922,7 @@ func (m *Tablet) Size() (n int) { n += 2 } if m.Space != 0 { - n += 1 + sovInternal(uint64(m.Space)) + n += 1 + sovPb(uint64(m.Space)) } if m.Remove { n += 2 @@ -5636,6 +6931,9 @@ func (m *Tablet) Size() (n int) { } func (m *DirectedEdge) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Entity != 0 { @@ -5643,57 +6941,60 @@ func (m *DirectedEdge) Size() (n int) { } l = len(m.Attr) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Value) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.ValueType != 0 { - n += 1 + sovInternal(uint64(m.ValueType)) + n += 1 + sovPb(uint64(m.ValueType)) } if m.ValueId != 0 { n += 9 } l = len(m.Label) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Lang) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Op != 0 { - n += 1 + sovInternal(uint64(m.Op)) + n += 1 + sovPb(uint64(m.Op)) } if len(m.Facets) > 0 { for _, e := range m.Facets { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *Mutations) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.GroupId != 0 { - n += 1 + sovInternal(uint64(m.GroupId)) + n += 1 + sovPb(uint64(m.GroupId)) } if m.StartTs != 0 { - n += 1 + sovInternal(uint64(m.StartTs)) + n += 1 + sovPb(uint64(m.StartTs)) } if len(m.Edges) > 0 { for _, e := range m.Edges { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if len(m.Schema) > 0 { for _, e := range m.Schema { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.DropAll { @@ -5706,103 +7007,121 @@ func (m *Mutations) Size() (n int) { } func (m *KeyValues) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Kv) > 0 { for _, e := range m.Kv { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *Snapshot) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Context != nil { l = m.Context.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Index != 0 { - n += 1 + sovInternal(uint64(m.Index)) + n += 1 + sovPb(uint64(m.Index)) } if m.ReadTs != 0 { - n += 1 + sovInternal(uint64(m.ReadTs)) + n += 1 + sovPb(uint64(m.ReadTs)) } return n } func (m *Proposal) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Mutations != nil { l = m.Mutations.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if len(m.Kv) > 0 { for _, e := range m.Kv { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.State != nil { l = m.State.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.CleanPredicate) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Key) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Delta != nil { l = m.Delta.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Snapshot != nil { l = m.Snapshot.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *KVS) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Kv) > 0 { for _, e := range m.Kv { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *KV) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Key) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Val) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.UserMeta) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Version != 0 { - n += 1 + sovInternal(uint64(m.Version)) + n += 1 + sovPb(uint64(m.Version)) } return n } func (m *Posting) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Uid != 0 { @@ -5810,78 +7129,87 @@ func (m *Posting) Size() (n int) { } l = len(m.Value) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.ValType != 0 { - n += 1 + sovInternal(uint64(m.ValType)) + n += 1 + sovPb(uint64(m.ValType)) } if m.PostingType != 0 { - n += 1 + sovInternal(uint64(m.PostingType)) + n += 1 + sovPb(uint64(m.PostingType)) } l = len(m.LangTag) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Label) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if len(m.Facets) > 0 { for _, e := range m.Facets { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.Op != 0 { - n += 1 + sovInternal(uint64(m.Op)) + n += 1 + sovPb(uint64(m.Op)) } if m.StartTs != 0 { - n += 1 + sovInternal(uint64(m.StartTs)) + n += 1 + sovPb(uint64(m.StartTs)) } if m.CommitTs != 0 { - n += 1 + sovInternal(uint64(m.CommitTs)) + n += 1 + sovPb(uint64(m.CommitTs)) } return n } func (m *PostingList) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Postings) > 0 { for _, e := range m.Postings { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } l = len(m.Checksum) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Commit != 0 { - n += 1 + sovInternal(uint64(m.Commit)) + n += 1 + sovPb(uint64(m.Commit)) } l = len(m.Uids) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *FacetParam) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Key) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Alias) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *FacetParams) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.AllKeys { @@ -5890,126 +7218,147 @@ func (m *FacetParams) Size() (n int) { if len(m.Param) > 0 { for _, e := range m.Param { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *Facets) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Facets) > 0 { for _, e := range m.Facets { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *FacetsList) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.FacetsList) > 0 { for _, e := range m.FacetsList { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *Function) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Name) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } l = len(m.Key) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if len(m.Args) > 0 { for _, s := range m.Args { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *FilterTree) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Op) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if len(m.Children) > 0 { for _, e := range m.Children { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.Func != nil { l = m.Func.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *SchemaRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.GroupId != 0 { - n += 1 + sovInternal(uint64(m.GroupId)) + n += 1 + sovPb(uint64(m.GroupId)) } if len(m.Predicates) > 0 { for _, s := range m.Predicates { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if len(m.Fields) > 0 { for _, s := range m.Fields { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *SchemaResult) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Schema) > 0 { for _, e := range m.Schema { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } return n } func (m *SchemaUpdate) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Predicate) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.ValueType != 0 { - n += 1 + sovInternal(uint64(m.ValueType)) + n += 1 + sovPb(uint64(m.ValueType)) } if m.Directive != 0 { - n += 1 + sovInternal(uint64(m.Directive)) + n += 1 + sovPb(uint64(m.Directive)) } if len(m.Tokenizer) > 0 { for _, s := range m.Tokenizer { l = len(s) - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.Count { @@ -6028,101 +7377,122 @@ func (m *SchemaUpdate) Size() (n int) { } func (m *MapEntry) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Key) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Uid != 0 { n += 9 } if m.Posting != nil { l = m.Posting.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *MovePredicatePayload) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Predicate) if l > 0 { - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.SourceGroupId != 0 { - n += 1 + sovInternal(uint64(m.SourceGroupId)) + n += 1 + sovPb(uint64(m.SourceGroupId)) } if m.DestGroupId != 0 { - n += 1 + sovInternal(uint64(m.DestGroupId)) + n += 1 + sovPb(uint64(m.DestGroupId)) } if m.State != nil { l = m.State.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *ExportPayload) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.ReqId != 0 { - n += 1 + sovInternal(uint64(m.ReqId)) + n += 1 + sovPb(uint64(m.ReqId)) } if m.GroupId != 0 { - n += 1 + sovInternal(uint64(m.GroupId)) + n += 1 + sovPb(uint64(m.GroupId)) } if m.Status != 0 { - n += 1 + sovInternal(uint64(m.Status)) + n += 1 + sovPb(uint64(m.Status)) } if m.ReadTs != 0 { - n += 1 + sovInternal(uint64(m.ReadTs)) + n += 1 + sovPb(uint64(m.ReadTs)) } return n } func (m *TxnStatus) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.StartTs != 0 { - n += 1 + sovInternal(uint64(m.StartTs)) + n += 1 + sovPb(uint64(m.StartTs)) } if m.CommitTs != 0 { - n += 1 + sovInternal(uint64(m.CommitTs)) + n += 1 + sovPb(uint64(m.CommitTs)) } return n } func (m *OracleDelta) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Txns) > 0 { for _, e := range m.Txns { l = e.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } } if m.MaxAssigned != 0 { - n += 1 + sovInternal(uint64(m.MaxAssigned)) + n += 1 + sovPb(uint64(m.MaxAssigned)) } return n } func (m *TxnTimestamps) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if len(m.Ts) > 0 { l = 0 for _, e := range m.Ts { - l += sovInternal(uint64(e)) + l += sovPb(uint64(e)) } - n += 1 + sovInternal(uint64(l)) + l + n += 1 + sovPb(uint64(l)) + l } return n } func (m *PeerResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Status { @@ -6132,24 +7502,30 @@ func (m *PeerResponse) Size() (n int) { } func (m *RaftBatch) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Context != nil { l = m.Context.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } if m.Payload != nil { l = m.Payload.Size() - n += 1 + l + sovInternal(uint64(l)) + n += 1 + l + sovPb(uint64(l)) } return n } func (m *Num) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.Val != 0 { - n += 1 + sovInternal(uint64(m.Val)) + n += 1 + sovPb(uint64(m.Val)) } if m.ReadOnly { n += 2 @@ -6158,33 +7534,39 @@ func (m *Num) Size() (n int) { } func (m *AssignedIds) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.StartId != 0 { - n += 1 + sovInternal(uint64(m.StartId)) + n += 1 + sovPb(uint64(m.StartId)) } if m.EndId != 0 { - n += 1 + sovInternal(uint64(m.EndId)) + n += 1 + sovPb(uint64(m.EndId)) } if m.ReadOnly != 0 { - n += 1 + sovInternal(uint64(m.ReadOnly)) + n += 1 + sovPb(uint64(m.ReadOnly)) } return n } func (m *SnapshotMeta) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l if m.ClientTs != 0 { - n += 1 + sovInternal(uint64(m.ClientTs)) + n += 1 + sovPb(uint64(m.ClientTs)) } if m.GroupId != 0 { - n += 1 + sovInternal(uint64(m.GroupId)) + n += 1 + sovPb(uint64(m.GroupId)) } return n } -func sovInternal(x uint64) (n int) { +func sovPb(x uint64) (n int) { for { n++ x >>= 7 @@ -6194,8 +7576,8 @@ func sovInternal(x uint64) (n int) { } return n } -func sozInternal(x uint64) (n int) { - return sovInternal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozPb(x uint64) (n int) { + return sovPb(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *List) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -6205,7 +7587,7 @@ func (m *List) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6232,14 +7614,14 @@ func (m *List) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 m.Uids = append(m.Uids, v) } else if wireType == 2 { var packedLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6252,18 +7634,23 @@ func (m *List) Unmarshal(dAtA []byte) error { } } if packedLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + packedLen if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.Uids) == 0 { + m.Uids = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 m.Uids = append(m.Uids, v) } @@ -6272,12 +7659,12 @@ func (m *List) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -6299,7 +7686,7 @@ func (m *TaskValue) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6327,7 +7714,7 @@ func (m *TaskValue) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6340,7 +7727,7 @@ func (m *TaskValue) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -6358,7 +7745,7 @@ func (m *TaskValue) Unmarshal(dAtA []byte) error { m.ValType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6372,12 +7759,12 @@ func (m *TaskValue) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -6399,7 +7786,7 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6427,7 +7814,7 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6441,7 +7828,7 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -6456,7 +7843,7 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6470,7 +7857,7 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -6485,7 +7872,7 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6500,12 +7887,12 @@ func (m *SrcFunction) Unmarshal(dAtA []byte) error { m.IsCount = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -6527,7 +7914,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6555,7 +7942,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6569,7 +7956,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -6584,7 +7971,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6598,7 +7985,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -6614,7 +8001,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.AfterUid = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.AfterUid = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 4: if wireType != 0 { @@ -6623,7 +8010,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6643,7 +8030,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6656,7 +8043,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -6676,7 +8063,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6689,7 +8076,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -6709,7 +8096,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6729,7 +8116,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6742,7 +8129,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -6762,7 +8149,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6775,7 +8162,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -6795,7 +8182,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6815,7 +8202,7 @@ func (m *Query) Unmarshal(dAtA []byte) error { m.ReadTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6829,12 +8216,12 @@ func (m *Query) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -6856,7 +8243,7 @@ func (m *ValueList) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6884,7 +8271,7 @@ func (m *ValueList) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6897,7 +8284,7 @@ func (m *ValueList) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -6910,12 +8297,12 @@ func (m *ValueList) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -6937,7 +8324,7 @@ func (m *LangList) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6965,7 +8352,7 @@ func (m *LangList) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -6979,7 +8366,7 @@ func (m *LangList) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -6989,12 +8376,12 @@ func (m *LangList) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7016,7 +8403,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7044,7 +8431,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7057,7 +8444,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7075,7 +8462,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7088,7 +8475,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7104,7 +8491,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var v uint32 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7121,7 +8508,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var packedLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7134,17 +8521,28 @@ func (m *Result) Unmarshal(dAtA []byte) error { } } if packedLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + packedLen if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Counts) == 0 { + m.Counts = make([]uint32, 0, elementCount) + } for iNdEx < postIndex { var v uint32 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7168,7 +8566,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7188,7 +8586,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7201,7 +8599,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7219,7 +8617,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7232,7 +8630,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7250,7 +8648,7 @@ func (m *Result) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7265,12 +8663,12 @@ func (m *Result) Unmarshal(dAtA []byte) error { m.List = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7292,7 +8690,7 @@ func (m *Order) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7320,7 +8718,7 @@ func (m *Order) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7334,7 +8732,7 @@ func (m *Order) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -7349,7 +8747,7 @@ func (m *Order) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7369,7 +8767,7 @@ func (m *Order) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7383,7 +8781,7 @@ func (m *Order) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -7393,12 +8791,12 @@ func (m *Order) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7420,7 +8818,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7448,7 +8846,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7461,7 +8859,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7479,7 +8877,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7492,7 +8890,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7510,7 +8908,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { m.Count = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7529,7 +8927,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { m.Offset = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7548,7 +8946,7 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { m.ReadTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7562,12 +8960,12 @@ func (m *SortMessage) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7589,7 +8987,7 @@ func (m *SortResult) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7617,7 +9015,7 @@ func (m *SortResult) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7630,7 +9028,7 @@ func (m *SortResult) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -7643,12 +9041,12 @@ func (m *SortResult) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7670,7 +9068,7 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7699,7 +9097,7 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.Id = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.Id = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 2: if wireType != 0 { @@ -7708,7 +9106,7 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { m.Group = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7727,7 +9125,7 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7741,7 +9139,7 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -7756,7 +9154,7 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { m.SnapshotTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7770,12 +9168,12 @@ func (m *RaftContext) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7797,7 +9195,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7826,7 +9224,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.Id = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.Id = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 2: if wireType != 0 { @@ -7835,7 +9233,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7854,7 +9252,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7868,7 +9266,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -7883,7 +9281,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7903,7 +9301,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7923,7 +9321,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { m.LastUpdate = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7942,7 +9340,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -7957,12 +9355,12 @@ func (m *Member) Unmarshal(dAtA []byte) error { m.ClusterInfoOnly = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -7984,7 +9382,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8012,7 +9410,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8025,7 +9423,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8041,7 +9439,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8057,7 +9455,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { if fieldNum == 1 { for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8073,7 +9471,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var mapmsglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8086,11 +9484,11 @@ func (m *Group) Unmarshal(dAtA []byte) error { } } if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postmsgIndex := iNdEx + mapmsglen if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if postmsgIndex > l { return io.ErrUnexpectedEOF @@ -8102,12 +9500,12 @@ func (m *Group) Unmarshal(dAtA []byte) error { iNdEx = postmsgIndex } else { iNdEx = entryPreIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > postIndex { return io.ErrUnexpectedEOF @@ -8124,7 +9522,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8137,7 +9535,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8153,7 +9551,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8170,7 +9568,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var stringLenmapkey uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8184,7 +9582,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { } intStringLenmapkey := int(stringLenmapkey) if intStringLenmapkey < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postStringIndexmapkey := iNdEx + intStringLenmapkey if postStringIndexmapkey > l { @@ -8196,7 +9594,7 @@ func (m *Group) Unmarshal(dAtA []byte) error { var mapmsglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8209,11 +9607,11 @@ func (m *Group) Unmarshal(dAtA []byte) error { } } if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postmsgIndex := iNdEx + mapmsglen if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if postmsgIndex > l { return io.ErrUnexpectedEOF @@ -8225,12 +9623,12 @@ func (m *Group) Unmarshal(dAtA []byte) error { iNdEx = postmsgIndex } else { iNdEx = entryPreIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > postIndex { return io.ErrUnexpectedEOF @@ -8242,12 +9640,12 @@ func (m *Group) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -8269,7 +9667,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8297,7 +9695,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8310,7 +9708,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8330,7 +9728,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8343,7 +9741,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8363,7 +9761,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { m.MaxLeaseId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8382,7 +9780,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { m.MaxTxnTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8401,7 +9799,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { m.MaxRaftId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8420,7 +9818,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8433,7 +9831,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8453,7 +9851,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8467,7 +9865,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -8482,7 +9880,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8496,7 +9894,7 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -8506,12 +9904,12 @@ func (m *ZeroProposal) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -8533,7 +9931,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8561,7 +9959,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { m.Counter = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8580,7 +9978,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8593,7 +9991,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8609,7 +10007,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8625,7 +10023,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { if fieldNum == 1 { for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8641,7 +10039,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var mapmsglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8654,11 +10052,11 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { } } if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postmsgIndex := iNdEx + mapmsglen if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if postmsgIndex > l { return io.ErrUnexpectedEOF @@ -8670,12 +10068,12 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { iNdEx = postmsgIndex } else { iNdEx = entryPreIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > postIndex { return io.ErrUnexpectedEOF @@ -8692,7 +10090,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8705,7 +10103,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8721,7 +10119,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8737,7 +10135,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { if fieldNum == 1 { for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8753,7 +10151,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var mapmsglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8766,11 +10164,11 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { } } if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postmsgIndex := iNdEx + mapmsglen if mapmsglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if postmsgIndex > l { return io.ErrUnexpectedEOF @@ -8782,12 +10180,12 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { iNdEx = postmsgIndex } else { iNdEx = entryPreIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > postIndex { return io.ErrUnexpectedEOF @@ -8804,7 +10202,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { m.MaxLeaseId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8823,7 +10221,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { m.MaxTxnTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8842,7 +10240,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { m.MaxRaftId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8861,7 +10259,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8874,7 +10272,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -8892,7 +10290,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8906,7 +10304,7 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -8916,12 +10314,12 @@ func (m *MembershipState) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -8943,7 +10341,7 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8971,7 +10369,7 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -8984,7 +10382,7 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9004,7 +10402,7 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9017,7 +10415,7 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9037,7 +10435,7 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { m.MaxPending = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9051,12 +10449,12 @@ func (m *ConnectionState) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -9078,7 +10476,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9106,7 +10504,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9125,7 +10523,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9139,7 +10537,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -9154,7 +10552,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9174,7 +10572,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9194,7 +10592,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { m.Space = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9213,7 +10611,7 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9228,12 +10626,12 @@ func (m *Tablet) Unmarshal(dAtA []byte) error { m.Remove = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -9255,7 +10653,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9284,7 +10682,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.Entity = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.Entity = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 2: if wireType != 2 { @@ -9293,7 +10691,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9307,7 +10705,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -9322,7 +10720,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9335,7 +10733,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -9353,7 +10751,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { m.ValueType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9373,7 +10771,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.ValueId = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.ValueId = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 6: if wireType != 2 { @@ -9382,7 +10780,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9396,7 +10794,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -9411,7 +10809,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9425,7 +10823,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -9440,7 +10838,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { m.Op = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9459,7 +10857,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9472,7 +10870,7 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9485,12 +10883,12 @@ func (m *DirectedEdge) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -9512,7 +10910,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9540,7 +10938,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9559,7 +10957,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { m.StartTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9578,7 +10976,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9591,7 +10989,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9609,7 +11007,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9622,7 +11020,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9640,7 +11038,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9660,7 +11058,7 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9675,12 +11073,12 @@ func (m *Mutations) Unmarshal(dAtA []byte) error { m.IgnoreIndexConflict = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -9702,7 +11100,7 @@ func (m *KeyValues) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9730,7 +11128,7 @@ func (m *KeyValues) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9743,7 +11141,7 @@ func (m *KeyValues) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9756,12 +11154,12 @@ func (m *KeyValues) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -9783,7 +11181,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9811,7 +11209,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9824,7 +11222,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9844,7 +11242,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { m.Index = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9863,7 +11261,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { m.ReadTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9877,12 +11275,12 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -9904,7 +11302,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9932,7 +11330,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9945,7 +11343,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9965,7 +11363,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -9978,7 +11376,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -9996,7 +11394,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10009,7 +11407,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -10029,7 +11427,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10043,7 +11441,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -10058,7 +11456,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10072,7 +11470,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -10087,7 +11485,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10100,7 +11498,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -10120,7 +11518,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10133,7 +11531,7 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -10148,12 +11546,12 @@ func (m *Proposal) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -10175,7 +11573,7 @@ func (m *KVS) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10203,7 +11601,7 @@ func (m *KVS) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10216,7 +11614,7 @@ func (m *KVS) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -10229,12 +11627,12 @@ func (m *KVS) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -10256,7 +11654,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10284,7 +11682,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10297,7 +11695,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10315,7 +11713,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10328,7 +11726,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10346,7 +11744,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10359,7 +11757,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10377,7 +11775,7 @@ func (m *KV) Unmarshal(dAtA []byte) error { m.Version = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10391,12 +11789,12 @@ func (m *KV) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -10418,7 +11816,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10447,7 +11845,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.Uid = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.Uid = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 2: if wireType != 2 { @@ -10456,7 +11854,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10469,7 +11867,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10487,7 +11885,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { m.ValType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10506,7 +11904,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { m.PostingType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10525,7 +11923,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10538,7 +11936,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10556,7 +11954,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10570,7 +11968,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -10585,7 +11983,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10598,7 +11996,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -10616,7 +12014,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { m.Op = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10635,7 +12033,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { m.StartTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10654,7 +12052,7 @@ func (m *Posting) Unmarshal(dAtA []byte) error { m.CommitTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10668,12 +12066,12 @@ func (m *Posting) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -10695,7 +12093,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10723,7 +12121,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10736,7 +12134,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -10754,7 +12152,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10767,7 +12165,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10785,7 +12183,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { m.Commit = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10804,7 +12202,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10817,7 +12215,7 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -10830,12 +12228,12 @@ func (m *PostingList) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -10857,7 +12255,7 @@ func (m *FacetParam) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10885,7 +12283,7 @@ func (m *FacetParam) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10899,7 +12297,7 @@ func (m *FacetParam) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -10914,7 +12312,7 @@ func (m *FacetParam) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10928,7 +12326,7 @@ func (m *FacetParam) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -10938,12 +12336,12 @@ func (m *FacetParam) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -10965,7 +12363,7 @@ func (m *FacetParams) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -10993,7 +12391,7 @@ func (m *FacetParams) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11013,7 +12411,7 @@ func (m *FacetParams) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11026,7 +12424,7 @@ func (m *FacetParams) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -11039,12 +12437,12 @@ func (m *FacetParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11066,7 +12464,7 @@ func (m *Facets) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11094,7 +12492,7 @@ func (m *Facets) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11107,7 +12505,7 @@ func (m *Facets) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -11120,12 +12518,12 @@ func (m *Facets) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11147,7 +12545,7 @@ func (m *FacetsList) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11175,7 +12573,7 @@ func (m *FacetsList) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11188,7 +12586,7 @@ func (m *FacetsList) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -11201,12 +12599,12 @@ func (m *FacetsList) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11228,7 +12626,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11256,7 +12654,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11270,7 +12668,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11285,7 +12683,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11299,7 +12697,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11314,7 +12712,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11328,7 +12726,7 @@ func (m *Function) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11338,12 +12736,12 @@ func (m *Function) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11365,7 +12763,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11393,7 +12791,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11407,7 +12805,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11422,7 +12820,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11435,7 +12833,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -11453,7 +12851,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11466,7 +12864,7 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -11481,12 +12879,12 @@ func (m *FilterTree) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11508,7 +12906,7 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11536,7 +12934,7 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11555,7 +12953,7 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11569,7 +12967,7 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11584,7 +12982,7 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11598,7 +12996,7 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11608,12 +13006,12 @@ func (m *SchemaRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11635,7 +13033,7 @@ func (m *SchemaResult) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11663,7 +13061,7 @@ func (m *SchemaResult) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11676,7 +13074,7 @@ func (m *SchemaResult) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -11689,12 +13087,12 @@ func (m *SchemaResult) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11716,7 +13114,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11744,7 +13142,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11758,7 +13156,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11773,7 +13171,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { m.ValueType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11792,7 +13190,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { m.Directive = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11811,7 +13209,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11825,7 +13223,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -11840,7 +13238,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11860,7 +13258,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11880,7 +13278,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11900,7 +13298,7 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11915,12 +13313,12 @@ func (m *SchemaUpdate) Unmarshal(dAtA []byte) error { m.Lang = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -11942,7 +13340,7 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11970,7 +13368,7 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -11983,7 +13381,7 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + byteLen if postIndex > l { @@ -12002,7 +13400,7 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.Uid = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + m.Uid = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 case 3: if wireType != 2 { @@ -12011,7 +13409,7 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12024,7 +13422,7 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -12039,12 +13437,12 @@ func (m *MapEntry) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12066,7 +13464,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12094,7 +13492,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12108,7 +13506,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + intStringLen if postIndex > l { @@ -12123,7 +13521,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { m.SourceGroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12142,7 +13540,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { m.DestGroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12161,7 +13559,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12174,7 +13572,7 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -12189,12 +13587,12 @@ func (m *MovePredicatePayload) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12216,7 +13614,7 @@ func (m *ExportPayload) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12244,7 +13642,7 @@ func (m *ExportPayload) Unmarshal(dAtA []byte) error { m.ReqId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12263,7 +13661,7 @@ func (m *ExportPayload) Unmarshal(dAtA []byte) error { m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12282,7 +13680,7 @@ func (m *ExportPayload) Unmarshal(dAtA []byte) error { m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12301,7 +13699,7 @@ func (m *ExportPayload) Unmarshal(dAtA []byte) error { m.ReadTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12315,12 +13713,12 @@ func (m *ExportPayload) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12342,7 +13740,7 @@ func (m *TxnStatus) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12370,7 +13768,7 @@ func (m *TxnStatus) Unmarshal(dAtA []byte) error { m.StartTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12389,7 +13787,7 @@ func (m *TxnStatus) Unmarshal(dAtA []byte) error { m.CommitTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12403,12 +13801,12 @@ func (m *TxnStatus) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12430,7 +13828,7 @@ func (m *OracleDelta) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12458,7 +13856,7 @@ func (m *OracleDelta) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12471,7 +13869,7 @@ func (m *OracleDelta) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -12489,7 +13887,7 @@ func (m *OracleDelta) Unmarshal(dAtA []byte) error { m.MaxAssigned = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12503,12 +13901,12 @@ func (m *OracleDelta) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12530,7 +13928,7 @@ func (m *TxnTimestamps) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12556,7 +13954,7 @@ func (m *TxnTimestamps) Unmarshal(dAtA []byte) error { var v uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12573,7 +13971,7 @@ func (m *TxnTimestamps) Unmarshal(dAtA []byte) error { var packedLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12586,17 +13984,28 @@ func (m *TxnTimestamps) Unmarshal(dAtA []byte) error { } } if packedLen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + packedLen if postIndex > l { return io.ErrUnexpectedEOF } + var elementCount int + var count int + for _, integer := range dAtA { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Ts) == 0 { + m.Ts = make([]uint64, 0, elementCount) + } for iNdEx < postIndex { var v uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12615,12 +14024,12 @@ func (m *TxnTimestamps) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12642,7 +14051,7 @@ func (m *PeerResponse) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12670,7 +14079,7 @@ func (m *PeerResponse) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12685,12 +14094,12 @@ func (m *PeerResponse) Unmarshal(dAtA []byte) error { m.Status = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12712,7 +14121,7 @@ func (m *RaftBatch) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12740,7 +14149,7 @@ func (m *RaftBatch) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12753,7 +14162,7 @@ func (m *RaftBatch) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -12773,7 +14182,7 @@ func (m *RaftBatch) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12786,7 +14195,7 @@ func (m *RaftBatch) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } postIndex := iNdEx + msglen if postIndex > l { @@ -12801,12 +14210,12 @@ func (m *RaftBatch) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12828,7 +14237,7 @@ func (m *Num) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12856,7 +14265,7 @@ func (m *Num) Unmarshal(dAtA []byte) error { m.Val = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12875,7 +14284,7 @@ func (m *Num) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12890,12 +14299,12 @@ func (m *Num) Unmarshal(dAtA []byte) error { m.ReadOnly = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -12917,7 +14326,7 @@ func (m *AssignedIds) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12945,7 +14354,7 @@ func (m *AssignedIds) Unmarshal(dAtA []byte) error { m.StartId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12964,7 +14373,7 @@ func (m *AssignedIds) Unmarshal(dAtA []byte) error { m.EndId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12983,7 +14392,7 @@ func (m *AssignedIds) Unmarshal(dAtA []byte) error { m.ReadOnly = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -12997,12 +14406,12 @@ func (m *AssignedIds) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -13024,7 +14433,7 @@ func (m *SnapshotMeta) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -13052,7 +14461,7 @@ func (m *SnapshotMeta) Unmarshal(dAtA []byte) error { m.ClientTs = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -13071,7 +14480,7 @@ func (m *SnapshotMeta) Unmarshal(dAtA []byte) error { m.GroupId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowInternal + return ErrIntOverflowPb } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -13085,12 +14494,12 @@ func (m *SnapshotMeta) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipInternal(dAtA[iNdEx:]) + skippy, err := skipPb(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthInternal + return ErrInvalidLengthPb } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -13104,14 +14513,14 @@ func (m *SnapshotMeta) Unmarshal(dAtA []byte) error { } return nil } -func skipInternal(dAtA []byte) (n int, err error) { +func skipPb(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 for iNdEx < l { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowInternal + return 0, ErrIntOverflowPb } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -13128,7 +14537,7 @@ func skipInternal(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowInternal + return 0, ErrIntOverflowPb } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -13146,7 +14555,7 @@ func skipInternal(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowInternal + return 0, ErrIntOverflowPb } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -13160,7 +14569,7 @@ func skipInternal(dAtA []byte) (n int, err error) { } iNdEx += length if length < 0 { - return 0, ErrInvalidLengthInternal + return 0, ErrInvalidLengthPb } return iNdEx, nil case 3: @@ -13169,7 +14578,7 @@ func skipInternal(dAtA []byte) (n int, err error) { var start int = iNdEx for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowInternal + return 0, ErrIntOverflowPb } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -13185,7 +14594,7 @@ func skipInternal(dAtA []byte) (n int, err error) { if innerWireType == 4 { break } - next, err := skipInternal(dAtA[start:]) + next, err := skipPb(dAtA[start:]) if err != nil { return 0, err } @@ -13205,205 +14614,204 @@ func skipInternal(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthInternal = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowInternal = fmt.Errorf("proto: integer overflow") + ErrInvalidLengthPb = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPb = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) } - -var fileDescriptorInternal = []byte{ - // 3075 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x39, 0x4b, 0x6f, 0x23, 0xc7, - 0xd1, 0x9a, 0x21, 0x39, 0x1c, 0x16, 0x49, 0x2d, 0xdd, 0x5e, 0xdb, 0x34, 0xed, 0x4f, 0x96, 0xc7, - 0xf6, 0xae, 0x6c, 0xaf, 0x65, 0xaf, 0xbc, 0x7e, 0x7e, 0x71, 0x00, 0xad, 0xc4, 0x5d, 0xd3, 0xab, - 0x97, 0x9b, 0xd4, 0x3a, 0xf6, 0x21, 0x44, 0x8b, 0xd3, 0xa2, 0x06, 0x1a, 0xce, 0x8c, 0xa7, 0x87, - 0x02, 0xe5, 0x63, 0x72, 0x0a, 0xf2, 0x07, 0x82, 0x1c, 0x73, 0x08, 0x92, 0x53, 0x80, 0xfc, 0x87, - 0x00, 0x09, 0xe0, 0x43, 0xee, 0xb9, 0x24, 0xce, 0x2d, 0xb7, 0xfc, 0x82, 0x04, 0x5d, 0xdd, 0xf3, - 0x20, 0xf5, 0xc8, 0x26, 0x41, 0x4e, 0x9c, 0xaa, 0xae, 0xea, 0xea, 0xae, 0xaa, 0xae, 0x17, 0x61, - 0xd9, 0x0b, 0x12, 0x1e, 0x07, 0xcc, 0x5f, 0x8f, 0xe2, 0x30, 0x09, 0x89, 0xa5, 0xe0, 0x4e, 0x8d, - 0x45, 0x9e, 0x42, 0x39, 0x1d, 0x28, 0xef, 0x78, 0x22, 0x21, 0x04, 0xca, 0x53, 0xcf, 0x15, 0x6d, - 0x63, 0xb5, 0xb4, 0x66, 0x51, 0xfc, 0x76, 0x3e, 0x87, 0xda, 0x80, 0x89, 0xd3, 0xc7, 0xcc, 0x9f, - 0x72, 0xd2, 0x82, 0xd2, 0x19, 0xf3, 0xdb, 0xc6, 0xaa, 0xb1, 0xd6, 0xa0, 0xf2, 0x93, 0x6c, 0x80, - 0x7d, 0xc6, 0xfc, 0x61, 0x72, 0x1e, 0xf1, 0xb6, 0xb9, 0x6a, 0xac, 0x2d, 0x6f, 0x3c, 0xb7, 0xae, - 0x04, 0xac, 0x1f, 0x84, 0x22, 0xf1, 0x82, 0xf1, 0xfa, 0x63, 0xe6, 0x0f, 0xce, 0x23, 0x4e, 0xab, - 0x67, 0xea, 0xc3, 0xd9, 0x87, 0x7a, 0x3f, 0x1e, 0x3d, 0x98, 0x06, 0xa3, 0xc4, 0x0b, 0x03, 0x29, - 0x35, 0x60, 0x13, 0x8e, 0xbb, 0xd6, 0x28, 0x7e, 0x4b, 0x1c, 0x8b, 0xc7, 0xa2, 0x5d, 0x5a, 0x2d, - 0x49, 0x9c, 0xfc, 0x26, 0x6d, 0xa8, 0x7a, 0x62, 0x2b, 0x9c, 0x06, 0x49, 0xbb, 0xbc, 0x6a, 0xac, - 0xd9, 0x34, 0x05, 0x9d, 0x1f, 0x97, 0xa0, 0xf2, 0xf9, 0x94, 0xc7, 0xe7, 0xc8, 0x97, 0x24, 0x71, - 0xba, 0x97, 0xfc, 0x26, 0x37, 0xa1, 0xe2, 0xb3, 0x60, 0x2c, 0xda, 0x26, 0x6e, 0xa6, 0x00, 0xf2, - 0x02, 0xd4, 0xd8, 0x71, 0xc2, 0xe3, 0xe1, 0xd4, 0x73, 0xdb, 0xa5, 0x55, 0x63, 0xcd, 0xa2, 0x36, - 0x22, 0x0e, 0x3d, 0x97, 0x3c, 0x0f, 0xb6, 0x1b, 0x0e, 0x47, 0x45, 0x59, 0x6e, 0x88, 0xb2, 0xc8, - 0x6d, 0xb0, 0xa7, 0x9e, 0x3b, 0xf4, 0x3d, 0x91, 0xb4, 0x2b, 0xab, 0xc6, 0x5a, 0x7d, 0xa3, 0x91, - 0x5e, 0x58, 0xea, 0x90, 0x56, 0xa7, 0x9e, 0x8b, 0xca, 0x5c, 0x07, 0x5b, 0xc4, 0xa3, 0xe1, 0xf1, - 0x34, 0x18, 0xb5, 0x2d, 0x24, 0x7c, 0x3a, 0x25, 0x2c, 0xdc, 0x9e, 0x56, 0x85, 0x02, 0xe4, 0xf5, - 0x62, 0x7e, 0xc6, 0x63, 0xc1, 0xdb, 0x55, 0x25, 0x52, 0x83, 0xe4, 0x1e, 0xd4, 0x8f, 0xd9, 0x88, - 0x27, 0xc3, 0x88, 0xc5, 0x6c, 0xd2, 0xb6, 0xe7, 0x37, 0x7b, 0x20, 0x97, 0x0e, 0xe4, 0x8a, 0xa0, - 0x70, 0x9c, 0x01, 0xe4, 0x03, 0x68, 0x22, 0x24, 0x86, 0xc7, 0x9e, 0x9f, 0xf0, 0xb8, 0x5d, 0x43, - 0x3e, 0x92, 0xf1, 0x21, 0x76, 0x10, 0x73, 0x4e, 0x1b, 0x8a, 0x50, 0x61, 0xc8, 0xff, 0x01, 0xf0, - 0x59, 0xc4, 0x02, 0x77, 0xc8, 0x7c, 0xbf, 0x0d, 0x78, 0x96, 0x9a, 0xc2, 0x6c, 0xfa, 0x3e, 0x79, - 0x4e, 0x9e, 0x93, 0xb9, 0xc3, 0x44, 0xb4, 0x9b, 0xab, 0xc6, 0x5a, 0x99, 0x5a, 0x12, 0x1c, 0x08, - 0xe7, 0x7d, 0xa8, 0xa1, 0x97, 0xe0, 0xed, 0x5f, 0x07, 0xeb, 0x4c, 0x02, 0xca, 0x99, 0xea, 0x1b, - 0x4f, 0xa5, 0x62, 0x33, 0x67, 0xa2, 0x9a, 0xc0, 0x59, 0x01, 0x7b, 0x87, 0x05, 0xe3, 0xd4, 0x03, - 0xa5, 0x79, 0x90, 0xa9, 0x46, 0xf1, 0xdb, 0xf9, 0x95, 0x09, 0x16, 0xe5, 0x62, 0xea, 0x27, 0xe4, - 0x4d, 0x00, 0xa9, 0xfc, 0x09, 0x4b, 0x62, 0x6f, 0xa6, 0x77, 0x9e, 0x57, 0x7f, 0x6d, 0xea, 0xb9, - 0xbb, 0xb8, 0x4c, 0xee, 0x41, 0x03, 0x25, 0xa4, 0xe4, 0xe6, 0xfc, 0x41, 0xb2, 0xb3, 0xd2, 0x3a, - 0x92, 0x69, 0xae, 0x67, 0xc1, 0x42, 0xbb, 0x2b, 0xdf, 0x6b, 0x52, 0x0d, 0x91, 0xd7, 0xf4, 0x43, - 0x12, 0x7c, 0x94, 0x0c, 0x5d, 0x2e, 0x52, 0xc7, 0x68, 0x66, 0xd8, 0x6d, 0x2e, 0x12, 0xf2, 0x1e, - 0x28, 0x65, 0xa6, 0x42, 0x2b, 0x28, 0x94, 0xcc, 0x19, 0x4b, 0x28, 0xa9, 0x48, 0xa7, 0xa5, 0xde, - 0x85, 0xba, 0xbc, 0x6b, 0xca, 0x65, 0x21, 0x57, 0x2b, 0xbb, 0x99, 0x56, 0x0f, 0x05, 0x49, 0xa4, - 0x59, 0xa4, 0xaa, 0xa4, 0x13, 0x2a, 0x67, 0xc1, 0x6f, 0xa7, 0x0b, 0x95, 0xfd, 0xd8, 0xe5, 0xf1, - 0xa5, 0xef, 0x80, 0x40, 0xd9, 0xe5, 0x62, 0x84, 0xcf, 0xd4, 0xa6, 0xf8, 0x9d, 0xbf, 0x8d, 0x52, - 0xe1, 0x6d, 0x38, 0xbf, 0x34, 0xa0, 0xde, 0x0f, 0xe3, 0x64, 0x97, 0x0b, 0xc1, 0xc6, 0x9c, 0xbc, - 0x02, 0x95, 0x50, 0x6e, 0xab, 0x35, 0xde, 0x4c, 0xcf, 0x85, 0xb2, 0xa8, 0x5a, 0x5b, 0xb0, 0x8d, - 0x79, 0xbd, 0x6d, 0x6e, 0x42, 0x45, 0xbd, 0x2e, 0xf9, 0xf2, 0x2a, 0x54, 0x01, 0x52, 0xf7, 0xe1, - 0xf1, 0xb1, 0xe0, 0x4a, 0xb7, 0x15, 0xaa, 0xa1, 0xab, 0x5d, 0xee, 0x23, 0x00, 0x79, 0xce, 0xff, - 0xc0, 0x3b, 0x9c, 0x13, 0xa8, 0x53, 0x76, 0x9c, 0x6c, 0x85, 0x41, 0xc2, 0x67, 0x09, 0x59, 0x06, - 0xd3, 0x73, 0x51, 0x5d, 0x16, 0x35, 0x3d, 0x57, 0x1e, 0x70, 0x1c, 0x87, 0xd3, 0x08, 0xb5, 0xd5, - 0xa4, 0x0a, 0x40, 0xb5, 0xba, 0x6e, 0x8c, 0xa7, 0x96, 0x6a, 0x75, 0xdd, 0x98, 0xbc, 0x04, 0x75, - 0x11, 0xb0, 0x48, 0x9c, 0x84, 0x89, 0x3c, 0x60, 0x19, 0x0f, 0x08, 0x29, 0x6a, 0x20, 0x9c, 0xdf, - 0x19, 0x60, 0xed, 0xf2, 0xc9, 0x11, 0x8f, 0x2f, 0x48, 0x79, 0x1e, 0x6c, 0xdc, 0x78, 0xe8, 0xb9, - 0x5a, 0x50, 0x15, 0xe1, 0x9e, 0x7b, 0xa9, 0xa8, 0x67, 0xc1, 0xf2, 0x39, 0x93, 0x86, 0x50, 0xbe, - 0xa7, 0x21, 0xa9, 0x1f, 0x36, 0x19, 0xba, 0x9c, 0xb9, 0x18, 0x92, 0x6c, 0x6a, 0xb1, 0xc9, 0x36, - 0x67, 0xae, 0x3c, 0x9b, 0xcf, 0x44, 0x32, 0x9c, 0x46, 0x2e, 0x4b, 0x38, 0x86, 0xa1, 0xb2, 0x74, - 0x22, 0x91, 0x1c, 0x22, 0x86, 0xbc, 0x01, 0x4f, 0x8d, 0xfc, 0xa9, 0x90, 0x71, 0xd0, 0x0b, 0x8e, - 0xc3, 0x61, 0x18, 0xf8, 0xe7, 0xa8, 0x63, 0x9b, 0xde, 0xd0, 0x0b, 0xbd, 0xe0, 0x38, 0xdc, 0x0f, - 0xfc, 0x73, 0xe7, 0xa7, 0x26, 0x54, 0x1e, 0xa2, 0x1a, 0xee, 0x41, 0x75, 0x82, 0x17, 0x4a, 0x5f, - 0x77, 0x27, 0xd5, 0x32, 0xae, 0xaf, 0xab, 0xdb, 0x8a, 0x6e, 0x90, 0xc4, 0xe7, 0x34, 0x25, 0x95, - 0x5c, 0x09, 0x3b, 0xf2, 0x79, 0x22, 0xb4, 0x77, 0x2c, 0x70, 0x0d, 0xd4, 0xa2, 0xe6, 0xd2, 0xa4, - 0x9d, 0xcf, 0xa0, 0x51, 0xdc, 0x4e, 0xa6, 0xa0, 0x53, 0x7e, 0x8e, 0x3a, 0x2c, 0x53, 0xf9, 0x49, - 0x5e, 0x85, 0x0a, 0x3e, 0x60, 0xd4, 0x60, 0x7d, 0x63, 0x39, 0xdd, 0x55, 0xb1, 0x51, 0xb5, 0xf8, - 0xb1, 0xf9, 0xa1, 0x21, 0xf7, 0x2a, 0x0a, 0x29, 0xee, 0x55, 0xbb, 0x7e, 0x2f, 0xc5, 0x56, 0xd8, - 0xcb, 0xf9, 0x87, 0x01, 0x8d, 0xaf, 0x78, 0x1c, 0x1e, 0xc4, 0x61, 0x14, 0x0a, 0xe6, 0x93, 0x5b, - 0x60, 0xa9, 0x9b, 0x5e, 0x71, 0x0e, 0xbd, 0x2a, 0xe9, 0xd4, 0xdd, 0xd0, 0xb4, 0x17, 0x65, 0xe8, - 0x55, 0xb2, 0x02, 0x30, 0x61, 0xb3, 0x1d, 0xce, 0x04, 0xef, 0xb9, 0xa9, 0x5b, 0xe5, 0x18, 0xd2, - 0x01, 0x7b, 0xc2, 0x66, 0x83, 0x59, 0x30, 0x10, 0x68, 0xf5, 0x32, 0xcd, 0x60, 0xf2, 0x22, 0xd4, - 0x26, 0x6c, 0x26, 0xfd, 0xbb, 0xe7, 0x6a, 0xab, 0xe7, 0x08, 0xf2, 0x32, 0x94, 0x92, 0x59, 0x80, - 0x81, 0xa3, 0xbe, 0x71, 0x63, 0x5d, 0xd6, 0x01, 0x83, 0x59, 0xa0, 0x5f, 0x02, 0x95, 0x6b, 0xa9, - 0x66, 0xec, 0x5c, 0x33, 0x2d, 0x28, 0x8d, 0x3c, 0x17, 0x93, 0x48, 0x8d, 0xca, 0x4f, 0xe7, 0xdb, - 0x12, 0xdc, 0xd0, 0xa6, 0x39, 0xf1, 0xa2, 0x7e, 0x22, 0xfd, 0xa9, 0x0d, 0x55, 0x7c, 0xca, 0x3c, - 0xd6, 0x16, 0x4a, 0x41, 0xf2, 0xff, 0x60, 0xa1, 0x6b, 0xa7, 0xc6, 0x7f, 0x65, 0x5e, 0x3d, 0xd9, - 0x16, 0xca, 0x19, 0xb4, 0x17, 0x68, 0x16, 0xf2, 0x21, 0x54, 0xbe, 0xe1, 0x71, 0xa8, 0xc2, 0x54, - 0x7d, 0xc3, 0xb9, 0x8a, 0x57, 0x1a, 0x44, 0xb3, 0x2a, 0x86, 0xff, 0xa1, 0x16, 0xd7, 0x64, 0x50, - 0x9a, 0x84, 0x67, 0xdc, 0x6d, 0x57, 0xf1, 0x54, 0x8b, 0x06, 0x4f, 0x97, 0x53, 0xd5, 0xd9, 0x99, - 0xea, 0x3a, 0x9f, 0x42, 0xbd, 0x70, 0xcd, 0xa2, 0x1f, 0x36, 0x95, 0xb6, 0x5f, 0x99, 0xf7, 0xc3, - 0xe6, 0xdc, 0x4b, 0x29, 0xba, 0xf4, 0xa7, 0x00, 0xf9, 0xa5, 0xff, 0x9b, 0xc7, 0xe1, 0xfc, 0xc4, - 0x80, 0x1b, 0x5b, 0x61, 0x10, 0x70, 0xac, 0x4b, 0x94, 0x39, 0x73, 0x9f, 0x36, 0xae, 0xf5, 0xe9, - 0xb7, 0xa0, 0x22, 0x24, 0x83, 0x96, 0xf2, 0xdc, 0x15, 0xf6, 0xa1, 0x8a, 0x4a, 0x86, 0xa5, 0x09, - 0x9b, 0x0d, 0x23, 0x1e, 0xb8, 0x5e, 0x30, 0xc6, 0x77, 0xa0, 0xac, 0x72, 0xa0, 0x30, 0xce, 0x2f, - 0x0c, 0xb0, 0xd4, 0x73, 0x98, 0x0b, 0x91, 0xc6, 0x7c, 0x88, 0x7c, 0x11, 0x6a, 0x51, 0xcc, 0x5d, - 0x6f, 0x94, 0x4a, 0xae, 0xd1, 0x1c, 0x21, 0x23, 0xf8, 0x71, 0x18, 0x8f, 0x38, 0x6e, 0x6f, 0x53, - 0x05, 0xc8, 0xb2, 0x0f, 0x53, 0x09, 0x06, 0x3a, 0x15, 0x45, 0x6d, 0x89, 0x90, 0x11, 0x4e, 0xb2, - 0x88, 0x88, 0x8d, 0x54, 0x01, 0x56, 0xa2, 0x0a, 0x90, 0x51, 0x57, 0x59, 0x12, 0x2d, 0x68, 0x53, - 0x0d, 0x39, 0xbf, 0x35, 0xa1, 0xb1, 0xed, 0xc5, 0x7c, 0x94, 0x70, 0xb7, 0xeb, 0x8e, 0x91, 0x90, - 0x07, 0x89, 0x97, 0x9c, 0xeb, 0x08, 0xaf, 0xa1, 0x2c, 0x19, 0x9b, 0xf3, 0x45, 0xa9, 0xb2, 0x4b, - 0x09, 0x6b, 0x69, 0x05, 0x90, 0xf7, 0x01, 0x54, 0xc9, 0x82, 0xf5, 0x74, 0xf9, 0xfa, 0x7a, 0xba, - 0x86, 0xa4, 0xf2, 0x53, 0x2a, 0x49, 0xf1, 0x79, 0x2a, 0x03, 0x58, 0x58, 0x6c, 0x4f, 0xa5, 0x83, - 0x63, 0x86, 0x3f, 0xe2, 0x3e, 0x3a, 0x30, 0x66, 0xf8, 0x23, 0xee, 0x67, 0x75, 0x56, 0x55, 0x1d, - 0x49, 0x7e, 0x93, 0xdb, 0x60, 0x86, 0x11, 0xde, 0xb1, 0x20, 0xb4, 0x78, 0xc1, 0xf5, 0xfd, 0x88, - 0x9a, 0x61, 0x44, 0x1c, 0xb0, 0x54, 0xc1, 0xd8, 0xae, 0xa1, 0xe3, 0x03, 0x86, 0x10, 0x2c, 0x6d, - 0xa8, 0x5e, 0x71, 0x9e, 0x05, 0x73, 0x3f, 0x22, 0x55, 0x28, 0xf5, 0xbb, 0x83, 0xd6, 0x92, 0xfc, - 0xd8, 0xee, 0xee, 0xb4, 0x0c, 0xe7, 0x6f, 0x06, 0xd4, 0x76, 0xa7, 0x09, 0x93, 0x3e, 0x26, 0xae, - 0x33, 0xee, 0xf3, 0x60, 0x8b, 0x84, 0xc5, 0x98, 0x53, 0x4d, 0x15, 0x4a, 0x10, 0x1e, 0x08, 0xf2, - 0x06, 0x54, 0xb8, 0x3b, 0xe6, 0x69, 0x34, 0xb8, 0x79, 0xd9, 0x59, 0xa9, 0x22, 0x21, 0x77, 0xc0, - 0x12, 0xa3, 0x13, 0x3e, 0x61, 0xed, 0xf2, 0x3c, 0x71, 0x1f, 0xb1, 0x2a, 0x0d, 0x52, 0x4d, 0x83, - 0x75, 0x7f, 0x1c, 0x46, 0x58, 0xf8, 0x56, 0x74, 0xdd, 0x1f, 0x87, 0x91, 0x2c, 0x7b, 0x37, 0xe0, - 0x19, 0x6f, 0x1c, 0x84, 0x31, 0x1f, 0x7a, 0x81, 0xcb, 0x67, 0xc3, 0x51, 0x18, 0x1c, 0xfb, 0xde, - 0x28, 0x41, 0xbd, 0xda, 0xf4, 0x69, 0xb5, 0xd8, 0x93, 0x6b, 0x5b, 0x7a, 0xc9, 0xb9, 0x0d, 0xb5, - 0x47, 0xfc, 0x1c, 0x0b, 0x4d, 0x41, 0x3a, 0x60, 0x9e, 0x9e, 0xe9, 0x7c, 0x09, 0xe9, 0x29, 0x1e, - 0x3d, 0xa6, 0xe6, 0xe9, 0x99, 0x73, 0x02, 0x76, 0x5f, 0x17, 0x0c, 0xe4, 0x2d, 0x19, 0x42, 0x31, - 0x14, 0xeb, 0x47, 0x97, 0x55, 0xfa, 0x85, 0x7a, 0x85, 0xa6, 0x34, 0xd2, 0xbe, 0x78, 0x20, 0xad, - 0x24, 0x05, 0x14, 0x2b, 0xa6, 0xd2, 0x5c, 0xc5, 0xf4, 0x73, 0x13, 0xec, 0x2c, 0x65, 0xbd, 0x0d, - 0xb5, 0x49, 0x6a, 0x0b, 0xfd, 0x74, 0xb3, 0xf2, 0x38, 0x33, 0x12, 0xcd, 0x69, 0xf4, 0x1d, 0xca, - 0x97, 0xdd, 0x21, 0x8f, 0x01, 0x95, 0x27, 0x8a, 0x01, 0xb7, 0xe1, 0xc6, 0xc8, 0xe7, 0x2c, 0x18, - 0xe6, 0x4f, 0x58, 0x79, 0xe8, 0x32, 0xa2, 0x0f, 0xb2, 0x77, 0xac, 0x63, 0x5a, 0x35, 0x4f, 0x45, - 0xaf, 0x43, 0xc5, 0xe5, 0x7e, 0xc2, 0x16, 0x3b, 0xa1, 0xfd, 0x98, 0x8d, 0x7c, 0xbe, 0x2d, 0x97, - 0xa8, 0xa2, 0x20, 0x77, 0xc0, 0x4e, 0x2b, 0x31, 0xdd, 0xff, 0x64, 0x45, 0x75, 0xaa, 0x70, 0x9a, - 0x51, 0x38, 0x2f, 0x43, 0xe9, 0xd1, 0xe3, 0xfe, 0xb5, 0x96, 0xfa, 0x21, 0x98, 0x8f, 0x1e, 0x17, - 0xe3, 0x6c, 0x23, 0x4b, 0x8f, 0xb2, 0x33, 0x36, 0xf3, 0xce, 0xb8, 0x03, 0xf6, 0x54, 0xf0, 0x78, - 0x97, 0x27, 0x4c, 0x3f, 0xf2, 0x0c, 0x96, 0x69, 0x52, 0xb6, 0x76, 0x5e, 0x18, 0xe8, 0x94, 0x94, - 0x82, 0xce, 0xdf, 0x4b, 0x50, 0xd5, 0x0f, 0x5d, 0xee, 0x39, 0xcd, 0xca, 0x45, 0xf9, 0x99, 0x47, - 0x0d, 0xb3, 0x18, 0x35, 0x8a, 0x3d, 0x78, 0xe9, 0xc9, 0x7a, 0x70, 0xf2, 0x7d, 0x68, 0x44, 0x6a, - 0xad, 0x18, 0x6b, 0x5e, 0x58, 0xe4, 0xd3, 0xbf, 0xc8, 0x5b, 0x8f, 0x72, 0x40, 0xbe, 0x14, 0x6c, - 0x58, 0x12, 0x36, 0x46, 0x83, 0x37, 0x68, 0x55, 0xc2, 0x03, 0x36, 0xbe, 0x22, 0xe2, 0x3c, 0x41, - 0xd0, 0x90, 0xe5, 0x71, 0x18, 0xb5, 0x1b, 0x18, 0x08, 0x64, 0xa0, 0x29, 0xc6, 0x80, 0xe6, 0x7c, - 0x0c, 0x78, 0x01, 0x6a, 0xa3, 0x70, 0x32, 0xf1, 0x70, 0x6d, 0x59, 0x25, 0x6e, 0x85, 0x18, 0x08, - 0xe7, 0x1b, 0xa8, 0xea, 0x0b, 0x93, 0x3a, 0x54, 0xb7, 0xbb, 0x0f, 0x36, 0x0f, 0x77, 0x64, 0x14, - 0x02, 0xb0, 0xee, 0xf7, 0xf6, 0x36, 0xe9, 0x97, 0x2d, 0x43, 0x46, 0xa4, 0xde, 0xde, 0xa0, 0x65, - 0x92, 0x1a, 0x54, 0x1e, 0xec, 0xec, 0x6f, 0x0e, 0x5a, 0x25, 0x62, 0x43, 0xf9, 0xfe, 0xfe, 0xfe, - 0x4e, 0xab, 0x4c, 0x1a, 0x60, 0x6f, 0x6f, 0x0e, 0xba, 0x83, 0xde, 0x6e, 0xb7, 0x55, 0x91, 0xb4, - 0x0f, 0xbb, 0xfb, 0x2d, 0x4b, 0x7e, 0x1c, 0xf6, 0xb6, 0x5b, 0x55, 0xb9, 0x7e, 0xb0, 0xd9, 0xef, - 0x7f, 0xb1, 0x4f, 0xb7, 0x5b, 0xb6, 0xdc, 0xb7, 0x3f, 0xa0, 0xbd, 0xbd, 0x87, 0xad, 0x9a, 0x73, - 0x17, 0xea, 0x05, 0xa5, 0x49, 0x0e, 0xda, 0x7d, 0xd0, 0x5a, 0x92, 0x62, 0x1e, 0x6f, 0xee, 0x1c, - 0x76, 0x5b, 0x06, 0x59, 0x06, 0xc0, 0xcf, 0xe1, 0xce, 0xe6, 0xde, 0xc3, 0x96, 0xe9, 0xfc, 0xc8, - 0xc8, 0x78, 0xb0, 0x09, 0x7e, 0x13, 0x6c, 0xad, 0xea, 0xb4, 0xbe, 0xbe, 0xb1, 0x60, 0x17, 0x9a, - 0x11, 0x48, 0x37, 0x1b, 0x9d, 0xf0, 0xd1, 0xa9, 0x98, 0x4e, 0xb4, 0x57, 0x64, 0xb0, 0xea, 0x65, - 0xa5, 0x4e, 0xd2, 0x20, 0xa0, 0xa0, 0x6c, 0xce, 0x53, 0x46, 0x7a, 0x35, 0xe7, 0xb9, 0x07, 0x90, - 0x4f, 0x12, 0x2e, 0xa9, 0x8c, 0x6f, 0x42, 0x85, 0xf9, 0x1e, 0x13, 0x3a, 0x8b, 0x29, 0xc0, 0xa1, - 0x50, 0x2f, 0xcc, 0x1f, 0xa4, 0xc1, 0x98, 0xef, 0x0f, 0x4f, 0xf9, 0xb9, 0x40, 0x5e, 0x9b, 0x56, - 0x99, 0xef, 0x3f, 0xe2, 0xe7, 0x82, 0xac, 0x41, 0x45, 0x8d, 0x2f, 0xcc, 0x4b, 0x3a, 0x62, 0x64, - 0xa7, 0x8a, 0xc0, 0xb9, 0x03, 0x96, 0x6a, 0x93, 0x0b, 0x3e, 0x63, 0x5c, 0x99, 0x68, 0x3e, 0xd1, - 0xe7, 0xc6, 0xa6, 0x9a, 0xbc, 0xad, 0x47, 0x25, 0x42, 0x0d, 0x68, 0x8c, 0xf9, 0xc2, 0x4c, 0x11, - 0xea, 0x29, 0x09, 0x32, 0x38, 0xdb, 0x60, 0x5f, 0x3b, 0x88, 0xd2, 0x8a, 0x30, 0x73, 0x45, 0x5c, - 0x32, 0x9a, 0x72, 0x62, 0x80, 0x7c, 0x9c, 0xa2, 0xdd, 0x58, 0xed, 0x22, 0xdd, 0x78, 0x5d, 0x9a, - 0xc8, 0xf3, 0xdd, 0x98, 0x07, 0x17, 0x6e, 0x9f, 0x0f, 0x61, 0x32, 0x1a, 0xf2, 0x2a, 0x94, 0x71, - 0x6a, 0x54, 0x9a, 0x0f, 0x58, 0xd9, 0xc8, 0x08, 0x57, 0x9d, 0x23, 0x68, 0xaa, 0x1c, 0x46, 0xf9, - 0xd7, 0x53, 0x2e, 0xae, 0xad, 0x94, 0x56, 0x00, 0xb2, 0x30, 0x9b, 0xce, 0xc1, 0x0a, 0x18, 0xe9, - 0x28, 0xc7, 0x1e, 0xf7, 0xdd, 0xf4, 0x56, 0x1a, 0x72, 0x3e, 0x80, 0x46, 0x2a, 0x03, 0x3b, 0xec, - 0xdb, 0x59, 0x36, 0x4d, 0xfd, 0x52, 0x1a, 0x44, 0x91, 0xec, 0x85, 0x6e, 0x96, 0x48, 0x9d, 0xbf, - 0x98, 0x29, 0xa7, 0x6e, 0x34, 0xe7, 0x6a, 0x35, 0x63, 0xb1, 0x56, 0x9b, 0xaf, 0x7b, 0xcc, 0x27, - 0xae, 0x7b, 0xbe, 0x07, 0x35, 0x17, 0x93, 0xbe, 0x77, 0x96, 0x86, 0xbe, 0x95, 0xcb, 0x12, 0xbc, - 0x2e, 0x0d, 0xbc, 0x33, 0x4e, 0x73, 0x06, 0x79, 0xa6, 0x24, 0x3c, 0xe5, 0x81, 0xf7, 0x0d, 0x76, - 0xd4, 0xf2, 0xe2, 0x39, 0x22, 0x1f, 0x51, 0xa8, 0x42, 0x40, 0x8f, 0x28, 0xd2, 0xa9, 0x8b, 0x95, - 0x4f, 0x5d, 0xa4, 0xf6, 0xa6, 0x91, 0xe0, 0x71, 0x92, 0x16, 0x88, 0x0a, 0xca, 0x8a, 0xac, 0x9a, - 0xa6, 0x65, 0xc1, 0xd8, 0xf9, 0x08, 0x6a, 0xd9, 0x59, 0x64, 0xbc, 0xd9, 0xdb, 0xdf, 0xeb, 0xaa, - 0xe8, 0xd0, 0xdb, 0xdb, 0xee, 0xfe, 0xa0, 0x65, 0xc8, 0x88, 0x45, 0xbb, 0x8f, 0xbb, 0xb4, 0xdf, - 0x6d, 0x99, 0x32, 0xb2, 0x6c, 0x77, 0x77, 0xba, 0x83, 0x6e, 0xab, 0xf4, 0x59, 0xd9, 0xae, 0xb6, - 0x6c, 0x6a, 0xf3, 0x59, 0xe4, 0x7b, 0x23, 0x2f, 0x71, 0xbe, 0x04, 0x7b, 0x97, 0x45, 0x17, 0x0a, - 0xff, 0x3c, 0x21, 0x4d, 0xf5, 0x54, 0x41, 0x27, 0x8f, 0xd7, 0xa1, 0xaa, 0xa3, 0x86, 0xf6, 0xac, - 0x0b, 0x51, 0x25, 0x5d, 0x77, 0x7e, 0x63, 0xc0, 0xcd, 0xdd, 0xf0, 0x8c, 0x67, 0x59, 0xf8, 0x80, - 0x9d, 0xfb, 0x21, 0x73, 0xff, 0x85, 0x19, 0x6f, 0xc1, 0x0d, 0x11, 0x4e, 0xe3, 0x11, 0x1f, 0x2e, - 0x4c, 0x35, 0x9a, 0x0a, 0xfd, 0x50, 0xbb, 0xa3, 0x03, 0x4d, 0x97, 0x8b, 0x24, 0xa7, 0x2a, 0x21, - 0x55, 0x5d, 0x22, 0x53, 0x9a, 0xac, 0x9c, 0x28, 0x3f, 0x49, 0x39, 0xe1, 0x7c, 0x6b, 0x40, 0xb3, - 0x3b, 0x8b, 0xc2, 0x38, 0x49, 0x8f, 0xfa, 0x8c, 0x2c, 0xdb, 0xbf, 0x4e, 0x1f, 0x43, 0x99, 0x56, - 0x62, 0xfe, 0x75, 0xef, 0xda, 0x91, 0xcb, 0x3d, 0xb0, 0xe4, 0x66, 0x53, 0xa1, 0x5d, 0xe9, 0xc5, - 0x54, 0xe6, 0xdc, 0xc6, 0xeb, 0x7d, 0xa4, 0xa1, 0x9a, 0xb6, 0x58, 0x6a, 0x95, 0xe7, 0x4a, 0xad, - 0x8f, 0xc1, 0x52, 0xa4, 0x05, 0x3b, 0xd7, 0xa1, 0xda, 0x3f, 0xdc, 0xda, 0xea, 0xf6, 0xfb, 0x2d, - 0x83, 0x34, 0xa1, 0xb6, 0x7d, 0x78, 0xb0, 0xd3, 0xdb, 0xda, 0x1c, 0x68, 0x5b, 0x3f, 0xd8, 0xec, - 0xed, 0x74, 0xb7, 0x5b, 0x25, 0x67, 0x0b, 0x6a, 0x83, 0x59, 0xa0, 0xd9, 0x8b, 0x69, 0xd0, 0xb8, - 0x26, 0x0d, 0x9a, 0x0b, 0x69, 0xf0, 0x0b, 0xa8, 0x17, 0x4a, 0x22, 0xf2, 0x1a, 0x94, 0x93, 0x59, - 0x70, 0x71, 0x20, 0x9b, 0xca, 0xa1, 0xb8, 0x4c, 0x5e, 0x86, 0x86, 0x6c, 0xce, 0x98, 0x10, 0xde, - 0x38, 0xe0, 0xae, 0xde, 0x55, 0x36, 0x6c, 0x9b, 0x1a, 0xe5, 0xbc, 0x04, 0x4d, 0xd9, 0x21, 0x7b, - 0x13, 0x2e, 0x12, 0x36, 0x89, 0x30, 0x71, 0xeb, 0x20, 0x5d, 0xa6, 0x66, 0x22, 0x9c, 0x5b, 0xd0, - 0x38, 0xe0, 0x3c, 0xa6, 0x5c, 0x44, 0x61, 0x20, 0xb0, 0x33, 0xd2, 0x9a, 0x55, 0x59, 0x41, 0x43, - 0xce, 0x11, 0xd4, 0x64, 0x51, 0x7b, 0x9f, 0x25, 0xa3, 0x93, 0x7f, 0xb7, 0xf0, 0xbd, 0x05, 0xd5, - 0x48, 0x59, 0x44, 0x97, 0xae, 0x0d, 0x0c, 0x46, 0xda, 0x4a, 0x34, 0x5d, 0x74, 0xee, 0x41, 0x69, - 0x6f, 0x3a, 0x29, 0xfe, 0x75, 0x51, 0x56, 0x05, 0xda, 0x5c, 0x2b, 0x68, 0xce, 0xb7, 0x82, 0xce, - 0x57, 0x50, 0x4f, 0xaf, 0xdb, 0x73, 0xf1, 0xbf, 0x07, 0x54, 0x79, 0xcf, 0x9d, 0xb3, 0x80, 0xea, - 0xaf, 0x78, 0xe0, 0xf6, 0x52, 0x3d, 0x29, 0x60, 0x7e, 0x6f, 0x3d, 0x57, 0xc8, 0xf6, 0x7e, 0x00, - 0x8d, 0xb4, 0xf8, 0xc4, 0x6a, 0x50, 0x1a, 0xd1, 0xf7, 0x78, 0x50, 0x30, 0xb0, 0xad, 0x10, 0x03, - 0x71, 0x8d, 0xbf, 0x6e, 0xfc, 0xc1, 0x80, 0xb2, 0x54, 0x8d, 0x4c, 0x18, 0xdd, 0xd1, 0x49, 0x48, - 0xe6, 0x34, 0xd0, 0x99, 0x83, 0x9c, 0x25, 0xf2, 0x8e, 0x9a, 0x78, 0xa6, 0x43, 0xdd, 0xa7, 0x8a, - 0xda, 0x45, 0x0b, 0x5c, 0xe0, 0xd8, 0x80, 0xfa, 0x67, 0xa1, 0x17, 0x6c, 0xa9, 0x41, 0x20, 0xb9, - 0xcc, 0x1e, 0x17, 0x78, 0xde, 0x03, 0xab, 0x27, 0xa4, 0xf1, 0x2f, 0x27, 0xcf, 0xfa, 0xaf, 0xa2, - 0x7f, 0x38, 0x4b, 0x1b, 0xbf, 0x2e, 0x41, 0xf9, 0x2b, 0x1e, 0x87, 0xe4, 0x1e, 0x54, 0xf5, 0x14, - 0x82, 0x2c, 0x4c, 0x1b, 0x3a, 0x59, 0x0c, 0x58, 0x18, 0x53, 0x38, 0x4b, 0xe4, 0x7d, 0xb0, 0x74, - 0xa2, 0x99, 0x1f, 0x95, 0x74, 0xae, 0x8a, 0x1b, 0xce, 0xd2, 0x9a, 0xf1, 0x8e, 0x41, 0xde, 0x06, - 0x4b, 0x3d, 0x91, 0x05, 0xdd, 0x5d, 0xd6, 0x53, 0x38, 0x4b, 0xc8, 0x50, 0xef, 0x9f, 0x84, 0x53, - 0xdf, 0xed, 0xf3, 0xf8, 0x8c, 0x93, 0x85, 0xe1, 0x5d, 0x67, 0x01, 0x46, 0xad, 0x83, 0x72, 0xa4, - 0x43, 0xcf, 0x15, 0xa4, 0x9e, 0xae, 0xef, 0x4d, 0x27, 0xb9, 0x90, 0x82, 0xa7, 0x29, 0x8e, 0xc2, - 0xd3, 0x7a, 0x12, 0x8e, 0x77, 0xa1, 0xb9, 0x85, 0x8f, 0x7e, 0x3f, 0xde, 0x3c, 0x0a, 0xe3, 0x84, - 0x2c, 0x0e, 0xf5, 0x3a, 0x8b, 0x08, 0x67, 0x89, 0x7c, 0x08, 0xf6, 0x20, 0x3e, 0x57, 0xf4, 0xcf, - 0x14, 0x82, 0x41, 0x2e, 0xfb, 0x0a, 0x2d, 0x6c, 0xfc, 0xa9, 0x04, 0xd6, 0x17, 0x61, 0x7c, 0xca, - 0x63, 0xb2, 0x0e, 0x16, 0x36, 0x8a, 0x05, 0x77, 0xca, 0x1a, 0xc7, 0xcb, 0x84, 0xde, 0x81, 0x1a, - 0x2a, 0x6e, 0xc0, 0xc4, 0x69, 0x6e, 0x2a, 0xfc, 0xef, 0x2e, 0xd7, 0x9d, 0x2a, 0x36, 0xf0, 0x5e, - 0xcb, 0xfd, 0x24, 0xe6, 0x6c, 0x92, 0x35, 0xc7, 0x17, 0xba, 0xb7, 0x4e, 0x3d, 0x6f, 0xd0, 0xfa, - 0x68, 0xa1, 0xbb, 0x50, 0xee, 0xcb, 0x3b, 0xe5, 0xff, 0xb6, 0xe5, 0xff, 0x64, 0x74, 0x48, 0x11, - 0x99, 0xc9, 0xf9, 0x00, 0x2c, 0x55, 0x2d, 0xe4, 0x8a, 0x98, 0x2b, 0xad, 0x3a, 0x37, 0x17, 0xd1, - 0x9a, 0xf1, 0x16, 0x54, 0x0f, 0xa6, 0xf1, 0x98, 0x0f, 0xc4, 0x82, 0xff, 0x14, 0xad, 0x86, 0xba, - 0xb6, 0x54, 0x0e, 0xc9, 0x05, 0xcc, 0xe5, 0x94, 0xce, 0xe5, 0x68, 0x67, 0x89, 0xdc, 0x85, 0x16, - 0xe5, 0x23, 0xee, 0x15, 0x72, 0x31, 0x29, 0x5e, 0x79, 0xf1, 0xfd, 0xad, 0x19, 0xe4, 0x13, 0x68, - 0xce, 0xe5, 0x6e, 0x92, 0xe5, 0xb1, 0xcb, 0x52, 0xfa, 0xe2, 0x06, 0xf7, 0x5b, 0xbf, 0xff, 0x6e, - 0xc5, 0xf8, 0xe3, 0x77, 0x2b, 0xc6, 0x9f, 0xbf, 0x5b, 0x31, 0x7e, 0xf6, 0xd7, 0x95, 0xa5, 0x23, - 0x0b, 0xff, 0x25, 0x7e, 0xf7, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x10, 0xb6, 0xef, 0x4a, - 0x1e, 0x00, 0x00, +func init() { proto.RegisterFile("pb.proto", fileDescriptor_pb_03862279bc4bb7c1) } + +var fileDescriptor_pb_03862279bc4bb7c1 = []byte{ + // 3057 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x19, 0x3d, 0x73, 0xe3, 0xc6, + 0x55, 0x00, 0x49, 0x10, 0x78, 0x24, 0x75, 0xf4, 0xfa, 0x7c, 0xa6, 0x69, 0x5b, 0x27, 0xc3, 0xf7, + 0x21, 0xdf, 0xd9, 0xca, 0x59, 0x76, 0xc6, 0x1f, 0x9d, 0x4e, 0xa4, 0x6e, 0xe8, 0xd3, 0x57, 0x96, + 0x94, 0x9c, 0xb8, 0x30, 0x07, 0x22, 0x56, 0x14, 0x22, 0x10, 0x80, 0xb1, 0xa0, 0x86, 0x72, 0x91, + 0x99, 0x34, 0xa9, 0x53, 0xa6, 0x4a, 0x91, 0x74, 0xc9, 0x1f, 0x48, 0x7e, 0x40, 0x66, 0x5c, 0xba, + 0x4c, 0xba, 0xcc, 0xb9, 0x4a, 0x9d, 0xc9, 0xa4, 0x48, 0x93, 0xd9, 0xb7, 0x8b, 0x0f, 0xf2, 0x24, + 0x9d, 0x9d, 0x99, 0x54, 0xc4, 0xfb, 0xd8, 0xb7, 0xbb, 0xef, 0xbd, 0x7d, 0x5f, 0x04, 0x33, 0x3a, + 0x5e, 0x8f, 0xe2, 0x30, 0x09, 0x89, 0x1e, 0x1d, 0xb7, 0x2d, 0x27, 0xf2, 0x24, 0x68, 0xb7, 0xa1, + 0xbc, 0xe3, 0xf1, 0x84, 0x10, 0x28, 0x4f, 0x3d, 0x97, 0xb7, 0xb4, 0xd5, 0xd2, 0x9a, 0x41, 0xf1, + 0xdb, 0xde, 0x05, 0x6b, 0xe0, 0xf0, 0xb3, 0x23, 0xc7, 0x9f, 0x32, 0xd2, 0x84, 0xd2, 0xb9, 0xe3, + 0xb7, 0xb4, 0x55, 0x6d, 0xad, 0x4e, 0xc5, 0x27, 0x59, 0x07, 0xf3, 0xdc, 0xf1, 0x87, 0xc9, 0x45, + 0xc4, 0x5a, 0xfa, 0xaa, 0xb6, 0xb6, 0xbc, 0xf1, 0xf2, 0x7a, 0x74, 0xbc, 0x7e, 0x10, 0xf2, 0xc4, + 0x0b, 0xc6, 0xeb, 0x47, 0x8e, 0x3f, 0xb8, 0x88, 0x18, 0xad, 0x9e, 0xcb, 0x0f, 0x7b, 0x1f, 0x6a, + 0xfd, 0x78, 0xb4, 0x3d, 0x0d, 0x46, 0x89, 0x17, 0x06, 0x62, 0xc7, 0xc0, 0x99, 0x30, 0x94, 0x68, + 0x51, 0xfc, 0x16, 0x38, 0x27, 0x1e, 0xf3, 0x56, 0x69, 0xb5, 0x24, 0x70, 0xe2, 0x9b, 0xb4, 0xa0, + 0xea, 0xf1, 0xad, 0x70, 0x1a, 0x24, 0xad, 0xf2, 0xaa, 0xb6, 0x66, 0xd2, 0x14, 0xb4, 0xff, 0xa9, + 0x43, 0xe5, 0x27, 0x53, 0x16, 0x5f, 0xe0, 0xba, 0x24, 0x89, 0x53, 0x59, 0xe2, 0x9b, 0xdc, 0x84, + 0x8a, 0xef, 0x04, 0x63, 0xde, 0xd2, 0x51, 0x98, 0x04, 0xc8, 0xeb, 0x60, 0x39, 0x27, 0x09, 0x8b, + 0x87, 0x53, 0xcf, 0x6d, 0x95, 0x56, 0xb5, 0x35, 0x83, 0x9a, 0x88, 0x38, 0xf4, 0x5c, 0xf2, 0x1a, + 0x98, 0x6e, 0x38, 0x1c, 0x15, 0xf7, 0x72, 0x43, 0xdc, 0x8b, 0xbc, 0x0d, 0xe6, 0xd4, 0x73, 0x87, + 0xbe, 0xc7, 0x93, 0x56, 0x65, 0x55, 0x5b, 0xab, 0x6d, 0x98, 0xe2, 0xb2, 0x42, 0x77, 0xb4, 0x3a, + 0xf5, 0x5c, 0x54, 0xe2, 0x03, 0x30, 0x79, 0x3c, 0x1a, 0x9e, 0x4c, 0x83, 0x51, 0xcb, 0x40, 0xa6, + 0x1b, 0x82, 0xa9, 0x70, 0x6b, 0x5a, 0xe5, 0x12, 0x10, 0xd7, 0x8a, 0xd9, 0x39, 0x8b, 0x39, 0x6b, + 0x55, 0xe5, 0x56, 0x0a, 0x24, 0x8f, 0xa0, 0x76, 0xe2, 0x8c, 0x58, 0x32, 0x8c, 0x9c, 0xd8, 0x99, + 0xb4, 0xcc, 0x5c, 0xd0, 0xb6, 0x40, 0x1f, 0x08, 0x2c, 0xa7, 0x70, 0x92, 0x01, 0xe4, 0x03, 0x68, + 0x20, 0xc4, 0x87, 0x27, 0x9e, 0x9f, 0xb0, 0xb8, 0x65, 0xe1, 0x9a, 0x65, 0x5c, 0x83, 0x98, 0x41, + 0xcc, 0x18, 0xad, 0x4b, 0x26, 0x89, 0x21, 0x6f, 0x02, 0xb0, 0x59, 0xe4, 0x04, 0xee, 0xd0, 0xf1, + 0xfd, 0x16, 0xe0, 0x19, 0x2c, 0x89, 0xd9, 0xf4, 0x7d, 0xf2, 0xaa, 0x38, 0x9f, 0xe3, 0x0e, 0x13, + 0xde, 0x6a, 0xac, 0x6a, 0x6b, 0x65, 0x6a, 0x08, 0x70, 0xc0, 0xed, 0x0d, 0xb0, 0xd0, 0x23, 0xf0, + 0xc6, 0x77, 0xc1, 0x38, 0x17, 0x80, 0x74, 0x9c, 0xda, 0x46, 0x43, 0x6c, 0x99, 0x39, 0x0d, 0x55, + 0x44, 0x7b, 0x05, 0xcc, 0x1d, 0x27, 0x18, 0xa7, 0x9e, 0x26, 0x4c, 0x81, 0x0b, 0x2c, 0x8a, 0xdf, + 0xf6, 0x6f, 0x74, 0x30, 0x28, 0xe3, 0x53, 0x3f, 0x21, 0xf7, 0x01, 0x84, 0xa2, 0x27, 0x4e, 0x12, + 0x7b, 0x33, 0x25, 0x35, 0x57, 0xb5, 0x35, 0xf5, 0xdc, 0x5d, 0x24, 0x91, 0x47, 0x50, 0x47, 0xe9, + 0x29, 0xab, 0x9e, 0x1f, 0x20, 0x3b, 0x1f, 0xad, 0x21, 0x8b, 0x5a, 0x71, 0x0b, 0x0c, 0xb4, 0xad, + 0xf4, 0xaf, 0x06, 0x55, 0x10, 0xb9, 0x0b, 0xcb, 0x5e, 0x90, 0x08, 0xdd, 0x8f, 0x92, 0xa1, 0xcb, + 0x78, 0x6a, 0xfc, 0x46, 0x86, 0xed, 0x30, 0x9e, 0x90, 0xf7, 0x41, 0x2a, 0x30, 0xdd, 0xb0, 0x82, + 0x1b, 0x2e, 0x67, 0x86, 0xe1, 0x72, 0x47, 0xe4, 0x51, 0x3b, 0xbe, 0x07, 0x35, 0x71, 0xbf, 0x74, + 0x85, 0x81, 0x2b, 0xea, 0x78, 0x1b, 0xa5, 0x0e, 0x0a, 0x82, 0x41, 0xb1, 0x0b, 0xd5, 0x08, 0x07, + 0x93, 0x0e, 0x81, 0xdf, 0x76, 0x17, 0x2a, 0xfb, 0xb1, 0xcb, 0xe2, 0x4b, 0x7d, 0x9c, 0x40, 0xd9, + 0x65, 0x7c, 0x84, 0xcf, 0xcf, 0xa4, 0xf8, 0x9d, 0xfb, 0x7d, 0xa9, 0xe0, 0xf7, 0xf6, 0x6f, 0x35, + 0xa8, 0xf5, 0xc3, 0x38, 0xd9, 0x65, 0x9c, 0x3b, 0x63, 0x46, 0x6e, 0x43, 0x25, 0x14, 0x62, 0x95, + 0x86, 0x2d, 0x71, 0x26, 0xdc, 0x87, 0x4a, 0xfc, 0x82, 0x1d, 0xf4, 0xab, 0xed, 0x70, 0x13, 0x2a, + 0xf2, 0xc5, 0x88, 0xd7, 0x54, 0xa1, 0x12, 0x10, 0xba, 0x0e, 0x4f, 0x4e, 0x38, 0x93, 0xba, 0xac, + 0x50, 0x05, 0x5d, 0xed, 0x56, 0x3f, 0x06, 0x10, 0xe7, 0xfb, 0x81, 0x5e, 0x60, 0x9f, 0x42, 0x8d, + 0x3a, 0x27, 0xc9, 0x56, 0x18, 0x24, 0x6c, 0x96, 0x90, 0x65, 0xd0, 0x3d, 0x17, 0x55, 0x64, 0x50, + 0xdd, 0x73, 0xc5, 0xe1, 0xc6, 0x71, 0x38, 0x8d, 0x50, 0x43, 0x0d, 0x2a, 0x01, 0x54, 0xa5, 0xeb, + 0xc6, 0x78, 0x62, 0xa1, 0x4a, 0xd7, 0x8d, 0xc9, 0x6d, 0xa8, 0xf1, 0xc0, 0x89, 0xf8, 0x69, 0x98, + 0x88, 0xc3, 0x95, 0xf1, 0x70, 0x90, 0xa2, 0x06, 0xdc, 0xfe, 0x8b, 0x06, 0xc6, 0x2e, 0x9b, 0x1c, + 0xb3, 0xf8, 0xb9, 0x5d, 0x5e, 0x03, 0x13, 0x05, 0x0f, 0x3d, 0x57, 0x6d, 0x54, 0x45, 0xb8, 0xe7, + 0x5e, 0xba, 0xd5, 0x2d, 0x30, 0x7c, 0xe6, 0x08, 0xe5, 0x4b, 0x3f, 0x53, 0x90, 0xd0, 0x8d, 0x33, + 0x19, 0xba, 0xcc, 0x71, 0x31, 0xc4, 0x98, 0xd4, 0x70, 0x26, 0x1d, 0xe6, 0xb8, 0xe2, 0x6c, 0xbe, + 0xc3, 0x93, 0xe1, 0x34, 0x72, 0x9d, 0x84, 0x61, 0x68, 0x29, 0x0b, 0xc7, 0xe1, 0xc9, 0x21, 0x62, + 0xc8, 0x03, 0x78, 0x69, 0xe4, 0x4f, 0xb9, 0x88, 0x6b, 0x5e, 0x70, 0x12, 0x0e, 0xc3, 0xc0, 0xbf, + 0x40, 0xfd, 0x9a, 0xf4, 0x86, 0x22, 0xf4, 0x82, 0x93, 0x70, 0x3f, 0xf0, 0x2f, 0xec, 0xff, 0x68, + 0x50, 0x79, 0x82, 0x6a, 0x78, 0x04, 0xd5, 0x09, 0x5e, 0x28, 0x7d, 0xbd, 0xb7, 0x84, 0x86, 0x91, + 0xb6, 0x2e, 0x6f, 0xca, 0xbb, 0x41, 0x12, 0x5f, 0xd0, 0x94, 0x4d, 0xac, 0x48, 0x9c, 0x63, 0x9f, + 0x25, 0x5c, 0x79, 0x44, 0x61, 0xc5, 0x40, 0x12, 0xd4, 0x0a, 0xc5, 0xd6, 0xde, 0x86, 0x7a, 0x51, + 0x94, 0x48, 0x23, 0x67, 0xec, 0x02, 0x75, 0x57, 0xa6, 0xe2, 0x93, 0xac, 0x42, 0x05, 0x1f, 0x29, + 0x6a, 0xae, 0xb6, 0x01, 0x42, 0xa2, 0x5c, 0x42, 0x25, 0xe1, 0x53, 0xfd, 0x63, 0x4d, 0xc8, 0x29, + 0x6e, 0x50, 0x94, 0x63, 0x5d, 0x2d, 0x47, 0x2e, 0x29, 0xc8, 0xb1, 0xff, 0xad, 0x41, 0xfd, 0x0b, + 0x16, 0x87, 0x07, 0x71, 0x18, 0x85, 0xdc, 0xf1, 0x89, 0x0d, 0x86, 0xbc, 0xdd, 0x25, 0xfb, 0x2b, + 0x8a, 0xe0, 0x91, 0xf7, 0x41, 0x33, 0xce, 0xcb, 0x56, 0x14, 0xb2, 0x02, 0x30, 0x71, 0x66, 0x3b, + 0xcc, 0xe1, 0xac, 0xe7, 0xa6, 0xee, 0x93, 0x63, 0x48, 0x1b, 0xcc, 0x89, 0x33, 0x1b, 0xcc, 0x82, + 0x01, 0x47, 0xeb, 0x96, 0x69, 0x06, 0x93, 0x37, 0xc0, 0x9a, 0x38, 0x33, 0xe1, 0xc7, 0x3d, 0x57, + 0x59, 0x37, 0x47, 0x90, 0xb7, 0xa0, 0x94, 0xcc, 0x02, 0x0c, 0x0a, 0x22, 0x0f, 0x88, 0xdc, 0x3d, + 0x98, 0x05, 0xca, 0xe3, 0xa9, 0xa0, 0xa5, 0xda, 0x30, 0x73, 0x6d, 0x34, 0xa1, 0x34, 0xf2, 0x5c, + 0x4c, 0x04, 0x16, 0x15, 0x9f, 0xf6, 0x9f, 0x4a, 0x70, 0x43, 0x99, 0xe2, 0xd4, 0x8b, 0xfa, 0x89, + 0xf0, 0x9b, 0x16, 0x54, 0xf1, 0xb9, 0xb2, 0x58, 0x59, 0x24, 0x05, 0xc9, 0x47, 0x60, 0xa0, 0x0b, + 0xa7, 0x86, 0xbe, 0x9d, 0xab, 0x25, 0x5b, 0x2e, 0x0d, 0xaf, 0x2c, 0xae, 0xd8, 0xc9, 0x87, 0x50, + 0xf9, 0x9a, 0xc5, 0xa1, 0x0c, 0x3f, 0xb5, 0x8d, 0x95, 0xcb, 0xd6, 0x09, 0x03, 0xa8, 0x65, 0x92, + 0xf9, 0xff, 0xa8, 0xbd, 0x3b, 0x22, 0xe0, 0x4c, 0xc2, 0x73, 0xe6, 0xb6, 0xaa, 0x78, 0xa2, 0xa2, + 0x81, 0x53, 0x52, 0xaa, 0x2e, 0x33, 0x53, 0x57, 0xbb, 0x03, 0xb5, 0xc2, 0xf5, 0x8a, 0xfe, 0xd6, + 0x90, 0x1a, 0xbe, 0x3d, 0xef, 0x6f, 0x56, 0xf6, 0x12, 0x8a, 0x6e, 0xdb, 0x01, 0xc8, 0x2f, 0xfb, + 0xbf, 0x3a, 0xbf, 0xfd, 0x4b, 0x0d, 0x6e, 0x6c, 0x85, 0x41, 0xc0, 0xb0, 0x86, 0x90, 0xa6, 0xcb, + 0xfd, 0x56, 0xbb, 0xd2, 0x6f, 0xdf, 0x81, 0x0a, 0x17, 0xcc, 0x4a, 0xfa, 0xcb, 0x97, 0xd8, 0x82, + 0x4a, 0x0e, 0x11, 0x62, 0x26, 0xce, 0x6c, 0x18, 0xb1, 0xc0, 0xf5, 0x82, 0x31, 0xfa, 0xb9, 0xb4, + 0xc0, 0x81, 0xc4, 0xd8, 0xbf, 0xd3, 0xc0, 0x90, 0x2e, 0x3f, 0x17, 0xee, 0xb4, 0xf9, 0x70, 0xf7, + 0x06, 0x58, 0x51, 0xcc, 0x5c, 0x6f, 0x94, 0xee, 0x6a, 0xd1, 0x1c, 0x21, 0xa2, 0xf1, 0x49, 0x18, + 0x8f, 0x18, 0x8a, 0x37, 0xa9, 0x04, 0x44, 0x49, 0x86, 0x29, 0x01, 0x83, 0x96, 0x8c, 0x88, 0xa6, + 0x40, 0x88, 0x68, 0x25, 0x96, 0xf0, 0xc8, 0x19, 0xc9, 0x22, 0xa9, 0x44, 0x25, 0x20, 0x22, 0xa8, + 0xb4, 0x1c, 0x5a, 0xcc, 0xa4, 0x0a, 0xb2, 0xff, 0xa0, 0x43, 0xbd, 0xe3, 0xc5, 0x6c, 0x94, 0x30, + 0xb7, 0xeb, 0x8e, 0x91, 0x91, 0x05, 0x89, 0x97, 0x5c, 0xa8, 0x68, 0xad, 0xa0, 0x2c, 0x99, 0xea, + 0xf3, 0x05, 0xa3, 0xb4, 0x45, 0x09, 0x6b, 0x5c, 0x09, 0x90, 0x0d, 0x00, 0x59, 0x66, 0x60, 0x9d, + 0x5b, 0xbe, 0xba, 0xce, 0xb5, 0x90, 0x4d, 0x7c, 0x0a, 0x05, 0xc9, 0x35, 0x9e, 0x8c, 0xe4, 0x06, + 0x16, 0xc1, 0x53, 0xe1, 0xc8, 0x98, 0x9d, 0x8f, 0x99, 0x8f, 0x8e, 0x8a, 0xd9, 0xf9, 0x98, 0xf9, + 0x59, 0x4d, 0x54, 0x95, 0xc7, 0x11, 0xdf, 0xe4, 0x6d, 0xd0, 0xc3, 0x08, 0xef, 0xa7, 0x36, 0x2c, + 0x5e, 0x6c, 0x7d, 0x3f, 0xa2, 0x7a, 0x18, 0x09, 0x2f, 0x90, 0x45, 0x5d, 0xcb, 0x52, 0xce, 0x2d, + 0xc2, 0x03, 0x96, 0x23, 0x54, 0x51, 0xec, 0x5b, 0xa0, 0xef, 0x47, 0xa4, 0x0a, 0xa5, 0x7e, 0x77, + 0xd0, 0x5c, 0x12, 0x1f, 0x9d, 0xee, 0x4e, 0x53, 0xb3, 0x9f, 0x69, 0x60, 0xed, 0x4e, 0x13, 0x47, + 0xf8, 0x14, 0xbf, 0xce, 0xa8, 0xaf, 0x81, 0xc9, 0x13, 0x27, 0xc6, 0xbc, 0xa8, 0xcb, 0x30, 0x81, + 0xf0, 0x80, 0x93, 0x7b, 0x50, 0x61, 0xee, 0x98, 0xa5, 0xaf, 0xbd, 0xb9, 0x78, 0x4e, 0x2a, 0xc9, + 0x64, 0x0d, 0x0c, 0x3e, 0x3a, 0x65, 0x13, 0xa7, 0x55, 0xce, 0x19, 0xfb, 0x88, 0x91, 0x29, 0x8c, + 0x2a, 0x3a, 0xd6, 0xe0, 0x71, 0x18, 0x61, 0x51, 0x5a, 0x51, 0x35, 0x78, 0x1c, 0x46, 0xa2, 0x24, + 0xdd, 0x80, 0x57, 0xbc, 0x71, 0x10, 0xc6, 0x6c, 0xe8, 0x05, 0x2e, 0x9b, 0x0d, 0x47, 0x61, 0x70, + 0xe2, 0x7b, 0xa3, 0x04, 0x75, 0x69, 0xd2, 0x97, 0x25, 0xb1, 0x27, 0x68, 0x5b, 0x8a, 0x64, 0xbf, + 0x0d, 0xd6, 0x53, 0x76, 0x81, 0x05, 0x21, 0x27, 0xb7, 0x40, 0x3f, 0x3b, 0x57, 0xb9, 0xce, 0x10, + 0x27, 0x78, 0x7a, 0x44, 0xf5, 0xb3, 0x73, 0xdb, 0x05, 0xb3, 0xaf, 0x12, 0x3d, 0x79, 0x47, 0x84, + 0x44, 0x0c, 0xad, 0xea, 0x61, 0x61, 0xe5, 0x5d, 0xa8, 0x31, 0x68, 0x4a, 0x17, 0xb6, 0xc4, 0x83, + 0x28, 0xa5, 0x48, 0xa0, 0x58, 0xe1, 0x94, 0xe6, 0x2a, 0x9c, 0x5f, 0xe9, 0x60, 0x66, 0x69, 0xe7, + 0x21, 0x58, 0x93, 0x54, 0xf7, 0xea, 0x79, 0x62, 0xe9, 0x9a, 0x19, 0x84, 0xe6, 0x74, 0x75, 0xee, + 0xf2, 0xe2, 0xb9, 0xf3, 0xf7, 0x5d, 0x79, 0xe1, 0xfb, 0xbe, 0x0f, 0x37, 0x46, 0x3e, 0x73, 0x82, + 0x61, 0xfe, 0x3c, 0xa5, 0x07, 0x2e, 0x23, 0xfa, 0x20, 0x7b, 0xa3, 0x2a, 0x46, 0x55, 0xf3, 0x54, + 0x72, 0x17, 0x2a, 0x2e, 0xf3, 0x13, 0xa7, 0xd8, 0x89, 0xec, 0xc7, 0xce, 0xc8, 0x67, 0x1d, 0x81, + 0xa6, 0x92, 0x4a, 0xd6, 0xc0, 0x4c, 0xab, 0x25, 0xd5, 0x7f, 0x60, 0xa1, 0x9b, 0x2a, 0x96, 0x66, + 0x54, 0xfb, 0x4d, 0x28, 0x3d, 0x3d, 0xea, 0x5f, 0x69, 0x8d, 0x2f, 0x41, 0x7f, 0x7a, 0x54, 0x8c, + 0x95, 0xf5, 0x2c, 0xa5, 0x89, 0x0e, 0x54, 0xcf, 0x3b, 0xd0, 0x36, 0x98, 0x53, 0xce, 0xe2, 0x5d, + 0x96, 0x38, 0xea, 0xd1, 0x66, 0xb0, 0x48, 0x6d, 0xa2, 0x9d, 0xf2, 0xc2, 0x40, 0xa5, 0x93, 0x14, + 0xb4, 0xff, 0x51, 0x82, 0xaa, 0x7a, 0xbc, 0x42, 0xe6, 0x34, 0x2b, 0xe5, 0xc4, 0x67, 0x1e, 0x05, + 0xf4, 0x62, 0x14, 0x28, 0xf6, 0xba, 0xa5, 0x17, 0xf7, 0xba, 0xe4, 0x53, 0xa8, 0x47, 0x92, 0x56, + 0x8c, 0x1b, 0xaf, 0x16, 0xd7, 0xa8, 0x5f, 0x5c, 0x57, 0x8b, 0x72, 0x40, 0xbc, 0x00, 0x6c, 0x1a, + 0x12, 0x67, 0x8c, 0x86, 0xad, 0xd3, 0xaa, 0x80, 0x07, 0xce, 0xf8, 0x8a, 0xe8, 0xf1, 0x3d, 0x82, + 0x80, 0x28, 0x59, 0xc3, 0xa8, 0x55, 0xc7, 0x87, 0x2d, 0x02, 0x47, 0xf1, 0x4d, 0x37, 0xe6, 0xdf, + 0xf4, 0xeb, 0x60, 0x8d, 0xc2, 0xc9, 0xc4, 0x43, 0xda, 0xb2, 0x4c, 0xb6, 0x12, 0x31, 0xe0, 0xf6, + 0xd7, 0x50, 0x55, 0x97, 0x25, 0x35, 0xa8, 0x76, 0xba, 0xdb, 0x9b, 0x87, 0x3b, 0x22, 0xaa, 0x00, + 0x18, 0x8f, 0x7b, 0x7b, 0x9b, 0xf4, 0x67, 0x4d, 0x4d, 0x44, 0x98, 0xde, 0xde, 0xa0, 0xa9, 0x13, + 0x0b, 0x2a, 0xdb, 0x3b, 0xfb, 0x9b, 0x83, 0x66, 0x89, 0x98, 0x50, 0x7e, 0xbc, 0xbf, 0xbf, 0xd3, + 0x2c, 0x93, 0x3a, 0x98, 0x9d, 0xcd, 0x41, 0x77, 0xd0, 0xdb, 0xed, 0x36, 0x2b, 0x82, 0xf7, 0x49, + 0x77, 0xbf, 0x69, 0x88, 0x8f, 0xc3, 0x5e, 0xa7, 0x59, 0x15, 0xf4, 0x83, 0xcd, 0x7e, 0xff, 0xf3, + 0x7d, 0xda, 0x69, 0x9a, 0x42, 0x6e, 0x7f, 0x40, 0x7b, 0x7b, 0x4f, 0x9a, 0x96, 0xfd, 0x3e, 0xd4, + 0x0a, 0x4a, 0x13, 0x2b, 0x68, 0x77, 0xbb, 0xb9, 0x24, 0xb6, 0x39, 0xda, 0xdc, 0x39, 0xec, 0x36, + 0x35, 0xb2, 0x0c, 0x80, 0x9f, 0xc3, 0x9d, 0xcd, 0xbd, 0x27, 0x4d, 0xdd, 0xfe, 0x45, 0xb6, 0x04, + 0x7b, 0xcf, 0xfb, 0x60, 0x2a, 0x4d, 0xa7, 0x25, 0x6f, 0xad, 0x60, 0x12, 0x9a, 0x11, 0x85, 0x67, + 0x8d, 0x4e, 0xd9, 0xe8, 0x8c, 0x4f, 0x27, 0xca, 0x11, 0x32, 0x58, 0xb6, 0x91, 0x42, 0x1d, 0xe9, + 0xfb, 0x96, 0x50, 0x36, 0x42, 0x29, 0x23, 0xbf, 0x1c, 0xa1, 0x7c, 0x08, 0x90, 0x37, 0xed, 0x97, + 0x14, 0xad, 0x37, 0xa1, 0xe2, 0xf8, 0x9e, 0xc3, 0x55, 0x22, 0x92, 0x80, 0xbd, 0x07, 0xb5, 0x42, + 0xab, 0x2f, 0x6c, 0xe5, 0xf8, 0xfe, 0xf0, 0x8c, 0x5d, 0x70, 0x5c, 0x6b, 0xd2, 0xaa, 0xe3, 0xfb, + 0x4f, 0xd9, 0x05, 0x27, 0x77, 0xa0, 0x22, 0xa7, 0x04, 0xfa, 0x42, 0x33, 0x8a, 0x4b, 0xa9, 0x24, + 0xda, 0xef, 0x82, 0x21, 0x3b, 0xd4, 0x82, 0xab, 0x68, 0x57, 0xe6, 0x8b, 0x4f, 0xd4, 0x99, 0xb1, + 0x9f, 0x25, 0x0f, 0xd5, 0x34, 0x82, 0xcb, 0xd9, 0x87, 0x96, 0xd7, 0x50, 0x92, 0x49, 0x0d, 0x22, + 0x90, 0xd9, 0xee, 0x80, 0x79, 0xed, 0x7c, 0x47, 0x29, 0x40, 0xcf, 0x15, 0x70, 0xc9, 0xc4, 0xc7, + 0xfe, 0x39, 0x40, 0x3e, 0xb5, 0x50, 0x9e, 0x2b, 0xa5, 0x08, 0xcf, 0x7d, 0x20, 0x4c, 0xe3, 0xf9, + 0x6e, 0xcc, 0x82, 0xb9, 0x5b, 0xe7, 0x73, 0x8e, 0x8c, 0x4e, 0x56, 0xa1, 0x8c, 0xc3, 0x98, 0x52, + 0x1e, 0x8f, 0xb2, 0x49, 0x0c, 0x52, 0xec, 0x63, 0x68, 0xc8, 0x34, 0x44, 0xd9, 0x57, 0x53, 0xd1, + 0xe5, 0x5f, 0x93, 0x07, 0x57, 0x00, 0xb2, 0xe8, 0x99, 0x8e, 0x95, 0x0a, 0x18, 0xe1, 0x18, 0x27, + 0x1e, 0xf3, 0xdd, 0xf4, 0x36, 0x0a, 0xb2, 0x3f, 0x82, 0x7a, 0xba, 0x87, 0x6a, 0x6e, 0xd3, 0x64, + 0x28, 0xb5, 0x29, 0x6b, 0x7a, 0xc9, 0xb2, 0x17, 0xba, 0x59, 0x2e, 0xb4, 0xff, 0xa6, 0xa7, 0x2b, + 0x55, 0x9f, 0x37, 0x57, 0x5e, 0x69, 0x8b, 0xe5, 0xd5, 0x7c, 0xa9, 0xa2, 0x7f, 0xaf, 0x52, 0xe5, + 0x63, 0xb0, 0x5c, 0xcc, 0xd7, 0xde, 0x79, 0x1a, 0xd9, 0xda, 0x8b, 0xb9, 0x59, 0x65, 0x74, 0xef, + 0x9c, 0xd1, 0x9c, 0x59, 0x9c, 0x25, 0x09, 0xcf, 0x58, 0xe0, 0x7d, 0x8d, 0x8d, 0xac, 0xb8, 0x70, + 0x8e, 0xc8, 0xa7, 0x02, 0x32, 0x87, 0xab, 0xa9, 0x40, 0x3a, 0xe0, 0x30, 0xf2, 0x01, 0x87, 0xd0, + 0xda, 0x34, 0xe2, 0x2c, 0x4e, 0xd2, 0x5a, 0x4e, 0x42, 0x59, 0x4d, 0x64, 0x29, 0x5e, 0x27, 0x18, + 0xdb, 0x9f, 0x80, 0x95, 0x9d, 0x45, 0x84, 0x94, 0xbd, 0xfd, 0xbd, 0xae, 0x0c, 0x00, 0xbd, 0xbd, + 0x4e, 0xf7, 0xa7, 0x4d, 0x4d, 0x04, 0x25, 0xda, 0x3d, 0xea, 0xd2, 0x7e, 0xb7, 0xa9, 0x8b, 0xe0, + 0xd1, 0xe9, 0xee, 0x74, 0x07, 0xdd, 0x66, 0xe9, 0xb3, 0xb2, 0x59, 0x6d, 0x9a, 0xd4, 0x64, 0xb3, + 0xc8, 0xf7, 0x46, 0x5e, 0x62, 0x1f, 0x82, 0xb9, 0xeb, 0x44, 0xcf, 0xd5, 0xe5, 0x79, 0xae, 0x99, + 0xaa, 0x66, 0x5e, 0xe5, 0x85, 0xbb, 0x50, 0x55, 0xd1, 0x41, 0x79, 0xd3, 0x5c, 0xe4, 0x48, 0x69, + 0xf6, 0x1f, 0x35, 0xb8, 0xb9, 0x1b, 0x9e, 0xb3, 0x2c, 0xa1, 0x1e, 0x38, 0x17, 0x7e, 0xe8, 0xb8, + 0x2f, 0x30, 0xdd, 0x3d, 0xb8, 0xc1, 0xc3, 0x69, 0x3c, 0x62, 0xc3, 0x85, 0x41, 0x42, 0x43, 0xa2, + 0x9f, 0x28, 0x17, 0xb4, 0xa1, 0xe1, 0x32, 0x9e, 0xe4, 0x5c, 0x25, 0xe4, 0xaa, 0x09, 0x64, 0xca, + 0x93, 0x55, 0x05, 0xe5, 0x17, 0x55, 0x05, 0xf6, 0x37, 0x1a, 0x34, 0xba, 0xb3, 0x28, 0x8c, 0x93, + 0xf4, 0x98, 0xaf, 0x88, 0xca, 0xfa, 0xab, 0xd4, 0xf9, 0xcb, 0xb4, 0x12, 0xb3, 0xaf, 0x7a, 0xd7, + 0x4e, 0x38, 0x1e, 0x81, 0x21, 0x84, 0x4d, 0xb9, 0x72, 0x9f, 0x96, 0xd8, 0x6f, 0x4e, 0xe8, 0x7a, + 0x1f, 0xe9, 0x54, 0xf1, 0x15, 0x2b, 0xa4, 0xf2, 0x5c, 0x85, 0xf4, 0x29, 0x18, 0x92, 0xb5, 0x60, + 0xdb, 0x1a, 0x54, 0xfb, 0x87, 0x5b, 0x5b, 0xdd, 0x7e, 0xbf, 0xa9, 0x91, 0x06, 0x58, 0x9d, 0xc3, + 0x83, 0x9d, 0xde, 0xd6, 0xe6, 0x40, 0xd9, 0x77, 0x7b, 0xb3, 0xb7, 0xd3, 0xed, 0x34, 0x4b, 0xf6, + 0x16, 0x58, 0x83, 0x59, 0xa0, 0x96, 0x17, 0xb3, 0x9b, 0x76, 0x4d, 0x76, 0xd3, 0x17, 0xb2, 0x5b, + 0x1f, 0x6a, 0x85, 0xca, 0x86, 0xbc, 0x05, 0xe5, 0x64, 0x16, 0xcc, 0xcf, 0x36, 0xd3, 0x3d, 0x28, + 0x92, 0xc8, 0x5b, 0x50, 0x17, 0x7d, 0x93, 0xc3, 0xb9, 0x37, 0x0e, 0x98, 0xab, 0x24, 0x8a, 0x5e, + 0x6a, 0x53, 0xa1, 0xec, 0xdb, 0xd0, 0x10, 0x8d, 0xaa, 0x37, 0x61, 0x3c, 0x71, 0x26, 0x11, 0xe6, + 0x62, 0x15, 0x80, 0xcb, 0x54, 0x4f, 0xb8, 0x7d, 0x0f, 0xea, 0x07, 0x8c, 0xc5, 0x94, 0xf1, 0x28, + 0x0c, 0x38, 0x36, 0x2d, 0x4a, 0xa3, 0x32, 0xda, 0x2b, 0xc8, 0xfe, 0x12, 0x2c, 0x51, 0x87, 0x3e, + 0x76, 0x92, 0xd1, 0xe9, 0x0f, 0xa9, 0x53, 0xef, 0x41, 0x35, 0x92, 0x96, 0x50, 0x95, 0x66, 0x1d, + 0x03, 0x8e, 0xb2, 0x0e, 0x4d, 0x89, 0xf6, 0x87, 0x50, 0xda, 0x9b, 0x4e, 0x8a, 0x93, 0xfe, 0xb2, + 0xac, 0xb3, 0xe6, 0x3a, 0x34, 0x7d, 0xbe, 0x43, 0xb3, 0xbf, 0x80, 0x5a, 0x7a, 0xd5, 0x9e, 0x8b, + 0xe3, 0x7a, 0x54, 0x75, 0xcf, 0x9d, 0xd3, 0xbc, 0x6c, 0x7d, 0x58, 0xe0, 0xf6, 0x52, 0x1d, 0x49, + 0x60, 0x5e, 0xb6, 0x6a, 0xed, 0x33, 0xd9, 0xdb, 0x50, 0x4f, 0xeb, 0x47, 0x2c, 0xea, 0x84, 0xf1, + 0x7c, 0x8f, 0x05, 0x05, 0xc3, 0x9a, 0x12, 0x31, 0xe0, 0xd7, 0xf8, 0xe8, 0xc6, 0x9f, 0x35, 0x28, + 0x0b, 0xd5, 0x90, 0x3b, 0x50, 0xee, 0x8e, 0x4e, 0x43, 0x32, 0xa7, 0x81, 0xf6, 0x1c, 0x64, 0x2f, + 0x91, 0x77, 0xe5, 0x50, 0x31, 0x9d, 0x95, 0x36, 0x52, 0xcd, 0xa2, 0xe6, 0x9f, 0xe3, 0x5e, 0x87, + 0xda, 0x67, 0xa1, 0x17, 0x6c, 0xc9, 0x39, 0x1b, 0x59, 0xb4, 0xc3, 0x73, 0xfc, 0xef, 0x81, 0xd1, + 0xe3, 0xc2, 0xe0, 0xcf, 0xb3, 0x62, 0x5b, 0x54, 0xf4, 0x05, 0x7b, 0x69, 0xe3, 0x5f, 0x3a, 0x94, + 0xbf, 0x60, 0x71, 0x48, 0xde, 0x85, 0xaa, 0x1a, 0x02, 0x90, 0x42, 0xb3, 0xdf, 0xc6, 0xf7, 0xbd, + 0x30, 0x1d, 0xc0, 0x53, 0x19, 0x2a, 0x69, 0xe4, 0x93, 0x89, 0xf6, 0x65, 0xb1, 0xc0, 0x5e, 0x5a, + 0xd3, 0x1e, 0x69, 0xe4, 0x21, 0x18, 0xd2, 0xf5, 0x17, 0x74, 0xb3, 0x58, 0xee, 0xdb, 0x4b, 0x8f, + 0x34, 0x72, 0x1f, 0x6a, 0xfd, 0xd3, 0x70, 0xea, 0xbb, 0x7d, 0x16, 0x9f, 0x33, 0x52, 0x98, 0x87, + 0xb5, 0x0b, 0xdf, 0xf6, 0x12, 0x59, 0x03, 0x90, 0xce, 0x71, 0xe8, 0xb9, 0x9c, 0x54, 0x05, 0x6d, + 0x6f, 0x3a, 0x91, 0x42, 0x0b, 0x5e, 0x23, 0x39, 0x0b, 0x4f, 0xe4, 0x3a, 0xce, 0x0f, 0xa0, 0xb1, + 0x85, 0x0f, 0x76, 0x3f, 0xde, 0x3c, 0x0e, 0xe3, 0x84, 0x2c, 0xce, 0xc4, 0xda, 0x8b, 0x08, 0x7b, + 0x89, 0x3c, 0x02, 0x73, 0x10, 0x5f, 0x48, 0xfe, 0x97, 0xd4, 0x43, 0xce, 0xf7, 0xbb, 0xe4, 0x96, + 0x1b, 0xbf, 0x2f, 0x81, 0xf1, 0x79, 0x18, 0x9f, 0xb1, 0x98, 0x3c, 0x00, 0x03, 0xfb, 0x32, 0xe5, + 0x0a, 0x59, 0x8f, 0x76, 0xd9, 0x46, 0x77, 0xc0, 0x42, 0xa5, 0x0c, 0x1c, 0x7e, 0x26, 0x55, 0x8f, + 0x7f, 0x51, 0x49, 0xbd, 0xc8, 0x02, 0xc0, 0x5e, 0x22, 0x0f, 0x61, 0xb9, 0x9f, 0xc4, 0xcc, 0x99, + 0x64, 0x7d, 0xe7, 0x5c, 0xb3, 0xd4, 0xae, 0xca, 0x7e, 0xa8, 0x8f, 0xda, 0x7e, 0x07, 0xca, 0x7d, + 0x79, 0x4f, 0xc1, 0x92, 0x0f, 0xf1, 0xdb, 0xcb, 0x29, 0x22, 0x93, 0xfb, 0x23, 0x30, 0x64, 0xe6, + 0x96, 0x97, 0x9c, 0x2b, 0x6d, 0xda, 0xcd, 0x22, 0x4a, 0x2d, 0xb0, 0xa1, 0x7a, 0x30, 0x8d, 0xc7, + 0x6c, 0xc0, 0x17, 0xec, 0x9e, 0x5a, 0x00, 0x75, 0x67, 0xc8, 0x78, 0x2e, 0x85, 0xce, 0xc5, 0xf6, + 0xf6, 0xf3, 0x28, 0x74, 0xf1, 0x26, 0x65, 0x23, 0xe6, 0x15, 0xf2, 0x20, 0x49, 0xaf, 0xb4, 0xf8, + 0x1e, 0xd6, 0x34, 0xf2, 0x09, 0x34, 0xe6, 0x72, 0x26, 0xc1, 0x1c, 0x72, 0x59, 0x1a, 0x5d, 0x5c, + 0xfc, 0xb8, 0xf5, 0xcd, 0xb3, 0x15, 0xed, 0xdb, 0x67, 0x2b, 0xda, 0xdf, 0x9f, 0xad, 0x68, 0xbf, + 0xfe, 0x6e, 0x65, 0xe9, 0xdb, 0xef, 0x56, 0x96, 0xfe, 0xfa, 0xdd, 0xca, 0xd2, 0xb1, 0x81, 0x7f, + 0x70, 0x7e, 0xf0, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x44, 0xac, 0xd6, 0xfb, 0x1c, 0x00, + 0x00, } diff --git a/query/aggregator.go b/query/aggregator.go index 989595e7fc5..93dbfb03fcb 100644 --- a/query/aggregator.go +++ b/query/aggregator.go @@ -12,7 +12,7 @@ import ( "math" "time" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" ) @@ -42,7 +42,7 @@ func isBinary(f string) bool { f == "max" || f == "min" || f == "logbase" || f == "pow" } -func convertTo(from *intern.TaskValue) (types.Val, error) { +func convertTo(from *pb.TaskValue) (types.Val, error) { vh, _ := getValue(from) if bytes.Equal(from.Val, x.Nilbyte) { return vh, ErrEmptyVal @@ -292,10 +292,10 @@ func (ag *aggregator) Apply(val types.Val) { ag.result = res } -func (ag *aggregator) ValueMarshalled() (*intern.TaskValue, error) { +func (ag *aggregator) ValueMarshalled() (*pb.TaskValue, error) { data := types.ValueForType(types.BinaryID) ag.divideByCount() - res := &intern.TaskValue{ValType: ag.result.Tid.Enum(), Val: x.Nilbyte} + res := &pb.TaskValue{ValType: ag.result.Tid.Enum(), Val: x.Nilbyte} if ag.result.Value == nil { return res, nil } diff --git a/query/common_test.go b/query/common_test.go index 6b065d2b904..8ceb0015fcc 100644 --- a/query/common_test.go +++ b/query/common_test.go @@ -23,7 +23,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" @@ -39,7 +39,7 @@ func childAttrs(sg *SubGraph) []string { return out } -func taskValues(t *testing.T, v []*intern.ValueList) []string { +func taskValues(t *testing.T, v []*pb.ValueList) []string { out := make([]string, len(v)) for i, tv := range v { out[i] = string(tv.Values[0].Val) @@ -49,11 +49,11 @@ func taskValues(t *testing.T, v []*intern.ValueList) []string { var index uint64 -func addEdge(t *testing.T, attr string, src uint64, edge *intern.DirectedEdge) { +func addEdge(t *testing.T, attr string, src uint64, edge *pb.DirectedEdge) { // Mutations don't go through normal flow, so default schema for predicate won't be present. // Lets add it. if _, ok := schema.State().Get(attr); !ok { - schema.State().Set(attr, intern.SchemaUpdate{ + schema.State().Set(attr, pb.SchemaUpdate{ Predicate: attr, ValueType: edge.ValueType, }) @@ -67,8 +67,8 @@ func addEdge(t *testing.T, attr string, src uint64, edge *intern.DirectedEdge) { commit := timestamp() require.NoError(t, txn.CommitToMemory(commit)) - delta := &intern.OracleDelta{MaxAssigned: commit} - delta.Txns = append(delta.Txns, &intern.TxnStatus{StartTs: startTs, CommitTs: commit}) + delta := &pb.OracleDelta{MaxAssigned: commit} + delta.Txns = append(delta.Txns, &pb.TxnStatus{StartTs: startTs, CommitTs: commit}) posting.Oracle().ProcessDelta(delta) } @@ -94,10 +94,10 @@ func makeFacets(facetKVs map[string]string) (fs []*api.Facet, err error) { func addPredicateEdge(t *testing.T, attr string, src uint64) { if worker.Config.ExpandEdge { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(attr), Attr: "_predicate_", - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } addEdge(t, "_predicate_", src, edge) } @@ -113,13 +113,13 @@ func addEdgeToLangValue(t *testing.T, attr string, src uint64, value, lang string, facetKVs map[string]string) { fs, err := makeFacets(facetKVs) require.NoError(t, err) - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(value), Lang: lang, Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, Facets: fs, } addEdge(t, attr, src, edge) @@ -130,13 +130,13 @@ func addEdgeToTypedValue(t *testing.T, attr string, src uint64, typ types.TypeID, value []byte, facetKVs map[string]string) { fs, err := makeFacets(facetKVs) require.NoError(t, err) - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: value, - ValueType: intern.Posting_ValType(typ), + ValueType: pb.Posting_ValType(typ), Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, Facets: fs, } addEdge(t, attr, src, edge) @@ -147,15 +147,15 @@ func addEdgeToUID(t *testing.T, attr string, src uint64, dst uint64, facetKVs map[string]string) { fs, err := makeFacets(facetKVs) require.NoError(t, err) - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: dst, // This is used to set uid schema type for pred for the purpose of tests. Actual mutation // won't set ValueType to types.UidID. - ValueType: intern.Posting_ValType(types.UidID), + ValueType: pb.Posting_ValType(types.UidID), Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, Facets: fs, } addEdge(t, attr, src, edge) @@ -163,25 +163,25 @@ func addEdgeToUID(t *testing.T, attr string, src uint64, } func delEdgeToUID(t *testing.T, attr string, src uint64, dst uint64) { - edge := &intern.DirectedEdge{ - ValueType: intern.Posting_ValType(types.UidID), + edge := &pb.DirectedEdge{ + ValueType: pb.Posting_ValType(types.UidID), ValueId: dst, Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } addEdge(t, attr, src, edge) } func delEdgeToLangValue(t *testing.T, attr string, src uint64, value, lang string) { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte(value), Lang: lang, Label: "testing", Attr: attr, Entity: src, - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, } addEdge(t, attr, src, edge) } diff --git a/query/groupby.go b/query/groupby.go index 7382c6d1be8..838b9cf5d16 100644 --- a/query/groupby.go +++ b/query/groupby.go @@ -13,7 +13,7 @@ import ( "strconv" "github.com/dgraph-io/dgraph/algo" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" ) @@ -69,7 +69,7 @@ type groupResults struct { } type groupElements struct { - entities *intern.List + entities *pb.List key types.Val } @@ -122,7 +122,7 @@ func (d *dedup) addValue(attr string, value types.Val, uid uint64) { // If this is the first element of the group. cur.elements[strKey] = groupElements{ key: value, - entities: &intern.List{make([]uint64, 0)}, + entities: &pb.List{make([]uint64, 0)}, } } curEntity := cur.elements[strKey].entities @@ -156,7 +156,7 @@ func aggregateGroup(grp *groupResult, child *SubGraph) (types.Val, error) { // formGroup creates all possible groups with the list of uids that belong to that // group. -func (res *groupResults) formGroups(dedupMap dedup, cur *intern.List, groupVal []groupPair) { +func (res *groupResults) formGroups(dedupMap dedup, cur *pb.List, groupVal []groupPair) { l := len(groupVal) if len(dedupMap.groups) == 0 || (l != 0 && len(cur.Uids) == 0) { // This group is already empty or no group can be formed. So stop. @@ -176,7 +176,7 @@ func (res *groupResults) formGroups(dedupMap dedup, cur *intern.List, groupVal [ } for _, v := range dedupMap.groups[l].elements { - temp := new(intern.List) + temp := new(pb.List) groupVal = append(groupVal, groupPair{ key: v.key, attr: dedupMap.groups[l].attr, @@ -192,7 +192,7 @@ func (res *groupResults) formGroups(dedupMap dedup, cur *intern.List, groupVal [ } } -func (sg *SubGraph) formResult(ul *intern.List) (*groupResults, error) { +func (sg *SubGraph) formResult(ul *pb.List) (*groupResults, error) { var dedupMap dedup res := new(groupResults) @@ -235,7 +235,7 @@ func (sg *SubGraph) formResult(ul *intern.List) (*groupResults, error) { } // Create all the groups here. - res.formGroups(dedupMap, &intern.List{}, []groupPair{}) + res.formGroups(dedupMap, &pb.List{}, []groupPair{}) // Go over the groups and aggregate the values. for _, child := range sg.Children { @@ -313,7 +313,7 @@ func (sg *SubGraph) fillGroupedVars(doneVars map[string]varValue, path []*SubGra // Create all the groups here. res := new(groupResults) - res.formGroups(dedupMap, &intern.List{}, []groupPair{}) + res.formGroups(dedupMap, &pb.List{}, []groupPair{}) // Go over the groups and aggregate the values. for _, child := range sg.Children { diff --git a/query/mutation.go b/query/mutation.go index 2cd5206c58a..ab3ae49c5a2 100644 --- a/query/mutation.go +++ b/query/mutation.go @@ -17,17 +17,17 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" ) -func ApplyMutations(ctx context.Context, m *intern.Mutations) (*api.TxnContext, error) { +func ApplyMutations(ctx context.Context, m *pb.Mutations) (*api.TxnContext, error) { if worker.Config.ExpandEdge { edges, err := expandEdges(ctx, m) if err != nil { - return nil, x.Wrapf(err, "While adding intern.edges") + return nil, x.Wrapf(err, "While adding pb.edges") } m.Edges = edges if tr, ok := trace.FromContext(ctx); ok { @@ -50,17 +50,17 @@ func ApplyMutations(ctx context.Context, m *intern.Mutations) (*api.TxnContext, return tctx, err } -func expandEdges(ctx context.Context, m *intern.Mutations) ([]*intern.DirectedEdge, error) { - edges := make([]*intern.DirectedEdge, 0, 2*len(m.Edges)) +func expandEdges(ctx context.Context, m *pb.Mutations) ([]*pb.DirectedEdge, error) { + edges := make([]*pb.DirectedEdge, 0, 2*len(m.Edges)) for _, edge := range m.Edges { - x.AssertTrue(edge.Op == intern.DirectedEdge_DEL || edge.Op == intern.DirectedEdge_SET) + x.AssertTrue(edge.Op == pb.DirectedEdge_DEL || edge.Op == pb.DirectedEdge_SET) var preds []string if edge.Attr != x.Star { preds = []string{edge.Attr} } else { sg := &SubGraph{} - sg.DestUIDs = &intern.List{[]uint64{edge.GetEntity()}} + sg.DestUIDs = &pb.List{[]uint64{edge.GetEntity()}} sg.ReadTs = m.StartTs valMatrix, err := getNodePredicates(ctx, sg) if err != nil { @@ -84,11 +84,11 @@ func expandEdges(ctx context.Context, m *intern.Mutations) ([]*intern.DirectedEd // We only want to delete the pred from + <_predicate_> posting list if this is // a SP* deletion operation. Otherwise we just continue. - if edge.Op == intern.DirectedEdge_DEL && string(edge.Value) != x.Star { + if edge.Op == pb.DirectedEdge_DEL && string(edge.Value) != x.Star { continue } - e := &intern.DirectedEdge{ + e := &pb.DirectedEdge{ Op: edge.Op, Entity: edge.GetEntity(), Attr: "_predicate_", @@ -117,7 +117,7 @@ func verifyUid(ctx context.Context, uid uint64) error { func AssignUids(ctx context.Context, nquads []*api.NQuad) (map[string]uint64, error) { newUids := make(map[string]uint64) - num := &intern.Num{} + num := &pb.Num{} var err error for _, nq := range nquads { // We dont want to assign uids to these. @@ -153,7 +153,7 @@ func AssignUids(ctx context.Context, nquads []*api.NQuad) (map[string]uint64, er num.Val = uint64(len(newUids)) if int(num.Val) > 0 { - var res *intern.AssignedIds + var res *pb.AssignedIds // TODO: Optimize later by prefetching. Also consolidate all the UID requests into a single // pending request from this server to zero. if res, err = worker.AssignUidsOverNetwork(ctx, num); err != nil { @@ -174,18 +174,18 @@ func AssignUids(ctx context.Context, nquads []*api.NQuad) (map[string]uint64, er } func ToInternal(gmu *gql.Mutation, - newUids map[string]uint64) (edges []*intern.DirectedEdge, err error) { + newUids map[string]uint64) (edges []*pb.DirectedEdge, err error) { // Wrapper for a pointer to protos.Nquad var wnq *gql.NQuad - parse := func(nq *api.NQuad, op intern.DirectedEdge_Op) error { + parse := func(nq *api.NQuad, op pb.DirectedEdge_Op) error { wnq = &gql.NQuad{nq} if len(nq.Subject) == 0 { return nil } // Get edge from nquad using newUids. - var edge *intern.DirectedEdge + var edge *pb.DirectedEdge edge, err = wnq.ToEdgeUsing(newUids) if err != nil { return x.Wrap(err) @@ -199,7 +199,7 @@ func ToInternal(gmu *gql.Mutation, if err := facets.SortAndValidate(nq.Facets); err != nil { return edges, err } - if err := parse(nq, intern.DirectedEdge_SET); err != nil { + if err := parse(nq, pb.DirectedEdge_SET); err != nil { return edges, err } } @@ -207,7 +207,7 @@ func ToInternal(gmu *gql.Mutation, if nq.Subject == x.Star && nq.ObjectValue.GetDefaultVal() == x.Star { return edges, errors.New("Predicate deletion should be called via alter.") } - if err := parse(nq, intern.DirectedEdge_DEL); err != nil { + if err := parse(nq, pb.DirectedEdge_DEL); err != nil { return edges, err } } diff --git a/query/query.go b/query/query.go index fd03a9cad94..9e0fa040737 100644 --- a/query/query.go +++ b/query/query.go @@ -23,7 +23,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/task" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" @@ -54,7 +54,7 @@ const ( * } * * REPRESENTATION: - * This would be represented in SubGraph format intern.y, as such: + * This would be represented in SubGraph format pb.y, as such: * SubGraph [result uid = me] * | * Children @@ -105,7 +105,7 @@ type params struct { AfterUID uint64 DoCount bool GetUid bool - Order []*intern.Order + Order []*pb.Order Var string NeedsVar []gql.VarContext ParentVars map[string]varValue @@ -122,7 +122,7 @@ type params struct { From uint64 To uint64 - Facet *intern.FacetParams + Facet *pb.FacetParams FacetOrder string FacetOrderDesc bool ExploreDepth uint64 @@ -148,7 +148,7 @@ type Function struct { IsValueVar bool // eq(val(s), 10) } -// SubGraph is the way to represent data intern.y. It contains both the +// SubGraph is the way to represent data pb.y. It contains both the // query and the response. Once generated, this can then be encoded to other // client convenient formats, like GraphQL / JSON. type SubGraph struct { @@ -156,26 +156,26 @@ type SubGraph struct { Attr string Params params counts []uint32 - valueMatrix []*intern.ValueList - uidMatrix []*intern.List - facetsMatrix []*intern.FacetsList - ExpandPreds []*intern.ValueList + valueMatrix []*pb.ValueList + uidMatrix []*pb.List + facetsMatrix []*pb.FacetsList + ExpandPreds []*pb.ValueList GroupbyRes []*groupResults // one result for each uid list. - LangTags []*intern.LangList + LangTags []*pb.LangList // SrcUIDs is a list of unique source UIDs. They are always copies of destUIDs // of parent nodes in GraphQL structure. - SrcUIDs *intern.List + SrcUIDs *pb.List SrcFunc *Function FilterOp string Filters []*SubGraph - facetsFilter *intern.FilterTree + facetsFilter *pb.FilterTree MathExp *mathTree Children []*SubGraph // destUIDs is a list of destination UIDs, after applying filters, pagination. - DestUIDs *intern.List + DestUIDs *pb.List List bool // whether predicate is of list type } @@ -232,7 +232,7 @@ func (sg *SubGraph) DebugPrint(prefix string) { } // getValue gets the value from the task. -func getValue(tv *intern.TaskValue) (types.Val, error) { +func getValue(tv *pb.TaskValue) (types.Val, error) { vID := types.TypeID(tv.ValType) val := types.ValueForType(vID) val.Value = tv.Val @@ -324,7 +324,7 @@ func addInternalNode(pc *SubGraph, uid uint64, dst outputNode) error { return nil } -func addCheckPwd(pc *SubGraph, vals []*intern.TaskValue, dst outputNode) { +func addCheckPwd(pc *SubGraph, vals []*pb.TaskValue, dst outputNode) { c := types.ValueForType(types.BoolID) if len(vals) == 0 { // No value found for predicate. @@ -413,7 +413,7 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { } else if pc.SrcFunc != nil && pc.SrcFunc.Name == "checkpwd" { addCheckPwd(pc, pc.valueMatrix[idx].Values, dst) } else if idx < len(pc.uidMatrix) && len(pc.uidMatrix[idx].Uids) > 0 { - var fcsList []*intern.Facets + var fcsList []*pb.Facets if pc.Params.Facet != nil { fcsList = pc.facetsMatrix[idx].FacetsList } @@ -500,7 +500,7 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { if pc.Params.expandAll && len(pc.LangTags[idx].Lang) != 0 { if i >= len(pc.LangTags[idx].Lang) { return x.Errorf( - "intern.error: all lang tags should be either present or absent") + "pb.error: all lang tags should be either present or absent") } fieldNameWithTag := fieldName lang := pc.LangTags[idx].Lang[i] @@ -545,7 +545,7 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { // convert from task.Val to types.Value, based on schema appropriate type // is already set in api.Value -func convertWithBestEffort(tv *intern.TaskValue, attr string) (types.Val, error) { +func convertWithBestEffort(tv *pb.TaskValue, attr string) (types.Val, error) { // value would be in binary format with appropriate type v, _ := getValue(tv) if !v.Tid.IsScalar() { @@ -819,7 +819,7 @@ func (args *params) fill(gq *gql.GraphQuery) error { return nil } -// ToSubGraph converts the GraphQuery into the intern.SubGraph instance type. +// ToSubGraph converts the GraphQuery into the pb.SubGraph instance type. func ToSubGraph(ctx context.Context, gq *gql.GraphQuery) (*SubGraph, error) { sg, err := newGraph(ctx, gq) if err != nil { @@ -846,9 +846,9 @@ func isDebug(ctx context.Context) bool { func (sg *SubGraph) populate(uids []uint64) error { // Put sorted entries in matrix. sort.Slice(uids, func(i, j int) bool { return uids[i] < uids[j] }) - sg.uidMatrix = []*intern.List{{uids}} + sg.uidMatrix = []*pb.List{{uids}} // User specified list may not be sorted. - sg.SrcUIDs = &intern.List{uids} + sg.SrcUIDs = &pb.List{uids} return nil } @@ -930,14 +930,14 @@ func newGraph(ctx context.Context, gq *gql.GraphQuery) (*SubGraph, error) { return sg, nil } -func toFacetsFilter(gft *gql.FilterTree) (*intern.FilterTree, error) { +func toFacetsFilter(gft *gql.FilterTree) (*pb.FilterTree, error) { if gft == nil { return nil, nil } if gft.Func != nil && len(gft.Func.NeedsVar) != 0 { - return nil, x.Errorf("Variables not supported in intern.FilterTree") + return nil, x.Errorf("Variables not supported in pb.FilterTree") } - ftree := new(intern.FilterTree) + ftree := new(pb.FilterTree) ftree.Op = gft.Op for _, gftc := range gft.Child { ftc, err := toFacetsFilter(gftc) @@ -947,7 +947,7 @@ func toFacetsFilter(gft *gql.FilterTree) (*intern.FilterTree, error) { ftree.Children = append(ftree.Children, ftc) } if gft.Func != nil { - ftree.Func = &intern.Function{ + ftree.Func = &pb.Function{ Key: gft.Func.Attr, Name: gft.Func.Name, Args: []string{}, @@ -961,16 +961,16 @@ func toFacetsFilter(gft *gql.FilterTree) (*intern.FilterTree, error) { } // createTaskQuery generates the query buffer. -func createTaskQuery(sg *SubGraph) (*intern.Query, error) { +func createTaskQuery(sg *SubGraph) (*pb.Query, error) { attr := sg.Attr // Might be safer than just checking first byte due to i18n reverse := strings.HasPrefix(attr, "~") if reverse { attr = strings.TrimPrefix(attr, "~") } - var srcFunc *intern.SrcFunction + var srcFunc *pb.SrcFunction if sg.SrcFunc != nil { - srcFunc = &intern.SrcFunction{} + srcFunc = &pb.SrcFunction{} srcFunc.Name = sg.SrcFunc.Name srcFunc.IsCount = sg.SrcFunc.IsCount for _, arg := range sg.SrcFunc.Args { @@ -980,7 +980,7 @@ func createTaskQuery(sg *SubGraph) (*intern.Query, error) { } } } - out := &intern.Query{ + out := &pb.Query{ ReadTs: sg.ReadTs, Attr: attr, Langs: sg.Params.Langs, @@ -999,11 +999,11 @@ func createTaskQuery(sg *SubGraph) (*intern.Query, error) { } type varValue struct { - Uids *intern.List + Uids *pb.List Vals map[uint64]types.Val path []*SubGraph // This stores the subgraph path from root to var definition. // TODO: Check if we can do without this field. - strList []*intern.ValueList + strList []*pb.ValueList } func evalLevelAgg(doneVars map[string]varValue, sg, parent *SubGraph) (mp map[uint64]types.Val, @@ -1262,7 +1262,7 @@ func (sg *SubGraph) valueVarAggregation(doneVars map[string]varValue, path []*Su // The value var can be empty. No need to check for nil. sg.Params.uidToVal = srcMap.Vals } else { - return x.Errorf("Unhandled intern.node %v with parent %v", sg.Attr, parent.Attr) + return x.Errorf("Unhandled pb.node %v with parent %v", sg.Attr, parent.Attr) } return nil } @@ -1380,7 +1380,7 @@ func (sg *SubGraph) populateVarMap(doneVars map[string]varValue, } // Note the we can't overwrite DestUids, as it'd also modify the SrcUids of // next level and the mapping from SrcUids to uidMatrix would be lost. - sg.DestUIDs = &intern.List{out} + sg.DestUIDs = &pb.List{out} AssignStep: return sg.updateVars(doneVars, sgPath) @@ -1429,7 +1429,7 @@ func (sg *SubGraph) populateUidValVar(doneVars map[string]varValue, sgPath []*Su } } else if len(sg.DestUIDs.Uids) != 0 || (sg.Attr == "uid" && sg.SrcUIDs != nil) { // Uid variable could be defined using uid or a predicate. - var uids *intern.List + var uids *pb.List if sg.Attr == "uid" { uids = sg.SrcUIDs } else { @@ -1448,7 +1448,7 @@ func (sg *SubGraph) populateUidValVar(doneVars map[string]varValue, sgPath []*Su // For a recurse query this can happen. We don't allow using the same variable more than // once otherwise. oldUids := v.Uids - lists := make([]*intern.List, 0, 2) + lists := make([]*pb.List, 0, 2) lists = append(lists, oldUids, uids) v.Uids = algo.MergeSorted(lists) doneVars[sg.Params.Var] = v @@ -1563,7 +1563,7 @@ func (sg *SubGraph) recursiveFillVars(doneVars map[string]varValue) error { } func (sg *SubGraph) fillVars(mp map[string]varValue) error { - lists := make([]*intern.List, 0, 3) + lists := make([]*pb.List, 0, 3) for _, v := range sg.Params.NeedsVar { if l, ok := mp[v.Name]; ok { if (v.Typ == gql.ANY_VAR || v.Typ == gql.LIST_VAR) && l.strList != nil { @@ -1584,7 +1584,7 @@ func (sg *SubGraph) fillVars(mp map[string]varValue) error { sort.Slice(uids, func(i, j int) bool { return uids[i] < uids[j] }) - lists = append(lists, &intern.List{uids}) + lists = append(lists, &pb.List{uids}) } else if len(l.Vals) != 0 || l.Uids != nil { return x.Errorf("Wrong variable type encountered for var(%v) %v.", v.Name, v.Typ) } @@ -1664,7 +1664,7 @@ func (sg *SubGraph) ApplyIneqFunc() error { sort.Slice(sg.DestUIDs.Uids, func(i, j int) bool { return sg.DestUIDs.Uids[i] < sg.DestUIDs.Uids[j] }) - sg.uidMatrix = []*intern.List{sg.DestUIDs} + sg.uidMatrix = []*pb.List{sg.DestUIDs} } return nil } @@ -1673,8 +1673,8 @@ func (sg *SubGraph) appendDummyValues() { if sg.SrcUIDs == nil { return } - var l intern.List - var val intern.ValueList + var l pb.List + var val pb.ValueList for i := 0; i < len(sg.SrcUIDs.Uids); i++ { // This is necessary so that preTraverse can be processed smoothly. sg.uidMatrix = append(sg.uidMatrix, &l) @@ -1682,7 +1682,7 @@ func (sg *SubGraph) appendDummyValues() { } } -func uniquePreds(vl []*intern.ValueList) []string { +func uniquePreds(vl []*pb.ValueList) []string { predMap := make(map[string]struct{}) for _, l := range vl { @@ -1772,7 +1772,7 @@ func expandSubgraph(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { } temp.Params.isInternal = false temp.Params.Expand = "" - temp.Params.Facet = &intern.FacetParams{AllKeys: true} + temp.Params.Facet = &pb.FacetParams{AllKeys: true} // Go through each child, create a copy and attach to temp.Children. for _, cc := range child.Children { @@ -1793,7 +1793,7 @@ func expandSubgraph(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { } func getReversePredicates(ctx context.Context) ([]string, error) { - schs, err := worker.GetSchemaOverNetwork(ctx, &intern.SchemaRequest{}) + schs, err := worker.GetSchemaOverNetwork(ctx, &pb.SchemaRequest{}) if err != nil { return nil, err } @@ -1834,7 +1834,7 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) { // Populated variable. o := make([]uint64, len(sg.DestUIDs.Uids)) copy(o, sg.DestUIDs.Uids) - sg.uidMatrix = []*intern.List{{o}} + sg.uidMatrix = []*pb.List{{o}} sort.Slice(sg.DestUIDs.Uids, func(i, j int) bool { return sg.DestUIDs.Uids[i] < sg.DestUIDs.Uids[j] }) } } else if len(sg.Attr) == 0 { @@ -1857,7 +1857,7 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) { // This is to allow providing SrcUIDs to the filter children. // Each filter use it's own (shallow) copy of SrcUIDs, so there is no race conditions, // when multiple filters replace their sg.DestUIDs - sg.DestUIDs = &intern.List{sg.SrcUIDs.Uids} + sg.DestUIDs = &pb.List{sg.SrcUIDs.Uids} } else { if sg.SrcFunc != nil && isInequalityFn(sg.SrcFunc.Name) && sg.SrcFunc.IsValueVar { @@ -1912,7 +1912,7 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) { if parent == nil { // I'm root. We reach here if root had a function. - sg.uidMatrix = []*intern.List{sg.DestUIDs} + sg.uidMatrix = []*pb.List{sg.DestUIDs} } } } @@ -1973,7 +1973,7 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) { } // Now apply the results from filter. - var lists []*intern.List + var lists []*pb.List for _, filter := range sg.Filters { lists = append(lists, filter.DestUIDs) } @@ -2141,7 +2141,7 @@ func (sg *SubGraph) applyOrderAndPagination(ctx context.Context) error { x.AssertTrue(len(sg.Params.Order) > 0) - sort := &intern.SortMessage{ + sort := &pb.SortMessage{ Order: sg.Params.Order, UidMatrix: sg.uidMatrix, Offset: int32(sg.Params.Offset), @@ -2158,7 +2158,7 @@ func (sg *SubGraph) applyOrderAndPagination(ctx context.Context) error { // The order of uids in the lists which are part of the uidMatrix would have been changed // after sort. We want to update the order of lists in the facetMatrix accordingly. for idx, rl := range result.UidMatrix { - fl := make([]*intern.Facets, 0, len(sg.facetsMatrix[idx].FacetsList)) + fl := make([]*pb.Facets, 0, len(sg.facetsMatrix[idx].FacetsList)) for _, uid := range rl.Uids { // Find index of this uid in original sorted uid list. oidx := algo.IndexOf(sg.uidMatrix[idx], uid) @@ -2227,7 +2227,7 @@ func (sg *SubGraph) sortAndPaginateUsingFacet(ctx context.Context) error { if len(values) == 0 { continue } - if err := types.SortWithFacet(values, &intern.List{uids}, + if err := types.SortWithFacet(values, &pb.List{uids}, facetList, []bool{sg.Params.FacetOrderDesc}); err != nil { return err } @@ -2272,7 +2272,7 @@ func (sg *SubGraph) sortAndPaginateUsingVar(ctx context.Context) error { if len(values) == 0 { continue } - if err := types.Sort(values, &intern.List{uids}, []bool{sg.Params.Order[0].Desc}); err != nil { + if err := types.Sort(values, &pb.List{uids}, []bool{sg.Params.Order[0].Desc}); err != nil { return err } sg.uidMatrix[i].Uids = uids @@ -2330,7 +2330,7 @@ func isUidFnWithoutVar(f *gql.Function) bool { return f.Name == "uid" && len(f.NeedsVar) == 0 } -func getNodePredicates(ctx context.Context, sg *SubGraph) ([]*intern.ValueList, error) { +func getNodePredicates(ctx context.Context, sg *SubGraph) ([]*pb.ValueList, error) { temp := new(SubGraph) temp.Attr = "_predicate_" temp.SrcUIDs = sg.DestUIDs @@ -2416,7 +2416,7 @@ func (req *QueryRequest) ProcessQuery(ctx context.Context) (err error) { if gq == nil || (len(gq.UID) == 0 && gq.Func == nil && len(gq.NeedsVar) == 0 && gq.Alias != "shortest" && !gq.IsEmpty) { - err := x.Errorf("Invalid query, query intern.id is zero and generator is nil") + err := x.Errorf("Invalid query, query pb.id is zero and generator is nil") if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf(err.Error()) } @@ -2568,7 +2568,7 @@ type InternalError struct { } func (e *InternalError) Error() string { - return "intern.error: " + e.err.Error() + return "pb.error: " + e.err.Error() } // TODO: This looks unnecessary. diff --git a/query/query0_test.go b/query/query0_test.go index 538bbaed103..9d33d909f6b 100644 --- a/query/query0_test.go +++ b/query/query0_test.go @@ -25,7 +25,7 @@ import ( "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/worker" @@ -35,7 +35,7 @@ import ( var passwordCache map[string]string = make(map[string]string, 2) var ts uint64 -var odch chan *intern.OracleDelta +var odch chan *pb.OracleDelta func timestamp() uint64 { return atomic.AddUint64(&ts, 1) @@ -1624,7 +1624,7 @@ var maxPendingCh chan uint64 func TestMain(m *testing.M) { x.Init(true) - odch = make(chan *intern.OracleDelta, 100) + odch = make(chan *pb.OracleDelta, 100) maxPendingCh = make(chan uint64, 100) cmd := exec.Command("go", "install", "github.com/dgraph-io/dgraph/dgraph") diff --git a/query/query1_test.go b/query/query1_test.go index eb498c67cc4..42ff5f7c439 100644 --- a/query/query1_test.go +++ b/query/query1_test.go @@ -18,7 +18,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" ) @@ -111,13 +111,13 @@ func (c *raftServer) RaftMessage(ctx context.Context, in *api.Payload) (*api.Pay return &api.Payload{}, nil } -func (c *raftServer) JoinCluster(ctx context.Context, in *intern.RaftContext) (*api.Payload, error) { +func (c *raftServer) JoinCluster(ctx context.Context, in *pb.RaftContext) (*api.Payload, error) { return &api.Payload{}, nil } func updateMaxPending() { for mp := range maxPendingCh { - posting.Oracle().ProcessDelta(&intern.OracleDelta{ + posting.Oracle().ProcessDelta(&pb.OracleDelta{ MaxAssigned: mp, }) } diff --git a/query/query2_test.go b/query/query2_test.go index 7bb65955124..799e3637148 100644 --- a/query/query2_test.go +++ b/query/query2_test.go @@ -18,7 +18,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" ) @@ -959,14 +959,14 @@ func TestToFastJSONOrderOffsetCount(t *testing.T) { } // Mocking Subgraph and Testing fast-json with it. -func ageSg(uidMatrix []*intern.List, srcUids *intern.List, ages []uint64) *SubGraph { - var as []*intern.ValueList +func ageSg(uidMatrix []*pb.List, srcUids *pb.List, ages []uint64) *SubGraph { + var as []*pb.ValueList for _, a := range ages { bs := make([]byte, 4) binary.LittleEndian.PutUint64(bs, a) - as = append(as, &intern.ValueList{ - Values: []*intern.TaskValue{ - &intern.TaskValue{[]byte(bs), 2}, + as = append(as, &pb.ValueList{ + Values: []*pb.TaskValue{ + &pb.TaskValue{[]byte(bs), 2}, }, }) } @@ -979,10 +979,10 @@ func ageSg(uidMatrix []*intern.List, srcUids *intern.List, ages []uint64) *SubGr Params: params{GetUid: true}, } } -func nameSg(uidMatrix []*intern.List, srcUids *intern.List, names []string) *SubGraph { - var ns []*intern.ValueList +func nameSg(uidMatrix []*pb.List, srcUids *pb.List, names []string) *SubGraph { + var ns []*pb.ValueList for _, n := range names { - ns = append(ns, &intern.ValueList{Values: []*intern.TaskValue{{[]byte(n), 0}}}) + ns = append(ns, &pb.ValueList{Values: []*pb.TaskValue{{[]byte(n), 0}}}) } return &SubGraph{ Attr: "name", @@ -993,7 +993,7 @@ func nameSg(uidMatrix []*intern.List, srcUids *intern.List, names []string) *Sub } } -func friendsSg(uidMatrix []*intern.List, srcUids *intern.List, friends []*SubGraph) *SubGraph { +func friendsSg(uidMatrix []*pb.List, srcUids *pb.List, friends []*SubGraph) *SubGraph { return &SubGraph{ Attr: "friend", uidMatrix: uidMatrix, @@ -1002,7 +1002,7 @@ func friendsSg(uidMatrix []*intern.List, srcUids *intern.List, friends []*SubGra Children: friends, } } -func rootSg(uidMatrix []*intern.List, srcUids *intern.List, names []string, ages []uint64) *SubGraph { +func rootSg(uidMatrix []*pb.List, srcUids *pb.List, names []string, ages []uint64) *SubGraph { nameSg := nameSg(uidMatrix, srcUids, names) ageSg := ageSg(uidMatrix, srcUids, ages) diff --git a/query/query3_test.go b/query/query3_test.go index e24ecf3d692..bd1627f17a4 100644 --- a/query/query3_test.go +++ b/query/query3_test.go @@ -13,7 +13,7 @@ import ( "testing" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/stretchr/testify/require" @@ -956,12 +956,12 @@ func TestMinSchema(t *testing.T) { `{"data": {"me":[{"name":"Michonne","gender":"female","alive":true,"friend":[{"survival_rate":1.600000},{"survival_rate":1.600000},{"survival_rate":1.600000},{"survival_rate":1.600000}],"min(val(x))":1.600000}]}}`, js) - schema.State().Set("survival_rate", intern.SchemaUpdate{ValueType: intern.Posting_ValType(types.IntID)}) + schema.State().Set("survival_rate", pb.SchemaUpdate{ValueType: pb.Posting_ValType(types.IntID)}) js = processToFastJsonNoErr(t, query) require.JSONEq(t, `{"data": {"me":[{"name":"Michonne","gender":"female","alive":true,"friend":[{"survival_rate":1},{"survival_rate":1},{"survival_rate":1},{"survival_rate":1}],"min(val(x))":1}]}}`, js) - schema.State().Set("survival_rate", intern.SchemaUpdate{ValueType: intern.Posting_ValType(types.FloatID)}) + schema.State().Set("survival_rate", pb.SchemaUpdate{ValueType: pb.Posting_ValType(types.FloatID)}) } func TestAvg(t *testing.T) { diff --git a/query/shortest.go b/query/shortest.go index e6cd18dc542..f3dbaf68233 100644 --- a/query/shortest.go +++ b/query/shortest.go @@ -16,7 +16,7 @@ import ( "golang.org/x/net/trace" "github.com/dgraph-io/dgraph/algo" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" "github.com/dgraph-io/dgraph/x" @@ -25,7 +25,7 @@ import ( type pathInfo struct { uid uint64 attr string - facet *intern.Facets + facet *pb.Facets } type route struct { @@ -78,7 +78,7 @@ func (h *priorityQueue) Pop() interface{} { type mapItem struct { attr string cost float64 - facet *intern.Facets + facet *pb.Facets } // We manintain a map from UID to nodeInfo for Djikstras. @@ -90,7 +90,7 @@ type nodeInfo struct { } func (sg *SubGraph) getCost(matrix, list int) (cost float64, - fcs *intern.Facets, rerr error) { + fcs *pb.Facets, rerr error) { cost = 1.0 if sg.Params.Facet == nil { @@ -128,8 +128,8 @@ func (start *SubGraph) expandOut(ctx context.Context, var exec []*SubGraph var err error in := []uint64{start.Params.From} - start.SrcUIDs = &intern.List{in} - start.uidMatrix = []*intern.List{{in}} + start.SrcUIDs = &pb.List{in} + start.uidMatrix = []*pb.List{{in}} start.DestUIDs = start.SrcUIDs for _, child := range start.Children { @@ -385,7 +385,7 @@ func KShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { next <- false if len(kroutes) == 0 { - sg.DestUIDs = &intern.List{} + sg.DestUIDs = &pb.List{} return nil, nil } var res []uint64 @@ -569,7 +569,7 @@ func ShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { } // Put the path in DestUIDs of the root. if cur != sg.Params.From { - sg.DestUIDs = &intern.List{} + sg.DestUIDs = &pb.List{} return nil, nil } @@ -592,9 +592,9 @@ func createPathSubgraph(ctx context.Context, dist map[uint64]nodeInfo, result [] shortest: true, } curUid := result[0] - shortestSg.SrcUIDs = &intern.List{[]uint64{curUid}} - shortestSg.DestUIDs = &intern.List{[]uint64{curUid}} - shortestSg.uidMatrix = []*intern.List{{[]uint64{curUid}}} + shortestSg.SrcUIDs = &pb.List{[]uint64{curUid}} + shortestSg.DestUIDs = &pb.List{[]uint64{curUid}} + shortestSg.uidMatrix = []*pb.List{{[]uint64{curUid}}} curNode := shortestSg for i := 0; i < len(result)-1; i++ { @@ -607,13 +607,13 @@ func createPathSubgraph(ctx context.Context, dist map[uint64]nodeInfo, result [] } if nodeInfo.facet != nil { // For consistent later processing. - node.Params.Facet = &intern.FacetParams{} + node.Params.Facet = &pb.FacetParams{} } node.Attr = nodeInfo.attr - node.facetsMatrix = []*intern.FacetsList{{[]*intern.Facets{nodeInfo.facet}}} - node.SrcUIDs = &intern.List{[]uint64{curUid}} - node.DestUIDs = &intern.List{[]uint64{childUid}} - node.uidMatrix = []*intern.List{{[]uint64{childUid}}} + node.facetsMatrix = []*pb.FacetsList{{[]*pb.Facets{nodeInfo.facet}}} + node.SrcUIDs = &pb.List{[]uint64{curUid}} + node.DestUIDs = &pb.List{[]uint64{childUid}} + node.uidMatrix = []*pb.List{{[]uint64{childUid}}} curNode.Children = append(curNode.Children, node) curNode = node @@ -624,8 +624,8 @@ func createPathSubgraph(ctx context.Context, dist map[uint64]nodeInfo, result [] shortest: true, } uid := result[len(result)-1] - node.SrcUIDs = &intern.List{[]uint64{uid}} - node.uidMatrix = []*intern.List{{[]uint64{uid}}} + node.SrcUIDs = &pb.List{[]uint64{uid}} + node.uidMatrix = []*pb.List{{[]uint64{uid}}} curNode.Children = append(curNode.Children, node) return shortestSg @@ -640,9 +640,9 @@ func createkroutesubgraph(ctx context.Context, kroutes []route) []*SubGraph { shortest: true, } curUid := it.route[0].uid - shortestSg.SrcUIDs = &intern.List{[]uint64{curUid}} - shortestSg.DestUIDs = &intern.List{[]uint64{curUid}} - shortestSg.uidMatrix = []*intern.List{{[]uint64{curUid}}} + shortestSg.SrcUIDs = &pb.List{[]uint64{curUid}} + shortestSg.DestUIDs = &pb.List{[]uint64{curUid}} + shortestSg.uidMatrix = []*pb.List{{[]uint64{curUid}}} curNode := shortestSg i := 0 @@ -655,13 +655,13 @@ func createkroutesubgraph(ctx context.Context, kroutes []route) []*SubGraph { } if it.route[i+1].facet != nil { // For consistent later processing. - node.Params.Facet = &intern.FacetParams{} + node.Params.Facet = &pb.FacetParams{} } node.Attr = it.route[i+1].attr - node.facetsMatrix = []*intern.FacetsList{{[]*intern.Facets{it.route[i+1].facet}}} - node.SrcUIDs = &intern.List{[]uint64{curUid}} - node.DestUIDs = &intern.List{[]uint64{childUid}} - node.uidMatrix = []*intern.List{{[]uint64{childUid}}} + node.facetsMatrix = []*pb.FacetsList{{[]*pb.Facets{it.route[i+1].facet}}} + node.SrcUIDs = &pb.List{[]uint64{curUid}} + node.DestUIDs = &pb.List{[]uint64{childUid}} + node.uidMatrix = []*pb.List{{[]uint64{childUid}}} curNode.Children = append(curNode.Children, node) curNode = node @@ -672,8 +672,8 @@ func createkroutesubgraph(ctx context.Context, kroutes []route) []*SubGraph { shortest: true, } uid := it.route[i].uid - node.SrcUIDs = &intern.List{[]uint64{uid}} - node.uidMatrix = []*intern.List{{[]uint64{uid}}} + node.SrcUIDs = &pb.List{[]uint64{uid}} + node.uidMatrix = []*pb.List{{[]uint64{uid}}} curNode.Children = append(curNode.Children, node) res = append(res, shortestSg) diff --git a/schema/parse.go b/schema/parse.go index 96c7e4591f7..be3ccf1d9ca 100644 --- a/schema/parse.go +++ b/schema/parse.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/dgraph-io/dgraph/lex" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" @@ -33,14 +33,14 @@ func ParseBytes(s []byte, gid uint32) (rerr error) { for _, update := range updates { State().Set(update.Predicate, *update) } - State().Set("_predicate_", intern.SchemaUpdate{ - ValueType: intern.Posting_STRING, + State().Set("_predicate_", pb.SchemaUpdate{ + ValueType: pb.Posting_STRING, List: true, }) return nil } -func parseDirective(it *lex.ItemIterator, schema *intern.SchemaUpdate, t types.TypeID) error { +func parseDirective(it *lex.ItemIterator, schema *pb.SchemaUpdate, t types.TypeID) error { it.Next() next := it.Item() if next.Typ != itemText { @@ -51,12 +51,12 @@ func parseDirective(it *lex.ItemIterator, schema *intern.SchemaUpdate, t types.T if t != types.UidID { return x.Errorf("Cannot reverse for non-UID type") } - schema.Directive = intern.SchemaUpdate_REVERSE + schema.Directive = pb.SchemaUpdate_REVERSE case "index": if tokenizer, err := parseIndexDirective(it, schema.Predicate, t); err != nil { return err } else { - schema.Directive = intern.SchemaUpdate_INDEX + schema.Directive = pb.SchemaUpdate_INDEX schema.Tokenizer = tokenizer } case "count": @@ -77,7 +77,7 @@ func parseDirective(it *lex.ItemIterator, schema *intern.SchemaUpdate, t types.T return nil } -func parseScalarPair(it *lex.ItemIterator, predicate string) (*intern.SchemaUpdate, +func parseScalarPair(it *lex.ItemIterator, predicate string) (*pb.SchemaUpdate, error) { it.Next() if next := it.Item(); next.Typ != itemColon { @@ -88,7 +88,7 @@ func parseScalarPair(it *lex.ItemIterator, predicate string) (*intern.SchemaUpda return nil, x.Errorf("Invalid ending while trying to parse schema.") } next := it.Item() - schema := &intern.SchemaUpdate{Predicate: predicate} + schema := &pb.SchemaUpdate{Predicate: predicate} // Could be list type. if next.Typ == itemLeftSquare { schema.List = true @@ -230,12 +230,12 @@ func parseIndexDirective(it *lex.ItemIterator, predicate string, } // resolveTokenizers resolves default tokenizers and verifies tokenizers definitions. -func resolveTokenizers(updates []*intern.SchemaUpdate) error { +func resolveTokenizers(updates []*pb.SchemaUpdate) error { for _, schema := range updates { typ := types.TypeID(schema.ValueType) if (typ == types.UidID || typ == types.DefaultID || typ == types.PasswordID) && - schema.Directive == intern.SchemaUpdate_INDEX { + schema.Directive == pb.SchemaUpdate_INDEX { return x.Errorf("Indexing not allowed on predicate %s of type %s", schema.Predicate, typ.Name()) } @@ -244,10 +244,10 @@ func resolveTokenizers(updates []*intern.SchemaUpdate) error { continue } - if len(schema.Tokenizer) == 0 && schema.Directive == intern.SchemaUpdate_INDEX { + if len(schema.Tokenizer) == 0 && schema.Directive == pb.SchemaUpdate_INDEX { return x.Errorf("Require type of tokenizer for pred: %s of type: %s for indexing.", schema.Predicate, typ.Name()) - } else if len(schema.Tokenizer) > 0 && schema.Directive != intern.SchemaUpdate_INDEX { + } else if len(schema.Tokenizer) > 0 && schema.Directive != pb.SchemaUpdate_INDEX { return x.Errorf("Tokenizers present without indexing on attr %s", schema.Predicate) } // check for valid tokeniser types and duplicates @@ -282,8 +282,8 @@ func resolveTokenizers(updates []*intern.SchemaUpdate) error { } // Parse parses a schema string and returns the schema representation for it. -func Parse(s string) ([]*intern.SchemaUpdate, error) { - var schemas []*intern.SchemaUpdate +func Parse(s string) ([]*pb.SchemaUpdate, error) { + var schemas []*pb.SchemaUpdate l := lex.Lexer{Input: s} l.Run(lexText) it := l.NewIterator() diff --git a/schema/parse_test.go b/schema/parse_test.go index 1df461ae338..b3de771bb84 100644 --- a/schema/parse_test.go +++ b/schema/parse_test.go @@ -15,17 +15,17 @@ import ( "github.com/dgraph-io/badger" "github.com/stretchr/testify/require" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" ) type nameType struct { name string - typ *intern.SchemaUpdate + typ *pb.SchemaUpdate } -func checkSchema(t *testing.T, h map[string]*intern.SchemaUpdate, expected []nameType) { +func checkSchema(t *testing.T, h map[string]*pb.SchemaUpdate, expected []nameType) { require.Len(t, h, len(expected)) for _, nt := range expected { typ, found := h[nt.name] @@ -45,25 +45,25 @@ name: string . func TestSchema(t *testing.T) { require.NoError(t, ParseBytes([]byte(schemaVal), 1)) checkSchema(t, State().predicate, []nameType{ - {"name", &intern.SchemaUpdate{ + {"name", &pb.SchemaUpdate{ Predicate: "name", - ValueType: intern.Posting_STRING, + ValueType: pb.Posting_STRING, }}, - {"_predicate_", &intern.SchemaUpdate{ - ValueType: intern.Posting_STRING, + {"_predicate_", &pb.SchemaUpdate{ + ValueType: pb.Posting_STRING, List: true, }}, - {"address", &intern.SchemaUpdate{ + {"address", &pb.SchemaUpdate{ Predicate: "address", - ValueType: intern.Posting_STRING, + ValueType: pb.Posting_STRING, }}, - {"http://scalar.com/helloworld/", &intern.SchemaUpdate{ + {"http://scalar.com/helloworld/", &pb.SchemaUpdate{ Predicate: "http://scalar.com/helloworld/", - ValueType: intern.Posting_STRING, + ValueType: pb.Posting_STRING, }}, - {"age", &intern.SchemaUpdate{ + {"age", &pb.SchemaUpdate{ Predicate: "age", - ValueType: intern.Posting_INT, + ValueType: pb.Posting_INT, }}, }) @@ -164,33 +164,33 @@ friend : uid @reverse @count . func TestSchemaIndexCustom(t *testing.T) { require.NoError(t, ParseBytes([]byte(schemaIndexVal5), 1)) checkSchema(t, State().predicate, []nameType{ - {"_predicate_", &intern.SchemaUpdate{ - ValueType: intern.Posting_STRING, + {"_predicate_", &pb.SchemaUpdate{ + ValueType: pb.Posting_STRING, List: true, }}, - {"name", &intern.SchemaUpdate{ + {"name", &pb.SchemaUpdate{ Predicate: "name", - ValueType: intern.Posting_STRING, + ValueType: pb.Posting_STRING, Tokenizer: []string{"exact"}, - Directive: intern.SchemaUpdate_INDEX, + Directive: pb.SchemaUpdate_INDEX, Count: true, }}, - {"address", &intern.SchemaUpdate{ + {"address", &pb.SchemaUpdate{ Predicate: "address", - ValueType: intern.Posting_STRING, + ValueType: pb.Posting_STRING, Tokenizer: []string{"term"}, - Directive: intern.SchemaUpdate_INDEX, + Directive: pb.SchemaUpdate_INDEX, }}, - {"age", &intern.SchemaUpdate{ + {"age", &pb.SchemaUpdate{ Predicate: "age", - ValueType: intern.Posting_INT, + ValueType: pb.Posting_INT, Tokenizer: []string{"int"}, - Directive: intern.SchemaUpdate_INDEX, + Directive: pb.SchemaUpdate_INDEX, }}, - {"friend", &intern.SchemaUpdate{ - ValueType: intern.Posting_UID, + {"friend", &pb.SchemaUpdate{ + ValueType: pb.Posting_UID, Predicate: "friend", - Directive: intern.SchemaUpdate_REVERSE, + Directive: pb.SchemaUpdate_REVERSE, Count: true, }}, }) @@ -272,21 +272,21 @@ func TestParseScalarList(t *testing.T) { `) require.NoError(t, err) require.Equal(t, 3, len(schemas)) - require.EqualValues(t, &intern.SchemaUpdate{ + require.EqualValues(t, &pb.SchemaUpdate{ Predicate: "jobs", ValueType: 9, - Directive: intern.SchemaUpdate_INDEX, + Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"term"}, List: true, }, schemas[0]) - require.EqualValues(t, &intern.SchemaUpdate{ + require.EqualValues(t, &pb.SchemaUpdate{ Predicate: "occupations", ValueType: 9, List: true, }, schemas[1]) - require.EqualValues(t, &intern.SchemaUpdate{ + require.EqualValues(t, &pb.SchemaUpdate{ Predicate: "graduation", ValueType: 5, List: true, diff --git a/schema/schema.go b/schema/schema.go index e80c6ccb6df..dd13c91d5aa 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -15,7 +15,7 @@ import ( "github.com/dgraph-io/badger" "golang.org/x/net/trace" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" @@ -27,14 +27,14 @@ var ( ) func (s *state) init() { - s.predicate = make(map[string]*intern.SchemaUpdate) + s.predicate = make(map[string]*pb.SchemaUpdate) s.elog = trace.NewEventLog("Dgraph", "Schema") } type state struct { sync.RWMutex // Map containing predicate to type information. - predicate map[string]*intern.SchemaUpdate + predicate map[string]*pb.SchemaUpdate elog trace.EventLog } @@ -70,7 +70,7 @@ func (s *state) Delete(attr string) error { return txn.CommitAt(1, nil) } -func logUpdate(schema intern.SchemaUpdate, pred string) string { +func logUpdate(schema pb.SchemaUpdate, pred string) string { typ := types.TypeID(schema.ValueType).Name() if schema.List { typ = fmt.Sprintf("[%s]", typ) @@ -82,7 +82,7 @@ func logUpdate(schema intern.SchemaUpdate, pred string) string { // Set sets the schema for given predicate in memory // schema mutations must flow through update function, which are // synced to db -func (s *state) Set(pred string, schema intern.SchemaUpdate) { +func (s *state) Set(pred string, schema pb.SchemaUpdate) { s.Lock() defer s.Unlock() s.predicate[pred] = &schema @@ -90,12 +90,12 @@ func (s *state) Set(pred string, schema intern.SchemaUpdate) { } // Get gets the schema for given predicate -func (s *state) Get(pred string) (intern.SchemaUpdate, bool) { +func (s *state) Get(pred string) (pb.SchemaUpdate, bool) { s.RLock() defer s.RUnlock() schema, has := s.predicate[pred] if !has { - return intern.SchemaUpdate{}, false + return pb.SchemaUpdate{}, false } return *schema, true } @@ -179,7 +179,7 @@ func (s *state) IsReversed(pred string) bool { s.RLock() defer s.RUnlock() if schema, ok := s.predicate[pred]; ok { - return schema.Directive == intern.SchemaUpdate_REVERSE + return schema.Directive == pb.SchemaUpdate_REVERSE } return false } @@ -245,7 +245,7 @@ func Load(predicate string) error { if err != nil { return err } - var s intern.SchemaUpdate + var s pb.SchemaUpdate x.Check(s.Unmarshal(val)) State().Set(predicate, s) State().elog.Printf(logUpdate(s, predicate)) @@ -272,7 +272,7 @@ func LoadFromDb() error { continue } attr := pk.Attr - var s intern.SchemaUpdate + var s pb.SchemaUpdate val, err := item.Value() if err != nil { return err diff --git a/task/conversion.go b/task/conversion.go index 9c4ab752c5d..8ef43fb3c57 100644 --- a/task/conversion.go +++ b/task/conversion.go @@ -10,7 +10,7 @@ package task import ( "encoding/binary" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" ) var ( @@ -18,25 +18,25 @@ var ( FalseVal = FromBool(false) ) -func FromInt(val int) *intern.TaskValue { +func FromInt(val int) *pb.TaskValue { bs := make([]byte, 4) binary.LittleEndian.PutUint32(bs, uint32(val)) - return &intern.TaskValue{Val: []byte(bs), ValType: intern.Posting_INT} + return &pb.TaskValue{Val: []byte(bs), ValType: pb.Posting_INT} } -func ToInt(val *intern.TaskValue) int32 { +func ToInt(val *pb.TaskValue) int32 { result := binary.LittleEndian.Uint32(val.Val) return int32(result) } -func FromBool(val bool) *intern.TaskValue { +func FromBool(val bool) *pb.TaskValue { if val == true { return FromInt(1) } return FromInt(0) } -func ToBool(val *intern.TaskValue) bool { +func ToBool(val *pb.TaskValue) bool { if len(val.Val) == 0 { return false } diff --git a/types/facets/utils.go b/types/facets/utils.go index 7e842c34385..92b349430f3 100644 --- a/types/facets/utils.go +++ b/types/facets/utils.go @@ -16,7 +16,7 @@ import ( "unicode" "github.com/dgraph-io/dgo/protos/api" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" @@ -40,7 +40,7 @@ func SortAndValidate(fs []*api.Facet) error { } // CopyFacets makes a copy of facets of the posting which are requested in param.Keys. -func CopyFacets(fcs []*api.Facet, param *intern.FacetParams) (fs []*api.Facet) { +func CopyFacets(fcs []*api.Facet, param *pb.FacetParams) (fs []*api.Facet) { if param == nil || fcs == nil { return nil } diff --git a/types/geofilter.go b/types/geofilter.go index 396702a2d9f..61fbcb80129 100644 --- a/types/geofilter.go +++ b/types/geofilter.go @@ -15,7 +15,7 @@ import ( "github.com/golang/geo/s2" "github.com/twpayne/go-geom" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -33,7 +33,7 @@ const ( QueryTypeNear ) -// GeoQueryData is intern.data used by the geo query filter to additionally filter the geometries. +// GeoQueryData is pb.data used by the geo query filter to additionally filter the geometries. type GeoQueryData struct { pt *s2.Point // If not nil, the input data was a point loops []*s2.Loop // If not empty, the input data was a polygon/multipolygon or it was a near query. @@ -52,7 +52,7 @@ func IsGeoFunc(str string) bool { // GetGeoTokens returns the corresponding index keys based on the type // of function. -func GetGeoTokens(srcFunc *intern.SrcFunction) ([]string, *GeoQueryData, error) { +func GetGeoTokens(srcFunc *pb.SrcFunction) ([]string, *GeoQueryData, error) { x.AssertTruef(len(srcFunc.Name) > 0, "Invalid function") funcName := strings.ToLower(srcFunc.Name) switch funcName { @@ -395,7 +395,7 @@ func (q GeoQueryData) intersects(g geom.T) bool { // MatchGeo matches values and GeoQueryData and ensures that the value actually // matches the query criteria. -func MatchGeo(value *intern.TaskValue, q *GeoQueryData) bool { +func MatchGeo(value *pb.TaskValue, q *GeoQueryData) bool { valBytes := value.Val if bytes.Equal(valBytes, nil) { return false diff --git a/types/scalar_types.go b/types/scalar_types.go index e3414e72f98..400d739ce7e 100644 --- a/types/scalar_types.go +++ b/types/scalar_types.go @@ -10,7 +10,7 @@ package types import ( "time" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" geom "github.com/twpayne/go-geom" ) @@ -23,16 +23,16 @@ const ( // data. When adding a new type *always* add to the end of this list. // Never delete anything from this list even if it becomes unused. const ( - BinaryID = TypeID(intern.Posting_BINARY) - IntID = TypeID(intern.Posting_INT) - FloatID = TypeID(intern.Posting_FLOAT) - BoolID = TypeID(intern.Posting_BOOL) - DateTimeID = TypeID(intern.Posting_DATETIME) - StringID = TypeID(intern.Posting_STRING) - GeoID = TypeID(intern.Posting_GEO) - UidID = TypeID(intern.Posting_UID) - PasswordID = TypeID(intern.Posting_PASSWORD) - DefaultID = TypeID(intern.Posting_DEFAULT) + BinaryID = TypeID(pb.Posting_BINARY) + IntID = TypeID(pb.Posting_INT) + FloatID = TypeID(pb.Posting_FLOAT) + BoolID = TypeID(pb.Posting_BOOL) + DateTimeID = TypeID(pb.Posting_DATETIME) + StringID = TypeID(pb.Posting_STRING) + GeoID = TypeID(pb.Posting_GEO) + UidID = TypeID(pb.Posting_UID) + PasswordID = TypeID(pb.Posting_PASSWORD) + DefaultID = TypeID(pb.Posting_DEFAULT) ) var typeNameMap = map[string]TypeID{ @@ -47,10 +47,10 @@ var typeNameMap = map[string]TypeID{ "default": DefaultID, } -type TypeID intern.Posting_ValType +type TypeID pb.Posting_ValType -func (t TypeID) Enum() intern.Posting_ValType { - return intern.Posting_ValType(t) +func (t TypeID) Enum() pb.Posting_ValType { + return pb.Posting_ValType(t) } func (t TypeID) Name() string { diff --git a/types/sort.go b/types/sort.go index 2e69e460cc9..3db44c95f2d 100644 --- a/types/sort.go +++ b/types/sort.go @@ -12,15 +12,15 @@ import ( "sort" "time" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) type sortBase struct { values [][]Val // Each uid could have multiple values which we need to sort it by. desc []bool // Sort orders for different values. - ul *intern.List - o []*intern.Facets + ul *pb.List + o []*pb.Facets } // Len returns size of vector. @@ -71,7 +71,7 @@ func (s byValue) Less(i, j int) bool { } // Sort sorts the given array in-place. -func SortWithFacet(v [][]Val, ul *intern.List, l []*intern.Facets, desc []bool) error { +func SortWithFacet(v [][]Val, ul *pb.List, l []*pb.Facets, desc []bool) error { if len(v) == 0 || len(v[0]) == 0 { return nil } @@ -91,7 +91,7 @@ func SortWithFacet(v [][]Val, ul *intern.List, l []*intern.Facets, desc []bool) } // Sort sorts the given array in-place. -func Sort(v [][]Val, ul *intern.List, desc []bool) error { +func Sort(v [][]Val, ul *pb.List, desc []bool) error { return SortWithFacet(v, ul, nil, desc) } diff --git a/types/sort_test.go b/types/sort_test.go index b39d09d1e20..cd7687f20a7 100644 --- a/types/sort_test.go +++ b/types/sort_test.go @@ -10,7 +10,7 @@ package types import ( "testing" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/stretchr/testify/require" ) @@ -35,12 +35,12 @@ func getInput(t *testing.T, tid TypeID, in []string) [][]Val { return list } -func getUIDList(n int) *intern.List { +func getUIDList(n int) *pb.List { data := make([]uint64, 0, n) for i := 1; i <= n; i++ { data = append(data, uint64(i*100)) } - return &intern.List{data} + return &pb.List{data} } func TestSortStrings(t *testing.T) { diff --git a/vendor/github.com/gogo/protobuf/LICENSE b/vendor/github.com/gogo/protobuf/LICENSE index 7be0cc7b62c..f57de90da8a 100644 --- a/vendor/github.com/gogo/protobuf/LICENSE +++ b/vendor/github.com/gogo/protobuf/LICENSE @@ -1,7 +1,6 @@ -Protocol Buffers for Go with Gadgets - Copyright (c) 2013, The GoGo Authors. All rights reserved. -http://github.com/gogo/protobuf + +Protocol Buffers for Go with Gadgets Go support for Protocol Buffers - Google's data interchange format diff --git a/vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go b/vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go index 8a0778ba952..b047d13e501 100644 --- a/vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go +++ b/vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go @@ -41,16 +41,22 @@ package jsonpb import ( "bytes" "encoding/json" + "errors" "fmt" "io" + "math" "reflect" "sort" "strconv" "strings" + "time" "github.com/gogo/protobuf/proto" + "github.com/gogo/protobuf/types" ) +const secondInNanos = int64(time.Second / time.Nanosecond) + // Marshaler is a configurable object for converting between // protocol buffer objects and a JSON representation for them. type Marshaler struct { @@ -68,12 +74,61 @@ type Marshaler struct { // Whether to use the original (.proto) name for fields. OrigName bool + + // A custom URL resolver to use when marshaling Any messages to JSON. + // If unset, the default resolution strategy is to extract the + // fully-qualified type name from the type URL and pass that to + // proto.MessageType(string). + AnyResolver AnyResolver +} + +// AnyResolver takes a type URL, present in an Any message, and resolves it into +// an instance of the associated message. +type AnyResolver interface { + Resolve(typeUrl string) (proto.Message, error) +} + +func defaultResolveAny(typeUrl string) (proto.Message, error) { + // Only the part of typeUrl after the last slash is relevant. + mname := typeUrl + if slash := strings.LastIndex(mname, "/"); slash >= 0 { + mname = mname[slash+1:] + } + mt := proto.MessageType(mname) + if mt == nil { + return nil, fmt.Errorf("unknown message type %q", mname) + } + return reflect.New(mt.Elem()).Interface().(proto.Message), nil +} + +// JSONPBMarshaler is implemented by protobuf messages that customize the +// way they are marshaled to JSON. Messages that implement this should +// also implement JSONPBUnmarshaler so that the custom format can be +// parsed. +type JSONPBMarshaler interface { + MarshalJSONPB(*Marshaler) ([]byte, error) +} + +// JSONPBUnmarshaler is implemented by protobuf messages that customize +// the way they are unmarshaled from JSON. Messages that implement this +// should also implement JSONPBMarshaler so that the custom format can be +// produced. +type JSONPBUnmarshaler interface { + UnmarshalJSONPB(*Unmarshaler, []byte) error } // Marshal marshals a protocol buffer into JSON. func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error { + v := reflect.ValueOf(pb) + if pb == nil || (v.Kind() == reflect.Ptr && v.IsNil()) { + return errors.New("Marshal called with nil") + } + // Check for unset required fields first. + if err := checkRequiredFields(pb); err != nil { + return err + } writer := &errWriter{writer: out} - return m.marshalObject(writer, pb, "") + return m.marshalObject(writer, pb, "", "") } // MarshalToString converts a protocol buffer object to JSON string. @@ -87,20 +142,132 @@ func (m *Marshaler) MarshalToString(pb proto.Message) (string, error) { type int32Slice []int32 +var nonFinite = map[string]float64{ + `"NaN"`: math.NaN(), + `"Infinity"`: math.Inf(1), + `"-Infinity"`: math.Inf(-1), +} + // For sorting extensions ids to ensure stable output. func (s int32Slice) Len() int { return len(s) } func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +type isWkt interface { + XXX_WellKnownType() string +} + // marshalObject writes a struct to the Writer. -func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent string) error { +func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error { + if jsm, ok := v.(JSONPBMarshaler); ok { + b, err := jsm.MarshalJSONPB(m) + if err != nil { + return err + } + if typeURL != "" { + // we are marshaling this object to an Any type + var js map[string]*json.RawMessage + if err = json.Unmarshal(b, &js); err != nil { + return fmt.Errorf("type %T produced invalid JSON: %v", v, err) + } + turl, err := json.Marshal(typeURL) + if err != nil { + return fmt.Errorf("failed to marshal type URL %q to JSON: %v", typeURL, err) + } + js["@type"] = (*json.RawMessage)(&turl) + if b, err = json.Marshal(js); err != nil { + return err + } + } + + out.write(string(b)) + return out.err + } + + s := reflect.ValueOf(v).Elem() + + // Handle well-known types. + if wkt, ok := v.(isWkt); ok { + switch wkt.XXX_WellKnownType() { + case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value", + "Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue": + // "Wrappers use the same representation in JSON + // as the wrapped primitive type, ..." + sprop := proto.GetProperties(s.Type()) + return m.marshalValue(out, sprop.Prop[0], s.Field(0), indent) + case "Any": + // Any is a bit more involved. + return m.marshalAny(out, v, indent) + case "Duration": + // "Generated output always contains 0, 3, 6, or 9 fractional digits, + // depending on required precision." + s, ns := s.Field(0).Int(), s.Field(1).Int() + if ns <= -secondInNanos || ns >= secondInNanos { + return fmt.Errorf("ns out of range (%v, %v)", -secondInNanos, secondInNanos) + } + if (s > 0 && ns < 0) || (s < 0 && ns > 0) { + return errors.New("signs of seconds and nanos do not match") + } + if s < 0 { + ns = -ns + } + x := fmt.Sprintf("%d.%09d", s, ns) + x = strings.TrimSuffix(x, "000") + x = strings.TrimSuffix(x, "000") + x = strings.TrimSuffix(x, ".000") + out.write(`"`) + out.write(x) + out.write(`s"`) + return out.err + case "Struct", "ListValue": + // Let marshalValue handle the `Struct.fields` map or the `ListValue.values` slice. + // TODO: pass the correct Properties if needed. + return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent) + case "Timestamp": + // "RFC 3339, where generated output will always be Z-normalized + // and uses 0, 3, 6 or 9 fractional digits." + s, ns := s.Field(0).Int(), s.Field(1).Int() + if ns < 0 || ns >= secondInNanos { + return fmt.Errorf("ns out of range [0, %v)", secondInNanos) + } + t := time.Unix(s, ns).UTC() + // time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits). + x := t.Format("2006-01-02T15:04:05.000000000") + x = strings.TrimSuffix(x, "000") + x = strings.TrimSuffix(x, "000") + x = strings.TrimSuffix(x, ".000") + out.write(`"`) + out.write(x) + out.write(`Z"`) + return out.err + case "Value": + // Value has a single oneof. + kind := s.Field(0) + if kind.IsNil() { + // "absence of any variant indicates an error" + return errors.New("nil Value") + } + // oneof -> *T -> T -> T.F + x := kind.Elem().Elem().Field(0) + // TODO: pass the correct Properties if needed. + return m.marshalValue(out, &proto.Properties{}, x, indent) + } + } + out.write("{") if m.Indent != "" { out.write("\n") } - s := reflect.ValueOf(v).Elem() firstField := true + + if typeURL != "" { + if err := m.marshalTypeURL(out, indent, typeURL); err != nil { + return err + } + firstField = false + } + for i := 0; i < s.NumField(); i++ { value := s.Field(i) valueField := s.Type().Field(i) @@ -108,9 +275,14 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent string continue } + //this is not a protobuf field + if valueField.Tag.Get("protobuf") == "" && valueField.Tag.Get("protobuf_oneof") == "" { + continue + } + // IsNil will panic on most value kinds. switch value.Kind() { - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + case reflect.Chan, reflect.Func, reflect.Interface: if value.IsNil() { continue } @@ -138,6 +310,10 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent string if value.Len() == 0 { continue } + case reflect.Map, reflect.Ptr, reflect.Slice: + if value.IsNil() { + continue + } } } @@ -175,12 +351,14 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent string } // Handle proto2 extensions. - if ep, ok := v.(extendableProto); ok { + if ep, ok := v.(proto.Message); ok { extensions := proto.RegisteredExtensions(v) - extensionMap := ep.ExtensionMap() // Sort extensions for stable output. - ids := make([]int32, 0, len(extensionMap)) - for id := range extensionMap { + ids := make([]int32, 0, len(extensions)) + for id, desc := range extensions { + if !proto.HasExtension(ep, desc) { + continue + } ids = append(ids, id) } sort.Sort(int32Slice(ids)) @@ -225,6 +403,77 @@ func (m *Marshaler) writeSep(out *errWriter) { } } +func (m *Marshaler) marshalAny(out *errWriter, any proto.Message, indent string) error { + // "If the Any contains a value that has a special JSON mapping, + // it will be converted as follows: {"@type": xxx, "value": yyy}. + // Otherwise, the value will be converted into a JSON object, + // and the "@type" field will be inserted to indicate the actual data type." + v := reflect.ValueOf(any).Elem() + turl := v.Field(0).String() + val := v.Field(1).Bytes() + + var msg proto.Message + var err error + if m.AnyResolver != nil { + msg, err = m.AnyResolver.Resolve(turl) + } else { + msg, err = defaultResolveAny(turl) + } + if err != nil { + return err + } + + if err := proto.Unmarshal(val, msg); err != nil { + return err + } + + if _, ok := msg.(isWkt); ok { + out.write("{") + if m.Indent != "" { + out.write("\n") + } + if err := m.marshalTypeURL(out, indent, turl); err != nil { + return err + } + m.writeSep(out) + if m.Indent != "" { + out.write(indent) + out.write(m.Indent) + out.write(`"value": `) + } else { + out.write(`"value":`) + } + if err := m.marshalObject(out, msg, indent+m.Indent, ""); err != nil { + return err + } + if m.Indent != "" { + out.write("\n") + out.write(indent) + } + out.write("}") + return out.err + } + + return m.marshalObject(out, msg, indent, turl) +} + +func (m *Marshaler) marshalTypeURL(out *errWriter, indent, typeURL string) error { + if m.Indent != "" { + out.write(indent) + out.write(m.Indent) + } + out.write(`"@type":`) + if m.Indent != "" { + out.write(" ") + } + b, err := json.Marshal(typeURL) + if err != nil { + return err + } + out.write(string(b)) + return out.err +} + // marshalField writes field description and value to the Writer. func (m *Marshaler) marshalField(out *errWriter, prop *proto.Properties, v reflect.Value, indent string) error { if m.Indent != "" { @@ -248,6 +497,12 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle v = reflect.Indirect(v) + // Handle nil pointer + if v.Kind() == reflect.Invalid { + out.write("null") + return out.err + } + // Handle repeated elements. if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 { out.write("[") @@ -275,6 +530,29 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle return out.err } + // Handle well-known types. + // Most are handled up in marshalObject (because 99% are messages). + if wkt, ok := v.Interface().(isWkt); ok { + switch wkt.XXX_WellKnownType() { + case "NullValue": + out.write("null") + return out.err + } + } + + if t, ok := v.Interface().(time.Time); ok { + ts, err := types.TimestampProto(t) + if err != nil { + return err + } + return m.marshalValue(out, prop, reflect.ValueOf(ts), indent) + } + + if d, ok := v.Interface().(time.Duration); ok { + dur := types.DurationProto(d) + return m.marshalValue(out, prop, reflect.ValueOf(dur), indent) + } + // Handle enumerations. if !m.EnumsAsInts && prop.Enum != "" { // Unknown enum values will are stringified by the proto library as their @@ -328,6 +606,18 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle out.write(`null`) return out.err } + + if m, ok := v.Interface().(interface { + MarshalJSON() ([]byte, error) + }); ok { + data, err := m.MarshalJSON() + if err != nil { + return err + } + out.write(string(data)) + return nil + } + pm, ok := iface.(proto.Message) if !ok { if prop.CustomType == "" { @@ -339,7 +629,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle } pm = i.Convert(t).Interface().(proto.Message) } - return m.marshalObject(out, pm, indent+m.Indent) + return m.marshalObject(out, pm, indent+m.Indent, "") } // Handle maps. @@ -393,6 +683,24 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle return out.err } + // Handle non-finite floats, e.g. NaN, Infinity and -Infinity. + if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { + f := v.Float() + var sval string + switch { + case math.IsInf(f, 1): + sval = `"Infinity"` + case math.IsInf(f, -1): + sval = `"-Infinity"` + case math.IsNaN(f): + sval = `"NaN"` + } + if sval != "" { + out.write(sval) + return out.err + } + } + // Default handling defers to the encoding/json library. b, err := json.Marshal(v.Interface()) if err != nil { @@ -415,6 +723,12 @@ type Unmarshaler struct { // Whether to allow messages to contain unknown fields, as opposed to // failing to unmarshal. AllowUnknownFields bool + + // A custom URL resolver to use when unmarshaling Any messages from JSON. + // If unset, the default resolution strategy is to extract the + // fully-qualified type name from the type URL and pass that to + // proto.MessageType(string). + AnyResolver AnyResolver } // UnmarshalNext unmarshals the next protocol buffer from a JSON object stream. @@ -425,7 +739,10 @@ func (u *Unmarshaler) UnmarshalNext(dec *json.Decoder, pb proto.Message) error { if err := dec.Decode(&inputValue); err != nil { return err } - return u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil) + if err := u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil); err != nil { + return err + } + return checkRequiredFields(pb) } // Unmarshal unmarshals a JSON object stream into a protocol @@ -464,10 +781,195 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe // Allocate memory for pointer fields. if targetType.Kind() == reflect.Ptr { + // If input value is "null" and target is a pointer type, then the field should be treated as not set + // UNLESS the target is structpb.Value, in which case it should be set to structpb.NullValue. + _, isJSONPBUnmarshaler := target.Interface().(JSONPBUnmarshaler) + if string(inputValue) == "null" && targetType != reflect.TypeOf(&types.Value{}) && !isJSONPBUnmarshaler { + return nil + } target.Set(reflect.New(targetType.Elem())) + return u.unmarshalValue(target.Elem(), inputValue, prop) } + if jsu, ok := target.Addr().Interface().(JSONPBUnmarshaler); ok { + return jsu.UnmarshalJSONPB(u, []byte(inputValue)) + } + + // Handle well-known types that are not pointers. + if w, ok := target.Addr().Interface().(isWkt); ok { + switch w.XXX_WellKnownType() { + case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value", + "Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue": + return u.unmarshalValue(target.Field(0), inputValue, prop) + case "Any": + // Use json.RawMessage pointer type instead of value to support pre-1.8 version. + // 1.8 changed RawMessage.MarshalJSON from pointer type to value type, see + // https://github.com/golang/go/issues/14493 + var jsonFields map[string]*json.RawMessage + if err := json.Unmarshal(inputValue, &jsonFields); err != nil { + return err + } + + val, ok := jsonFields["@type"] + if !ok || val == nil { + return errors.New("Any JSON doesn't have '@type'") + } + + var turl string + if err := json.Unmarshal([]byte(*val), &turl); err != nil { + return fmt.Errorf("can't unmarshal Any's '@type': %q", *val) + } + target.Field(0).SetString(turl) + + var m proto.Message + var err error + if u.AnyResolver != nil { + m, err = u.AnyResolver.Resolve(turl) + } else { + m, err = defaultResolveAny(turl) + } + if err != nil { + return err + } + + if _, ok := m.(isWkt); ok { + val, ok := jsonFields["value"] + if !ok { + return errors.New("Any JSON doesn't have 'value'") + } + + if err = u.unmarshalValue(reflect.ValueOf(m).Elem(), *val, nil); err != nil { + return fmt.Errorf("can't unmarshal Any nested proto %T: %v", m, err) + } + } else { + delete(jsonFields, "@type") + nestedProto, uerr := json.Marshal(jsonFields) + if uerr != nil { + return fmt.Errorf("can't generate JSON for Any's nested proto to be unmarshaled: %v", uerr) + } + + if err = u.unmarshalValue(reflect.ValueOf(m).Elem(), nestedProto, nil); err != nil { + return fmt.Errorf("can't unmarshal Any nested proto %T: %v", m, err) + } + } + + b, err := proto.Marshal(m) + if err != nil { + return fmt.Errorf("can't marshal proto %T into Any.Value: %v", m, err) + } + target.Field(1).SetBytes(b) + + return nil + case "Duration": + unq, err := unquote(string(inputValue)) + if err != nil { + return err + } + + d, err := time.ParseDuration(unq) + if err != nil { + return fmt.Errorf("bad Duration: %v", err) + } + + ns := d.Nanoseconds() + s := ns / 1e9 + ns %= 1e9 + target.Field(0).SetInt(s) + target.Field(1).SetInt(ns) + return nil + case "Timestamp": + unq, err := unquote(string(inputValue)) + if err != nil { + return err + } + + t, err := time.Parse(time.RFC3339Nano, unq) + if err != nil { + return fmt.Errorf("bad Timestamp: %v", err) + } + + target.Field(0).SetInt(t.Unix()) + target.Field(1).SetInt(int64(t.Nanosecond())) + return nil + case "Struct": + var m map[string]json.RawMessage + if err := json.Unmarshal(inputValue, &m); err != nil { + return fmt.Errorf("bad StructValue: %v", err) + } + target.Field(0).Set(reflect.ValueOf(map[string]*types.Value{})) + for k, jv := range m { + pv := &types.Value{} + if err := u.unmarshalValue(reflect.ValueOf(pv).Elem(), jv, prop); err != nil { + return fmt.Errorf("bad value in StructValue for key %q: %v", k, err) + } + target.Field(0).SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(pv)) + } + return nil + case "ListValue": + var s []json.RawMessage + if err := json.Unmarshal(inputValue, &s); err != nil { + return fmt.Errorf("bad ListValue: %v", err) + } + + target.Field(0).Set(reflect.ValueOf(make([]*types.Value, len(s)))) + for i, sv := range s { + if err := u.unmarshalValue(target.Field(0).Index(i), sv, prop); err != nil { + return err + } + } + return nil + case "Value": + ivStr := string(inputValue) + if ivStr == "null" { + target.Field(0).Set(reflect.ValueOf(&types.Value_NullValue{})) + } else if v, err := strconv.ParseFloat(ivStr, 0); err == nil { + target.Field(0).Set(reflect.ValueOf(&types.Value_NumberValue{NumberValue: v})) + } else if v, err := unquote(ivStr); err == nil { + target.Field(0).Set(reflect.ValueOf(&types.Value_StringValue{StringValue: v})) + } else if v, err := strconv.ParseBool(ivStr); err == nil { + target.Field(0).Set(reflect.ValueOf(&types.Value_BoolValue{BoolValue: v})) + } else if err := json.Unmarshal(inputValue, &[]json.RawMessage{}); err == nil { + lv := &types.ListValue{} + target.Field(0).Set(reflect.ValueOf(&types.Value_ListValue{ListValue: lv})) + return u.unmarshalValue(reflect.ValueOf(lv).Elem(), inputValue, prop) + } else if err := json.Unmarshal(inputValue, &map[string]json.RawMessage{}); err == nil { + sv := &types.Struct{} + target.Field(0).Set(reflect.ValueOf(&types.Value_StructValue{StructValue: sv})) + return u.unmarshalValue(reflect.ValueOf(sv).Elem(), inputValue, prop) + } else { + return fmt.Errorf("unrecognized type for Value %q", ivStr) + } + return nil + } + } + + if t, ok := target.Addr().Interface().(*time.Time); ok { + ts := &types.Timestamp{} + if err := u.unmarshalValue(reflect.ValueOf(ts).Elem(), inputValue, prop); err != nil { + return err + } + tt, err := types.TimestampFromProto(ts) + if err != nil { + return err + } + *t = tt + return nil + } + + if d, ok := target.Addr().Interface().(*time.Duration); ok { + dur := &types.Duration{} + if err := u.unmarshalValue(reflect.ValueOf(dur).Elem(), inputValue, prop); err != nil { + return err + } + dd, err := types.DurationFromProto(dur) + if err != nil { + return err + } + *d = dd + return nil + } + // Handle enums, which have an underlying type of int32, // and may appear as strings. // The case of an enum appearing as a number is handled @@ -491,6 +993,14 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe // Handle nested messages. if targetType.Kind() == reflect.Struct { + if prop != nil && len(prop.CustomType) > 0 && target.CanAddr() { + if m, ok := target.Addr().Interface().(interface { + UnmarshalJSON([]byte) error + }); ok { + return json.Unmarshal(inputValue, m) + } + } + var jsonFields map[string]json.RawMessage if err := json.Unmarshal(inputValue, &jsonFields); err != nil { return err @@ -547,6 +1057,26 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe } } } + // Handle proto2 extensions. + if len(jsonFields) > 0 { + if ep, ok := target.Addr().Interface().(proto.Message); ok { + for _, ext := range proto.RegisteredExtensions(ep) { + name := fmt.Sprintf("[%s]", ext.Name) + raw, ok := jsonFields[name] + if !ok { + continue + } + delete(jsonFields, name) + nv := reflect.New(reflect.TypeOf(ext.ExtensionType).Elem()) + if err := u.unmarshalValue(nv.Elem(), raw, nil); err != nil { + return err + } + if err := proto.SetExtension(ep, ext, nv.Interface()); err != nil { + return err + } + } + } + } if !u.AllowUnknownFields && len(jsonFields) > 0 { // Pick any field to be the scapegoat. var f string @@ -561,11 +1091,23 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe // Handle arrays if targetType.Kind() == reflect.Slice { - // Special case for encoded bytes. Pre-go1.5 doesn't support unmarshalling - // strings into aliased []byte types. - // https://github.com/golang/go/commit/4302fd0409da5e4f1d71471a6770dacdc3301197 - // https://github.com/golang/go/commit/c60707b14d6be26bf4213114d13070bff00d0b0a if targetType.Elem().Kind() == reflect.Uint8 { + outRef := reflect.New(targetType) + outVal := outRef.Interface() + //CustomType with underlying type []byte + if _, ok := outVal.(interface { + UnmarshalJSON([]byte) error + }); ok { + if err := json.Unmarshal(inputValue, outVal); err != nil { + return err + } + target.Set(outRef.Elem()) + return nil + } + // Special case for encoded bytes. Pre-go1.5 doesn't support unmarshalling + // strings into aliased []byte types. + // https://github.com/golang/go/commit/4302fd0409da5e4f1d71471a6770dacdc3301197 + // https://github.com/golang/go/commit/c60707b14d6be26bf4213114d13070bff00d0b0a var out []byte if err := json.Unmarshal(inputValue, &out); err != nil { return err @@ -578,11 +1120,13 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe if err := json.Unmarshal(inputValue, &slc); err != nil { return err } - len := len(slc) - target.Set(reflect.MakeSlice(targetType, len, len)) - for i := 0; i < len; i++ { - if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil { - return err + if slc != nil { + l := len(slc) + target.Set(reflect.MakeSlice(targetType, l, l)) + for i := 0; i < l; i++ { + if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil { + return err + } } } return nil @@ -594,37 +1138,34 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe if err := json.Unmarshal(inputValue, &mp); err != nil { return err } - target.Set(reflect.MakeMap(targetType)) - var keyprop, valprop *proto.Properties - if prop != nil { - // These could still be nil if the protobuf metadata is broken somehow. - // TODO: This won't work because the fields are unexported. - // We should probably just reparse them. - //keyprop, valprop = prop.mkeyprop, prop.mvalprop - } - for ks, raw := range mp { - // Unmarshal map key. The core json library already decoded the key into a - // string, so we handle that specially. Other types were quoted post-serialization. - var k reflect.Value - if targetType.Key().Kind() == reflect.String { - k = reflect.ValueOf(ks) - } else { - k = reflect.New(targetType.Key()).Elem() - if err := u.unmarshalValue(k, json.RawMessage(ks), keyprop); err != nil { - return err + if mp != nil { + target.Set(reflect.MakeMap(targetType)) + for ks, raw := range mp { + // Unmarshal map key. The core json library already decoded the key into a + // string, so we handle that specially. Other types were quoted post-serialization. + var k reflect.Value + if targetType.Key().Kind() == reflect.String { + k = reflect.ValueOf(ks) + } else { + k = reflect.New(targetType.Key()).Elem() + // TODO: pass the correct Properties if needed. + if err := u.unmarshalValue(k, json.RawMessage(ks), nil); err != nil { + return err + } } - } - if !k.Type().AssignableTo(targetType.Key()) { - k = k.Convert(targetType.Key()) - } + if !k.Type().AssignableTo(targetType.Key()) { + k = k.Convert(targetType.Key()) + } - // Unmarshal map value. - v := reflect.New(targetType.Elem()).Elem() - if err := u.unmarshalValue(v, raw, valprop); err != nil { - return err + // Unmarshal map value. + v := reflect.New(targetType.Elem()).Elem() + // TODO: pass the correct Properties if needed. + if err := u.unmarshalValue(v, raw, nil); err != nil { + return err + } + target.SetMapIndex(k, v) } - target.SetMapIndex(k, v) } return nil } @@ -636,10 +1177,25 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe inputValue = inputValue[1 : len(inputValue)-1] } + // Non-finite numbers can be encoded as strings. + isFloat := targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64 + if isFloat { + if num, ok := nonFinite[string(inputValue)]; ok { + target.SetFloat(num) + return nil + } + } + // Use the encoding/json for parsing other value types. return json.Unmarshal(inputValue, target.Addr().Interface()) } +func unquote(s string) (string, error) { + var ret string + err := json.Unmarshal([]byte(s), &ret) + return ret, err +} + // jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute. func jsonProperties(f reflect.StructField, origName bool) *proto.Properties { var prop proto.Properties @@ -662,13 +1218,6 @@ func acceptedJSONFieldNames(prop *proto.Properties) fieldNames { return opts } -// extendableProto is an interface implemented by any protocol buffer that may be extended. -type extendableProto interface { - proto.Message - ExtensionRangeArray() []proto.ExtensionRange - ExtensionMap() map[int32]proto.Extension -} - // Writer wrapper inspired by https://blog.golang.org/errors-are-values type errWriter struct { writer io.Writer @@ -704,3 +1253,140 @@ func (s mapKeys) Less(i, j int) bool { } return fmt.Sprint(s[i].Interface()) < fmt.Sprint(s[j].Interface()) } + +// checkRequiredFields returns an error if any required field in the given proto message is not set. +// This function is used by both Marshal and Unmarshal. While required fields only exist in a +// proto2 message, a proto3 message can contain proto2 message(s). +func checkRequiredFields(pb proto.Message) error { + // Most well-known type messages do not contain required fields. The "Any" type may contain + // a message that has required fields. + // + // When an Any message is being marshaled, the code will invoked proto.Unmarshal on Any.Value + // field in order to transform that into JSON, and that should have returned an error if a + // required field is not set in the embedded message. + // + // When an Any message is being unmarshaled, the code will have invoked proto.Marshal on the + // embedded message to store the serialized message in Any.Value field, and that should have + // returned an error if a required field is not set. + if _, ok := pb.(isWkt); ok { + return nil + } + + v := reflect.ValueOf(pb) + // Skip message if it is not a struct pointer. + if v.Kind() != reflect.Ptr { + return nil + } + v = v.Elem() + if v.Kind() != reflect.Struct { + return nil + } + + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + sfield := v.Type().Field(i) + + if sfield.PkgPath != "" { + // blank PkgPath means the field is exported; skip if not exported + continue + } + + if strings.HasPrefix(sfield.Name, "XXX_") { + continue + } + + // Oneof field is an interface implemented by wrapper structs containing the actual oneof + // field, i.e. an interface containing &T{real_value}. + if sfield.Tag.Get("protobuf_oneof") != "" { + if field.Kind() != reflect.Interface { + continue + } + v := field.Elem() + if v.Kind() != reflect.Ptr || v.IsNil() { + continue + } + v = v.Elem() + if v.Kind() != reflect.Struct || v.NumField() < 1 { + continue + } + field = v.Field(0) + sfield = v.Type().Field(0) + } + + protoTag := sfield.Tag.Get("protobuf") + if protoTag == "" { + continue + } + var prop proto.Properties + prop.Init(sfield.Type, sfield.Name, protoTag, &sfield) + + switch field.Kind() { + case reflect.Map: + if field.IsNil() { + continue + } + // Check each map value. + keys := field.MapKeys() + for _, k := range keys { + v := field.MapIndex(k) + if err := checkRequiredFieldsInValue(v); err != nil { + return err + } + } + case reflect.Slice: + // Handle non-repeated type, e.g. bytes. + if !prop.Repeated { + if prop.Required && field.IsNil() { + return fmt.Errorf("required field %q is not set", prop.Name) + } + continue + } + + // Handle repeated type. + if field.IsNil() { + continue + } + // Check each slice item. + for i := 0; i < field.Len(); i++ { + v := field.Index(i) + if err := checkRequiredFieldsInValue(v); err != nil { + return err + } + } + case reflect.Ptr: + if field.IsNil() { + if prop.Required { + return fmt.Errorf("required field %q is not set", prop.Name) + } + continue + } + if err := checkRequiredFieldsInValue(field); err != nil { + return err + } + } + } + + // Handle proto2 extensions. + for _, ext := range proto.RegisteredExtensions(pb) { + if !proto.HasExtension(pb, ext) { + continue + } + ep, err := proto.GetExtension(pb, ext) + if err != nil { + return err + } + err = checkRequiredFieldsInValue(reflect.ValueOf(ep)) + if err != nil { + return err + } + } + + return nil +} + +func checkRequiredFieldsInValue(v reflect.Value) error { + if pm, ok := v.Interface().(proto.Message); ok { + return checkRequiredFields(pm) + } + return nil +} diff --git a/vendor/github.com/gogo/protobuf/proto/Makefile b/vendor/github.com/gogo/protobuf/proto/Makefile index 23a6b173440..00d65f32773 100644 --- a/vendor/github.com/gogo/protobuf/proto/Makefile +++ b/vendor/github.com/gogo/protobuf/proto/Makefile @@ -38,6 +38,6 @@ test: install generate-test-pbs generate-test-pbs: make install - make -C testdata - protoc-min-version --version="3.0.0" --proto_path=.:../../../../ --gogo_out=. proto3_proto/proto3.proto + make -C test_proto + make -C proto3_proto make diff --git a/vendor/github.com/gogo/protobuf/proto/clone.go b/vendor/github.com/gogo/protobuf/proto/clone.go index 79edb86119a..a26b046d94f 100644 --- a/vendor/github.com/gogo/protobuf/proto/clone.go +++ b/vendor/github.com/gogo/protobuf/proto/clone.go @@ -35,22 +35,39 @@ package proto import ( + "fmt" "log" "reflect" "strings" ) // Clone returns a deep copy of a protocol buffer. -func Clone(pb Message) Message { - in := reflect.ValueOf(pb) +func Clone(src Message) Message { + in := reflect.ValueOf(src) if in.IsNil() { - return pb + return src } - out := reflect.New(in.Type().Elem()) - // out is empty so a merge is a deep copy. - mergeStruct(out.Elem(), in.Elem()) - return out.Interface().(Message) + dst := out.Interface().(Message) + Merge(dst, src) + return dst +} + +// Merger is the interface representing objects that can merge messages of the same type. +type Merger interface { + // Merge merges src into this message. + // Required and optional fields that are set in src will be set to that value in dst. + // Elements of repeated fields will be appended. + // + // Merge may panic if called with a different argument type than the receiver. + Merge(src Message) +} + +// generatedMerger is the custom merge method that generated protos will have. +// We must add this method since a generate Merge method will conflict with +// many existing protos that have a Merge data field already defined. +type generatedMerger interface { + XXX_Merge(src Message) } // Merge merges src into dst. @@ -58,17 +75,24 @@ func Clone(pb Message) Message { // Elements of repeated fields will be appended. // Merge panics if src and dst are not the same type, or if dst is nil. func Merge(dst, src Message) { + if m, ok := dst.(Merger); ok { + m.Merge(src) + return + } + in := reflect.ValueOf(src) out := reflect.ValueOf(dst) if out.IsNil() { panic("proto: nil destination") } if in.Type() != out.Type() { - // Explicit test prior to mergeStruct so that mistyped nils will fail - panic("proto: type mismatch") + panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src)) } if in.IsNil() { - // Merging nil into non-nil is a quiet no-op + return // Merge from nil src is a noop + } + if m, ok := dst.(generatedMerger); ok { + m.XXX_Merge(src) return } mergeStruct(out.Elem(), in.Elem()) @@ -84,14 +108,20 @@ func mergeStruct(out, in reflect.Value) { mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) } - if emIn, ok := in.Addr().Interface().(extensionsMap); ok { - emOut := out.Addr().Interface().(extensionsMap) - mergeExtension(emOut.ExtensionMap(), emIn.ExtensionMap()) - } else if emIn, ok := in.Addr().Interface().(extensionsBytes); ok { + if emIn, ok := in.Addr().Interface().(extensionsBytes); ok { emOut := out.Addr().Interface().(extensionsBytes) bIn := emIn.GetExtensions() bOut := emOut.GetExtensions() *bOut = append(*bOut, *bIn...) + } else if emIn, err := extendable(in.Addr().Interface()); err == nil { + emOut, _ := extendable(out.Addr().Interface()) + mIn, muIn := emIn.extensionsRead() + if mIn != nil { + mOut := emOut.extensionsWrite() + muIn.Lock() + mergeExtension(mOut, mIn) + muIn.Unlock() + } } uf := in.FieldByName("XXX_unrecognized") diff --git a/vendor/github.com/gogo/protobuf/proto/custom_gogo.go b/vendor/github.com/gogo/protobuf/proto/custom_gogo.go new file mode 100644 index 00000000000..24552483c6c --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/custom_gogo.go @@ -0,0 +1,39 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import "reflect" + +type custom interface { + Marshal() ([]byte, error) + Unmarshal(data []byte) error + Size() int +} + +var customType = reflect.TypeOf((*custom)(nil)).Elem() diff --git a/vendor/github.com/gogo/protobuf/proto/decode.go b/vendor/github.com/gogo/protobuf/proto/decode.go index 343cd99bfa3..d9aa3c42d66 100644 --- a/vendor/github.com/gogo/protobuf/proto/decode.go +++ b/vendor/github.com/gogo/protobuf/proto/decode.go @@ -39,8 +39,6 @@ import ( "errors" "fmt" "io" - "os" - "reflect" ) // errOverflow is returned when an integer is too large to be represented. @@ -50,10 +48,6 @@ var errOverflow = errors.New("proto: integer overflow") // wire type is encountered. It does not get returned to user code. var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") -// The fundamental decoders that interpret bytes on the wire. -// Those that take integer types all return uint64 and are -// therefore of type valueDecoder. - // DecodeVarint reads a varint-encoded integer from the slice. // It returns the integer and the number of bytes consumed, or // zero if there is not enough. @@ -61,7 +55,6 @@ var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for // int32, int64, uint32, uint64, bool, and enum // protocol buffer types. func DecodeVarint(buf []byte) (x uint64, n int) { - // x, n already 0 for shift := uint(0); shift < 64; shift += 7 { if n >= len(buf) { return 0, 0 @@ -78,13 +71,7 @@ func DecodeVarint(buf []byte) (x uint64, n int) { return 0, 0 } -// DecodeVarint reads a varint-encoded integer from the Buffer. -// This is the format for the -// int32, int64, uint32, uint64, bool, and enum -// protocol buffer types. -func (p *Buffer) DecodeVarint() (x uint64, err error) { - // x, err already 0 - +func (p *Buffer) decodeVarintSlow() (x uint64, err error) { i := p.index l := len(p.buf) @@ -107,6 +94,107 @@ func (p *Buffer) DecodeVarint() (x uint64, err error) { return } +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + i := p.index + buf := p.buf + + if i >= len(buf) { + return 0, io.ErrUnexpectedEOF + } else if buf[i] < 0x80 { + p.index++ + return uint64(buf[i]), nil + } else if len(buf)-i < 10 { + return p.decodeVarintSlow() + } + + var b uint64 + // we already checked the first byte + x = uint64(buf[i]) - 0x80 + i++ + + b = uint64(buf[i]) + i++ + x += b << 7 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 7 + + b = uint64(buf[i]) + i++ + x += b << 14 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 14 + + b = uint64(buf[i]) + i++ + x += b << 21 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 21 + + b = uint64(buf[i]) + i++ + x += b << 28 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 28 + + b = uint64(buf[i]) + i++ + x += b << 35 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 35 + + b = uint64(buf[i]) + i++ + x += b << 42 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 42 + + b = uint64(buf[i]) + i++ + x += b << 49 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 49 + + b = uint64(buf[i]) + i++ + x += b << 56 + if b&0x80 == 0 { + goto done + } + x -= 0x80 << 56 + + b = uint64(buf[i]) + i++ + x += b << 63 + if b&0x80 == 0 { + goto done + } + // x -= 0x80 << 63 // Always zero. + + return 0, errOverflow + +done: + p.index = i + return x, nil +} + // DecodeFixed64 reads a 64-bit integer from the Buffer. // This is the format for the // fixed64, sfixed64, and double protocol buffer types. @@ -173,9 +261,6 @@ func (p *Buffer) DecodeZigzag32() (x uint64, err error) { return } -// These are not ValueDecoders: they produce an array of bytes or a string. -// bytes, embedded messages - // DecodeRawBytes reads a count-delimited byte buffer from the Buffer. // This is the format used for the bytes protocol buffer // type and for embedded messages. @@ -217,81 +302,29 @@ func (p *Buffer) DecodeStringBytes() (s string, err error) { return string(buf), nil } -// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. -// If the protocol buffer has extensions, and the field matches, add it as an extension. -// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. -func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { - oi := o.index - - err := o.skip(t, tag, wire) - if err != nil { - return err - } - - if !unrecField.IsValid() { - return nil - } - - ptr := structPointer_Bytes(base, unrecField) - - // Add the skipped field to struct field - obuf := o.buf - - o.buf = *ptr - o.EncodeVarint(uint64(tag<<3 | wire)) - *ptr = append(o.buf, obuf[oi:o.index]...) - - o.buf = obuf - - return nil -} - -// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. -func (o *Buffer) skip(t reflect.Type, tag, wire int) error { - - var u uint64 - var err error - - switch wire { - case WireVarint: - _, err = o.DecodeVarint() - case WireFixed64: - _, err = o.DecodeFixed64() - case WireBytes: - _, err = o.DecodeRawBytes(false) - case WireFixed32: - _, err = o.DecodeFixed32() - case WireStartGroup: - for { - u, err = o.DecodeVarint() - if err != nil { - break - } - fwire := int(u & 0x7) - if fwire == WireEndGroup { - break - } - ftag := int(u >> 3) - err = o.skip(t, ftag, fwire) - if err != nil { - break - } - } - default: - err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) - } - return err -} - // Unmarshaler is the interface representing objects that can -// unmarshal themselves. The method should reset the receiver before -// decoding starts. The argument points to data that may be +// unmarshal themselves. The argument points to data that may be // overwritten, so implementations should not keep references to the // buffer. +// Unmarshal implementations should not clear the receiver. +// Any unmarshaled data should be merged into the receiver. +// Callers of Unmarshal that do not want to retain existing data +// should Reset the receiver before calling Unmarshal. type Unmarshaler interface { Unmarshal([]byte) error } +// newUnmarshaler is the interface representing objects that can +// unmarshal themselves. The semantics are identical to Unmarshaler. +// +// This exists to support protoc-gen-go generated messages. +// The proto package will stop type-asserting to this interface in the future. +// +// DO NOT DEPEND ON THIS. +type newUnmarshaler interface { + XXX_Unmarshal([]byte) error +} + // Unmarshal parses the protocol buffer representation in buf and places the // decoded result in pb. If the struct underlying pb does not match // the data in buf, the results can be unpredictable. @@ -301,7 +334,13 @@ type Unmarshaler interface { // to preserve and append to existing data. func Unmarshal(buf []byte, pb Message) error { pb.Reset() - return UnmarshalMerge(buf, pb) + if u, ok := pb.(newUnmarshaler); ok { + return u.XXX_Unmarshal(buf) + } + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) } // UnmarshalMerge parses the protocol buffer representation in buf and @@ -311,8 +350,16 @@ func Unmarshal(buf []byte, pb Message) error { // UnmarshalMerge merges into existing data in pb. // Most code should use Unmarshal instead. func UnmarshalMerge(buf []byte, pb Message) error { - // If the object can unmarshal itself, let it. + if u, ok := pb.(newUnmarshaler); ok { + return u.XXX_Unmarshal(buf) + } if u, ok := pb.(Unmarshaler); ok { + // NOTE: The history of proto have unfortunately been inconsistent + // whether Unmarshaler should or should not implicitly clear itself. + // Some implementations do, most do not. + // Thus, calling this here may or may not do what people want. + // + // See https://github.com/golang/protobuf/issues/424 return u.Unmarshal(buf) } return NewBuffer(buf).Unmarshal(pb) @@ -328,551 +375,54 @@ func (p *Buffer) DecodeMessage(pb Message) error { } // DecodeGroup reads a tag-delimited group from the Buffer. +// StartGroup tag is already consumed. This function consumes +// EndGroup tag. func (p *Buffer) DecodeGroup(pb Message) error { - typ, base, err := getbase(pb) - if err != nil { - return err + b := p.buf[p.index:] + x, y := findEndGroup(b) + if x < 0 { + return io.ErrUnexpectedEOF } - return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) + err := Unmarshal(b[:x], pb) + p.index += y + return err } // Unmarshal parses the protocol buffer representation in the // Buffer and places the decoded result in pb. If the struct // underlying pb does not match the data in the buffer, the results can be // unpredictable. +// +// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal. func (p *Buffer) Unmarshal(pb Message) error { // If the object can unmarshal itself, let it. - if u, ok := pb.(Unmarshaler); ok { - err := u.Unmarshal(p.buf[p.index:]) + if u, ok := pb.(newUnmarshaler); ok { + err := u.XXX_Unmarshal(p.buf[p.index:]) p.index = len(p.buf) return err } - - typ, base, err := getbase(pb) - if err != nil { - return err - } - - err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) - - if collectStats { - stats.Decode++ - } - - return err -} - -// unmarshalType does the work of unmarshaling a structure. -func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { - var state errorState - required, reqFields := prop.reqCount, uint64(0) - - var err error - for err == nil && o.index < len(o.buf) { - oi := o.index - var u uint64 - u, err = o.DecodeVarint() - if err != nil { - break - } - wire := int(u & 0x7) - if wire == WireEndGroup { - if is_group { - if required > 0 { - // Not enough information to determine the exact field. - // (See below.) - return &RequiredNotSetError{"{Unknown}"} - } - return nil // input is satisfied - } - return fmt.Errorf("proto: %s: wiretype end group for non-group", st) - } - tag := int(u >> 3) - if tag <= 0 { - return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) - } - fieldnum, ok := prop.decoderTags.get(tag) - if !ok { - // Maybe it's an extension? - if prop.extendable { - if e := structPointer_Interface(base, st).(extendableProto); isExtensionField(e, int32(tag)) { - if err = o.skip(st, tag, wire); err == nil { - if ee, eok := e.(extensionsMap); eok { - ext := ee.ExtensionMap()[int32(tag)] // may be missing - ext.enc = append(ext.enc, o.buf[oi:o.index]...) - ee.ExtensionMap()[int32(tag)] = ext - } else if ee, eok := e.(extensionsBytes); eok { - ext := ee.GetExtensions() - *ext = append(*ext, o.buf[oi:o.index]...) - } - } - continue - } - } - // Maybe it's a oneof? - if prop.oneofUnmarshaler != nil { - m := structPointer_Interface(base, st).(Message) - // First return value indicates whether tag is a oneof field. - ok, err = prop.oneofUnmarshaler(m, tag, wire, o) - if err == ErrInternalBadWireType { - // Map the error to something more descriptive. - // Do the formatting here to save generated code space. - err = fmt.Errorf("bad wiretype for oneof field in %T", m) - } - if ok { - continue - } - } - err = o.skipAndSave(st, tag, wire, base, prop.unrecField) - continue - } - p := prop.Prop[fieldnum] - - if p.dec == nil { - fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) - continue - } - dec := p.dec - if wire != WireStartGroup && wire != p.WireType { - if wire == WireBytes && p.packedDec != nil { - // a packable field - dec = p.packedDec - } else { - err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) - continue - } - } - decErr := dec(o, p, base) - if decErr != nil && !state.shouldContinue(decErr, p) { - err = decErr - } - if err == nil && p.Required { - // Successfully decoded a required field. - if tag <= 64 { - // use bitmap for fields 1-64 to catch field reuse. - var mask uint64 = 1 << uint64(tag-1) - if reqFields&mask == 0 { - // new required field - reqFields |= mask - required-- - } - } else { - // This is imprecise. It can be fooled by a required field - // with a tag > 64 that is encoded twice; that's very rare. - // A fully correct implementation would require allocating - // a data structure, which we would like to avoid. - required-- - } - } - } - if err == nil { - if is_group { - return io.ErrUnexpectedEOF - } - if state.err != nil { - return state.err - } - if required > 0 { - // Not enough information to determine the exact field. If we use extra - // CPU, we could determine the field only if the missing required field - // has a tag <= 64 and we check reqFields. - return &RequiredNotSetError{"{Unknown}"} - } - } - return err -} - -// Individual type decoders -// For each, -// u is the decoded value, -// v is a pointer to the field (pointer) in the struct - -// Sizes of the pools to allocate inside the Buffer. -// The goal is modest amortization and allocation -// on at least 16-byte boundaries. -const ( - boolPoolSize = 16 - uint32PoolSize = 8 - uint64PoolSize = 4 -) - -// Decode a bool. -func (o *Buffer) dec_bool(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - if len(o.bools) == 0 { - o.bools = make([]bool, boolPoolSize) - } - o.bools[0] = u != 0 - *structPointer_Bool(base, p.field) = &o.bools[0] - o.bools = o.bools[1:] - return nil -} - -func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - *structPointer_BoolVal(base, p.field) = u != 0 - return nil -} - -// Decode an int32. -func (o *Buffer) dec_int32(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) - return nil -} - -func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) - return nil -} - -// Decode an int64. -func (o *Buffer) dec_int64(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word64_Set(structPointer_Word64(base, p.field), o, u) - return nil -} - -func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - word64Val_Set(structPointer_Word64Val(base, p.field), o, u) - return nil -} - -// Decode a string. -func (o *Buffer) dec_string(p *Properties, base structPointer) error { - s, err := o.DecodeStringBytes() - if err != nil { - return err - } - *structPointer_String(base, p.field) = &s - return nil -} - -func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { - s, err := o.DecodeStringBytes() - if err != nil { - return err - } - *structPointer_StringVal(base, p.field) = s - return nil -} - -// Decode a slice of bytes ([]byte). -func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - *structPointer_Bytes(base, p.field) = b - return nil -} - -// Decode a slice of bools ([]bool). -func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - v := structPointer_BoolSlice(base, p.field) - *v = append(*v, u != 0) - return nil -} - -// Decode a slice of bools ([]bool) in packed format. -func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { - v := structPointer_BoolSlice(base, p.field) - - nn, err := o.DecodeVarint() - if err != nil { - return err - } - nb := int(nn) // number of bytes of encoded bools - fin := o.index + nb - if fin < o.index { - return errOverflow - } - - y := *v - for o.index < fin { - u, err := p.valDec(o) - if err != nil { - return err - } - y = append(y, u != 0) - } - - *v = y - return nil -} - -// Decode a slice of int32s ([]int32). -func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - structPointer_Word32Slice(base, p.field).Append(uint32(u)) - return nil -} - -// Decode a slice of int32s ([]int32) in packed format. -func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { - v := structPointer_Word32Slice(base, p.field) - - nn, err := o.DecodeVarint() - if err != nil { - return err - } - nb := int(nn) // number of bytes of encoded int32s - - fin := o.index + nb - if fin < o.index { - return errOverflow - } - for o.index < fin { - u, err := p.valDec(o) - if err != nil { - return err - } - v.Append(uint32(u)) - } - return nil -} - -// Decode a slice of int64s ([]int64). -func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { - u, err := p.valDec(o) - if err != nil { - return err - } - - structPointer_Word64Slice(base, p.field).Append(u) - return nil -} - -// Decode a slice of int64s ([]int64) in packed format. -func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { - v := structPointer_Word64Slice(base, p.field) - - nn, err := o.DecodeVarint() - if err != nil { - return err - } - nb := int(nn) // number of bytes of encoded int64s - - fin := o.index + nb - if fin < o.index { - return errOverflow - } - for o.index < fin { - u, err := p.valDec(o) - if err != nil { - return err - } - v.Append(u) - } - return nil -} - -// Decode a slice of strings ([]string). -func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { - s, err := o.DecodeStringBytes() - if err != nil { - return err - } - v := structPointer_StringSlice(base, p.field) - *v = append(*v, s) - return nil -} - -// Decode a slice of slice of bytes ([][]byte). -func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - v := structPointer_BytesSlice(base, p.field) - *v = append(*v, b) - return nil -} - -// Decode a map field. -func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { - raw, err := o.DecodeRawBytes(false) - if err != nil { - return err - } - oi := o.index // index at the end of this map entry - o.index -= len(raw) // move buffer back to start of map entry - - mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V - if mptr.Elem().IsNil() { - mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) - } - v := mptr.Elem() // map[K]V - - // Prepare addressable doubly-indirect placeholders for the key and value types. - // See enc_new_map for why. - keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K - keybase := toStructPointer(keyptr.Addr()) // **K - - var valbase structPointer - var valptr reflect.Value - switch p.mtype.Elem().Kind() { - case reflect.Slice: - // []byte - var dummy []byte - valptr = reflect.ValueOf(&dummy) // *[]byte - valbase = toStructPointer(valptr) // *[]byte - case reflect.Ptr: - // message; valptr is **Msg; need to allocate the intermediate pointer - valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V - valptr.Set(reflect.New(valptr.Type().Elem())) - valbase = toStructPointer(valptr) - default: - // everything else - valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V - valbase = toStructPointer(valptr.Addr()) // **V - } - - // Decode. - // This parses a restricted wire format, namely the encoding of a message - // with two fields. See enc_new_map for the format. - for o.index < oi { - // tagcode for key and value properties are always a single byte - // because they have tags 1 and 2. - tagcode := o.buf[o.index] - o.index++ - switch tagcode { - case p.mkeyprop.tagcode[0]: - if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { - return err - } - case p.mvalprop.tagcode[0]: - if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { - return err - } - default: - // TODO: Should we silently skip this instead? - return fmt.Errorf("proto: bad map data tag %d", raw[0]) - } - } - keyelem, valelem := keyptr.Elem(), valptr.Elem() - if !keyelem.IsValid() { - keyelem = reflect.Zero(p.mtype.Key()) - } - if !valelem.IsValid() { - valelem = reflect.Zero(p.mtype.Elem()) - } - - v.SetMapIndex(keyelem, valelem) - return nil -} - -// Decode a group. -func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { - bas := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(bas) { - // allocate new nested message - bas = toStructPointer(reflect.New(p.stype)) - structPointer_SetStructPointer(base, p.field, bas) - } - return o.unmarshalType(p.stype, p.sprop, true, bas) -} - -// Decode an embedded message. -func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { - raw, e := o.DecodeRawBytes(false) - if e != nil { - return e - } - - bas := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(bas) { - // allocate new nested message - bas = toStructPointer(reflect.New(p.stype)) - structPointer_SetStructPointer(base, p.field, bas) - } - - // If the object can unmarshal itself, let it. - if p.isUnmarshaler { - iv := structPointer_Interface(bas, p.stype) - return iv.(Unmarshaler).Unmarshal(raw) - } - - obuf := o.buf - oi := o.index - o.buf = raw - o.index = 0 - - err = o.unmarshalType(p.stype, p.sprop, false, bas) - o.buf = obuf - o.index = oi - - return err -} - -// Decode a slice of embedded messages. -func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { - return o.dec_slice_struct(p, false, base) -} - -// Decode a slice of embedded groups. -func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { - return o.dec_slice_struct(p, true, base) -} - -// Decode a slice of structs ([]*struct). -func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { - v := reflect.New(p.stype) - bas := toStructPointer(v) - structPointer_StructPointerSlice(base, p.field).Append(bas) - - if is_group { - err := o.unmarshalType(p.stype, p.sprop, is_group, bas) - return err - } - - raw, err := o.DecodeRawBytes(false) - if err != nil { + if u, ok := pb.(Unmarshaler); ok { + // NOTE: The history of proto have unfortunately been inconsistent + // whether Unmarshaler should or should not implicitly clear itself. + // Some implementations do, most do not. + // Thus, calling this here may or may not do what people want. + // + // See https://github.com/golang/protobuf/issues/424 + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) return err } - // If the object can unmarshal itself, let it. - if p.isUnmarshaler { - iv := v.Interface() - return iv.(Unmarshaler).Unmarshal(raw) - } - - obuf := o.buf - oi := o.index - o.buf = raw - o.index = 0 - - err = o.unmarshalType(p.stype, p.sprop, is_group, bas) - - o.buf = obuf - o.index = oi - + // Slow workaround for messages that aren't Unmarshalers. + // This includes some hand-coded .pb.go files and + // bootstrap protos. + // TODO: fix all of those and then add Unmarshal to + // the Message interface. Then: + // The cast above and code below can be deleted. + // The old unmarshaler can be deleted. + // Clients can call Unmarshal directly (can already do that, actually). + var info InternalMessageInfo + err := info.Unmarshal(pb, p.buf[p.index:]) + p.index = len(p.buf) return err } diff --git a/vendor/github.com/gogo/protobuf/proto/decode_gogo.go b/vendor/github.com/gogo/protobuf/proto/decode_gogo.go deleted file mode 100644 index 603dabec3f7..00000000000 --- a/vendor/github.com/gogo/protobuf/proto/decode_gogo.go +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package proto - -import ( - "reflect" -) - -// Decode a reference to a struct pointer. -func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) { - raw, e := o.DecodeRawBytes(false) - if e != nil { - return e - } - - // If the object can unmarshal itself, let it. - if p.isUnmarshaler { - panic("not supported, since this is a pointer receiver") - } - - obuf := o.buf - oi := o.index - o.buf = raw - o.index = 0 - - bas := structPointer_FieldPointer(base, p.field) - - err = o.unmarshalType(p.stype, p.sprop, false, bas) - o.buf = obuf - o.index = oi - - return err -} - -// Decode a slice of references to struct pointers ([]struct). -func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error { - newBas := appendStructPointer(base, p.field, p.sstype) - - if is_group { - panic("not supported, maybe in future, if requested.") - } - - raw, err := o.DecodeRawBytes(false) - if err != nil { - return err - } - - // If the object can unmarshal itself, let it. - if p.isUnmarshaler { - panic("not supported, since this is not a pointer receiver.") - } - - obuf := o.buf - oi := o.index - o.buf = raw - o.index = 0 - - err = o.unmarshalType(p.stype, p.sprop, is_group, newBas) - - o.buf = obuf - o.index = oi - - return err -} - -// Decode a slice of references to struct pointers. -func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error { - return o.dec_slice_ref_struct(p, false, base) -} - -func setPtrCustomType(base structPointer, f field, v interface{}) { - if v == nil { - return - } - structPointer_SetStructPointer(base, f, structPointer(reflect.ValueOf(v).Pointer())) -} - -func setCustomType(base structPointer, f field, value interface{}) { - if value == nil { - return - } - v := reflect.ValueOf(value).Elem() - t := reflect.TypeOf(value).Elem() - kind := t.Kind() - switch kind { - case reflect.Slice: - slice := reflect.MakeSlice(t, v.Len(), v.Cap()) - reflect.Copy(slice, v) - oldHeader := structPointer_GetSliceHeader(base, f) - oldHeader.Data = slice.Pointer() - oldHeader.Len = v.Len() - oldHeader.Cap = v.Cap() - default: - size := reflect.TypeOf(value).Elem().Size() - structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), int(size)) - } -} - -func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - i := reflect.New(p.ctype.Elem()).Interface() - custom := (i).(Unmarshaler) - if err := custom.Unmarshal(b); err != nil { - return err - } - setPtrCustomType(base, p.field, custom) - return nil -} - -func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - i := reflect.New(p.ctype).Interface() - custom := (i).(Unmarshaler) - if err := custom.Unmarshal(b); err != nil { - return err - } - if custom != nil { - setCustomType(base, p.field, custom) - } - return nil -} - -// Decode a slice of bytes ([]byte) into a slice of custom types. -func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error { - b, err := o.DecodeRawBytes(true) - if err != nil { - return err - } - i := reflect.New(p.ctype.Elem()).Interface() - custom := (i).(Unmarshaler) - if err := custom.Unmarshal(b); err != nil { - return err - } - newBas := appendStructPointer(base, p.field, p.ctype) - - setCustomType(newBas, 0, custom) - - return nil -} diff --git a/vendor/github.com/gogo/protobuf/proto/discard.go b/vendor/github.com/gogo/protobuf/proto/discard.go new file mode 100644 index 00000000000..fe1bd7d904e --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/discard.go @@ -0,0 +1,350 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2017 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "fmt" + "reflect" + "strings" + "sync" + "sync/atomic" +) + +type generatedDiscarder interface { + XXX_DiscardUnknown() +} + +// DiscardUnknown recursively discards all unknown fields from this message +// and all embedded messages. +// +// When unmarshaling a message with unrecognized fields, the tags and values +// of such fields are preserved in the Message. This allows a later call to +// marshal to be able to produce a message that continues to have those +// unrecognized fields. To avoid this, DiscardUnknown is used to +// explicitly clear the unknown fields after unmarshaling. +// +// For proto2 messages, the unknown fields of message extensions are only +// discarded from messages that have been accessed via GetExtension. +func DiscardUnknown(m Message) { + if m, ok := m.(generatedDiscarder); ok { + m.XXX_DiscardUnknown() + return + } + // TODO: Dynamically populate a InternalMessageInfo for legacy messages, + // but the master branch has no implementation for InternalMessageInfo, + // so it would be more work to replicate that approach. + discardLegacy(m) +} + +// DiscardUnknown recursively discards all unknown fields. +func (a *InternalMessageInfo) DiscardUnknown(m Message) { + di := atomicLoadDiscardInfo(&a.discard) + if di == nil { + di = getDiscardInfo(reflect.TypeOf(m).Elem()) + atomicStoreDiscardInfo(&a.discard, di) + } + di.discard(toPointer(&m)) +} + +type discardInfo struct { + typ reflect.Type + + initialized int32 // 0: only typ is valid, 1: everything is valid + lock sync.Mutex + + fields []discardFieldInfo + unrecognized field +} + +type discardFieldInfo struct { + field field // Offset of field, guaranteed to be valid + discard func(src pointer) +} + +var ( + discardInfoMap = map[reflect.Type]*discardInfo{} + discardInfoLock sync.Mutex +) + +func getDiscardInfo(t reflect.Type) *discardInfo { + discardInfoLock.Lock() + defer discardInfoLock.Unlock() + di := discardInfoMap[t] + if di == nil { + di = &discardInfo{typ: t} + discardInfoMap[t] = di + } + return di +} + +func (di *discardInfo) discard(src pointer) { + if src.isNil() { + return // Nothing to do. + } + + if atomic.LoadInt32(&di.initialized) == 0 { + di.computeDiscardInfo() + } + + for _, fi := range di.fields { + sfp := src.offset(fi.field) + fi.discard(sfp) + } + + // For proto2 messages, only discard unknown fields in message extensions + // that have been accessed via GetExtension. + if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil { + // Ignore lock since DiscardUnknown is not concurrency safe. + emm, _ := em.extensionsRead() + for _, mx := range emm { + if m, ok := mx.value.(Message); ok { + DiscardUnknown(m) + } + } + } + + if di.unrecognized.IsValid() { + *src.offset(di.unrecognized).toBytes() = nil + } +} + +func (di *discardInfo) computeDiscardInfo() { + di.lock.Lock() + defer di.lock.Unlock() + if di.initialized != 0 { + return + } + t := di.typ + n := t.NumField() + + for i := 0; i < n; i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + + dfi := discardFieldInfo{field: toField(&f)} + tf := f.Type + + // Unwrap tf to get its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name)) + } + + switch tf.Kind() { + case reflect.Struct: + switch { + case !isPointer: + panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name)) + case isSlice: // E.g., []*pb.T + discardInfo := getDiscardInfo(tf) + dfi.discard = func(src pointer) { + sps := src.getPointerSlice() + for _, sp := range sps { + if !sp.isNil() { + discardInfo.discard(sp) + } + } + } + default: // E.g., *pb.T + discardInfo := getDiscardInfo(tf) + dfi.discard = func(src pointer) { + sp := src.getPointer() + if !sp.isNil() { + discardInfo.discard(sp) + } + } + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name)) + default: // E.g., map[K]V + if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T) + dfi.discard = func(src pointer) { + sm := src.asPointerTo(tf).Elem() + if sm.Len() == 0 { + return + } + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + DiscardUnknown(val.Interface().(Message)) + } + } + } else { + dfi.discard = func(pointer) {} // Noop + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name)) + default: // E.g., interface{} + // TODO: Make this faster? + dfi.discard = func(src pointer) { + su := src.asPointerTo(tf).Elem() + if !su.IsNil() { + sv := su.Elem().Elem().Field(0) + if sv.Kind() == reflect.Ptr && sv.IsNil() { + return + } + switch sv.Type().Kind() { + case reflect.Ptr: // Proto struct (e.g., *T) + DiscardUnknown(sv.Interface().(Message)) + } + } + } + } + default: + continue + } + di.fields = append(di.fields, dfi) + } + + di.unrecognized = invalidField + if f, ok := t.FieldByName("XXX_unrecognized"); ok { + if f.Type != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + di.unrecognized = toField(&f) + } + + atomic.StoreInt32(&di.initialized, 1) +} + +func discardLegacy(m Message) { + v := reflect.ValueOf(m) + if v.Kind() != reflect.Ptr || v.IsNil() { + return + } + v = v.Elem() + if v.Kind() != reflect.Struct { + return + } + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + vf := v.Field(i) + tf := f.Type + + // Unwrap tf to get its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name)) + } + + switch tf.Kind() { + case reflect.Struct: + switch { + case !isPointer: + panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name)) + case isSlice: // E.g., []*pb.T + for j := 0; j < vf.Len(); j++ { + discardLegacy(vf.Index(j).Interface().(Message)) + } + default: // E.g., *pb.T + discardLegacy(vf.Interface().(Message)) + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name)) + default: // E.g., map[K]V + tv := vf.Type().Elem() + if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T) + for _, key := range vf.MapKeys() { + val := vf.MapIndex(key) + discardLegacy(val.Interface().(Message)) + } + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name)) + default: // E.g., test_proto.isCommunique_Union interface + if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" { + vf = vf.Elem() // E.g., *test_proto.Communique_Msg + if !vf.IsNil() { + vf = vf.Elem() // E.g., test_proto.Communique_Msg + vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value + if vf.Kind() == reflect.Ptr { + discardLegacy(vf.Interface().(Message)) + } + } + } + } + } + } + + if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() { + if vf.Type() != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + vf.Set(reflect.ValueOf([]byte(nil))) + } + + // For proto2 messages, only discard unknown fields in message extensions + // that have been accessed via GetExtension. + if em, err := extendable(m); err == nil { + // Ignore lock since discardLegacy is not concurrency safe. + emm, _ := em.extensionsRead() + for _, mx := range emm { + if m, ok := mx.value.(Message); ok { + discardLegacy(m) + } + } + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/duration.go b/vendor/github.com/gogo/protobuf/proto/duration.go new file mode 100644 index 00000000000..93464c91cff --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/duration.go @@ -0,0 +1,100 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +// This file implements conversions between google.protobuf.Duration +// and time.Duration. + +import ( + "errors" + "fmt" + "time" +) + +const ( + // Range of a Duration in seconds, as specified in + // google/protobuf/duration.proto. This is about 10,000 years in seconds. + maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60) + minSeconds = -maxSeconds +) + +// validateDuration determines whether the Duration is valid according to the +// definition in google/protobuf/duration.proto. A valid Duration +// may still be too large to fit into a time.Duration (the range of Duration +// is about 10,000 years, and the range of time.Duration is about 290). +func validateDuration(d *duration) error { + if d == nil { + return errors.New("duration: nil Duration") + } + if d.Seconds < minSeconds || d.Seconds > maxSeconds { + return fmt.Errorf("duration: %#v: seconds out of range", d) + } + if d.Nanos <= -1e9 || d.Nanos >= 1e9 { + return fmt.Errorf("duration: %#v: nanos out of range", d) + } + // Seconds and Nanos must have the same sign, unless d.Nanos is zero. + if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) { + return fmt.Errorf("duration: %#v: seconds and nanos have different signs", d) + } + return nil +} + +// DurationFromProto converts a Duration to a time.Duration. DurationFromProto +// returns an error if the Duration is invalid or is too large to be +// represented in a time.Duration. +func durationFromProto(p *duration) (time.Duration, error) { + if err := validateDuration(p); err != nil { + return 0, err + } + d := time.Duration(p.Seconds) * time.Second + if int64(d/time.Second) != p.Seconds { + return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p) + } + if p.Nanos != 0 { + d += time.Duration(p.Nanos) + if (d < 0) != (p.Nanos < 0) { + return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p) + } + } + return d, nil +} + +// DurationProto converts a time.Duration to a Duration. +func durationProto(d time.Duration) *duration { + nanos := d.Nanoseconds() + secs := nanos / 1e9 + nanos -= secs * 1e9 + return &duration{ + Seconds: secs, + Nanos: int32(nanos), + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/duration_gogo.go b/vendor/github.com/gogo/protobuf/proto/duration_gogo.go new file mode 100644 index 00000000000..e748e1730e1 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/duration_gogo.go @@ -0,0 +1,49 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2016, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "reflect" + "time" +) + +var durationType = reflect.TypeOf((*time.Duration)(nil)).Elem() + +type duration struct { + Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` + Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` +} + +func (m *duration) Reset() { *m = duration{} } +func (*duration) ProtoMessage() {} +func (*duration) String() string { return "duration" } + +func init() { + RegisterType((*duration)(nil), "gogo.protobuf.proto.duration") +} diff --git a/vendor/github.com/gogo/protobuf/proto/encode.go b/vendor/github.com/gogo/protobuf/proto/encode.go index 401c1143c88..4c35d337380 100644 --- a/vendor/github.com/gogo/protobuf/proto/encode.go +++ b/vendor/github.com/gogo/protobuf/proto/encode.go @@ -39,23 +39,19 @@ import ( "errors" "fmt" "reflect" - "sort" ) -// RequiredNotSetError is the error returned if Marshal is called with -// a protocol buffer struct whose required fields have not -// all been initialized. It is also the error returned if Unmarshal is -// called with an encoded protocol buffer that does not include all the -// required fields. -// -// When printed, RequiredNotSetError reports the first unset required field in a -// message. If the field cannot be precisely determined, it is reported as -// "{Unknown}". +// RequiredNotSetError is an error type returned by either Marshal or Unmarshal. +// Marshal reports this when a required field is not initialized. +// Unmarshal reports this when a required field is missing from the wire data. type RequiredNotSetError struct { field string } func (e *RequiredNotSetError) Error() string { + if e.field == "" { + return fmt.Sprintf("proto: required field not set") + } return fmt.Sprintf("proto: required field %q not set", e.field) } @@ -82,10 +78,6 @@ var ( const maxVarintBytes = 10 // maximum length of a varint -// maxMarshalSize is the largest allowed size of an encoded protobuf, -// since C++ and Java use signed int32s for the size. -const maxMarshalSize = 1<<31 - 1 - // EncodeVarint returns the varint encoding of x. // This is the format for the // int32, int64, uint32, uint64, bool, and enum @@ -119,18 +111,27 @@ func (p *Buffer) EncodeVarint(x uint64) error { // SizeVarint returns the varint encoding size of an integer. func SizeVarint(x uint64) int { - return sizeVarint(x) -} - -func sizeVarint(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + switch { + case x < 1<<7: + return 1 + case x < 1<<14: + return 2 + case x < 1<<21: + return 3 + case x < 1<<28: + return 4 + case x < 1<<35: + return 5 + case x < 1<<42: + return 6 + case x < 1<<49: + return 7 + case x < 1<<56: + return 8 + case x < 1<<63: + return 9 + } + return 10 } // EncodeFixed64 writes a 64-bit integer to the Buffer. @@ -149,10 +150,6 @@ func (p *Buffer) EncodeFixed64(x uint64) error { return nil } -func sizeFixed64(x uint64) int { - return 8 -} - // EncodeFixed32 writes a 32-bit integer to the Buffer. // This is the format for the // fixed32, sfixed32, and float protocol buffer types. @@ -165,10 +162,6 @@ func (p *Buffer) EncodeFixed32(x uint64) error { return nil } -func sizeFixed32(x uint64) int { - return 4 -} - // EncodeZigzag64 writes a zigzag-encoded 64-bit integer // to the Buffer. // This is the format used for the sint64 protocol buffer type. @@ -177,10 +170,6 @@ func (p *Buffer) EncodeZigzag64(x uint64) error { return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func sizeZigzag64(x uint64) int { - return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - // EncodeZigzag32 writes a zigzag-encoded 32-bit integer // to the Buffer. // This is the format used for the sint32 protocol buffer type. @@ -189,10 +178,6 @@ func (p *Buffer) EncodeZigzag32(x uint64) error { return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) } -func sizeZigzag32(x uint64) int { - return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) -} - // EncodeRawBytes writes a count-delimited byte buffer to the Buffer. // This is the format used for the bytes protocol buffer // type and for embedded messages. @@ -202,11 +187,6 @@ func (p *Buffer) EncodeRawBytes(b []byte) error { return nil } -func sizeRawBytes(b []byte) int { - return sizeVarint(uint64(len(b))) + - len(b) -} - // EncodeStringBytes writes an encoded string to the Buffer. // This is the format used for the proto2 string type. func (p *Buffer) EncodeStringBytes(s string) error { @@ -215,326 +195,17 @@ func (p *Buffer) EncodeStringBytes(s string) error { return nil } -func sizeStringBytes(s string) int { - return sizeVarint(uint64(len(s))) + - len(s) -} - // Marshaler is the interface representing objects that can marshal themselves. type Marshaler interface { Marshal() ([]byte, error) } -// Marshal takes the protocol buffer -// and encodes it into the wire format, returning the data. -func Marshal(pb Message) ([]byte, error) { - // Can the object marshal itself? - if m, ok := pb.(Marshaler); ok { - return m.Marshal() - } - p := NewBuffer(nil) - err := p.Marshal(pb) - var state errorState - if err != nil && !state.shouldContinue(err, nil) { - return nil, err - } - if p.buf == nil && err == nil { - // Return a non-nil slice on success. - return []byte{}, nil - } - return p.buf, err -} - // EncodeMessage writes the protocol buffer to the Buffer, // prefixed by a varint-encoded length. func (p *Buffer) EncodeMessage(pb Message) error { - t, base, err := getbase(pb) - if structPointer_IsNil(base) { - return ErrNil - } - if err == nil { - var state errorState - err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) - } - return err -} - -// Marshal takes the protocol buffer -// and encodes it into the wire format, writing the result to the -// Buffer. -func (p *Buffer) Marshal(pb Message) error { - // Can the object marshal itself? - if m, ok := pb.(Marshaler); ok { - data, err := m.Marshal() - if err != nil { - return err - } - p.buf = append(p.buf, data...) - return nil - } - - t, base, err := getbase(pb) - if structPointer_IsNil(base) { - return ErrNil - } - if err == nil { - err = p.enc_struct(GetProperties(t.Elem()), base) - } - - if collectStats { - stats.Encode++ - } - - if len(p.buf) > maxMarshalSize { - return ErrTooLarge - } - return err -} - -// Size returns the encoded size of a protocol buffer. -func Size(pb Message) (n int) { - // Can the object marshal itself? If so, Size is slow. - // TODO: add Size to Marshaler, or add a Sizer interface. - if m, ok := pb.(Marshaler); ok { - b, _ := m.Marshal() - return len(b) - } - - t, base, err := getbase(pb) - if structPointer_IsNil(base) { - return 0 - } - if err == nil { - n = size_struct(GetProperties(t.Elem()), base) - } - - if collectStats { - stats.Size++ - } - - return -} - -// Individual type encoders. - -// Encode a bool. -func (o *Buffer) enc_bool(p *Properties, base structPointer) error { - v := *structPointer_Bool(base, p.field) - if v == nil { - return ErrNil - } - x := 0 - if *v { - x = 1 - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { - v := *structPointer_BoolVal(base, p.field) - if !v { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, 1) - return nil -} - -func size_bool(p *Properties, base structPointer) int { - v := *structPointer_Bool(base, p.field) - if v == nil { - return 0 - } - return len(p.tagcode) + 1 // each bool takes exactly one byte -} - -func size_proto3_bool(p *Properties, base structPointer) int { - v := *structPointer_BoolVal(base, p.field) - if !v && !p.oneof { - return 0 - } - return len(p.tagcode) + 1 // each bool takes exactly one byte -} - -// Encode an int32. -func (o *Buffer) enc_int32(p *Properties, base structPointer) error { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return ErrNil - } - x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { - v := structPointer_Word32Val(base, p.field) - x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range - if x == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_int32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return 0 - } - x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -func size_proto3_int32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32Val(base, p.field) - x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range - if x == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -// Encode a uint32. -// Exactly the same as int32, except for no sign extension. -func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return ErrNil - } - x := word32_Get(v) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { - v := structPointer_Word32Val(base, p.field) - x := word32Val_Get(v) - if x == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_uint32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32(base, p.field) - if word32_IsNil(v) { - return 0 - } - x := word32_Get(v) - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -func size_proto3_uint32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32Val(base, p.field) - x := word32Val_Get(v) - if x == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -// Encode an int64. -func (o *Buffer) enc_int64(p *Properties, base structPointer) error { - v := structPointer_Word64(base, p.field) - if word64_IsNil(v) { - return ErrNil - } - x := word64_Get(v) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, x) - return nil -} - -func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { - v := structPointer_Word64Val(base, p.field) - x := word64Val_Get(v) - if x == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, x) - return nil -} - -func size_int64(p *Properties, base structPointer) (n int) { - v := structPointer_Word64(base, p.field) - if word64_IsNil(v) { - return 0 - } - x := word64_Get(v) - n += len(p.tagcode) - n += p.valSize(x) - return -} - -func size_proto3_int64(p *Properties, base structPointer) (n int) { - v := structPointer_Word64Val(base, p.field) - x := word64Val_Get(v) - if x == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += p.valSize(x) - return -} - -// Encode a string. -func (o *Buffer) enc_string(p *Properties, base structPointer) error { - v := *structPointer_String(base, p.field) - if v == nil { - return ErrNil - } - x := *v - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(x) - return nil -} - -func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { - v := *structPointer_StringVal(base, p.field) - if v == "" { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(v) - return nil -} - -func size_string(p *Properties, base structPointer) (n int) { - v := *structPointer_String(base, p.field) - if v == nil { - return 0 - } - x := *v - n += len(p.tagcode) - n += sizeStringBytes(x) - return -} - -func size_proto3_string(p *Properties, base structPointer) (n int) { - v := *structPointer_StringVal(base, p.field) - if v == "" && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += sizeStringBytes(v) - return + siz := Size(pb) + p.EncodeVarint(uint64(siz)) + return p.Marshal(pb) } // All protocol buffer fields are nillable, but be careful. @@ -545,804 +216,3 @@ func isNil(v reflect.Value) bool { } return false } - -// Encode a message struct. -func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { - var state errorState - structp := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(structp) { - return ErrNil - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, err := m.Marshal() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - return state.err - } - - o.buf = append(o.buf, p.tagcode...) - return o.enc_len_struct(p.sprop, structp, &state) -} - -func size_struct_message(p *Properties, base structPointer) int { - structp := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(structp) { - return 0 - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, _ := m.Marshal() - n0 := len(p.tagcode) - n1 := sizeRawBytes(data) - return n0 + n1 - } - - n0 := len(p.tagcode) - n1 := size_struct(p.sprop, structp) - n2 := sizeVarint(uint64(n1)) // size of encoded length - return n0 + n1 + n2 -} - -// Encode a group struct. -func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { - var state errorState - b := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(b) { - return ErrNil - } - - o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) - err := o.enc_struct(p.sprop, b) - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) - return state.err -} - -func size_struct_group(p *Properties, base structPointer) (n int) { - b := structPointer_GetStructPointer(base, p.field) - if structPointer_IsNil(b) { - return 0 - } - - n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) - n += size_struct(p.sprop, b) - n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) - return -} - -// Encode a slice of bools ([]bool). -func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return ErrNil - } - for _, x := range s { - o.buf = append(o.buf, p.tagcode...) - v := uint64(0) - if x { - v = 1 - } - p.valEnc(o, v) - } - return nil -} - -func size_slice_bool(p *Properties, base structPointer) int { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return 0 - } - return l * (len(p.tagcode) + 1) // each bool takes exactly one byte -} - -// Encode a slice of bools ([]bool) in packed format. -func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(l)) // each bool takes exactly one byte - for _, x := range s { - v := uint64(0) - if x { - v = 1 - } - p.valEnc(o, v) - } - return nil -} - -func size_slice_packed_bool(p *Properties, base structPointer) (n int) { - s := *structPointer_BoolSlice(base, p.field) - l := len(s) - if l == 0 { - return 0 - } - n += len(p.tagcode) - n += sizeVarint(uint64(l)) - n += l // each bool takes exactly one byte - return -} - -// Encode a slice of bytes ([]byte). -func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { - s := *structPointer_Bytes(base, p.field) - if s == nil { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(s) - return nil -} - -func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { - s := *structPointer_Bytes(base, p.field) - if len(s) == 0 { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(s) - return nil -} - -func size_slice_byte(p *Properties, base structPointer) (n int) { - s := *structPointer_Bytes(base, p.field) - if s == nil && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += sizeRawBytes(s) - return -} - -func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { - s := *structPointer_Bytes(base, p.field) - if len(s) == 0 && !p.oneof { - return 0 - } - n += len(p.tagcode) - n += sizeRawBytes(s) - return -} - -// Encode a slice of int32s ([]int32). -func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - p.valEnc(o, uint64(x)) - } - return nil -} - -func size_slice_int32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - for i := 0; i < l; i++ { - n += len(p.tagcode) - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - n += p.valSize(uint64(x)) - } - return -} - -// Encode a slice of int32s ([]int32) in packed format. -func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - // TODO: Reuse a Buffer. - buf := NewBuffer(nil) - for i := 0; i < l; i++ { - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - p.valEnc(buf, uint64(x)) - } - - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(len(buf.buf))) - o.buf = append(o.buf, buf.buf...) - return nil -} - -func size_slice_packed_int32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - var bufSize int - for i := 0; i < l; i++ { - x := int32(s.Index(i)) // permit sign extension to use full 64-bit range - bufSize += p.valSize(uint64(x)) - } - - n += len(p.tagcode) - n += sizeVarint(uint64(bufSize)) - n += bufSize - return -} - -// Encode a slice of uint32s ([]uint32). -// Exactly the same as int32, except for no sign extension. -func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - x := s.Index(i) - p.valEnc(o, uint64(x)) - } - return nil -} - -func size_slice_uint32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - for i := 0; i < l; i++ { - n += len(p.tagcode) - x := s.Index(i) - n += p.valSize(uint64(x)) - } - return -} - -// Encode a slice of uint32s ([]uint32) in packed format. -// Exactly the same as int32, except for no sign extension. -func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - // TODO: Reuse a Buffer. - buf := NewBuffer(nil) - for i := 0; i < l; i++ { - p.valEnc(buf, uint64(s.Index(i))) - } - - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(len(buf.buf))) - o.buf = append(o.buf, buf.buf...) - return nil -} - -func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { - s := structPointer_Word32Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - var bufSize int - for i := 0; i < l; i++ { - bufSize += p.valSize(uint64(s.Index(i))) - } - - n += len(p.tagcode) - n += sizeVarint(uint64(bufSize)) - n += bufSize - return -} - -// Encode a slice of int64s ([]int64). -func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, s.Index(i)) - } - return nil -} - -func size_slice_int64(p *Properties, base structPointer) (n int) { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - for i := 0; i < l; i++ { - n += len(p.tagcode) - n += p.valSize(s.Index(i)) - } - return -} - -// Encode a slice of int64s ([]int64) in packed format. -func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return ErrNil - } - // TODO: Reuse a Buffer. - buf := NewBuffer(nil) - for i := 0; i < l; i++ { - p.valEnc(buf, s.Index(i)) - } - - o.buf = append(o.buf, p.tagcode...) - o.EncodeVarint(uint64(len(buf.buf))) - o.buf = append(o.buf, buf.buf...) - return nil -} - -func size_slice_packed_int64(p *Properties, base structPointer) (n int) { - s := structPointer_Word64Slice(base, p.field) - l := s.Len() - if l == 0 { - return 0 - } - var bufSize int - for i := 0; i < l; i++ { - bufSize += p.valSize(s.Index(i)) - } - - n += len(p.tagcode) - n += sizeVarint(uint64(bufSize)) - n += bufSize - return -} - -// Encode a slice of slice of bytes ([][]byte). -func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { - ss := *structPointer_BytesSlice(base, p.field) - l := len(ss) - if l == 0 { - return ErrNil - } - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(ss[i]) - } - return nil -} - -func size_slice_slice_byte(p *Properties, base structPointer) (n int) { - ss := *structPointer_BytesSlice(base, p.field) - l := len(ss) - if l == 0 { - return 0 - } - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - n += sizeRawBytes(ss[i]) - } - return -} - -// Encode a slice of strings ([]string). -func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { - ss := *structPointer_StringSlice(base, p.field) - l := len(ss) - for i := 0; i < l; i++ { - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(ss[i]) - } - return nil -} - -func size_slice_string(p *Properties, base structPointer) (n int) { - ss := *structPointer_StringSlice(base, p.field) - l := len(ss) - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - n += sizeStringBytes(ss[i]) - } - return -} - -// Encode a slice of message structs ([]*struct). -func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { - var state errorState - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - - for i := 0; i < l; i++ { - structp := s.Index(i) - if structPointer_IsNil(structp) { - return errRepeatedHasNil - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, err := m.Marshal() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - continue - } - - o.buf = append(o.buf, p.tagcode...) - err := o.enc_len_struct(p.sprop, structp, &state) - if err != nil && !state.shouldContinue(err, nil) { - if err == ErrNil { - return errRepeatedHasNil - } - return err - } - } - return state.err -} - -func size_slice_struct_message(p *Properties, base structPointer) (n int) { - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - structp := s.Index(i) - if structPointer_IsNil(structp) { - return // return the size up to this point - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, _ := m.Marshal() - n += len(p.tagcode) - n += sizeRawBytes(data) - continue - } - - n0 := size_struct(p.sprop, structp) - n1 := sizeVarint(uint64(n0)) // size of encoded length - n += n0 + n1 - } - return -} - -// Encode a slice of group structs ([]*struct). -func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { - var state errorState - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - - for i := 0; i < l; i++ { - b := s.Index(i) - if structPointer_IsNil(b) { - return errRepeatedHasNil - } - - o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) - - err := o.enc_struct(p.sprop, b) - - if err != nil && !state.shouldContinue(err, nil) { - if err == ErrNil { - return errRepeatedHasNil - } - return err - } - - o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) - } - return state.err -} - -func size_slice_struct_group(p *Properties, base structPointer) (n int) { - s := structPointer_StructPointerSlice(base, p.field) - l := s.Len() - - n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) - n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) - for i := 0; i < l; i++ { - b := s.Index(i) - if structPointer_IsNil(b) { - return // return size up to this point - } - - n += size_struct(p.sprop, b) - } - return -} - -// Encode an extension map. -func (o *Buffer) enc_map(p *Properties, base structPointer) error { - v := *structPointer_ExtMap(base, p.field) - if err := encodeExtensionMap(v); err != nil { - return err - } - // Fast-path for common cases: zero or one extensions. - if len(v) <= 1 { - for _, e := range v { - o.buf = append(o.buf, e.enc...) - } - return nil - } - - // Sort keys to provide a deterministic encoding. - keys := make([]int, 0, len(v)) - for k := range v { - keys = append(keys, int(k)) - } - sort.Ints(keys) - - for _, k := range keys { - o.buf = append(o.buf, v[int32(k)].enc...) - } - return nil -} - -func size_map(p *Properties, base structPointer) int { - v := *structPointer_ExtMap(base, p.field) - return sizeExtensionMap(v) -} - -// Encode a map field. -func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { - var state errorState // XXX: or do we need to plumb this through? - - /* - A map defined as - map map_field = N; - is encoded in the same way as - message MapFieldEntry { - key_type key = 1; - value_type value = 2; - } - repeated MapFieldEntry map_field = N; - */ - - v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V - if v.Len() == 0 { - return nil - } - - keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) - - enc := func() error { - if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { - return err - } - if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil { - return err - } - return nil - } - - // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. - for _, key := range v.MapKeys() { - val := v.MapIndex(key) - - // The only illegal map entry values are nil message pointers. - if val.Kind() == reflect.Ptr && val.IsNil() { - return errors.New("proto: map has nil element") - } - - keycopy.Set(key) - valcopy.Set(val) - - o.buf = append(o.buf, p.tagcode...) - if err := o.enc_len_thing(enc, &state); err != nil { - return err - } - } - return nil -} - -func size_new_map(p *Properties, base structPointer) int { - v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V - - keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) - - n := 0 - for _, key := range v.MapKeys() { - val := v.MapIndex(key) - keycopy.Set(key) - valcopy.Set(val) - - // Tag codes for key and val are the responsibility of the sub-sizer. - keysize := p.mkeyprop.size(p.mkeyprop, keybase) - valsize := p.mvalprop.size(p.mvalprop, valbase) - entry := keysize + valsize - // Add on tag code and length of map entry itself. - n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry - } - return n -} - -// mapEncodeScratch returns a new reflect.Value matching the map's value type, -// and a structPointer suitable for passing to an encoder or sizer. -func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { - // Prepare addressable doubly-indirect placeholders for the key and value types. - // This is needed because the element-type encoders expect **T, but the map iteration produces T. - - keycopy = reflect.New(mapType.Key()).Elem() // addressable K - keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K - keyptr.Set(keycopy.Addr()) // - keybase = toStructPointer(keyptr.Addr()) // **K - - // Value types are more varied and require special handling. - switch mapType.Elem().Kind() { - case reflect.Slice: - // []byte - var dummy []byte - valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte - valbase = toStructPointer(valcopy.Addr()) - case reflect.Ptr: - // message; the generated field type is map[K]*Msg (so V is *Msg), - // so we only need one level of indirection. - valcopy = reflect.New(mapType.Elem()).Elem() // addressable V - valbase = toStructPointer(valcopy.Addr()) - default: - // everything else - valcopy = reflect.New(mapType.Elem()).Elem() // addressable V - valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V - valptr.Set(valcopy.Addr()) // - valbase = toStructPointer(valptr.Addr()) // **V - } - return -} - -// Encode a struct. -func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { - var state errorState - // Encode fields in tag order so that decoders may use optimizations - // that depend on the ordering. - // https://developers.google.com/protocol-buffers/docs/encoding#order - for _, i := range prop.order { - p := prop.Prop[i] - if p.enc != nil { - err := p.enc(o, p, base) - if err != nil { - if err == ErrNil { - if p.Required && state.err == nil { - state.err = &RequiredNotSetError{p.Name} - } - } else if err == errRepeatedHasNil { - // Give more context to nil values in repeated fields. - return errors.New("repeated field " + p.OrigName + " has nil element") - } else if !state.shouldContinue(err, p) { - return err - } - } - if len(o.buf) > maxMarshalSize { - return ErrTooLarge - } - } - } - - // Do oneof fields. - if prop.oneofMarshaler != nil { - m := structPointer_Interface(base, prop.stype).(Message) - if err := prop.oneofMarshaler(m, o); err == ErrNil { - return errOneofHasNil - } else if err != nil { - return err - } - } - - // Add unrecognized fields at the end. - if prop.unrecField.IsValid() { - v := *structPointer_Bytes(base, prop.unrecField) - if len(o.buf)+len(v) > maxMarshalSize { - return ErrTooLarge - } - if len(v) > 0 { - o.buf = append(o.buf, v...) - } - } - - return state.err -} - -func size_struct(prop *StructProperties, base structPointer) (n int) { - for _, i := range prop.order { - p := prop.Prop[i] - if p.size != nil { - n += p.size(p, base) - } - } - - // Add unrecognized fields at the end. - if prop.unrecField.IsValid() { - v := *structPointer_Bytes(base, prop.unrecField) - n += len(v) - } - - // Factor in any oneof fields. - if prop.oneofSizer != nil { - m := structPointer_Interface(base, prop.stype).(Message) - n += prop.oneofSizer(m) - } - - return -} - -var zeroes [20]byte // longer than any conceivable sizeVarint - -// Encode a struct, preceded by its encoded length (as a varint). -func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { - return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) -} - -// Encode something, preceded by its encoded length (as a varint). -func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { - iLen := len(o.buf) - o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length - iMsg := len(o.buf) - err := enc() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - lMsg := len(o.buf) - iMsg - lLen := sizeVarint(uint64(lMsg)) - switch x := lLen - (iMsg - iLen); { - case x > 0: // actual length is x bytes larger than the space we reserved - // Move msg x bytes right. - o.buf = append(o.buf, zeroes[:x]...) - copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) - case x < 0: // actual length is x bytes smaller than the space we reserved - // Move msg x bytes left. - copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) - o.buf = o.buf[:len(o.buf)+x] // x is negative - } - // Encode the length in the reserved space. - o.buf = o.buf[:iLen] - o.EncodeVarint(uint64(lMsg)) - o.buf = o.buf[:len(o.buf)+lMsg] - return state.err -} - -// errorState maintains the first error that occurs and updates that error -// with additional context. -type errorState struct { - err error -} - -// shouldContinue reports whether encoding should continue upon encountering the -// given error. If the error is RequiredNotSetError, shouldContinue returns true -// and, if this is the first appearance of that error, remembers it for future -// reporting. -// -// If prop is not nil, it may update any error with additional context about the -// field with the error. -func (s *errorState) shouldContinue(err error, prop *Properties) bool { - // Ignore unset required fields. - reqNotSet, ok := err.(*RequiredNotSetError) - if !ok { - return false - } - if s.err == nil { - if prop != nil { - err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} - } - s.err = err - } - return true -} diff --git a/vendor/github.com/gogo/protobuf/proto/encode_gogo.go b/vendor/github.com/gogo/protobuf/proto/encode_gogo.go index f77cfb1eea4..0f5fb173e9f 100644 --- a/vendor/github.com/gogo/protobuf/proto/encode_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/encode_gogo.go @@ -1,12 +1,7 @@ -// Extensions for Protocol Buffers to create more go like structures. +// Protocol Buffers for Go with Gadgets // -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto -// -// Go support for Protocol Buffers - Google's data interchange format -// -// Copyright 2010 The Go Authors. All rights reserved. -// http://github.com/golang/protobuf/ +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -18,9 +13,6 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -36,319 +28,6 @@ package proto -import ( - "reflect" -) - func NewRequiredNotSetError(field string) *RequiredNotSetError { return &RequiredNotSetError{field} } - -type Sizer interface { - Size() int -} - -func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error { - s := *structPointer_Bytes(base, p.field) - if s == nil { - return ErrNil - } - o.buf = append(o.buf, s...) - return nil -} - -func size_ext_slice_byte(p *Properties, base structPointer) (n int) { - s := *structPointer_Bytes(base, p.field) - if s == nil { - return 0 - } - n += len(s) - return -} - -// Encode a reference to bool pointer. -func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error { - v := *structPointer_BoolVal(base, p.field) - x := 0 - if v { - x = 1 - } - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_ref_bool(p *Properties, base structPointer) int { - return len(p.tagcode) + 1 // each bool takes exactly one byte -} - -// Encode a reference to int32 pointer. -func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error { - v := structPointer_Word32Val(base, p.field) - x := int32(word32Val_Get(v)) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_ref_int32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32Val(base, p.field) - x := int32(word32Val_Get(v)) - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error { - v := structPointer_Word32Val(base, p.field) - x := word32Val_Get(v) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, uint64(x)) - return nil -} - -func size_ref_uint32(p *Properties, base structPointer) (n int) { - v := structPointer_Word32Val(base, p.field) - x := word32Val_Get(v) - n += len(p.tagcode) - n += p.valSize(uint64(x)) - return -} - -// Encode a reference to an int64 pointer. -func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error { - v := structPointer_Word64Val(base, p.field) - x := word64Val_Get(v) - o.buf = append(o.buf, p.tagcode...) - p.valEnc(o, x) - return nil -} - -func size_ref_int64(p *Properties, base structPointer) (n int) { - v := structPointer_Word64Val(base, p.field) - x := word64Val_Get(v) - n += len(p.tagcode) - n += p.valSize(x) - return -} - -// Encode a reference to a string pointer. -func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error { - v := *structPointer_StringVal(base, p.field) - o.buf = append(o.buf, p.tagcode...) - o.EncodeStringBytes(v) - return nil -} - -func size_ref_string(p *Properties, base structPointer) (n int) { - v := *structPointer_StringVal(base, p.field) - n += len(p.tagcode) - n += sizeStringBytes(v) - return -} - -// Encode a reference to a message struct. -func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error { - var state errorState - structp := structPointer_GetRefStructPointer(base, p.field) - if structPointer_IsNil(structp) { - return ErrNil - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, err := m.Marshal() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - return nil - } - - o.buf = append(o.buf, p.tagcode...) - return o.enc_len_struct(p.sprop, structp, &state) -} - -//TODO this is only copied, please fix this -func size_ref_struct_message(p *Properties, base structPointer) int { - structp := structPointer_GetRefStructPointer(base, p.field) - if structPointer_IsNil(structp) { - return 0 - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, _ := m.Marshal() - n0 := len(p.tagcode) - n1 := sizeRawBytes(data) - return n0 + n1 - } - - n0 := len(p.tagcode) - n1 := size_struct(p.sprop, structp) - n2 := sizeVarint(uint64(n1)) // size of encoded length - return n0 + n1 + n2 -} - -// Encode a slice of references to message struct pointers ([]struct). -func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error { - var state errorState - ss := structPointer_GetStructPointer(base, p.field) - ss1 := structPointer_GetRefStructPointer(ss, field(0)) - size := p.stype.Size() - l := structPointer_Len(base, p.field) - for i := 0; i < l; i++ { - structp := structPointer_Add(ss1, field(uintptr(i)*size)) - if structPointer_IsNil(structp) { - return errRepeatedHasNil - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, err := m.Marshal() - if err != nil && !state.shouldContinue(err, nil) { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - continue - } - - o.buf = append(o.buf, p.tagcode...) - err := o.enc_len_struct(p.sprop, structp, &state) - if err != nil && !state.shouldContinue(err, nil) { - if err == ErrNil { - return errRepeatedHasNil - } - return err - } - - } - return state.err -} - -//TODO this is only copied, please fix this -func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) { - ss := structPointer_GetStructPointer(base, p.field) - ss1 := structPointer_GetRefStructPointer(ss, field(0)) - size := p.stype.Size() - l := structPointer_Len(base, p.field) - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - structp := structPointer_Add(ss1, field(uintptr(i)*size)) - if structPointer_IsNil(structp) { - return // return the size up to this point - } - - // Can the object marshal itself? - if p.isMarshaler { - m := structPointer_Interface(structp, p.stype).(Marshaler) - data, _ := m.Marshal() - n += len(p.tagcode) - n += sizeRawBytes(data) - continue - } - - n0 := size_struct(p.sprop, structp) - n1 := sizeVarint(uint64(n0)) // size of encoded length - n += n0 + n1 - } - return -} - -func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error { - i := structPointer_InterfaceRef(base, p.field, p.ctype) - if i == nil { - return ErrNil - } - custom := i.(Marshaler) - data, err := custom.Marshal() - if err != nil { - return err - } - if data == nil { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - return nil -} - -func size_custom_bytes(p *Properties, base structPointer) (n int) { - n += len(p.tagcode) - i := structPointer_InterfaceRef(base, p.field, p.ctype) - if i == nil { - return 0 - } - custom := i.(Marshaler) - data, _ := custom.Marshal() - n += sizeRawBytes(data) - return -} - -func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error { - custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler) - data, err := custom.Marshal() - if err != nil { - return err - } - if data == nil { - return ErrNil - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - return nil -} - -func size_custom_ref_bytes(p *Properties, base structPointer) (n int) { - n += len(p.tagcode) - i := structPointer_InterfaceAt(base, p.field, p.ctype) - if i == nil { - return 0 - } - custom := i.(Marshaler) - data, _ := custom.Marshal() - n += sizeRawBytes(data) - return -} - -func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error { - inter := structPointer_InterfaceRef(base, p.field, p.ctype) - if inter == nil { - return ErrNil - } - slice := reflect.ValueOf(inter) - l := slice.Len() - for i := 0; i < l; i++ { - v := slice.Index(i) - custom := v.Interface().(Marshaler) - data, err := custom.Marshal() - if err != nil { - return err - } - o.buf = append(o.buf, p.tagcode...) - o.EncodeRawBytes(data) - } - return nil -} - -func size_custom_slice_bytes(p *Properties, base structPointer) (n int) { - inter := structPointer_InterfaceRef(base, p.field, p.ctype) - if inter == nil { - return 0 - } - slice := reflect.ValueOf(inter) - l := slice.Len() - n += l * len(p.tagcode) - for i := 0; i < l; i++ { - v := slice.Index(i) - custom := v.Interface().(Marshaler) - data, _ := custom.Marshal() - n += sizeRawBytes(data) - } - return -} diff --git a/vendor/github.com/gogo/protobuf/proto/equal.go b/vendor/github.com/gogo/protobuf/proto/equal.go index a9b3591e1ed..d4db5a1c145 100644 --- a/vendor/github.com/gogo/protobuf/proto/equal.go +++ b/vendor/github.com/gogo/protobuf/proto/equal.go @@ -54,13 +54,17 @@ Equality is defined in this way: in a proto3 .proto file, fields are not "set"; specifically, zero length proto3 "bytes" fields are equal (nil == {}). - Two repeated fields are equal iff their lengths are the same, - and their corresponding elements are equal (a "bytes" field, - although represented by []byte, is not a repeated field) + and their corresponding elements are equal. Note a "bytes" field, + although represented by []byte, is not a repeated field and the + rule for the scalar fields described above applies. - Two unset fields are equal. - Two unknown field sets are equal if their current encoded state is equal. - Two extension sets are equal iff they have corresponding elements that are pairwise equal. + - Two map fields are equal iff their lengths are the same, + and they contain the same set of elements. Zero-length map + fields are equal. - Every other combination of things are not equal. The return value is undefined if a and b are not protocol buffers. @@ -105,15 +109,6 @@ func equalStruct(v1, v2 reflect.Value) bool { // set/unset mismatch return false } - b1, ok := f1.Interface().(raw) - if ok { - b2 := f2.Interface().(raw) - // RawMessage - if !bytes.Equal(b1.Bytes(), b2.Bytes()) { - return false - } - continue - } f1, f2 = f1.Elem(), f2.Elem() } if !equalAny(f1, f2, sprop.Prop[i]) { @@ -121,9 +116,16 @@ func equalStruct(v1, v2 reflect.Value) bool { } } + if em1 := v1.FieldByName("XXX_InternalExtensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_InternalExtensions") + if !equalExtensions(v1.Type(), em1.Interface().(XXX_InternalExtensions), em2.Interface().(XXX_InternalExtensions)) { + return false + } + } + if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { em2 := v2.FieldByName("XXX_extensions") - if !equalExtensions(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { + if !equalExtMap(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { return false } } @@ -135,11 +137,7 @@ func equalStruct(v1, v2 reflect.Value) bool { u1 := uf.Bytes() u2 := v2.FieldByName("XXX_unrecognized").Bytes() - if !bytes.Equal(u1, u2) { - return false - } - - return true + return bytes.Equal(u1, u2) } // v1 and v2 are known to have the same type. @@ -230,8 +228,14 @@ func equalAny(v1, v2 reflect.Value, prop *Properties) bool { } // base is the struct type that the extensions are based on. -// em1 and em2 are extension maps. -func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { +// x1 and x2 are InternalExtensions. +func equalExtensions(base reflect.Type, x1, x2 XXX_InternalExtensions) bool { + em1, _ := x1.extensionsRead() + em2, _ := x2.extensionsRead() + return equalExtMap(base, em1, em2) +} + +func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { if len(em1) != len(em2) { return false } @@ -244,6 +248,15 @@ func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { m1, m2 := e1.value, e2.value + if m1 == nil && m2 == nil { + // Both have only encoded form. + if bytes.Equal(e1.enc, e2.enc) { + continue + } + // The bytes are different, but the extensions might still be + // equal. We need to decode them to compare. + } + if m1 != nil && m2 != nil { // Both are unencoded. if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { @@ -259,8 +272,12 @@ func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { desc = m[extNum] } if desc == nil { + // If both have only encoded form and the bytes are the same, + // it is handled above. We get here when the bytes are different. + // We don't know how to decode it, so just compare them as byte + // slices. log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) - continue + return false } var err error if m1 == nil { diff --git a/vendor/github.com/gogo/protobuf/proto/extensions.go b/vendor/github.com/gogo/protobuf/proto/extensions.go index 798b8841f48..44ebd457cf6 100644 --- a/vendor/github.com/gogo/protobuf/proto/extensions.go +++ b/vendor/github.com/gogo/protobuf/proto/extensions.go @@ -38,6 +38,7 @@ package proto import ( "errors" "fmt" + "io" "reflect" "strconv" "sync" @@ -52,23 +53,113 @@ type ExtensionRange struct { Start, End int32 // both inclusive } -// extendableProto is an interface implemented by any protocol buffer that may be extended. +// extendableProto is an interface implemented by any protocol buffer generated by the current +// proto compiler that may be extended. type extendableProto interface { Message ExtensionRangeArray() []ExtensionRange + extensionsWrite() map[int32]Extension + extensionsRead() (map[int32]Extension, sync.Locker) } -type extensionsMap interface { - extendableProto +// extendableProtoV1 is an interface implemented by a protocol buffer generated by the previous +// version of the proto compiler that may be extended. +type extendableProtoV1 interface { + Message + ExtensionRangeArray() []ExtensionRange ExtensionMap() map[int32]Extension } -type extensionsBytes interface { - extendableProto - GetExtensions() *[]byte +// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto. +type extensionAdapter struct { + extendableProtoV1 +} + +func (e extensionAdapter) extensionsWrite() map[int32]Extension { + return e.ExtensionMap() +} + +func (e extensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) { + return e.ExtensionMap(), notLocker{} +} + +// notLocker is a sync.Locker whose Lock and Unlock methods are nops. +type notLocker struct{} + +func (n notLocker) Lock() {} +func (n notLocker) Unlock() {} + +// extendable returns the extendableProto interface for the given generated proto message. +// If the proto message has the old extension format, it returns a wrapper that implements +// the extendableProto interface. +func extendable(p interface{}) (extendableProto, error) { + switch p := p.(type) { + case extendableProto: + if isNilPtr(p) { + return nil, fmt.Errorf("proto: nil %T is not extendable", p) + } + return p, nil + case extendableProtoV1: + if isNilPtr(p) { + return nil, fmt.Errorf("proto: nil %T is not extendable", p) + } + return extensionAdapter{p}, nil + case extensionsBytes: + return slowExtensionAdapter{p}, nil + } + // Don't allocate a specific error containing %T: + // this is the hot path for Clone and MarshalText. + return nil, errNotExtendable } -var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() +var errNotExtendable = errors.New("proto: not an extendable proto.Message") + +func isNilPtr(x interface{}) bool { + v := reflect.ValueOf(x) + return v.Kind() == reflect.Ptr && v.IsNil() +} + +// XXX_InternalExtensions is an internal representation of proto extensions. +// +// Each generated message struct type embeds an anonymous XXX_InternalExtensions field, +// thus gaining the unexported 'extensions' method, which can be called only from the proto package. +// +// The methods of XXX_InternalExtensions are not concurrency safe in general, +// but calls to logically read-only methods such as has and get may be executed concurrently. +type XXX_InternalExtensions struct { + // The struct must be indirect so that if a user inadvertently copies a + // generated message and its embedded XXX_InternalExtensions, they + // avoid the mayhem of a copied mutex. + // + // The mutex serializes all logically read-only operations to p.extensionMap. + // It is up to the client to ensure that write operations to p.extensionMap are + // mutually exclusive with other accesses. + p *struct { + mu sync.Mutex + extensionMap map[int32]Extension + } +} + +// extensionsWrite returns the extension map, creating it on first use. +func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension { + if e.p == nil { + e.p = new(struct { + mu sync.Mutex + extensionMap map[int32]Extension + }) + e.p.extensionMap = make(map[int32]Extension) + } + return e.p.extensionMap +} + +// extensionsRead returns the extensions map for read-only use. It may be nil. +// The caller must hold the returned mutex's lock when accessing Elements within the map. +func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) { + if e.p == nil { + return nil, nil + } + return e.p.extensionMap, &e.p.mu +} // ExtensionDesc represents an extension specification. // Used in generated code from the protocol compiler. @@ -78,6 +169,7 @@ type ExtensionDesc struct { Field int32 // field number Name string // fully-qualified name of extension, for text formatting Tag string // protobuf tag style + Filename string // name of the file in which the extension is defined } func (ed *ExtensionDesc) repeated() bool { @@ -102,13 +194,18 @@ type Extension struct { // SetRawExtension is for testing only. func SetRawExtension(base Message, id int32, b []byte) { - if ebase, ok := base.(extensionsMap); ok { - ebase.ExtensionMap()[id] = Extension{enc: b} - } else if ebase, ok := base.(extensionsBytes); ok { + if ebase, ok := base.(extensionsBytes); ok { clearExtension(base, id) ext := ebase.GetExtensions() *ext = append(*ext, b...) + return } + epb, err := extendable(base) + if err != nil { + return + } + extmap := epb.extensionsWrite() + extmap[id] = Extension{enc: b} } // isExtensionField returns true iff the given field number is in an extension range. @@ -123,9 +220,16 @@ func isExtensionField(pb extendableProto, field int32) bool { // checkExtensionTypes checks that the given extension is valid for pb. func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { + var pbi interface{} = pb // Check the extended type. - if a, b := reflect.TypeOf(pb), reflect.TypeOf(extension.ExtendedType); a != b { - return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + if ea, ok := pbi.(extensionAdapter); ok { + pbi = ea.extendableProtoV1 + } + if ea, ok := pbi.(slowExtensionAdapter); ok { + pbi = ea.extensionsBytes + } + if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { + return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a) } // Check the range. if !isExtensionField(pb, extension.Field) { @@ -170,73 +274,9 @@ func extensionProperties(ed *ExtensionDesc) *Properties { return prop } -// encodeExtensionMap encodes any unmarshaled (unencoded) extensions in m. -func encodeExtensionMap(m map[int32]Extension) error { - for k, e := range m { - err := encodeExtension(&e) - if err != nil { - return err - } - m[k] = e - } - return nil -} - -func encodeExtension(e *Extension) error { - if e.value == nil || e.desc == nil { - // Extension is only in its encoded form. - return nil - } - // We don't skip extensions that have an encoded form set, - // because the extension value may have been mutated after - // the last time this function was called. - - et := reflect.TypeOf(e.desc.ExtensionType) - props := extensionProperties(e.desc) - - p := NewBuffer(nil) - // If e.value has type T, the encoder expects a *struct{ X T }. - // Pass a *T with a zero field and hope it all works out. - x := reflect.New(et) - x.Elem().Set(reflect.ValueOf(e.value)) - if err := props.enc(p, props, toStructPointer(x)); err != nil { - return err - } - e.enc = p.buf - return nil -} - -func sizeExtensionMap(m map[int32]Extension) (n int) { - for _, e := range m { - if e.value == nil || e.desc == nil { - // Extension is only in its encoded form. - n += len(e.enc) - continue - } - - // We don't skip extensions that have an encoded form set, - // because the extension value may have been mutated after - // the last time this function was called. - - et := reflect.TypeOf(e.desc.ExtensionType) - props := extensionProperties(e.desc) - - // If e.value has type T, the encoder expects a *struct{ X T }. - // Pass a *T with a zero field and hope it all works out. - x := reflect.New(et) - x.Elem().Set(reflect.ValueOf(e.value)) - n += props.size(props, toStructPointer(x)) - } - return -} - // HasExtension returns whether the given extension is present in pb. func HasExtension(pb Message, extension *ExtensionDesc) bool { - // TODO: Check types, field numbers, etc.? - if epb, doki := pb.(extensionsMap); doki { - _, ok := epb.ExtensionMap()[extension.Field] - return ok - } else if epb, doki := pb.(extensionsBytes); doki { + if epb, doki := pb.(extensionsBytes); doki { ext := epb.GetExtensions() buf := *ext o := 0 @@ -256,116 +296,121 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool { } return false } - return false + // TODO: Check types, field numbers, etc.? + epb, err := extendable(pb) + if err != nil { + return false + } + extmap, mu := epb.extensionsRead() + if extmap == nil { + return false + } + mu.Lock() + _, ok := extmap[extension.Field] + mu.Unlock() + return ok } -func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int { - ext := pb.GetExtensions() - for offset < len(*ext) { - tag, n1 := DecodeVarint((*ext)[offset:]) - fieldNum := int32(tag >> 3) - wireType := int(tag & 0x7) - n2, err := size((*ext)[offset+n1:], wireType) - if err != nil { - panic(err) - } - newOffset := offset + n1 + n2 - if fieldNum == theFieldNum { - *ext = append((*ext)[:offset], (*ext)[newOffset:]...) - return offset - } - offset = newOffset - } - return -1 +// ClearExtension removes the given extension from pb. +func ClearExtension(pb Message, extension *ExtensionDesc) { + clearExtension(pb, extension.Field) } func clearExtension(pb Message, fieldNum int32) { - if epb, doki := pb.(extensionsMap); doki { - delete(epb.ExtensionMap(), fieldNum) - } else if epb, doki := pb.(extensionsBytes); doki { + if epb, ok := pb.(extensionsBytes); ok { offset := 0 for offset != -1 { offset = deleteExtension(epb, fieldNum, offset) } + return + } + epb, err := extendable(pb) + if err != nil { + return } -} - -// ClearExtension removes the given extension from pb. -func ClearExtension(pb Message, extension *ExtensionDesc) { // TODO: Check types, field numbers, etc.? - clearExtension(pb, extension.Field) + extmap := epb.extensionsWrite() + delete(extmap, fieldNum) } -// GetExtension parses and returns the given extension of pb. -// If the extension is not present it returns ErrMissingExtension. +// GetExtension retrieves a proto2 extended field from pb. +// +// If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil), +// then GetExtension parses the encoded field and returns a Go value of the specified type. +// If the field is not present, then the default value is returned (if one is specified), +// otherwise ErrMissingExtension is reported. +// +// If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil), +// then GetExtension returns the raw encoded bytes of the field extension. func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { - epb, ok := pb.(extendableProto) - if !ok { - return nil, errors.New("proto: not an extendable proto") + if epb, doki := pb.(extensionsBytes); doki { + ext := epb.GetExtensions() + return decodeExtensionFromBytes(extension, *ext) } - if err := checkExtensionTypes(epb, extension); err != nil { + + epb, err := extendable(pb) + if err != nil { return nil, err } - if epb, doki := pb.(extensionsMap); doki { - emap := epb.ExtensionMap() - e, ok := emap[extension.Field] - if !ok { - // defaultExtensionValue returns the default value or - // ErrMissingExtension if there is no default. - return defaultExtensionValue(extension) - } - if e.value != nil { - // Already decoded. Check the descriptor, though. - if e.desc != extension { - // This shouldn't happen. If it does, it means that - // GetExtension was called twice with two different - // descriptors with the same field number. - return nil, errors.New("proto: descriptor conflict") - } - return e.value, nil + if extension.ExtendedType != nil { + // can only check type if this is a complete descriptor + if cerr := checkExtensionTypes(epb, extension); cerr != nil { + return nil, cerr } + } - v, err := decodeExtension(e.enc, extension) - if err != nil { - return nil, err - } + emap, mu := epb.extensionsRead() + if emap == nil { + return defaultExtensionValue(extension) + } + mu.Lock() + defer mu.Unlock() + e, ok := emap[extension.Field] + if !ok { + // defaultExtensionValue returns the default value or + // ErrMissingExtension if there is no default. + return defaultExtensionValue(extension) + } - // Remember the decoded version and drop the encoded version. - // That way it is safe to mutate what we return. - e.value = v - e.desc = extension - e.enc = nil - emap[extension.Field] = e - return e.value, nil - } else if epb, doki := pb.(extensionsBytes); doki { - ext := epb.GetExtensions() - o := 0 - for o < len(*ext) { - tag, n := DecodeVarint((*ext)[o:]) - fieldNum := int32(tag >> 3) - wireType := int(tag & 0x7) - l, err := size((*ext)[o+n:], wireType) - if err != nil { - return nil, err - } - if int32(fieldNum) == extension.Field { - v, err := decodeExtension((*ext)[o:o+n+l], extension) - if err != nil { - return nil, err - } - return v, nil - } - o += n + l + if e.value != nil { + // Already decoded. Check the descriptor, though. + if e.desc != extension { + // This shouldn't happen. If it does, it means that + // GetExtension was called twice with two different + // descriptors with the same field number. + return nil, errors.New("proto: descriptor conflict") } - return defaultExtensionValue(extension) + return e.value, nil } - return nil, errors.New("proto: not an extendable proto") + + if extension.ExtensionType == nil { + // incomplete descriptor + return e.enc, nil + } + + v, err := decodeExtension(e.enc, extension) + if err != nil { + return nil, err + } + + // Remember the decoded version and drop the encoded version. + // That way it is safe to mutate what we return. + e.value = v + e.desc = extension + e.enc = nil + emap[extension.Field] = e + return e.value, nil } // defaultExtensionValue returns the default value for extension. // If no default for an extension is defined ErrMissingExtension is returned. func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + if extension.ExtensionType == nil { + // incomplete descriptor, so no default + return nil, ErrMissingExtension + } + t := reflect.TypeOf(extension.ExtensionType) props := extensionProperties(extension) @@ -400,31 +445,28 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { // decodeExtension decodes an extension encoded in b. func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { - o := NewBuffer(b) - t := reflect.TypeOf(extension.ExtensionType) - - props := extensionProperties(extension) + unmarshal := typeUnmarshaler(t, extension.Tag) // t is a pointer to a struct, pointer to basic type or a slice. - // Allocate a "field" to store the pointer/slice itself; the - // pointer/slice will be stored here. We pass - // the address of this field to props.dec. - // This passes a zero field and a *t and lets props.dec - // interpret it as a *struct{ x t }. + // Allocate space to store the pointer/slice. value := reflect.New(t).Elem() + var err error for { - // Discard wire type and field number varint. It isn't needed. - if _, err := o.DecodeVarint(); err != nil { - return nil, err + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF } + b = b[n:] + wire := int(x) & 7 - if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + b, err = unmarshal(b, valToPointer(value.Addr()), wire) + if err != nil { return nil, err } - if o.index >= len(o.buf) { + if len(b) == 0 { break } } @@ -434,9 +476,9 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { // GetExtensions returns a slice of the extensions present in pb that are also listed in es. // The returned slice has the same length as es; missing extensions will appear as nil elements. func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { - epb, ok := pb.(extendableProto) - if !ok { - return nil, errors.New("proto: not an extendable proto") + epb, err := extendable(pb) + if err != nil { + return nil, err } extensions = make([]interface{}, len(es)) for i, e := range es { @@ -451,9 +493,53 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e return } +// ExtensionDescs returns a new slice containing pb's extension descriptors, in undefined order. +// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing +// just the Field field, which defines the extension's field number. +func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { + epb, err := extendable(pb) + if err != nil { + return nil, err + } + registeredExtensions := RegisteredExtensions(pb) + + emap, mu := epb.extensionsRead() + if emap == nil { + return nil, nil + } + mu.Lock() + defer mu.Unlock() + extensions := make([]*ExtensionDesc, 0, len(emap)) + for extid, e := range emap { + desc := e.desc + if desc == nil { + desc = registeredExtensions[extid] + if desc == nil { + desc = &ExtensionDesc{Field: extid} + } + } + + extensions = append(extensions, desc) + } + return extensions, nil +} + // SetExtension sets the specified extension of pb to the specified value. -func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { - if err := checkExtensionTypes(pb, extension); err != nil { +func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { + if epb, ok := pb.(extensionsBytes); ok { + newb, err := encodeExtension(extension, value) + if err != nil { + return err + } + bb := epb.GetExtensions() + *bb = append(*bb, newb...) + return nil + } + epb, err := extendable(pb) + if err != nil { + return err + } + if err := checkExtensionTypes(epb, extension); err != nil { return err } typ := reflect.TypeOf(extension.ExtensionType) @@ -468,40 +554,27 @@ func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{ if reflect.ValueOf(value).IsNil() { return fmt.Errorf("proto: SetExtension called with nil value of type %T", value) } - return setExtension(pb, extension, value) -} -func setExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { - if epb, doki := pb.(extensionsMap); doki { - epb.ExtensionMap()[extension.Field] = Extension{desc: extension, value: value} - } else if epb, doki := pb.(extensionsBytes); doki { - ClearExtension(pb, extension) - ext := epb.GetExtensions() - et := reflect.TypeOf(extension.ExtensionType) - props := extensionProperties(extension) - p := NewBuffer(nil) - x := reflect.New(et) - x.Elem().Set(reflect.ValueOf(value)) - if err := props.enc(p, props, toStructPointer(x)); err != nil { - return err - } - *ext = append(*ext, p.buf...) - } + extmap := epb.extensionsWrite() + extmap[extension.Field] = Extension{desc: extension, value: value} return nil } // ClearAllExtensions clears all extensions from pb. func ClearAllExtensions(pb Message) { - if epb, doki := pb.(extensionsMap); doki { - m := epb.ExtensionMap() - for k := range m { - delete(m, k) - } - } else if epb, doki := pb.(extensionsBytes); doki { + if epb, doki := pb.(extensionsBytes); doki { ext := epb.GetExtensions() *ext = []byte{} + return + } + epb, err := extendable(pb) + if err != nil { + return + } + m := epb.extensionsWrite() + for k := range m { + delete(m, k) } - return } // A global registry of extensions. diff --git a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go index 86b1fa2344f..53ebd8cca01 100644 --- a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go @@ -1,5 +1,7 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -30,12 +32,37 @@ import ( "bytes" "errors" "fmt" + "io" "reflect" "sort" "strings" + "sync" ) -func GetBoolExtension(pb extendableProto, extension *ExtensionDesc, ifnotset bool) bool { +type extensionsBytes interface { + Message + ExtensionRangeArray() []ExtensionRange + GetExtensions() *[]byte +} + +type slowExtensionAdapter struct { + extensionsBytes +} + +func (s slowExtensionAdapter) extensionsWrite() map[int32]Extension { + panic("Please report a bug to github.com/gogo/protobuf if you see this message: Writing extensions is not supported for extensions stored in a byte slice field.") +} + +func (s slowExtensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) { + b := s.GetExtensions() + m, err := BytesToExtensionsMap(*b) + if err != nil { + panic(err) + } + return m, notLocker{} +} + +func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool { if reflect.ValueOf(pb).IsNil() { return ifnotset } @@ -53,15 +80,28 @@ func GetBoolExtension(pb extendableProto, extension *ExtensionDesc, ifnotset boo } func (this *Extension) Equal(that *Extension) bool { + if err := this.Encode(); err != nil { + return false + } + if err := that.Encode(); err != nil { + return false + } return bytes.Equal(this.enc, that.enc) } func (this *Extension) Compare(that *Extension) int { + if err := this.Encode(); err != nil { + return 1 + } + if err := that.Encode(); err != nil { + return -1 + } return bytes.Compare(this.enc, that.enc) } -func SizeOfExtensionMap(m map[int32]Extension) (n int) { - return sizeExtensionMap(m) +func SizeOfInternalExtension(m extendableProto) (n int) { + info := getMarshalInfo(reflect.TypeOf(m)) + return info.sizeV1Extensions(m.extensionsWrite()) } type sortableMapElem struct { @@ -94,6 +134,10 @@ func (this sortableExtensions) String() string { return "map[" + strings.Join(ss, ",") + "]" } +func StringFromInternalExtension(m extendableProto) string { + return StringFromExtensionsMap(m.extensionsWrite()) +} + func StringFromExtensionsMap(m map[int32]Extension) string { return newSortableExtensionsFromMap(m).String() } @@ -106,29 +150,31 @@ func StringFromExtensionsBytes(ext []byte) string { return StringFromExtensionsMap(m) } +func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error) { + return EncodeExtensionMap(m.extensionsWrite(), data) +} + func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { - if err := encodeExtensionMap(m); err != nil { - return 0, err - } - keys := make([]int, 0, len(m)) - for k := range m { - keys = append(keys, int(k)) - } - sort.Ints(keys) - for _, k := range keys { - n += copy(data[n:], m[int32(k)].enc) + o := 0 + for _, e := range m { + if err := e.Encode(); err != nil { + return 0, err + } + n := copy(data[o:], e.enc) + if n != len(e.enc) { + return 0, io.ErrShortBuffer + } + o += n } - return n, nil + return o, nil } func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) { - if m[id].value == nil || m[id].desc == nil { - return m[id].enc, nil - } - if err := encodeExtensionMap(m); err != nil { + e := m[id] + if err := e.Encode(); err != nil { return nil, err } - return m[id].enc, nil + return e.enc, nil } func size(buf []byte, wire int) (int, error) { @@ -189,27 +235,77 @@ func NewExtension(e []byte) Extension { return ee } -func AppendExtension(e extendableProto, tag int32, buf []byte) { - if ee, eok := e.(extensionsMap); eok { - ext := ee.ExtensionMap()[int32(tag)] // may be missing - ext.enc = append(ext.enc, buf...) - ee.ExtensionMap()[int32(tag)] = ext - } else if ee, eok := e.(extensionsBytes); eok { +func AppendExtension(e Message, tag int32, buf []byte) { + if ee, eok := e.(extensionsBytes); eok { ext := ee.GetExtensions() *ext = append(*ext, buf...) + return + } + if ee, eok := e.(extendableProto); eok { + m := ee.extensionsWrite() + ext := m[int32(tag)] // may be missing + ext.enc = append(ext.enc, buf...) + m[int32(tag)] = ext } } -func (this Extension) GoString() string { +func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error) { + u := getMarshalInfo(reflect.TypeOf(extension.ExtendedType)) + ei := u.getExtElemInfo(extension) + v := value + p := toAddrPointer(&v, ei.isptr) + siz := ei.sizer(p, SizeVarint(ei.wiretag)) + buf := make([]byte, 0, siz) + return ei.marshaler(buf, p, ei.wiretag, false) +} + +func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (interface{}, error) { + o := 0 + for o < len(buf) { + tag, n := DecodeVarint((buf)[o:]) + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + if o+n > len(buf) { + return nil, fmt.Errorf("unable to decode extension") + } + l, err := size((buf)[o+n:], wireType) + if err != nil { + return nil, err + } + if int32(fieldNum) == extension.Field { + if o+n+l > len(buf) { + return nil, fmt.Errorf("unable to decode extension") + } + v, err := decodeExtension((buf)[o:o+n+l], extension) + if err != nil { + return nil, err + } + return v, nil + } + o += n + l + } + return defaultExtensionValue(extension) +} + +func (this *Extension) Encode() error { if this.enc == nil { - if err := encodeExtension(&this); err != nil { - panic(err) + var err error + this.enc, err = encodeExtension(this.desc, this.value) + if err != nil { + return err } } + return nil +} + +func (this Extension) GoString() string { + if err := this.Encode(); err != nil { + return fmt.Sprintf("error encoding extension: %v", err) + } return fmt.Sprintf("proto.NewExtension(%#v)", this.enc) } -func SetUnsafeExtension(pb extendableProto, fieldNum int32, value interface{}) error { +func SetUnsafeExtension(pb Message, fieldNum int32, value interface{}) error { typ := reflect.TypeOf(pb).Elem() ext, ok := extensionMaps[typ] if !ok { @@ -219,10 +315,10 @@ func SetUnsafeExtension(pb extendableProto, fieldNum int32, value interface{}) e if !ok { return errors.New("proto: bad extension number; not in declared ranges") } - return setExtension(pb, desc, value) + return SetExtension(pb, desc, value) } -func GetUnsafeExtension(pb extendableProto, fieldNum int32) (interface{}, error) { +func GetUnsafeExtension(pb Message, fieldNum int32) (interface{}, error) { typ := reflect.TypeOf(pb).Elem() ext, ok := extensionMaps[typ] if !ok { @@ -234,3 +330,39 @@ func GetUnsafeExtension(pb extendableProto, fieldNum int32) (interface{}, error) } return GetExtension(pb, desc) } + +func NewUnsafeXXX_InternalExtensions(m map[int32]Extension) XXX_InternalExtensions { + x := &XXX_InternalExtensions{ + p: new(struct { + mu sync.Mutex + extensionMap map[int32]Extension + }), + } + x.p.extensionMap = m + return *x +} + +func GetUnsafeExtensionsMap(extendable Message) map[int32]Extension { + pb := extendable.(extendableProto) + return pb.extensionsWrite() +} + +func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int { + ext := pb.GetExtensions() + for offset < len(*ext) { + tag, n1 := DecodeVarint((*ext)[offset:]) + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + n2, err := size((*ext)[offset+n1:], wireType) + if err != nil { + panic(err) + } + newOffset := offset + n1 + n2 + if fieldNum == theFieldNum { + *ext = append((*ext)[:offset], (*ext)[newOffset:]...) + return offset + } + offset = newOffset + } + return -1 +} diff --git a/vendor/github.com/gogo/protobuf/proto/lib.go b/vendor/github.com/gogo/protobuf/proto/lib.go index 2e35ae2d2ac..37d17813288 100644 --- a/vendor/github.com/gogo/protobuf/proto/lib.go +++ b/vendor/github.com/gogo/protobuf/proto/lib.go @@ -73,7 +73,6 @@ for a protocol buffer variable v: When the .proto file specifies `syntax="proto3"`, there are some differences: - Non-repeated fields of non-message type are values instead of pointers. - - Getters are only generated for message and oneof fields. - Enum types do not get an Enum method. The simplest way to describe this is to see an example. @@ -266,6 +265,7 @@ package proto import ( "encoding/json" + "errors" "fmt" "log" "reflect" @@ -274,6 +274,8 @@ import ( "sync" ) +var errInvalidUTF8 = errors.New("proto: invalid UTF-8 string") + // Message is implemented by generated protocol buffer messages. type Message interface { Reset() @@ -308,18 +310,9 @@ func GetStats() Stats { return stats } // temporary Buffer and are fine for most applications. type Buffer struct { buf []byte // encode/decode byte stream - index int // write point - - // pools of basic types to amortize allocation. - bools []bool - uint32s []uint32 - uint64s []uint64 - - // extra pools, only used with pointer_reflect.go - int32s []int32 - int64s []int64 - float32s []float32 - float64s []float64 + index int // read point + + deterministic bool } // NewBuffer allocates a new Buffer and initializes its internal data to @@ -344,6 +337,30 @@ func (p *Buffer) SetBuf(s []byte) { // Bytes returns the contents of the Buffer. func (p *Buffer) Bytes() []byte { return p.buf } +// SetDeterministic sets whether to use deterministic serialization. +// +// Deterministic serialization guarantees that for a given binary, equal +// messages will always be serialized to the same bytes. This implies: +// +// - Repeated serialization of a message will return the same bytes. +// - Different processes of the same binary (which may be executing on +// different machines) will serialize equal messages to the same bytes. +// +// Note that the deterministic serialization is NOT canonical across +// languages. It is not guaranteed to remain stable over time. It is unstable +// across different builds with schema changes due to unknown fields. +// Users who need canonical serialization (e.g., persistent storage in a +// canonical form, fingerprinting, etc.) should define their own +// canonicalization specification and implement their own serializer rather +// than relying on this API. +// +// If deterministic serialization is requested, map entries will be sorted +// by keys in lexographical order. This is an implementation detail and +// subject to change. +func (p *Buffer) SetDeterministic(deterministic bool) { + p.deterministic = deterministic +} + /* * Helper routines for simplifying the creation of optional fields of basic type. */ @@ -553,9 +570,11 @@ func SetDefaults(pb Message) { setDefaults(reflect.ValueOf(pb), true, false) } -// v is a pointer to a struct. +// v is a struct. func setDefaults(v reflect.Value, recur, zeros bool) { - v = v.Elem() + if v.Kind() == reflect.Ptr { + v = v.Elem() + } defaultMu.RLock() dm, ok := defaults[v.Type()] @@ -657,8 +676,11 @@ func setDefaults(v reflect.Value, recur, zeros bool) { for _, ni := range dm.nested { f := v.Field(ni) - // f is *T or []*T or map[T]*T + // f is *T or T or []*T or []T switch f.Kind() { + case reflect.Struct: + setDefaults(f, recur, zeros) + case reflect.Ptr: if f.IsNil() { continue @@ -668,7 +690,7 @@ func setDefaults(v reflect.Value, recur, zeros bool) { case reflect.Slice: for i := 0; i < f.Len(); i++ { e := f.Index(i) - if e.IsNil() { + if e.Kind() == reflect.Ptr && e.IsNil() { continue } setDefaults(e, recur, zeros) @@ -740,6 +762,9 @@ func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { var canHaveDefault bool switch ft.Kind() { + case reflect.Struct: + nestedMessage = true // non-nullable + case reflect.Ptr: if ft.Elem().Kind() == reflect.Struct { nestedMessage = true @@ -749,7 +774,7 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes case reflect.Slice: switch ft.Elem().Kind() { - case reflect.Ptr: + case reflect.Ptr, reflect.Struct: nestedMessage = true // repeated message case reflect.Uint8: canHaveDefault = true // bytes field @@ -832,22 +857,12 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes return sf, false, nil } +// mapKeys returns a sort.Interface to be used for sorting the map keys. // Map fields may have key types of non-float scalars, strings and enums. -// The easiest way to sort them in some deterministic order is to use fmt. -// If this turns out to be inefficient we can always consider other options, -// such as doing a Schwartzian transform. - func mapKeys(vs []reflect.Value) sort.Interface { - s := mapKeySorter{ - vs: vs, - // default Less function: textual comparison - less: func(a, b reflect.Value) bool { - return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) - }, - } + s := mapKeySorter{vs: vs} - // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; - // numeric keys are sorted numerically. + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps. if len(vs) == 0 { return s } @@ -856,6 +871,12 @@ func mapKeys(vs []reflect.Value) sort.Interface { s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } case reflect.Uint32, reflect.Uint64: s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + case reflect.Bool: + s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true + case reflect.String: + s.less = func(a, b reflect.Value) bool { return a.String() < b.String() } + default: + panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind())) } return s @@ -889,6 +910,20 @@ func isProto3Zero(v reflect.Value) bool { return false } +// ProtoPackageIsVersion2 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const GoGoProtoPackageIsVersion2 = true + // ProtoPackageIsVersion1 is referenced from generated protocol buffer files // to assert that that code is compatible with this version of the proto package. const GoGoProtoPackageIsVersion1 = true + +// InternalMessageInfo is a type used internally by generated .pb.go files. +// This type is not intended to be used by non-generated code. +// This type is not subject to any compatibility guarantee. +type InternalMessageInfo struct { + marshal *marshalInfo + unmarshal *unmarshalInfo + merge *mergeInfo + discard *discardInfo +} diff --git a/vendor/github.com/gogo/protobuf/proto/lib_gogo.go b/vendor/github.com/gogo/protobuf/proto/lib_gogo.go index a6c2c06b23d..b3aa39190a1 100644 --- a/vendor/github.com/gogo/protobuf/proto/lib_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/lib_gogo.go @@ -1,5 +1,7 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -31,6 +33,14 @@ import ( "strconv" ) +type Sizer interface { + Size() int +} + +type ProtoSizer interface { + ProtoSize() int +} + func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { s, ok := m[value] if !ok { diff --git a/vendor/github.com/gogo/protobuf/proto/message_set.go b/vendor/github.com/gogo/protobuf/proto/message_set.go index e25e01e6374..3b6ca41d5e5 100644 --- a/vendor/github.com/gogo/protobuf/proto/message_set.go +++ b/vendor/github.com/gogo/protobuf/proto/message_set.go @@ -42,6 +42,7 @@ import ( "fmt" "reflect" "sort" + "sync" ) // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. @@ -94,10 +95,7 @@ func (ms *messageSet) find(pb Message) *_MessageSet_Item { } func (ms *messageSet) Has(pb Message) bool { - if ms.find(pb) != nil { - return true - } - return false + return ms.find(pb) != nil } func (ms *messageSet) Unmarshal(pb Message) error { @@ -149,36 +147,54 @@ func skipVarint(buf []byte) []byte { // MarshalMessageSet encodes the extension map represented by m in the message set wire format. // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. -func MarshalMessageSet(m map[int32]Extension) ([]byte, error) { - if err := encodeExtensionMap(m); err != nil { - return nil, err - } +func MarshalMessageSet(exts interface{}) ([]byte, error) { + return marshalMessageSet(exts, false) +} - // Sort extension IDs to provide a deterministic encoding. - // See also enc_map in encode.go. - ids := make([]int, 0, len(m)) - for id := range m { - ids = append(ids, int(id)) - } - sort.Ints(ids) - - ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} - for _, id := range ids { - e := m[int32(id)] - // Remove the wire type and field number varint, as well as the length varint. - msg := skipVarint(skipVarint(e.enc)) - - ms.Item = append(ms.Item, &_MessageSet_Item{ - TypeId: Int32(int32(id)), - Message: msg, - }) +// marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal. +func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) { + switch exts := exts.(type) { + case *XXX_InternalExtensions: + var u marshalInfo + siz := u.sizeMessageSet(exts) + b := make([]byte, 0, siz) + return u.appendMessageSet(b, exts, deterministic) + + case map[int32]Extension: + // This is an old-style extension map. + // Wrap it in a new-style XXX_InternalExtensions. + ie := XXX_InternalExtensions{ + p: &struct { + mu sync.Mutex + extensionMap map[int32]Extension + }{ + extensionMap: exts, + }, + } + + var u marshalInfo + siz := u.sizeMessageSet(&ie) + b := make([]byte, 0, siz) + return u.appendMessageSet(b, &ie, deterministic) + + default: + return nil, errors.New("proto: not an extension map") } - return Marshal(ms) } // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. -// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. -func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { +// It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSet(buf []byte, exts interface{}) error { + var m map[int32]Extension + switch exts := exts.(type) { + case *XXX_InternalExtensions: + m = exts.extensionsWrite() + case map[int32]Extension: + m = exts + default: + return errors.New("proto: not an extension map") + } + ms := new(messageSet) if err := Unmarshal(buf, ms); err != nil { return err @@ -209,7 +225,24 @@ func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { // MarshalMessageSetJSON encodes the extension map represented by m in JSON format. // It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. -func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { +func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { + var m map[int32]Extension + switch exts := exts.(type) { + case *XXX_InternalExtensions: + var mu sync.Locker + m, mu = exts.extensionsRead() + if m != nil { + // Keep the extensions map locked until we're done marshaling to prevent + // races between marshaling and unmarshaling the lazily-{en,de}coded + // values. + mu.Lock() + defer mu.Unlock() + } + case map[int32]Extension: + m = exts + default: + return nil, errors.New("proto: not an extension map") + } var b bytes.Buffer b.WriteByte('{') @@ -222,15 +255,16 @@ func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { for i, id := range ids { ext := m[id] - if i > 0 { - b.WriteByte(',') - } - msd, ok := messageSetMap[id] if !ok { // Unknown type; we can't render it, so skip it. continue } + + if i > 0 && b.Len() > 1 { + b.WriteByte(',') + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) x := ext.value @@ -252,7 +286,7 @@ func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { // UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. // It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. -func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error { +func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { // Common-case fast path. if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { return nil diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go index 989914177d0..b6cad90834b 100644 --- a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build appengine js +// +build purego appengine js // This file contains an implementation of proto field accesses using package reflect. // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can @@ -38,32 +38,13 @@ package proto import ( - "math" "reflect" + "sync" ) -// A structPointer is a pointer to a struct. -type structPointer struct { - v reflect.Value -} - -// toStructPointer returns a structPointer equivalent to the given reflect value. -// The reflect value must itself be a pointer to a struct. -func toStructPointer(v reflect.Value) structPointer { - return structPointer{v} -} - -// IsNil reports whether p is nil. -func structPointer_IsNil(p structPointer) bool { - return p.v.IsNil() -} +const unsafeAllowed = false -// Interface returns the struct pointer as an interface value. -func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { - return p.v.Interface() -} - -// A field identifies a field in a struct, accessible from a structPointer. +// A field identifies a field in a struct, accessible from a pointer. // In this implementation, a field is identified by the sequence of field indices // passed to reflect's FieldByIndex. type field []int @@ -76,404 +57,301 @@ func toField(f *reflect.StructField) field { // invalidField is an invalid field identifier. var invalidField = field(nil) +// zeroField is a noop when calling pointer.offset. +var zeroField = field([]int{}) + // IsValid reports whether the field identifier is valid. func (f field) IsValid() bool { return f != nil } -// field returns the given field in the struct as a reflect value. -func structPointer_field(p structPointer, f field) reflect.Value { - // Special case: an extension map entry with a value of type T - // passes a *T to the struct-handling code with a zero field, - // expecting that it will be treated as equivalent to *struct{ X T }, - // which has the same memory layout. We have to handle that case - // specially, because reflect will panic if we call FieldByIndex on a - // non-struct. - if f == nil { - return p.v.Elem() - } - - return p.v.Elem().FieldByIndex(f) +// The pointer type is for the table-driven decoder. +// The implementation here uses a reflect.Value of pointer type to +// create a generic pointer. In pointer_unsafe.go we use unsafe +// instead of reflect to implement the same (but faster) interface. +type pointer struct { + v reflect.Value } -// ifield returns the given field in the struct as an interface value. -func structPointer_ifield(p structPointer, f field) interface{} { - return structPointer_field(p, f).Addr().Interface() +// toPointer converts an interface of pointer type to a pointer +// that points to the same target. +func toPointer(i *Message) pointer { + return pointer{v: reflect.ValueOf(*i)} } -// Bytes returns the address of a []byte field in the struct. -func structPointer_Bytes(p structPointer, f field) *[]byte { - return structPointer_ifield(p, f).(*[]byte) +// toAddrPointer converts an interface to a pointer that points to +// the interface data. +func toAddrPointer(i *interface{}, isptr bool) pointer { + v := reflect.ValueOf(*i) + u := reflect.New(v.Type()) + u.Elem().Set(v) + return pointer{v: u} } -// BytesSlice returns the address of a [][]byte field in the struct. -func structPointer_BytesSlice(p structPointer, f field) *[][]byte { - return structPointer_ifield(p, f).(*[][]byte) +// valToPointer converts v to a pointer. v must be of pointer type. +func valToPointer(v reflect.Value) pointer { + return pointer{v: v} } -// Bool returns the address of a *bool field in the struct. -func structPointer_Bool(p structPointer, f field) **bool { - return structPointer_ifield(p, f).(**bool) +// offset converts from a pointer to a structure to a pointer to +// one of its fields. +func (p pointer) offset(f field) pointer { + return pointer{v: p.v.Elem().FieldByIndex(f).Addr()} } -// BoolVal returns the address of a bool field in the struct. -func structPointer_BoolVal(p structPointer, f field) *bool { - return structPointer_ifield(p, f).(*bool) +func (p pointer) isNil() bool { + return p.v.IsNil() } -// BoolSlice returns the address of a []bool field in the struct. -func structPointer_BoolSlice(p structPointer, f field) *[]bool { - return structPointer_ifield(p, f).(*[]bool) +// grow updates the slice s in place to make it one element longer. +// s must be addressable. +// Returns the (addressable) new element. +func grow(s reflect.Value) reflect.Value { + n, m := s.Len(), s.Cap() + if n < m { + s.SetLen(n + 1) + } else { + s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem()))) + } + return s.Index(n) } -// String returns the address of a *string field in the struct. -func structPointer_String(p structPointer, f field) **string { - return structPointer_ifield(p, f).(**string) +func (p pointer) toInt64() *int64 { + return p.v.Interface().(*int64) } - -// StringVal returns the address of a string field in the struct. -func structPointer_StringVal(p structPointer, f field) *string { - return structPointer_ifield(p, f).(*string) +func (p pointer) toInt64Ptr() **int64 { + return p.v.Interface().(**int64) } - -// StringSlice returns the address of a []string field in the struct. -func structPointer_StringSlice(p structPointer, f field) *[]string { - return structPointer_ifield(p, f).(*[]string) +func (p pointer) toInt64Slice() *[]int64 { + return p.v.Interface().(*[]int64) } -// ExtMap returns the address of an extension map field in the struct. -func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { - return structPointer_ifield(p, f).(*map[int32]Extension) -} +var int32ptr = reflect.TypeOf((*int32)(nil)) -// NewAt returns the reflect.Value for a pointer to a field in the struct. -func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { - return structPointer_field(p, f).Addr() +func (p pointer) toInt32() *int32 { + return p.v.Convert(int32ptr).Interface().(*int32) } -// SetStructPointer writes a *struct field in the struct. -func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { - structPointer_field(p, f).Set(q.v) +// The toInt32Ptr/Slice methods don't work because of enums. +// Instead, we must use set/get methods for the int32ptr/slice case. +/* + func (p pointer) toInt32Ptr() **int32 { + return p.v.Interface().(**int32) } - -// GetStructPointer reads a *struct field in the struct. -func structPointer_GetStructPointer(p structPointer, f field) structPointer { - return structPointer{structPointer_field(p, f)} + func (p pointer) toInt32Slice() *[]int32 { + return p.v.Interface().(*[]int32) } - -// StructPointerSlice the address of a []*struct field in the struct. -func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { - return structPointerSlice{structPointer_field(p, f)} +*/ +func (p pointer) getInt32Ptr() *int32 { + if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { + // raw int32 type + return p.v.Elem().Interface().(*int32) + } + // an enum + return p.v.Elem().Convert(int32PtrType).Interface().(*int32) +} +func (p pointer) setInt32Ptr(v int32) { + // Allocate value in a *int32. Possibly convert that to a *enum. + // Then assign it to a **int32 or **enum. + // Note: we can convert *int32 to *enum, but we can't convert + // **int32 to **enum! + p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem())) +} + +// getInt32Slice copies []int32 from p as a new slice. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) getInt32Slice() []int32 { + if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { + // raw int32 type + return p.v.Elem().Interface().([]int32) + } + // an enum + // Allocate a []int32, then assign []enum's values into it. + // Note: we can't convert []enum to []int32. + slice := p.v.Elem() + s := make([]int32, slice.Len()) + for i := 0; i < slice.Len(); i++ { + s[i] = int32(slice.Index(i).Int()) + } + return s } -// A structPointerSlice represents the address of a slice of pointers to structs -// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. -type structPointerSlice struct { - v reflect.Value +// setInt32Slice copies []int32 into p as a new slice. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) setInt32Slice(v []int32) { + if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { + // raw int32 type + p.v.Elem().Set(reflect.ValueOf(v)) + return + } + // an enum + // Allocate a []enum, then assign []int32's values into it. + // Note: we can't convert []enum to []int32. + slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v)) + for i, x := range v { + slice.Index(i).SetInt(int64(x)) + } + p.v.Elem().Set(slice) } - -func (p structPointerSlice) Len() int { return p.v.Len() } -func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } -func (p structPointerSlice) Append(q structPointer) { - p.v.Set(reflect.Append(p.v, q.v)) +func (p pointer) appendInt32Slice(v int32) { + grow(p.v.Elem()).SetInt(int64(v)) } -var ( - int32Type = reflect.TypeOf(int32(0)) - uint32Type = reflect.TypeOf(uint32(0)) - float32Type = reflect.TypeOf(float32(0)) - int64Type = reflect.TypeOf(int64(0)) - uint64Type = reflect.TypeOf(uint64(0)) - float64Type = reflect.TypeOf(float64(0)) -) - -// A word32 represents a field of type *int32, *uint32, *float32, or *enum. -// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. -type word32 struct { - v reflect.Value +func (p pointer) toUint64() *uint64 { + return p.v.Interface().(*uint64) } - -// IsNil reports whether p is nil. -func word32_IsNil(p word32) bool { - return p.v.IsNil() +func (p pointer) toUint64Ptr() **uint64 { + return p.v.Interface().(**uint64) } - -// Set sets p to point at a newly allocated word with bits set to x. -func word32_Set(p word32, o *Buffer, x uint32) { - t := p.v.Type().Elem() - switch t { - case int32Type: - if len(o.int32s) == 0 { - o.int32s = make([]int32, uint32PoolSize) - } - o.int32s[0] = int32(x) - p.v.Set(reflect.ValueOf(&o.int32s[0])) - o.int32s = o.int32s[1:] - return - case uint32Type: - if len(o.uint32s) == 0 { - o.uint32s = make([]uint32, uint32PoolSize) - } - o.uint32s[0] = x - p.v.Set(reflect.ValueOf(&o.uint32s[0])) - o.uint32s = o.uint32s[1:] - return - case float32Type: - if len(o.float32s) == 0 { - o.float32s = make([]float32, uint32PoolSize) - } - o.float32s[0] = math.Float32frombits(x) - p.v.Set(reflect.ValueOf(&o.float32s[0])) - o.float32s = o.float32s[1:] - return - } - - // must be enum - p.v.Set(reflect.New(t)) - p.v.Elem().SetInt(int64(int32(x))) +func (p pointer) toUint64Slice() *[]uint64 { + return p.v.Interface().(*[]uint64) } - -// Get gets the bits pointed at by p, as a uint32. -func word32_Get(p word32) uint32 { - elem := p.v.Elem() - switch elem.Kind() { - case reflect.Int32: - return uint32(elem.Int()) - case reflect.Uint32: - return uint32(elem.Uint()) - case reflect.Float32: - return math.Float32bits(float32(elem.Float())) - } - panic("unreachable") +func (p pointer) toUint32() *uint32 { + return p.v.Interface().(*uint32) } - -// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. -func structPointer_Word32(p structPointer, f field) word32 { - return word32{structPointer_field(p, f)} +func (p pointer) toUint32Ptr() **uint32 { + return p.v.Interface().(**uint32) } - -// A word32Val represents a field of type int32, uint32, float32, or enum. -// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. -type word32Val struct { - v reflect.Value +func (p pointer) toUint32Slice() *[]uint32 { + return p.v.Interface().(*[]uint32) } - -// Set sets *p to x. -func word32Val_Set(p word32Val, x uint32) { - switch p.v.Type() { - case int32Type: - p.v.SetInt(int64(x)) - return - case uint32Type: - p.v.SetUint(uint64(x)) - return - case float32Type: - p.v.SetFloat(float64(math.Float32frombits(x))) - return - } - - // must be enum - p.v.SetInt(int64(int32(x))) +func (p pointer) toBool() *bool { + return p.v.Interface().(*bool) } - -// Get gets the bits pointed at by p, as a uint32. -func word32Val_Get(p word32Val) uint32 { - elem := p.v - switch elem.Kind() { - case reflect.Int32: - return uint32(elem.Int()) - case reflect.Uint32: - return uint32(elem.Uint()) - case reflect.Float32: - return math.Float32bits(float32(elem.Float())) - } - panic("unreachable") +func (p pointer) toBoolPtr() **bool { + return p.v.Interface().(**bool) } - -// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. -func structPointer_Word32Val(p structPointer, f field) word32Val { - return word32Val{structPointer_field(p, f)} +func (p pointer) toBoolSlice() *[]bool { + return p.v.Interface().(*[]bool) } - -// A word32Slice is a slice of 32-bit values. -// That is, v.Type() is []int32, []uint32, []float32, or []enum. -type word32Slice struct { - v reflect.Value +func (p pointer) toFloat64() *float64 { + return p.v.Interface().(*float64) } - -func (p word32Slice) Append(x uint32) { - n, m := p.v.Len(), p.v.Cap() - if n < m { - p.v.SetLen(n + 1) - } else { - t := p.v.Type().Elem() - p.v.Set(reflect.Append(p.v, reflect.Zero(t))) - } - elem := p.v.Index(n) - switch elem.Kind() { - case reflect.Int32: - elem.SetInt(int64(int32(x))) - case reflect.Uint32: - elem.SetUint(uint64(x)) - case reflect.Float32: - elem.SetFloat(float64(math.Float32frombits(x))) - } +func (p pointer) toFloat64Ptr() **float64 { + return p.v.Interface().(**float64) } - -func (p word32Slice) Len() int { - return p.v.Len() +func (p pointer) toFloat64Slice() *[]float64 { + return p.v.Interface().(*[]float64) } - -func (p word32Slice) Index(i int) uint32 { - elem := p.v.Index(i) - switch elem.Kind() { - case reflect.Int32: - return uint32(elem.Int()) - case reflect.Uint32: - return uint32(elem.Uint()) - case reflect.Float32: - return math.Float32bits(float32(elem.Float())) - } - panic("unreachable") +func (p pointer) toFloat32() *float32 { + return p.v.Interface().(*float32) } - -// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. -func structPointer_Word32Slice(p structPointer, f field) word32Slice { - return word32Slice{structPointer_field(p, f)} +func (p pointer) toFloat32Ptr() **float32 { + return p.v.Interface().(**float32) } - -// word64 is like word32 but for 64-bit values. -type word64 struct { - v reflect.Value +func (p pointer) toFloat32Slice() *[]float32 { + return p.v.Interface().(*[]float32) } - -func word64_Set(p word64, o *Buffer, x uint64) { - t := p.v.Type().Elem() - switch t { - case int64Type: - if len(o.int64s) == 0 { - o.int64s = make([]int64, uint64PoolSize) - } - o.int64s[0] = int64(x) - p.v.Set(reflect.ValueOf(&o.int64s[0])) - o.int64s = o.int64s[1:] - return - case uint64Type: - if len(o.uint64s) == 0 { - o.uint64s = make([]uint64, uint64PoolSize) - } - o.uint64s[0] = x - p.v.Set(reflect.ValueOf(&o.uint64s[0])) - o.uint64s = o.uint64s[1:] - return - case float64Type: - if len(o.float64s) == 0 { - o.float64s = make([]float64, uint64PoolSize) - } - o.float64s[0] = math.Float64frombits(x) - p.v.Set(reflect.ValueOf(&o.float64s[0])) - o.float64s = o.float64s[1:] - return - } - panic("unreachable") +func (p pointer) toString() *string { + return p.v.Interface().(*string) } - -func word64_IsNil(p word64) bool { - return p.v.IsNil() +func (p pointer) toStringPtr() **string { + return p.v.Interface().(**string) } - -func word64_Get(p word64) uint64 { - elem := p.v.Elem() - switch elem.Kind() { - case reflect.Int64: - return uint64(elem.Int()) - case reflect.Uint64: - return elem.Uint() - case reflect.Float64: - return math.Float64bits(elem.Float()) - } - panic("unreachable") +func (p pointer) toStringSlice() *[]string { + return p.v.Interface().(*[]string) } - -func structPointer_Word64(p structPointer, f field) word64 { - return word64{structPointer_field(p, f)} +func (p pointer) toBytes() *[]byte { + return p.v.Interface().(*[]byte) +} +func (p pointer) toBytesSlice() *[][]byte { + return p.v.Interface().(*[][]byte) +} +func (p pointer) toExtensions() *XXX_InternalExtensions { + return p.v.Interface().(*XXX_InternalExtensions) +} +func (p pointer) toOldExtensions() *map[int32]Extension { + return p.v.Interface().(*map[int32]Extension) +} +func (p pointer) getPointer() pointer { + return pointer{v: p.v.Elem()} +} +func (p pointer) setPointer(q pointer) { + p.v.Elem().Set(q.v) +} +func (p pointer) appendPointer(q pointer) { + grow(p.v.Elem()).Set(q.v) } -// word64Val is like word32Val but for 64-bit values. -type word64Val struct { - v reflect.Value +// getPointerSlice copies []*T from p as a new []pointer. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) getPointerSlice() []pointer { + if p.v.IsNil() { + return nil + } + n := p.v.Elem().Len() + s := make([]pointer, n) + for i := 0; i < n; i++ { + s[i] = pointer{v: p.v.Elem().Index(i)} + } + return s } -func word64Val_Set(p word64Val, o *Buffer, x uint64) { - switch p.v.Type() { - case int64Type: - p.v.SetInt(int64(x)) - return - case uint64Type: - p.v.SetUint(x) - return - case float64Type: - p.v.SetFloat(math.Float64frombits(x)) +// setPointerSlice copies []pointer into p as a new []*T. +// This behavior differs from the implementation in pointer_unsafe.go. +func (p pointer) setPointerSlice(v []pointer) { + if v == nil { + p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem()) return } - panic("unreachable") + s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v)) + for _, p := range v { + s = reflect.Append(s, p.v) + } + p.v.Elem().Set(s) } -func word64Val_Get(p word64Val) uint64 { - elem := p.v - switch elem.Kind() { - case reflect.Int64: - return uint64(elem.Int()) - case reflect.Uint64: - return elem.Uint() - case reflect.Float64: - return math.Float64bits(elem.Float()) +// getInterfacePointer returns a pointer that points to the +// interface data of the interface pointed by p. +func (p pointer) getInterfacePointer() pointer { + if p.v.Elem().IsNil() { + return pointer{v: p.v.Elem()} } - panic("unreachable") + return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct } -func structPointer_Word64Val(p structPointer, f field) word64Val { - return word64Val{structPointer_field(p, f)} +func (p pointer) asPointerTo(t reflect.Type) reflect.Value { + // TODO: check that p.v.Type().Elem() == t? + return p.v } -type word64Slice struct { - v reflect.Value +func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p } - -func (p word64Slice) Append(x uint64) { - n, m := p.v.Len(), p.v.Cap() - if n < m { - p.v.SetLen(n + 1) - } else { - t := p.v.Type().Elem() - p.v.Set(reflect.Append(p.v, reflect.Zero(t))) - } - elem := p.v.Index(n) - switch elem.Kind() { - case reflect.Int64: - elem.SetInt(int64(int64(x))) - case reflect.Uint64: - elem.SetUint(uint64(x)) - case reflect.Float64: - elem.SetFloat(float64(math.Float64frombits(x))) - } +func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v } - -func (p word64Slice) Len() int { - return p.v.Len() +func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p } - -func (p word64Slice) Index(i int) uint64 { - elem := p.v.Index(i) - switch elem.Kind() { - case reflect.Int64: - return uint64(elem.Int()) - case reflect.Uint64: - return uint64(elem.Uint()) - case reflect.Float64: - return math.Float64bits(float64(elem.Float())) - } - panic("unreachable") +func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v } - -func structPointer_Word64Slice(p structPointer, f field) word64Slice { - return word64Slice{structPointer_field(p, f)} +func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p +} +func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v } +func atomicLoadDiscardInfo(p **discardInfo) *discardInfo { + atomicLock.Lock() + defer atomicLock.Unlock() + return *p +} +func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) { + atomicLock.Lock() + defer atomicLock.Unlock() + *p = v +} + +var atomicLock sync.Mutex diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go b/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go new file mode 100644 index 00000000000..7ffd3c29d90 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go @@ -0,0 +1,59 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +build purego appengine js + +// This file contains an implementation of proto field accesses using package reflect. +// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can +// be used on App Engine. + +package proto + +import ( + "reflect" +) + +// TODO: untested, so probably incorrect. + +func (p pointer) getRef() pointer { + return pointer{v: p.v.Addr()} +} + +func (p pointer) appendRef(v pointer, typ reflect.Type) { + slice := p.getSlice(typ) + elem := v.asPointerTo(typ).Elem() + newSlice := reflect.Append(slice, elem) + slice.Set(newSlice) +} + +func (p pointer) getSlice(typ reflect.Type) reflect.Value { + sliceTyp := reflect.SliceOf(typ) + slice := p.asPointerTo(sliceTyp) + slice = slice.Elem() + return slice +} diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go index ceece772a2d..d55a335d945 100644 --- a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go @@ -29,7 +29,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build !appengine,!js +// +build !purego,!appengine,!js // This file contains the implementation of the proto field accesses using package unsafe. @@ -37,38 +37,13 @@ package proto import ( "reflect" + "sync/atomic" "unsafe" ) -// NOTE: These type_Foo functions would more idiomatically be methods, -// but Go does not allow methods on pointer types, and we must preserve -// some pointer type for the garbage collector. We use these -// funcs with clunky names as our poor approximation to methods. -// -// An alternative would be -// type structPointer struct { p unsafe.Pointer } -// but that does not registerize as well. - -// A structPointer is a pointer to a struct. -type structPointer unsafe.Pointer - -// toStructPointer returns a structPointer equivalent to the given reflect value. -func toStructPointer(v reflect.Value) structPointer { - return structPointer(unsafe.Pointer(v.Pointer())) -} - -// IsNil reports whether p is nil. -func structPointer_IsNil(p structPointer) bool { - return p == nil -} - -// Interface returns the struct pointer, assumed to have element type t, -// as an interface value. -func structPointer_Interface(p structPointer, t reflect.Type) interface{} { - return reflect.NewAt(t, unsafe.Pointer(p)).Interface() -} +const unsafeAllowed = true -// A field identifies a field in a struct, accessible from a structPointer. +// A field identifies a field in a struct, accessible from a pointer. // In this implementation, a field is identified by its byte offset from the start of the struct. type field uintptr @@ -80,187 +55,254 @@ func toField(f *reflect.StructField) field { // invalidField is an invalid field identifier. const invalidField = ^field(0) +// zeroField is a noop when calling pointer.offset. +const zeroField = field(0) + // IsValid reports whether the field identifier is valid. func (f field) IsValid() bool { - return f != ^field(0) + return f != invalidField } -// Bytes returns the address of a []byte field in the struct. -func structPointer_Bytes(p structPointer, f field) *[]byte { - return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// The pointer type below is for the new table-driven encoder/decoder. +// The implementation here uses unsafe.Pointer to create a generic pointer. +// In pointer_reflect.go we use reflect instead of unsafe to implement +// the same (but slower) interface. +type pointer struct { + p unsafe.Pointer } -// BytesSlice returns the address of a [][]byte field in the struct. -func structPointer_BytesSlice(p structPointer, f field) *[][]byte { - return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) -} +// size of pointer +var ptrSize = unsafe.Sizeof(uintptr(0)) -// Bool returns the address of a *bool field in the struct. -func structPointer_Bool(p structPointer, f field) **bool { - return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// toPointer converts an interface of pointer type to a pointer +// that points to the same target. +func toPointer(i *Message) pointer { + // Super-tricky - read pointer out of data word of interface value. + // Saves ~25ns over the equivalent: + // return valToPointer(reflect.ValueOf(*i)) + return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} } -// BoolVal returns the address of a bool field in the struct. -func structPointer_BoolVal(p structPointer, f field) *bool { - return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// toAddrPointer converts an interface to a pointer that points to +// the interface data. +func toAddrPointer(i *interface{}, isptr bool) pointer { + // Super-tricky - read or get the address of data word of interface value. + if isptr { + // The interface is of pointer type, thus it is a direct interface. + // The data word is the pointer data itself. We take its address. + return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} + } + // The interface is not of pointer type. The data word is the pointer + // to the data. + return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} } -// BoolSlice returns the address of a []bool field in the struct. -func structPointer_BoolSlice(p structPointer, f field) *[]bool { - return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// valToPointer converts v to a pointer. v must be of pointer type. +func valToPointer(v reflect.Value) pointer { + return pointer{p: unsafe.Pointer(v.Pointer())} } -// String returns the address of a *string field in the struct. -func structPointer_String(p structPointer, f field) **string { - return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// offset converts from a pointer to a structure to a pointer to +// one of its fields. +func (p pointer) offset(f field) pointer { + // For safety, we should panic if !f.IsValid, however calling panic causes + // this to no longer be inlineable, which is a serious performance cost. + /* + if !f.IsValid() { + panic("invalid field") + } + */ + return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))} } -// StringVal returns the address of a string field in the struct. -func structPointer_StringVal(p structPointer, f field) *string { - return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) isNil() bool { + return p.p == nil } -// StringSlice returns the address of a []string field in the struct. -func structPointer_StringSlice(p structPointer, f field) *[]string { - return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toInt64() *int64 { + return (*int64)(p.p) } - -// ExtMap returns the address of an extension map field in the struct. -func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { - return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toInt64Ptr() **int64 { + return (**int64)(p.p) } - -// NewAt returns the reflect.Value for a pointer to a field in the struct. -func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { - return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +func (p pointer) toInt64Slice() *[]int64 { + return (*[]int64)(p.p) } - -// SetStructPointer writes a *struct field in the struct. -func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { - *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +func (p pointer) toInt32() *int32 { + return (*int32)(p.p) } -// GetStructPointer reads a *struct field in the struct. -func structPointer_GetStructPointer(p structPointer, f field) structPointer { - return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +// See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist. +/* + func (p pointer) toInt32Ptr() **int32 { + return (**int32)(p.p) + } + func (p pointer) toInt32Slice() *[]int32 { + return (*[]int32)(p.p) + } +*/ +func (p pointer) getInt32Ptr() *int32 { + return *(**int32)(p.p) } - -// StructPointerSlice the address of a []*struct field in the struct. -func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { - return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) setInt32Ptr(v int32) { + *(**int32)(p.p) = &v } -// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). -type structPointerSlice []structPointer - -func (v *structPointerSlice) Len() int { return len(*v) } -func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } -func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } - -// A word32 is the address of a "pointer to 32-bit value" field. -type word32 **uint32 - -// IsNil reports whether *v is nil. -func word32_IsNil(p word32) bool { - return *p == nil +// getInt32Slice loads a []int32 from p. +// The value returned is aliased with the original slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) getInt32Slice() []int32 { + return *(*[]int32)(p.p) } -// Set sets *v to point at a newly allocated word set to x. -func word32_Set(p word32, o *Buffer, x uint32) { - if len(o.uint32s) == 0 { - o.uint32s = make([]uint32, uint32PoolSize) - } - o.uint32s[0] = x - *p = &o.uint32s[0] - o.uint32s = o.uint32s[1:] +// setInt32Slice stores a []int32 to p. +// The value set is aliased with the input slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) setInt32Slice(v []int32) { + *(*[]int32)(p.p) = v } -// Get gets the value pointed at by *v. -func word32_Get(p word32) uint32 { - return **p +// TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead? +func (p pointer) appendInt32Slice(v int32) { + s := (*[]int32)(p.p) + *s = append(*s, v) } -// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. -func structPointer_Word32(p structPointer, f field) word32 { - return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +func (p pointer) toUint64() *uint64 { + return (*uint64)(p.p) } - -// A word32Val is the address of a 32-bit value field. -type word32Val *uint32 - -// Set sets *p to x. -func word32Val_Set(p word32Val, x uint32) { - *p = x +func (p pointer) toUint64Ptr() **uint64 { + return (**uint64)(p.p) } - -// Get gets the value pointed at by p. -func word32Val_Get(p word32Val) uint32 { - return *p +func (p pointer) toUint64Slice() *[]uint64 { + return (*[]uint64)(p.p) } - -// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. -func structPointer_Word32Val(p structPointer, f field) word32Val { - return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +func (p pointer) toUint32() *uint32 { + return (*uint32)(p.p) } - -// A word32Slice is a slice of 32-bit values. -type word32Slice []uint32 - -func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } -func (v *word32Slice) Len() int { return len(*v) } -func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } - -// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. -func structPointer_Word32Slice(p structPointer, f field) *word32Slice { - return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) toUint32Ptr() **uint32 { + return (**uint32)(p.p) } - -// word64 is like word32 but for 64-bit values. -type word64 **uint64 - -func word64_Set(p word64, o *Buffer, x uint64) { - if len(o.uint64s) == 0 { - o.uint64s = make([]uint64, uint64PoolSize) - } - o.uint64s[0] = x - *p = &o.uint64s[0] - o.uint64s = o.uint64s[1:] +func (p pointer) toUint32Slice() *[]uint32 { + return (*[]uint32)(p.p) } - -func word64_IsNil(p word64) bool { - return *p == nil +func (p pointer) toBool() *bool { + return (*bool)(p.p) } - -func word64_Get(p word64) uint64 { - return **p +func (p pointer) toBoolPtr() **bool { + return (**bool)(p.p) +} +func (p pointer) toBoolSlice() *[]bool { + return (*[]bool)(p.p) +} +func (p pointer) toFloat64() *float64 { + return (*float64)(p.p) +} +func (p pointer) toFloat64Ptr() **float64 { + return (**float64)(p.p) +} +func (p pointer) toFloat64Slice() *[]float64 { + return (*[]float64)(p.p) +} +func (p pointer) toFloat32() *float32 { + return (*float32)(p.p) +} +func (p pointer) toFloat32Ptr() **float32 { + return (**float32)(p.p) +} +func (p pointer) toFloat32Slice() *[]float32 { + return (*[]float32)(p.p) +} +func (p pointer) toString() *string { + return (*string)(p.p) +} +func (p pointer) toStringPtr() **string { + return (**string)(p.p) +} +func (p pointer) toStringSlice() *[]string { + return (*[]string)(p.p) +} +func (p pointer) toBytes() *[]byte { + return (*[]byte)(p.p) +} +func (p pointer) toBytesSlice() *[][]byte { + return (*[][]byte)(p.p) +} +func (p pointer) toExtensions() *XXX_InternalExtensions { + return (*XXX_InternalExtensions)(p.p) +} +func (p pointer) toOldExtensions() *map[int32]Extension { + return (*map[int32]Extension)(p.p) } -func structPointer_Word64(p structPointer, f field) word64 { - return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +// getPointerSlice loads []*T from p as a []pointer. +// The value returned is aliased with the original slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) getPointerSlice() []pointer { + // Super-tricky - p should point to a []*T where T is a + // message type. We load it as []pointer. + return *(*[]pointer)(p.p) } -// word64Val is like word32Val but for 64-bit values. -type word64Val *uint64 +// setPointerSlice stores []pointer into p as a []*T. +// The value set is aliased with the input slice. +// This behavior differs from the implementation in pointer_reflect.go. +func (p pointer) setPointerSlice(v []pointer) { + // Super-tricky - p should point to a []*T where T is a + // message type. We store it as []pointer. + *(*[]pointer)(p.p) = v +} -func word64Val_Set(p word64Val, o *Buffer, x uint64) { - *p = x +// getPointer loads the pointer at p and returns it. +func (p pointer) getPointer() pointer { + return pointer{p: *(*unsafe.Pointer)(p.p)} } -func word64Val_Get(p word64Val) uint64 { - return *p +// setPointer stores the pointer q at p. +func (p pointer) setPointer(q pointer) { + *(*unsafe.Pointer)(p.p) = q.p } -func structPointer_Word64Val(p structPointer, f field) word64Val { - return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +// append q to the slice pointed to by p. +func (p pointer) appendPointer(q pointer) { + s := (*[]unsafe.Pointer)(p.p) + *s = append(*s, q.p) } -// word64Slice is like word32Slice but for 64-bit values. -type word64Slice []uint64 +// getInterfacePointer returns a pointer that points to the +// interface data of the interface pointed by p. +func (p pointer) getInterfacePointer() pointer { + // Super-tricky - read pointer out of data word of interface value. + return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]} +} -func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } -func (v *word64Slice) Len() int { return len(*v) } -func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } +// asPointerTo returns a reflect.Value that is a pointer to an +// object of type t stored at p. +func (p pointer) asPointerTo(t reflect.Type) reflect.Value { + return reflect.NewAt(t, p.p) +} -func structPointer_Word64Slice(p structPointer, f field) *word64Slice { - return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { + return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) +} +func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { + return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) +} +func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo { + return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) +} +func atomicLoadDiscardInfo(p **discardInfo) *discardInfo { + return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) +} +func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) { + atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) } diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go index 6bc85fa9873..aca8eed02a1 100644 --- a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go @@ -1,5 +1,7 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -24,7 +26,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +build !appengine +// +build !purego,!appengine,!js // This file contains the implementation of the proto field accesses using package unsafe. @@ -35,74 +37,20 @@ import ( "unsafe" ) -func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} { - point := unsafe.Pointer(uintptr(p) + uintptr(f)) - r := reflect.NewAt(t, point) - return r.Interface() -} - -func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} { - point := unsafe.Pointer(uintptr(p) + uintptr(f)) - r := reflect.NewAt(t, point) - if r.Elem().IsNil() { - return nil - } - return r.Elem().Interface() -} - -func copyUintPtr(oldptr, newptr uintptr, size int) { - oldbytes := make([]byte, 0) - oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes)) - oldslice.Data = oldptr - oldslice.Len = size - oldslice.Cap = size - newbytes := make([]byte, 0) - newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes)) - newslice.Data = newptr - newslice.Len = size - newslice.Cap = size - copy(newbytes, oldbytes) -} - -func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) { - copyUintPtr(uintptr(oldptr), uintptr(newptr), size) -} - -func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer { - size := typ.Elem().Size() - oldHeader := structPointer_GetSliceHeader(base, f) - newLen := oldHeader.Len + 1 - slice := reflect.MakeSlice(typ, newLen, newLen) - bas := toStructPointer(slice) - for i := 0; i < oldHeader.Len; i++ { - newElemptr := uintptr(bas) + uintptr(i)*size - oldElemptr := oldHeader.Data + uintptr(i)*size - copyUintPtr(oldElemptr, newElemptr, int(size)) - } - - oldHeader.Data = uintptr(bas) - oldHeader.Len = newLen - oldHeader.Cap = newLen - - return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size))) -} - -func structPointer_FieldPointer(p structPointer, f field) structPointer { - return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f))) -} - -func structPointer_GetRefStructPointer(p structPointer, f field) structPointer { - return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))) -} - -func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader { - return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f))) +func (p pointer) getRef() pointer { + return pointer{p: (unsafe.Pointer)(&p.p)} } -func structPointer_Add(p structPointer, size field) structPointer { - return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size))) +func (p pointer) appendRef(v pointer, typ reflect.Type) { + slice := p.getSlice(typ) + elem := v.asPointerTo(typ).Elem() + newSlice := reflect.Append(slice, elem) + slice.Set(newSlice) } -func structPointer_Len(p structPointer, f field) int { - return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f)))) +func (p pointer) getSlice(typ reflect.Type) reflect.Value { + sliceTyp := reflect.SliceOf(typ) + slice := p.asPointerTo(sliceTyp) + slice = slice.Elem() + return slice } diff --git a/vendor/github.com/gogo/protobuf/proto/properties.go b/vendor/github.com/gogo/protobuf/proto/properties.go index 5e372f2b223..7a5e28efe51 100644 --- a/vendor/github.com/gogo/protobuf/proto/properties.go +++ b/vendor/github.com/gogo/protobuf/proto/properties.go @@ -1,7 +1,7 @@ -// Extensions for Protocol Buffers to create more go like structures. +// Protocol Buffers for Go with Gadgets // -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Go support for Protocol Buffers - Google's data interchange format // @@ -63,42 +63,6 @@ const ( WireFixed32 = 5 ) -const startSize = 10 // initial slice/string sizes - -// Encoders are defined in encode.go -// An encoder outputs the full representation of a field, including its -// tag and encoder type. -type encoder func(p *Buffer, prop *Properties, base structPointer) error - -// A valueEncoder encodes a single integer in a particular encoding. -type valueEncoder func(o *Buffer, x uint64) error - -// Sizers are defined in encode.go -// A sizer returns the encoded size of a field, including its tag and encoder -// type. -type sizer func(prop *Properties, base structPointer) int - -// A valueSizer returns the encoded size of a single integer in a particular -// encoding. -type valueSizer func(x uint64) int - -// Decoders are defined in decode.go -// A decoder creates a value from its wire representation. -// Unrecognized subelements are saved in unrec. -type decoder func(p *Buffer, prop *Properties, base structPointer) error - -// A valueDecoder decodes a single integer in a particular encoding. -type valueDecoder func(o *Buffer) (x uint64, err error) - -// A oneofMarshaler does the marshaling for all oneof fields in a message. -type oneofMarshaler func(Message, *Buffer) error - -// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. -type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) - -// A oneofSizer does the sizing for all oneof fields in a message. -type oneofSizer func(Message) int - // tagMap is an optimization over map[int]int for typical protocol buffer // use-cases. Encoded protocol buffers are often in tag order with small tag // numbers. @@ -145,13 +109,6 @@ type StructProperties struct { decoderTags tagMap // map from proto tag to struct field number decoderOrigNames map[string]int // map from original name to struct field number order []int // list of struct field numbers in tag order - unrecField field // field id of the XXX_unrecognized []byte field - extendable bool // is this an extendable proto - - oneofMarshaler oneofMarshaler - oneofUnmarshaler oneofUnmarshaler - oneofSizer oneofSizer - stype reflect.Type // OneofTypes contains information about the oneof fields in this message. // It is keyed by the original name of a field. @@ -190,41 +147,26 @@ type Properties struct { proto3 bool // whether this is known to be a proto3 field; set for []byte only oneof bool // whether this is a oneof field - Default string // default value - HasDefault bool // whether an explicit default was provided - CustomType string - def_uint64 uint64 - - enc encoder - valEnc valueEncoder // set for bool and numeric types only - field field - tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) - tagbuf [8]byte - stype reflect.Type // set for struct types only - sstype reflect.Type // set for slices of structs types only - ctype reflect.Type // set for custom types only - sprop *StructProperties // set for struct types only - isMarshaler bool - isUnmarshaler bool + Default string // default value + HasDefault bool // whether an explicit default was provided + CustomType string + CastType string + StdTime bool + StdDuration bool + + stype reflect.Type // set for struct types only + ctype reflect.Type // set for custom types only + sprop *StructProperties // set for struct types only mtype reflect.Type // set for map types only mkeyprop *Properties // set for map types only mvalprop *Properties // set for map types only - - size sizer - valSize valueSizer // set for bool and numeric types only - - dec decoder - valDec valueDecoder // set for bool and numeric types only - - // If this is a packable field, this will be the decoder for the packed version of the field. - packedDec decoder } // String formats the properties in the protobuf struct field tag style. func (p *Properties) String() string { s := p.Wire - s = "," + s += "," s += strconv.Itoa(p.Tag) if p.Required { s += ",req" @@ -270,29 +212,14 @@ func (p *Properties) Parse(s string) { switch p.Wire { case "varint": p.WireType = WireVarint - p.valEnc = (*Buffer).EncodeVarint - p.valDec = (*Buffer).DecodeVarint - p.valSize = sizeVarint case "fixed32": p.WireType = WireFixed32 - p.valEnc = (*Buffer).EncodeFixed32 - p.valDec = (*Buffer).DecodeFixed32 - p.valSize = sizeFixed32 case "fixed64": p.WireType = WireFixed64 - p.valEnc = (*Buffer).EncodeFixed64 - p.valDec = (*Buffer).DecodeFixed64 - p.valSize = sizeFixed64 case "zigzag32": p.WireType = WireVarint - p.valEnc = (*Buffer).EncodeZigzag32 - p.valDec = (*Buffer).DecodeZigzag32 - p.valSize = sizeZigzag32 case "zigzag64": p.WireType = WireVarint - p.valEnc = (*Buffer).EncodeZigzag64 - p.valDec = (*Buffer).DecodeZigzag64 - p.valSize = sizeZigzag64 case "bytes", "group": p.WireType = WireBytes // no numeric converter for non-numeric types @@ -307,6 +234,7 @@ func (p *Properties) Parse(s string) { return } +outer: for i := 2; i < len(fields); i++ { f := fields[i] switch { @@ -334,295 +262,59 @@ func (p *Properties) Parse(s string) { if i+1 < len(fields) { // Commas aren't escaped, and def is always last. p.Default += "," + strings.Join(fields[i+1:], ",") - break + break outer } case strings.HasPrefix(f, "embedded="): p.OrigName = strings.Split(f, "=")[1] case strings.HasPrefix(f, "customtype="): p.CustomType = strings.Split(f, "=")[1] + case strings.HasPrefix(f, "casttype="): + p.CastType = strings.Split(f, "=")[1] + case f == "stdtime": + p.StdTime = true + case f == "stdduration": + p.StdDuration = true } } } -func logNoSliceEnc(t1, t2 reflect.Type) { - fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) -} - var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() -// Initialize the fields for encoding and decoding. -func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { - p.enc = nil - p.dec = nil - p.size = nil - if len(p.CustomType) > 0 { - p.setCustomEncAndDec(typ) +// setFieldProps initializes the field properties for submessages and maps. +func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { + isMap := typ.Kind() == reflect.Map + if len(p.CustomType) > 0 && !isMap { + p.ctype = typ + p.setTag(lockGetProp) + return + } + if p.StdTime && !isMap { + p.setTag(lockGetProp) + return + } + if p.StdDuration && !isMap { p.setTag(lockGetProp) return } switch t1 := typ; t1.Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) - - // proto3 scalar types - - case reflect.Bool: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_bool - p.dec = (*Buffer).dec_proto3_bool - p.size = size_proto3_bool - } else { - p.enc = (*Buffer).enc_ref_bool - p.dec = (*Buffer).dec_proto3_bool - p.size = size_ref_bool - } - case reflect.Int32: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_int32 - p.dec = (*Buffer).dec_proto3_int32 - p.size = size_proto3_int32 - } else { - p.enc = (*Buffer).enc_ref_int32 - p.dec = (*Buffer).dec_proto3_int32 - p.size = size_ref_int32 - } - case reflect.Uint32: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_uint32 - p.dec = (*Buffer).dec_proto3_int32 // can reuse - p.size = size_proto3_uint32 - } else { - p.enc = (*Buffer).enc_ref_uint32 - p.dec = (*Buffer).dec_proto3_int32 // can reuse - p.size = size_ref_uint32 - } - case reflect.Int64, reflect.Uint64: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_int64 - p.dec = (*Buffer).dec_proto3_int64 - p.size = size_proto3_int64 - } else { - p.enc = (*Buffer).enc_ref_int64 - p.dec = (*Buffer).dec_proto3_int64 - p.size = size_ref_int64 - } - case reflect.Float32: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits - p.dec = (*Buffer).dec_proto3_int32 - p.size = size_proto3_uint32 - } else { - p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits - p.dec = (*Buffer).dec_proto3_int32 - p.size = size_ref_uint32 - } - case reflect.Float64: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits - p.dec = (*Buffer).dec_proto3_int64 - p.size = size_proto3_int64 - } else { - p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits - p.dec = (*Buffer).dec_proto3_int64 - p.size = size_ref_int64 - } - case reflect.String: - if p.proto3 { - p.enc = (*Buffer).enc_proto3_string - p.dec = (*Buffer).dec_proto3_string - p.size = size_proto3_string - } else { - p.enc = (*Buffer).enc_ref_string - p.dec = (*Buffer).dec_proto3_string - p.size = size_ref_string - } case reflect.Struct: p.stype = typ - p.isMarshaler = isMarshaler(typ) - p.isUnmarshaler = isUnmarshaler(typ) - if p.Wire == "bytes" { - p.enc = (*Buffer).enc_ref_struct_message - p.dec = (*Buffer).dec_ref_struct_message - p.size = size_ref_struct_message - } else { - fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ) - } - case reflect.Ptr: - switch t2 := t1.Elem(); t2.Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) - break - case reflect.Bool: - p.enc = (*Buffer).enc_bool - p.dec = (*Buffer).dec_bool - p.size = size_bool - case reflect.Int32: - p.enc = (*Buffer).enc_int32 - p.dec = (*Buffer).dec_int32 - p.size = size_int32 - case reflect.Uint32: - p.enc = (*Buffer).enc_uint32 - p.dec = (*Buffer).dec_int32 // can reuse - p.size = size_uint32 - case reflect.Int64, reflect.Uint64: - p.enc = (*Buffer).enc_int64 - p.dec = (*Buffer).dec_int64 - p.size = size_int64 - case reflect.Float32: - p.enc = (*Buffer).enc_uint32 // can just treat them as bits - p.dec = (*Buffer).dec_int32 - p.size = size_uint32 - case reflect.Float64: - p.enc = (*Buffer).enc_int64 // can just treat them as bits - p.dec = (*Buffer).dec_int64 - p.size = size_int64 - case reflect.String: - p.enc = (*Buffer).enc_string - p.dec = (*Buffer).dec_string - p.size = size_string - case reflect.Struct: + if t1.Elem().Kind() == reflect.Struct { p.stype = t1.Elem() - p.isMarshaler = isMarshaler(t1) - p.isUnmarshaler = isUnmarshaler(t1) - if p.Wire == "bytes" { - p.enc = (*Buffer).enc_struct_message - p.dec = (*Buffer).dec_struct_message - p.size = size_struct_message - } else { - p.enc = (*Buffer).enc_struct_group - p.dec = (*Buffer).dec_struct_group - p.size = size_struct_group - } } - case reflect.Slice: switch t2 := t1.Elem(); t2.Kind() { - default: - logNoSliceEnc(t1, t2) - break - case reflect.Bool: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_bool - p.size = size_slice_packed_bool - } else { - p.enc = (*Buffer).enc_slice_bool - p.size = size_slice_bool - } - p.dec = (*Buffer).dec_slice_bool - p.packedDec = (*Buffer).dec_slice_packed_bool - case reflect.Int32: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_int32 - p.size = size_slice_packed_int32 - } else { - p.enc = (*Buffer).enc_slice_int32 - p.size = size_slice_int32 - } - p.dec = (*Buffer).dec_slice_int32 - p.packedDec = (*Buffer).dec_slice_packed_int32 - case reflect.Uint32: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_uint32 - p.size = size_slice_packed_uint32 - } else { - p.enc = (*Buffer).enc_slice_uint32 - p.size = size_slice_uint32 - } - p.dec = (*Buffer).dec_slice_int32 - p.packedDec = (*Buffer).dec_slice_packed_int32 - case reflect.Int64, reflect.Uint64: - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_int64 - p.size = size_slice_packed_int64 - } else { - p.enc = (*Buffer).enc_slice_int64 - p.size = size_slice_int64 - } - p.dec = (*Buffer).dec_slice_int64 - p.packedDec = (*Buffer).dec_slice_packed_int64 - case reflect.Uint8: - p.enc = (*Buffer).enc_slice_byte - p.dec = (*Buffer).dec_slice_byte - p.size = size_slice_byte - // This is a []byte, which is either a bytes field, - // or the value of a map field. In the latter case, - // we always encode an empty []byte, so we should not - // use the proto3 enc/size funcs. - // f == nil iff this is the key/value of a map field. - if p.proto3 && f != nil { - p.enc = (*Buffer).enc_proto3_slice_byte - p.size = size_proto3_slice_byte - } - case reflect.Float32, reflect.Float64: - switch t2.Bits() { - case 32: - // can just treat them as bits - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_uint32 - p.size = size_slice_packed_uint32 - } else { - p.enc = (*Buffer).enc_slice_uint32 - p.size = size_slice_uint32 - } - p.dec = (*Buffer).dec_slice_int32 - p.packedDec = (*Buffer).dec_slice_packed_int32 - case 64: - // can just treat them as bits - if p.Packed { - p.enc = (*Buffer).enc_slice_packed_int64 - p.size = size_slice_packed_int64 - } else { - p.enc = (*Buffer).enc_slice_int64 - p.size = size_slice_int64 - } - p.dec = (*Buffer).dec_slice_int64 - p.packedDec = (*Buffer).dec_slice_packed_int64 - default: - logNoSliceEnc(t1, t2) - break - } - case reflect.String: - p.enc = (*Buffer).enc_slice_string - p.dec = (*Buffer).dec_slice_string - p.size = size_slice_string case reflect.Ptr: switch t3 := t2.Elem(); t3.Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) - break case reflect.Struct: - p.stype = t2.Elem() - p.isMarshaler = isMarshaler(t2) - p.isUnmarshaler = isUnmarshaler(t2) - if p.Wire == "bytes" { - p.enc = (*Buffer).enc_slice_struct_message - p.dec = (*Buffer).dec_slice_struct_message - p.size = size_slice_struct_message - } else { - p.enc = (*Buffer).enc_slice_struct_group - p.dec = (*Buffer).dec_slice_struct_group - p.size = size_slice_struct_group - } - } - case reflect.Slice: - switch t2.Elem().Kind() { - default: - fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) - break - case reflect.Uint8: - p.enc = (*Buffer).enc_slice_slice_byte - p.dec = (*Buffer).dec_slice_slice_byte - p.size = size_slice_slice_byte + p.stype = t3 } case reflect.Struct: - p.setSliceOfNonPointerStructs(t1) + p.stype = t2 } case reflect.Map: - p.enc = (*Buffer).enc_new_map - p.dec = (*Buffer).dec_new_map - p.size = size_new_map p.mtype = t1 p.mkeyprop = &Properties{} @@ -634,26 +326,16 @@ func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lock // so we need encoders for the pointer to this type. vtype = reflect.PtrTo(vtype) } + + p.mvalprop.CustomType = p.CustomType + p.mvalprop.StdDuration = p.StdDuration + p.mvalprop.StdTime = p.StdTime p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) } p.setTag(lockGetProp) } func (p *Properties) setTag(lockGetProp bool) { - // precalculate tag code - wire := p.WireType - if p.Packed { - wire = WireBytes - } - x := uint32(p.Tag)<<3 | uint32(wire) - i := 0 - for i = 0; x > 127; i++ { - p.tagbuf[i] = 0x80 | uint8(x&0x7F) - x >>= 7 - } - p.tagbuf[i] = uint8(x) - p.tagcode = p.tagbuf[0 : i+1] - if p.stype != nil { if lockGetProp { p.sprop = GetProperties(p.stype) @@ -664,20 +346,9 @@ func (p *Properties) setTag(lockGetProp bool) { } var ( - marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() - unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() ) -// isMarshaler reports whether type t implements Marshaler. -func isMarshaler(t reflect.Type) bool { - return t.Implements(marshalerType) -} - -// isUnmarshaler reports whether type t implements Unmarshaler. -func isUnmarshaler(t reflect.Type) bool { - return t.Implements(unmarshalerType) -} - // Init populates the properties from a protocol buffer struct tag. func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { p.init(typ, name, tag, f, true) @@ -687,14 +358,11 @@ func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructF // "bytes,49,opt,def=hello!" p.Name = name p.OrigName = name - if f != nil { - p.field = toField(f) - } if tag == "" { return } p.Parse(tag) - p.setEncAndDec(typ, f, lockGetProp) + p.setFieldProps(typ, f, lockGetProp) } var ( @@ -744,8 +412,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { propertiesMap[t] = prop // build properties - prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) - prop.unrecField = invalidField prop.Prop = make([]*Properties, t.NumField()) prop.order = make([]int, t.NumField()) @@ -756,20 +422,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { name := f.Name p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) - if f.Name == "XXX_extensions" { // special case - if len(f.Tag.Get("protobuf")) > 0 { - p.enc = (*Buffer).enc_ext_slice_byte - p.dec = nil // not needed - p.size = size_ext_slice_byte - } else { - p.enc = (*Buffer).enc_map - p.dec = nil // not needed - p.size = size_map - } - } - if f.Name == "XXX_unrecognized" { // special case - prop.unrecField = toField(&f) - } oneof := f.Tag.Get("protobuf_oneof") // special case if oneof != "" { isOneofMessage = true @@ -785,9 +437,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { } print("\n") } - if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" { - fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") - } } // Re-order prop.order. @@ -798,8 +447,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { } if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { var oots []interface{} - prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() - prop.stype = t + _, _, _, oots = om.XXX_OneofFuncs() // Interpret oneof metadata. prop.OneofTypes = make(map[string]*OneofProperties) @@ -849,30 +497,6 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { return prop } -// Return the Properties object for the x[0]'th field of the structure. -func propByIndex(t reflect.Type, x []int) *Properties { - if len(x) != 1 { - fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) - return nil - } - prop := GetProperties(t) - return prop.Prop[x[0]] -} - -// Get the address and type of a pointer to a struct from an interface. -func getbase(pb Message) (t reflect.Type, b structPointer, err error) { - if pb == nil { - err = ErrNil - return - } - // get the reflect type of the pointer to the struct. - t = reflect.TypeOf(pb) - // get the address of the struct. - value := reflect.ValueOf(pb) - b = toStructPointer(value) - return -} - // A global registry of enum types. // The generated code will register the generated maps by calling RegisterEnum. @@ -901,28 +525,65 @@ func EnumValueMap(enumType string) map[string]int32 { // A registry of all linked message types. // The string is a fully-qualified proto name ("pkg.Message"). var ( - protoTypes = make(map[string]reflect.Type) - revProtoTypes = make(map[reflect.Type]string) + protoTypedNils = make(map[string]Message) // a map from proto names to typed nil pointers + protoMapTypes = make(map[string]reflect.Type) // a map from proto names to map types + revProtoTypes = make(map[reflect.Type]string) ) // RegisterType is called from generated code and maps from the fully qualified // proto name to the type (pointer to struct) of the protocol buffer. func RegisterType(x Message, name string) { - if _, ok := protoTypes[name]; ok { + if _, ok := protoTypedNils[name]; ok { // TODO: Some day, make this a panic. log.Printf("proto: duplicate proto type registered: %s", name) return } t := reflect.TypeOf(x) - protoTypes[name] = t + if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 { + // Generated code always calls RegisterType with nil x. + // This check is just for extra safety. + protoTypedNils[name] = x + } else { + protoTypedNils[name] = reflect.Zero(t).Interface().(Message) + } + revProtoTypes[t] = name +} + +// RegisterMapType is called from generated code and maps from the fully qualified +// proto name to the native map type of the proto map definition. +func RegisterMapType(x interface{}, name string) { + if reflect.TypeOf(x).Kind() != reflect.Map { + panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) + } + if _, ok := protoMapTypes[name]; ok { + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoMapTypes[name] = t revProtoTypes[t] = name } // MessageName returns the fully-qualified proto name for the given message type. -func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } +func MessageName(x Message) string { + type xname interface { + XXX_MessageName() string + } + if m, ok := x.(xname); ok { + return m.XXX_MessageName() + } + return revProtoTypes[reflect.TypeOf(x)] +} // MessageType returns the message type (pointer to struct) for a named message. -func MessageType(name string) reflect.Type { return protoTypes[name] } +// The type is not guaranteed to implement proto.Message if the name refers to a +// map entry. +func MessageType(name string) reflect.Type { + if t, ok := protoTypedNils[name]; ok { + return reflect.TypeOf(t) + } + return protoMapTypes[name] +} // A registry of all linked proto files. var ( diff --git a/vendor/github.com/gogo/protobuf/proto/properties_gogo.go b/vendor/github.com/gogo/protobuf/proto/properties_gogo.go index 8daf9f7768c..40ea3dd935c 100644 --- a/vendor/github.com/gogo/protobuf/proto/properties_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/properties_gogo.go @@ -1,5 +1,7 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -27,38 +29,8 @@ package proto import ( - "fmt" - "os" "reflect" ) -func (p *Properties) setCustomEncAndDec(typ reflect.Type) { - p.ctype = typ - if p.Repeated { - p.enc = (*Buffer).enc_custom_slice_bytes - p.dec = (*Buffer).dec_custom_slice_bytes - p.size = size_custom_slice_bytes - } else if typ.Kind() == reflect.Ptr { - p.enc = (*Buffer).enc_custom_bytes - p.dec = (*Buffer).dec_custom_bytes - p.size = size_custom_bytes - } else { - p.enc = (*Buffer).enc_custom_ref_bytes - p.dec = (*Buffer).dec_custom_ref_bytes - p.size = size_custom_ref_bytes - } -} - -func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) { - t2 := typ.Elem() - p.sstype = typ - p.stype = t2 - p.isMarshaler = isMarshaler(t2) - p.isUnmarshaler = isUnmarshaler(t2) - p.enc = (*Buffer).enc_slice_ref_struct_message - p.dec = (*Buffer).dec_slice_ref_struct_message - p.size = size_slice_ref_struct_message - if p.Wire != "bytes" { - fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2) - } -} +var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem() +var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem() diff --git a/vendor/github.com/gogo/protobuf/proto/skip_gogo.go b/vendor/github.com/gogo/protobuf/proto/skip_gogo.go index 4fe7e0815c9..5a5fd93f7c1 100644 --- a/vendor/github.com/gogo/protobuf/proto/skip_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/skip_gogo.go @@ -1,5 +1,7 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are diff --git a/vendor/github.com/gogo/protobuf/proto/table_marshal.go b/vendor/github.com/gogo/protobuf/proto/table_marshal.go new file mode 100644 index 00000000000..b479760a84b --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/table_marshal.go @@ -0,0 +1,2803 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "errors" + "fmt" + "math" + "reflect" + "sort" + "strconv" + "strings" + "sync" + "sync/atomic" + "unicode/utf8" +) + +// a sizer takes a pointer to a field and the size of its tag, computes the size of +// the encoded data. +type sizer func(pointer, int) int + +// a marshaler takes a byte slice, a pointer to a field, and its tag (in wire format), +// marshals the field to the end of the slice, returns the slice and error (if any). +type marshaler func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) + +// marshalInfo is the information used for marshaling a message. +type marshalInfo struct { + typ reflect.Type + fields []*marshalFieldInfo + unrecognized field // offset of XXX_unrecognized + extensions field // offset of XXX_InternalExtensions + v1extensions field // offset of XXX_extensions + sizecache field // offset of XXX_sizecache + initialized int32 // 0 -- only typ is set, 1 -- fully initialized + messageset bool // uses message set wire format + hasmarshaler bool // has custom marshaler + sync.RWMutex // protect extElems map, also for initialization + extElems map[int32]*marshalElemInfo // info of extension elements + + hassizer bool // has custom sizer + hasprotosizer bool // has custom protosizer + + bytesExtensions field // offset of XXX_extensions where the field type is []byte +} + +// marshalFieldInfo is the information used for marshaling a field of a message. +type marshalFieldInfo struct { + field field + wiretag uint64 // tag in wire format + tagsize int // size of tag in wire format + sizer sizer + marshaler marshaler + isPointer bool + required bool // field is required + name string // name of the field, for error reporting + oneofElems map[reflect.Type]*marshalElemInfo // info of oneof elements +} + +// marshalElemInfo is the information used for marshaling an extension or oneof element. +type marshalElemInfo struct { + wiretag uint64 // tag in wire format + tagsize int // size of tag in wire format + sizer sizer + marshaler marshaler + isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only) +} + +var ( + marshalInfoMap = map[reflect.Type]*marshalInfo{} + marshalInfoLock sync.Mutex +) + +// getMarshalInfo returns the information to marshal a given type of message. +// The info it returns may not necessarily initialized. +// t is the type of the message (NOT the pointer to it). +func getMarshalInfo(t reflect.Type) *marshalInfo { + marshalInfoLock.Lock() + u, ok := marshalInfoMap[t] + if !ok { + u = &marshalInfo{typ: t} + marshalInfoMap[t] = u + } + marshalInfoLock.Unlock() + return u +} + +// Size is the entry point from generated code, +// and should be ONLY called by generated code. +// It computes the size of encoded data of msg. +// a is a pointer to a place to store cached marshal info. +func (a *InternalMessageInfo) Size(msg Message) int { + u := getMessageMarshalInfo(msg, a) + ptr := toPointer(&msg) + if ptr.isNil() { + // We get here if msg is a typed nil ((*SomeMessage)(nil)), + // so it satisfies the interface, and msg == nil wouldn't + // catch it. We don't want crash in this case. + return 0 + } + return u.size(ptr) +} + +// Marshal is the entry point from generated code, +// and should be ONLY called by generated code. +// It marshals msg to the end of b. +// a is a pointer to a place to store cached marshal info. +func (a *InternalMessageInfo) Marshal(b []byte, msg Message, deterministic bool) ([]byte, error) { + u := getMessageMarshalInfo(msg, a) + ptr := toPointer(&msg) + if ptr.isNil() { + // We get here if msg is a typed nil ((*SomeMessage)(nil)), + // so it satisfies the interface, and msg == nil wouldn't + // catch it. We don't want crash in this case. + return b, ErrNil + } + return u.marshal(b, ptr, deterministic) +} + +func getMessageMarshalInfo(msg interface{}, a *InternalMessageInfo) *marshalInfo { + // u := a.marshal, but atomically. + // We use an atomic here to ensure memory consistency. + u := atomicLoadMarshalInfo(&a.marshal) + if u == nil { + // Get marshal information from type of message. + t := reflect.ValueOf(msg).Type() + if t.Kind() != reflect.Ptr { + panic(fmt.Sprintf("cannot handle non-pointer message type %v", t)) + } + u = getMarshalInfo(t.Elem()) + // Store it in the cache for later users. + // a.marshal = u, but atomically. + atomicStoreMarshalInfo(&a.marshal, u) + } + return u +} + +// size is the main function to compute the size of the encoded data of a message. +// ptr is the pointer to the message. +func (u *marshalInfo) size(ptr pointer) int { + if atomic.LoadInt32(&u.initialized) == 0 { + u.computeMarshalInfo() + } + + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + if u.hasmarshaler { + // Uses the message's Size method if available + if u.hassizer { + s := ptr.asPointerTo(u.typ).Interface().(Sizer) + return s.Size() + } + // Uses the message's ProtoSize method if available + if u.hasprotosizer { + s := ptr.asPointerTo(u.typ).Interface().(ProtoSizer) + return s.ProtoSize() + } + + m := ptr.asPointerTo(u.typ).Interface().(Marshaler) + b, _ := m.Marshal() + return len(b) + } + + n := 0 + for _, f := range u.fields { + if f.isPointer && ptr.offset(f.field).getPointer().isNil() { + // nil pointer always marshals to nothing + continue + } + n += f.sizer(ptr.offset(f.field), f.tagsize) + } + if u.extensions.IsValid() { + e := ptr.offset(u.extensions).toExtensions() + if u.messageset { + n += u.sizeMessageSet(e) + } else { + n += u.sizeExtensions(e) + } + } + if u.v1extensions.IsValid() { + m := *ptr.offset(u.v1extensions).toOldExtensions() + n += u.sizeV1Extensions(m) + } + if u.bytesExtensions.IsValid() { + s := *ptr.offset(u.bytesExtensions).toBytes() + n += len(s) + } + if u.unrecognized.IsValid() { + s := *ptr.offset(u.unrecognized).toBytes() + n += len(s) + } + + // cache the result for use in marshal + if u.sizecache.IsValid() { + atomic.StoreInt32(ptr.offset(u.sizecache).toInt32(), int32(n)) + } + return n +} + +// cachedsize gets the size from cache. If there is no cache (i.e. message is not generated), +// fall back to compute the size. +func (u *marshalInfo) cachedsize(ptr pointer) int { + if u.sizecache.IsValid() { + return int(atomic.LoadInt32(ptr.offset(u.sizecache).toInt32())) + } + return u.size(ptr) +} + +// marshal is the main function to marshal a message. It takes a byte slice and appends +// the encoded data to the end of the slice, returns the slice and error (if any). +// ptr is the pointer to the message. +// If deterministic is true, map is marshaled in deterministic order. +func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte, error) { + if atomic.LoadInt32(&u.initialized) == 0 { + u.computeMarshalInfo() + } + + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + if u.hasmarshaler { + if deterministic { + return nil, errors.New("proto: deterministic not supported by the Marshal method of " + u.typ.String()) + } + m := ptr.asPointerTo(u.typ).Interface().(Marshaler) + b1, err := m.Marshal() + b = append(b, b1...) + return b, err + } + + var err, errreq error + // The old marshaler encodes extensions at beginning. + if u.extensions.IsValid() { + e := ptr.offset(u.extensions).toExtensions() + if u.messageset { + b, err = u.appendMessageSet(b, e, deterministic) + } else { + b, err = u.appendExtensions(b, e, deterministic) + } + if err != nil { + return b, err + } + } + if u.v1extensions.IsValid() { + m := *ptr.offset(u.v1extensions).toOldExtensions() + b, err = u.appendV1Extensions(b, m, deterministic) + if err != nil { + return b, err + } + } + if u.bytesExtensions.IsValid() { + s := *ptr.offset(u.bytesExtensions).toBytes() + b = append(b, s...) + } + for _, f := range u.fields { + if f.required && errreq == nil { + if f.isPointer && ptr.offset(f.field).getPointer().isNil() { + // Required field is not set. + // We record the error but keep going, to give a complete marshaling. + errreq = &RequiredNotSetError{f.name} + continue + } + } + if f.isPointer && ptr.offset(f.field).getPointer().isNil() { + // nil pointer always marshals to nothing + continue + } + b, err = f.marshaler(b, ptr.offset(f.field), f.wiretag, deterministic) + if err != nil { + if err1, ok := err.(*RequiredNotSetError); ok { + // Required field in submessage is not set. + // We record the error but keep going, to give a complete marshaling. + if errreq == nil { + errreq = &RequiredNotSetError{f.name + "." + err1.field} + } + continue + } + if err == errRepeatedHasNil { + err = errors.New("proto: repeated field " + f.name + " has nil element") + } + if err == errInvalidUTF8 { + fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name + err = fmt.Errorf("proto: string field %q contains invalid UTF-8", fullName) + } + return b, err + } + } + if u.unrecognized.IsValid() { + s := *ptr.offset(u.unrecognized).toBytes() + b = append(b, s...) + } + return b, errreq +} + +// computeMarshalInfo initializes the marshal info. +func (u *marshalInfo) computeMarshalInfo() { + u.Lock() + defer u.Unlock() + if u.initialized != 0 { // non-atomic read is ok as it is protected by the lock + return + } + + t := u.typ + u.unrecognized = invalidField + u.extensions = invalidField + u.v1extensions = invalidField + u.bytesExtensions = invalidField + u.sizecache = invalidField + isOneofMessage := false + + if reflect.PtrTo(t).Implements(sizerType) { + u.hassizer = true + } + if reflect.PtrTo(t).Implements(protosizerType) { + u.hasprotosizer = true + } + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + if reflect.PtrTo(t).Implements(marshalerType) { + u.hasmarshaler = true + atomic.StoreInt32(&u.initialized, 1) + return + } + + n := t.NumField() + + // deal with XXX fields first + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Tag.Get("protobuf_oneof") != "" { + isOneofMessage = true + } + if !strings.HasPrefix(f.Name, "XXX_") { + continue + } + switch f.Name { + case "XXX_sizecache": + u.sizecache = toField(&f) + case "XXX_unrecognized": + u.unrecognized = toField(&f) + case "XXX_InternalExtensions": + u.extensions = toField(&f) + u.messageset = f.Tag.Get("protobuf_messageset") == "1" + case "XXX_extensions": + if f.Type.Kind() == reflect.Map { + u.v1extensions = toField(&f) + } else { + u.bytesExtensions = toField(&f) + } + case "XXX_NoUnkeyedLiteral": + // nothing to do + default: + panic("unknown XXX field: " + f.Name) + } + n-- + } + + // get oneof implementers + var oneofImplementers []interface{} + // gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler + if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok && isOneofMessage { + _, _, _, oneofImplementers = m.XXX_OneofFuncs() + } + + // normal fields + fields := make([]marshalFieldInfo, n) // batch allocation + u.fields = make([]*marshalFieldInfo, 0, n) + for i, j := 0, 0; i < t.NumField(); i++ { + f := t.Field(i) + + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + field := &fields[j] + j++ + field.name = f.Name + u.fields = append(u.fields, field) + if f.Tag.Get("protobuf_oneof") != "" { + field.computeOneofFieldInfo(&f, oneofImplementers) + continue + } + if f.Tag.Get("protobuf") == "" { + // field has no tag (not in generated message), ignore it + u.fields = u.fields[:len(u.fields)-1] + j-- + continue + } + field.computeMarshalFieldInfo(&f) + } + + // fields are marshaled in tag order on the wire. + sort.Sort(byTag(u.fields)) + + atomic.StoreInt32(&u.initialized, 1) +} + +// helper for sorting fields by tag +type byTag []*marshalFieldInfo + +func (a byTag) Len() int { return len(a) } +func (a byTag) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a byTag) Less(i, j int) bool { return a[i].wiretag < a[j].wiretag } + +// getExtElemInfo returns the information to marshal an extension element. +// The info it returns is initialized. +func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo { + // get from cache first + u.RLock() + e, ok := u.extElems[desc.Field] + u.RUnlock() + if ok { + return e + } + + t := reflect.TypeOf(desc.ExtensionType) // pointer or slice to basic type or struct + tags := strings.Split(desc.Tag, ",") + tag, err := strconv.Atoi(tags[1]) + if err != nil { + panic("tag is not an integer") + } + wt := wiretype(tags[0]) + sizr, marshalr := typeMarshaler(t, tags, false, false) + e = &marshalElemInfo{ + wiretag: uint64(tag)<<3 | wt, + tagsize: SizeVarint(uint64(tag) << 3), + sizer: sizr, + marshaler: marshalr, + isptr: t.Kind() == reflect.Ptr, + } + + // update cache + u.Lock() + if u.extElems == nil { + u.extElems = make(map[int32]*marshalElemInfo) + } + u.extElems[desc.Field] = e + u.Unlock() + return e +} + +// computeMarshalFieldInfo fills up the information to marshal a field. +func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) { + // parse protobuf tag of the field. + // tag has format of "bytes,49,opt,name=foo,def=hello!" + tags := strings.Split(f.Tag.Get("protobuf"), ",") + if tags[0] == "" { + return + } + tag, err := strconv.Atoi(tags[1]) + if err != nil { + panic("tag is not an integer") + } + wt := wiretype(tags[0]) + if tags[2] == "req" { + fi.required = true + } + fi.setTag(f, tag, wt) + fi.setMarshaler(f, tags) +} + +func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { + fi.field = toField(f) + fi.wiretag = 1<<31 - 1 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. + fi.isPointer = true + fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f) + fi.oneofElems = make(map[reflect.Type]*marshalElemInfo) + + ityp := f.Type // interface type + for _, o := range oneofImplementers { + t := reflect.TypeOf(o) + if !t.Implements(ityp) { + continue + } + sf := t.Elem().Field(0) // oneof implementer is a struct with a single field + tags := strings.Split(sf.Tag.Get("protobuf"), ",") + tag, err := strconv.Atoi(tags[1]) + if err != nil { + panic("tag is not an integer") + } + wt := wiretype(tags[0]) + sizr, marshalr := typeMarshaler(sf.Type, tags, false, true) // oneof should not omit any zero value + fi.oneofElems[t.Elem()] = &marshalElemInfo{ + wiretag: uint64(tag)<<3 | wt, + tagsize: SizeVarint(uint64(tag) << 3), + sizer: sizr, + marshaler: marshalr, + } + } +} + +type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) +} + +// wiretype returns the wire encoding of the type. +func wiretype(encoding string) uint64 { + switch encoding { + case "fixed32": + return WireFixed32 + case "fixed64": + return WireFixed64 + case "varint", "zigzag32", "zigzag64": + return WireVarint + case "bytes": + return WireBytes + case "group": + return WireStartGroup + } + panic("unknown wire type " + encoding) +} + +// setTag fills up the tag (in wire format) and its size in the info of a field. +func (fi *marshalFieldInfo) setTag(f *reflect.StructField, tag int, wt uint64) { + fi.field = toField(f) + fi.wiretag = uint64(tag)<<3 | wt + fi.tagsize = SizeVarint(uint64(tag) << 3) +} + +// setMarshaler fills up the sizer and marshaler in the info of a field. +func (fi *marshalFieldInfo) setMarshaler(f *reflect.StructField, tags []string) { + switch f.Type.Kind() { + case reflect.Map: + // map field + fi.isPointer = true + fi.sizer, fi.marshaler = makeMapMarshaler(f) + return + case reflect.Ptr, reflect.Slice: + fi.isPointer = true + } + fi.sizer, fi.marshaler = typeMarshaler(f.Type, tags, true, false) +} + +// typeMarshaler returns the sizer and marshaler of a given field. +// t is the type of the field. +// tags is the generated "protobuf" tag of the field. +// If nozero is true, zero value is not marshaled to the wire. +// If oneof is true, it is a oneof field. +func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, marshaler) { + encoding := tags[0] + + pointer := false + slice := false + if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 { + slice = true + t = t.Elem() + } + if t.Kind() == reflect.Ptr { + pointer = true + t = t.Elem() + } + + packed := false + proto3 := false + ctype := false + isTime := false + isDuration := false + for i := 2; i < len(tags); i++ { + if tags[i] == "packed" { + packed = true + } + if tags[i] == "proto3" { + proto3 = true + } + if strings.HasPrefix(tags[i], "customtype=") { + ctype = true + } + if tags[i] == "stdtime" { + isTime = true + } + if tags[i] == "stdduration" { + isDuration = true + } + } + if !proto3 && !pointer && !slice { + nozero = false + } + + if ctype { + if reflect.PtrTo(t).Implements(customType) { + if slice { + return makeMessageRefSliceMarshaler(getMarshalInfo(t)) + } + if pointer { + return makeCustomPtrMarshaler(getMarshalInfo(t)) + } + return makeCustomMarshaler(getMarshalInfo(t)) + } else { + panic(fmt.Sprintf("custom type: type: %v, does not implement the proto.custom interface", t)) + } + } + + if isTime { + if pointer { + if slice { + return makeTimePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeTimePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeTimeSliceMarshaler(getMarshalInfo(t)) + } + return makeTimeMarshaler(getMarshalInfo(t)) + } + + if isDuration { + if pointer { + if slice { + return makeDurationPtrSliceMarshaler(getMarshalInfo(t)) + } + return makeDurationPtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeDurationSliceMarshaler(getMarshalInfo(t)) + } + return makeDurationMarshaler(getMarshalInfo(t)) + } + + switch t.Kind() { + case reflect.Bool: + if pointer { + return sizeBoolPtr, appendBoolPtr + } + if slice { + if packed { + return sizeBoolPackedSlice, appendBoolPackedSlice + } + return sizeBoolSlice, appendBoolSlice + } + if nozero { + return sizeBoolValueNoZero, appendBoolValueNoZero + } + return sizeBoolValue, appendBoolValue + case reflect.Uint32: + switch encoding { + case "fixed32": + if pointer { + return sizeFixed32Ptr, appendFixed32Ptr + } + if slice { + if packed { + return sizeFixed32PackedSlice, appendFixed32PackedSlice + } + return sizeFixed32Slice, appendFixed32Slice + } + if nozero { + return sizeFixed32ValueNoZero, appendFixed32ValueNoZero + } + return sizeFixed32Value, appendFixed32Value + case "varint": + if pointer { + return sizeVarint32Ptr, appendVarint32Ptr + } + if slice { + if packed { + return sizeVarint32PackedSlice, appendVarint32PackedSlice + } + return sizeVarint32Slice, appendVarint32Slice + } + if nozero { + return sizeVarint32ValueNoZero, appendVarint32ValueNoZero + } + return sizeVarint32Value, appendVarint32Value + } + case reflect.Int32: + switch encoding { + case "fixed32": + if pointer { + return sizeFixedS32Ptr, appendFixedS32Ptr + } + if slice { + if packed { + return sizeFixedS32PackedSlice, appendFixedS32PackedSlice + } + return sizeFixedS32Slice, appendFixedS32Slice + } + if nozero { + return sizeFixedS32ValueNoZero, appendFixedS32ValueNoZero + } + return sizeFixedS32Value, appendFixedS32Value + case "varint": + if pointer { + return sizeVarintS32Ptr, appendVarintS32Ptr + } + if slice { + if packed { + return sizeVarintS32PackedSlice, appendVarintS32PackedSlice + } + return sizeVarintS32Slice, appendVarintS32Slice + } + if nozero { + return sizeVarintS32ValueNoZero, appendVarintS32ValueNoZero + } + return sizeVarintS32Value, appendVarintS32Value + case "zigzag32": + if pointer { + return sizeZigzag32Ptr, appendZigzag32Ptr + } + if slice { + if packed { + return sizeZigzag32PackedSlice, appendZigzag32PackedSlice + } + return sizeZigzag32Slice, appendZigzag32Slice + } + if nozero { + return sizeZigzag32ValueNoZero, appendZigzag32ValueNoZero + } + return sizeZigzag32Value, appendZigzag32Value + } + case reflect.Uint64: + switch encoding { + case "fixed64": + if pointer { + return sizeFixed64Ptr, appendFixed64Ptr + } + if slice { + if packed { + return sizeFixed64PackedSlice, appendFixed64PackedSlice + } + return sizeFixed64Slice, appendFixed64Slice + } + if nozero { + return sizeFixed64ValueNoZero, appendFixed64ValueNoZero + } + return sizeFixed64Value, appendFixed64Value + case "varint": + if pointer { + return sizeVarint64Ptr, appendVarint64Ptr + } + if slice { + if packed { + return sizeVarint64PackedSlice, appendVarint64PackedSlice + } + return sizeVarint64Slice, appendVarint64Slice + } + if nozero { + return sizeVarint64ValueNoZero, appendVarint64ValueNoZero + } + return sizeVarint64Value, appendVarint64Value + } + case reflect.Int64: + switch encoding { + case "fixed64": + if pointer { + return sizeFixedS64Ptr, appendFixedS64Ptr + } + if slice { + if packed { + return sizeFixedS64PackedSlice, appendFixedS64PackedSlice + } + return sizeFixedS64Slice, appendFixedS64Slice + } + if nozero { + return sizeFixedS64ValueNoZero, appendFixedS64ValueNoZero + } + return sizeFixedS64Value, appendFixedS64Value + case "varint": + if pointer { + return sizeVarintS64Ptr, appendVarintS64Ptr + } + if slice { + if packed { + return sizeVarintS64PackedSlice, appendVarintS64PackedSlice + } + return sizeVarintS64Slice, appendVarintS64Slice + } + if nozero { + return sizeVarintS64ValueNoZero, appendVarintS64ValueNoZero + } + return sizeVarintS64Value, appendVarintS64Value + case "zigzag64": + if pointer { + return sizeZigzag64Ptr, appendZigzag64Ptr + } + if slice { + if packed { + return sizeZigzag64PackedSlice, appendZigzag64PackedSlice + } + return sizeZigzag64Slice, appendZigzag64Slice + } + if nozero { + return sizeZigzag64ValueNoZero, appendZigzag64ValueNoZero + } + return sizeZigzag64Value, appendZigzag64Value + } + case reflect.Float32: + if pointer { + return sizeFloat32Ptr, appendFloat32Ptr + } + if slice { + if packed { + return sizeFloat32PackedSlice, appendFloat32PackedSlice + } + return sizeFloat32Slice, appendFloat32Slice + } + if nozero { + return sizeFloat32ValueNoZero, appendFloat32ValueNoZero + } + return sizeFloat32Value, appendFloat32Value + case reflect.Float64: + if pointer { + return sizeFloat64Ptr, appendFloat64Ptr + } + if slice { + if packed { + return sizeFloat64PackedSlice, appendFloat64PackedSlice + } + return sizeFloat64Slice, appendFloat64Slice + } + if nozero { + return sizeFloat64ValueNoZero, appendFloat64ValueNoZero + } + return sizeFloat64Value, appendFloat64Value + case reflect.String: + if pointer { + return sizeStringPtr, appendStringPtr + } + if slice { + return sizeStringSlice, appendStringSlice + } + if nozero { + return sizeStringValueNoZero, appendStringValueNoZero + } + return sizeStringValue, appendStringValue + case reflect.Slice: + if slice { + return sizeBytesSlice, appendBytesSlice + } + if oneof { + // Oneof bytes field may also have "proto3" tag. + // We want to marshal it as a oneof field. Do this + // check before the proto3 check. + return sizeBytesOneof, appendBytesOneof + } + if proto3 { + return sizeBytes3, appendBytes3 + } + return sizeBytes, appendBytes + case reflect.Struct: + switch encoding { + case "group": + if slice { + return makeGroupSliceMarshaler(getMarshalInfo(t)) + } + return makeGroupMarshaler(getMarshalInfo(t)) + case "bytes": + if pointer { + if slice { + return makeMessageSliceMarshaler(getMarshalInfo(t)) + } + return makeMessageMarshaler(getMarshalInfo(t)) + } else { + if slice { + return makeMessageRefSliceMarshaler(getMarshalInfo(t)) + } + return makeMessageRefMarshaler(getMarshalInfo(t)) + } + } + } + panic(fmt.Sprintf("unknown or mismatched type: type: %v, wire type: %v", t, encoding)) +} + +// Below are functions to size/marshal a specific type of a field. +// They are stored in the field's info, and called by function pointers. +// They have type sizer or marshaler. + +func sizeFixed32Value(_ pointer, tagsize int) int { + return 4 + tagsize +} +func sizeFixed32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint32() + if v == 0 { + return 0 + } + return 4 + tagsize +} +func sizeFixed32Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint32Ptr() + if p == nil { + return 0 + } + return 4 + tagsize +} +func sizeFixed32Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + return (4 + tagsize) * len(s) +} +func sizeFixed32PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return 0 + } + return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize +} +func sizeFixedS32Value(_ pointer, tagsize int) int { + return 4 + tagsize +} +func sizeFixedS32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + if v == 0 { + return 0 + } + return 4 + tagsize +} +func sizeFixedS32Ptr(ptr pointer, tagsize int) int { + p := ptr.getInt32Ptr() + if p == nil { + return 0 + } + return 4 + tagsize +} +func sizeFixedS32Slice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + return (4 + tagsize) * len(s) +} +func sizeFixedS32PackedSlice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + if len(s) == 0 { + return 0 + } + return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize +} +func sizeFloat32Value(_ pointer, tagsize int) int { + return 4 + tagsize +} +func sizeFloat32ValueNoZero(ptr pointer, tagsize int) int { + v := math.Float32bits(*ptr.toFloat32()) + if v == 0 { + return 0 + } + return 4 + tagsize +} +func sizeFloat32Ptr(ptr pointer, tagsize int) int { + p := *ptr.toFloat32Ptr() + if p == nil { + return 0 + } + return 4 + tagsize +} +func sizeFloat32Slice(ptr pointer, tagsize int) int { + s := *ptr.toFloat32Slice() + return (4 + tagsize) * len(s) +} +func sizeFloat32PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toFloat32Slice() + if len(s) == 0 { + return 0 + } + return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize +} +func sizeFixed64Value(_ pointer, tagsize int) int { + return 8 + tagsize +} +func sizeFixed64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint64() + if v == 0 { + return 0 + } + return 8 + tagsize +} +func sizeFixed64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint64Ptr() + if p == nil { + return 0 + } + return 8 + tagsize +} +func sizeFixed64Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + return (8 + tagsize) * len(s) +} +func sizeFixed64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return 0 + } + return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize +} +func sizeFixedS64Value(_ pointer, tagsize int) int { + return 8 + tagsize +} +func sizeFixedS64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + if v == 0 { + return 0 + } + return 8 + tagsize +} +func sizeFixedS64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toInt64Ptr() + if p == nil { + return 0 + } + return 8 + tagsize +} +func sizeFixedS64Slice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + return (8 + tagsize) * len(s) +} +func sizeFixedS64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return 0 + } + return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize +} +func sizeFloat64Value(_ pointer, tagsize int) int { + return 8 + tagsize +} +func sizeFloat64ValueNoZero(ptr pointer, tagsize int) int { + v := math.Float64bits(*ptr.toFloat64()) + if v == 0 { + return 0 + } + return 8 + tagsize +} +func sizeFloat64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toFloat64Ptr() + if p == nil { + return 0 + } + return 8 + tagsize +} +func sizeFloat64Slice(ptr pointer, tagsize int) int { + s := *ptr.toFloat64Slice() + return (8 + tagsize) * len(s) +} +func sizeFloat64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toFloat64Slice() + if len(s) == 0 { + return 0 + } + return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize +} +func sizeVarint32Value(ptr pointer, tagsize int) int { + v := *ptr.toUint32() + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarint32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint32() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarint32Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint32Ptr() + if p == nil { + return 0 + } + return SizeVarint(uint64(*p)) + tagsize +} +func sizeVarint32Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + tagsize + } + return n +} +func sizeVarint32PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeVarintS32Value(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS32Ptr(ptr pointer, tagsize int) int { + p := ptr.getInt32Ptr() + if p == nil { + return 0 + } + return SizeVarint(uint64(*p)) + tagsize +} +func sizeVarintS32Slice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + tagsize + } + return n +} +func sizeVarintS32PackedSlice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeVarint64Value(ptr pointer, tagsize int) int { + v := *ptr.toUint64() + return SizeVarint(v) + tagsize +} +func sizeVarint64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toUint64() + if v == 0 { + return 0 + } + return SizeVarint(v) + tagsize +} +func sizeVarint64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toUint64Ptr() + if p == nil { + return 0 + } + return SizeVarint(*p) + tagsize +} +func sizeVarint64Slice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + n := 0 + for _, v := range s { + n += SizeVarint(v) + tagsize + } + return n +} +func sizeVarint64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(v) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeVarintS64Value(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v)) + tagsize +} +func sizeVarintS64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toInt64Ptr() + if p == nil { + return 0 + } + return SizeVarint(uint64(*p)) + tagsize +} +func sizeVarintS64Slice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + tagsize + } + return n +} +func sizeVarintS64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeZigzag32Value(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize +} +func sizeZigzag32ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt32() + if v == 0 { + return 0 + } + return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize +} +func sizeZigzag32Ptr(ptr pointer, tagsize int) int { + p := ptr.getInt32Ptr() + if p == nil { + return 0 + } + v := *p + return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize +} +func sizeZigzag32Slice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize + } + return n +} +func sizeZigzag32PackedSlice(ptr pointer, tagsize int) int { + s := ptr.getInt32Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31)))) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeZigzag64Value(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize +} +func sizeZigzag64ValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toInt64() + if v == 0 { + return 0 + } + return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize +} +func sizeZigzag64Ptr(ptr pointer, tagsize int) int { + p := *ptr.toInt64Ptr() + if p == nil { + return 0 + } + v := *p + return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize +} +func sizeZigzag64Slice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize + } + return n +} +func sizeZigzag64PackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return 0 + } + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63))) + } + return n + SizeVarint(uint64(n)) + tagsize +} +func sizeBoolValue(_ pointer, tagsize int) int { + return 1 + tagsize +} +func sizeBoolValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toBool() + if !v { + return 0 + } + return 1 + tagsize +} +func sizeBoolPtr(ptr pointer, tagsize int) int { + p := *ptr.toBoolPtr() + if p == nil { + return 0 + } + return 1 + tagsize +} +func sizeBoolSlice(ptr pointer, tagsize int) int { + s := *ptr.toBoolSlice() + return (1 + tagsize) * len(s) +} +func sizeBoolPackedSlice(ptr pointer, tagsize int) int { + s := *ptr.toBoolSlice() + if len(s) == 0 { + return 0 + } + return len(s) + SizeVarint(uint64(len(s))) + tagsize +} +func sizeStringValue(ptr pointer, tagsize int) int { + v := *ptr.toString() + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeStringValueNoZero(ptr pointer, tagsize int) int { + v := *ptr.toString() + if v == "" { + return 0 + } + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeStringPtr(ptr pointer, tagsize int) int { + p := *ptr.toStringPtr() + if p == nil { + return 0 + } + v := *p + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeStringSlice(ptr pointer, tagsize int) int { + s := *ptr.toStringSlice() + n := 0 + for _, v := range s { + n += len(v) + SizeVarint(uint64(len(v))) + tagsize + } + return n +} +func sizeBytes(ptr pointer, tagsize int) int { + v := *ptr.toBytes() + if v == nil { + return 0 + } + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeBytes3(ptr pointer, tagsize int) int { + v := *ptr.toBytes() + if len(v) == 0 { + return 0 + } + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeBytesOneof(ptr pointer, tagsize int) int { + v := *ptr.toBytes() + return len(v) + SizeVarint(uint64(len(v))) + tagsize +} +func sizeBytesSlice(ptr pointer, tagsize int) int { + s := *ptr.toBytesSlice() + n := 0 + for _, v := range s { + n += len(v) + SizeVarint(uint64(len(v))) + tagsize + } + return n +} + +// appendFixed32 appends an encoded fixed32 to b. +func appendFixed32(b []byte, v uint32) []byte { + b = append(b, + byte(v), + byte(v>>8), + byte(v>>16), + byte(v>>24)) + return b +} + +// appendFixed64 appends an encoded fixed64 to b. +func appendFixed64(b []byte, v uint64) []byte { + b = append(b, + byte(v), + byte(v>>8), + byte(v>>16), + byte(v>>24), + byte(v>>32), + byte(v>>40), + byte(v>>48), + byte(v>>56)) + return b +} + +// appendVarint appends an encoded varint to b. +func appendVarint(b []byte, v uint64) []byte { + // TODO: make 1-byte (maybe 2-byte) case inline-able, once we + // have non-leaf inliner. + switch { + case v < 1<<7: + b = append(b, byte(v)) + case v < 1<<14: + b = append(b, + byte(v&0x7f|0x80), + byte(v>>7)) + case v < 1<<21: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte(v>>14)) + case v < 1<<28: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte(v>>21)) + case v < 1<<35: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte(v>>28)) + case v < 1<<42: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte(v>>35)) + case v < 1<<49: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte(v>>42)) + case v < 1<<56: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte((v>>42)&0x7f|0x80), + byte(v>>49)) + case v < 1<<63: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte((v>>42)&0x7f|0x80), + byte((v>>49)&0x7f|0x80), + byte(v>>56)) + default: + b = append(b, + byte(v&0x7f|0x80), + byte((v>>7)&0x7f|0x80), + byte((v>>14)&0x7f|0x80), + byte((v>>21)&0x7f|0x80), + byte((v>>28)&0x7f|0x80), + byte((v>>35)&0x7f|0x80), + byte((v>>42)&0x7f|0x80), + byte((v>>49)&0x7f|0x80), + byte((v>>56)&0x7f|0x80), + 1) + } + return b +} + +func appendFixed32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFixed32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFixed32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, *p) + return b, nil +} +func appendFixed32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + } + return b, nil +} +func appendFixed32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(4*len(s))) + for _, v := range s { + b = appendFixed32(b, v) + } + return b, nil +} +func appendFixedS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(v)) + return b, nil +} +func appendFixedS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(v)) + return b, nil +} +func appendFixedS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := ptr.getInt32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(*p)) + return b, nil +} +func appendFixedS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed32(b, uint32(v)) + } + return b, nil +} +func appendFixedS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(4*len(s))) + for _, v := range s { + b = appendFixed32(b, uint32(v)) + } + return b, nil +} +func appendFloat32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float32bits(*ptr.toFloat32()) + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFloat32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float32bits(*ptr.toFloat32()) + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, v) + return b, nil +} +func appendFloat32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toFloat32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed32(b, math.Float32bits(*p)) + return b, nil +} +func appendFloat32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed32(b, math.Float32bits(v)) + } + return b, nil +} +func appendFloat32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(4*len(s))) + for _, v := range s { + b = appendFixed32(b, math.Float32bits(v)) + } + return b, nil +} +func appendFixed64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFixed64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFixed64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, *p) + return b, nil +} +func appendFixed64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + } + return b, nil +} +func appendFixed64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(8*len(s))) + for _, v := range s { + b = appendFixed64(b, v) + } + return b, nil +} +func appendFixedS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(v)) + return b, nil +} +func appendFixedS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(v)) + return b, nil +} +func appendFixedS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toInt64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(*p)) + return b, nil +} +func appendFixedS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed64(b, uint64(v)) + } + return b, nil +} +func appendFixedS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(8*len(s))) + for _, v := range s { + b = appendFixed64(b, uint64(v)) + } + return b, nil +} +func appendFloat64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float64bits(*ptr.toFloat64()) + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFloat64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := math.Float64bits(*ptr.toFloat64()) + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, v) + return b, nil +} +func appendFloat64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toFloat64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendFixed64(b, math.Float64bits(*p)) + return b, nil +} +func appendFloat64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendFixed64(b, math.Float64bits(v)) + } + return b, nil +} +func appendFloat64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toFloat64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(8*len(s))) + for _, v := range s { + b = appendFixed64(b, math.Float64bits(v)) + } + return b, nil +} +func appendVarint32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarint32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarint32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(*p)) + return b, nil +} +func appendVarint32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarint32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarintS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := ptr.getInt32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(*p)) + return b, nil +} +func appendVarintS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarintS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarint64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + b = appendVarint(b, wiretag) + b = appendVarint(b, v) + return b, nil +} +func appendVarint64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toUint64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, v) + return b, nil +} +func appendVarint64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toUint64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, *p) + return b, nil +} +func appendVarint64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, v) + } + return b, nil +} +func appendVarint64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toUint64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(v) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, v) + } + return b, nil +} +func appendVarintS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + return b, nil +} +func appendVarintS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toInt64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(*p)) + return b, nil +} +func appendVarintS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendVarintS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v)) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v)) + } + return b, nil +} +func appendZigzag32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + return b, nil +} +func appendZigzag32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt32() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + return b, nil +} +func appendZigzag32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := ptr.getInt32Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + v := *p + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + return b, nil +} +func appendZigzag32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + } + return b, nil +} +func appendZigzag32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := ptr.getInt32Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31)))) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + } + return b, nil +} +func appendZigzag64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + return b, nil +} +func appendZigzag64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toInt64() + if v == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + return b, nil +} +func appendZigzag64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toInt64Ptr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + v := *p + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + return b, nil +} +func appendZigzag64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + } + return b, nil +} +func appendZigzag64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toInt64Slice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + // compute size + n := 0 + for _, v := range s { + n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63))) + } + b = appendVarint(b, uint64(n)) + for _, v := range s { + b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63))) + } + return b, nil +} +func appendBoolValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBool() + b = appendVarint(b, wiretag) + if v { + b = append(b, 1) + } else { + b = append(b, 0) + } + return b, nil +} +func appendBoolValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBool() + if !v { + return b, nil + } + b = appendVarint(b, wiretag) + b = append(b, 1) + return b, nil +} + +func appendBoolPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toBoolPtr() + if p == nil { + return b, nil + } + b = appendVarint(b, wiretag) + if *p { + b = append(b, 1) + } else { + b = append(b, 0) + } + return b, nil +} +func appendBoolSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toBoolSlice() + for _, v := range s { + b = appendVarint(b, wiretag) + if v { + b = append(b, 1) + } else { + b = append(b, 0) + } + } + return b, nil +} +func appendBoolPackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toBoolSlice() + if len(s) == 0 { + return b, nil + } + b = appendVarint(b, wiretag&^7|WireBytes) + b = appendVarint(b, uint64(len(s))) + for _, v := range s { + if v { + b = append(b, 1) + } else { + b = append(b, 0) + } + } + return b, nil +} +func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toString() + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendStringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toString() + if v == "" { + return b, nil + } + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendStringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + p := *ptr.toStringPtr() + if p == nil { + return b, nil + } + v := *p + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toStringSlice() + for _, v := range s { + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + } + return b, nil +} +func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBytes() + if v == nil { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendBytes3(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBytes() + if len(v) == 0 { + return b, nil + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendBytesOneof(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + v := *ptr.toBytes() + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + return b, nil +} +func appendBytesSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) { + s := *ptr.toBytesSlice() + for _, v := range s { + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(v))) + b = append(b, v...) + } + return b, nil +} + +// makeGroupMarshaler returns the sizer and marshaler for a group. +// u is the marshal info of the underlying message. +func makeGroupMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + p := ptr.getPointer() + if p.isNil() { + return 0 + } + return u.size(p) + 2*tagsize + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + p := ptr.getPointer() + if p.isNil() { + return b, nil + } + var err error + b = appendVarint(b, wiretag) // start group + b, err = u.marshal(b, p, deterministic) + b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group + return b, err + } +} + +// makeGroupSliceMarshaler returns the sizer and marshaler for a group slice. +// u is the marshal info of the underlying message. +func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getPointerSlice() + n := 0 + for _, v := range s { + if v.isNil() { + continue + } + n += u.size(v) + 2*tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getPointerSlice() + var err, errreq error + for _, v := range s { + if v.isNil() { + return b, errRepeatedHasNil + } + b = appendVarint(b, wiretag) // start group + b, err = u.marshal(b, v, deterministic) + b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group + if err != nil { + if _, ok := err.(*RequiredNotSetError); ok { + // Required field in submessage is not set. + // We record the error but keep going, to give a complete marshaling. + if errreq == nil { + errreq = err + } + continue + } + if err == ErrNil { + err = errRepeatedHasNil + } + return b, err + } + } + return b, errreq + } +} + +// makeMessageMarshaler returns the sizer and marshaler for a message field. +// u is the marshal info of the message. +func makeMessageMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + p := ptr.getPointer() + if p.isNil() { + return 0 + } + siz := u.size(p) + return siz + SizeVarint(uint64(siz)) + tagsize + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + p := ptr.getPointer() + if p.isNil() { + return b, nil + } + b = appendVarint(b, wiretag) + siz := u.cachedsize(p) + b = appendVarint(b, uint64(siz)) + return u.marshal(b, p, deterministic) + } +} + +// makeMessageSliceMarshaler returns the sizer and marshaler for a message slice. +// u is the marshal info of the message. +func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getPointerSlice() + n := 0 + for _, v := range s { + if v.isNil() { + continue + } + siz := u.size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getPointerSlice() + var err, errreq error + for _, v := range s { + if v.isNil() { + return b, errRepeatedHasNil + } + b = appendVarint(b, wiretag) + siz := u.cachedsize(v) + b = appendVarint(b, uint64(siz)) + b, err = u.marshal(b, v, deterministic) + if err != nil { + if _, ok := err.(*RequiredNotSetError); ok { + // Required field in submessage is not set. + // We record the error but keep going, to give a complete marshaling. + if errreq == nil { + errreq = err + } + continue + } + if err == ErrNil { + err = errRepeatedHasNil + } + return b, err + } + } + return b, errreq + } +} + +// makeMapMarshaler returns the sizer and marshaler for a map field. +// f is the pointer to the reflect data structure of the field. +func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { + // figure out key and value type + t := f.Type + keyType := t.Key() + valType := t.Elem() + tags := strings.Split(f.Tag.Get("protobuf"), ",") + keyTags := strings.Split(f.Tag.Get("protobuf_key"), ",") + valTags := strings.Split(f.Tag.Get("protobuf_val"), ",") + for _, t := range tags { + if strings.HasPrefix(t, "customtype=") { + valTags = append(valTags, t) + } + if t == "stdtime" { + valTags = append(valTags, t) + } + if t == "stdduration" { + valTags = append(valTags, t) + } + } + keySizer, keyMarshaler := typeMarshaler(keyType, keyTags, false, false) // don't omit zero value in map + valSizer, valMarshaler := typeMarshaler(valType, valTags, false, false) // don't omit zero value in map + keyWireTag := 1<<3 | wiretype(keyTags[0]) + valWireTag := 2<<3 | wiretype(valTags[0]) + + // We create an interface to get the addresses of the map key and value. + // If value is pointer-typed, the interface is a direct interface, the + // idata itself is the value. Otherwise, the idata is the pointer to the + // value. + // Key cannot be pointer-typed. + valIsPtr := valType.Kind() == reflect.Ptr + return func(ptr pointer, tagsize int) int { + m := ptr.asPointerTo(t).Elem() // the map + n := 0 + for _, k := range m.MapKeys() { + ki := k.Interface() + vi := m.MapIndex(k).Interface() + kaddr := toAddrPointer(&ki, false) // pointer to key + vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value + siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, tag uint64, deterministic bool) ([]byte, error) { + m := ptr.asPointerTo(t).Elem() // the map + var err error + keys := m.MapKeys() + if len(keys) > 1 && deterministic { + sort.Sort(mapKeys(keys)) + } + for _, k := range keys { + ki := k.Interface() + vi := m.MapIndex(k).Interface() + kaddr := toAddrPointer(&ki, false) // pointer to key + vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value + b = appendVarint(b, tag) + siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) + b = appendVarint(b, uint64(siz)) + b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic) + if err != nil { + return b, err + } + b, err = valMarshaler(b, vaddr, valWireTag, deterministic) + if err != nil && err != ErrNil { // allow nil value in map + return b, err + } + } + return b, nil + } +} + +// makeOneOfMarshaler returns the sizer and marshaler for a oneof field. +// fi is the marshal info of the field. +// f is the pointer to the reflect data structure of the field. +func makeOneOfMarshaler(fi *marshalFieldInfo, f *reflect.StructField) (sizer, marshaler) { + // Oneof field is an interface. We need to get the actual data type on the fly. + t := f.Type + return func(ptr pointer, _ int) int { + p := ptr.getInterfacePointer() + if p.isNil() { + return 0 + } + v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct + telem := v.Type() + e := fi.oneofElems[telem] + return e.sizer(p, e.tagsize) + }, + func(b []byte, ptr pointer, _ uint64, deterministic bool) ([]byte, error) { + p := ptr.getInterfacePointer() + if p.isNil() { + return b, nil + } + v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct + telem := v.Type() + if telem.Field(0).Type.Kind() == reflect.Ptr && p.getPointer().isNil() { + return b, errOneofHasNil + } + e := fi.oneofElems[telem] + return e.marshaler(b, p, e.wiretag, deterministic) + } +} + +// sizeExtensions computes the size of encoded data for a XXX_InternalExtensions field. +func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int { + m, mu := ext.extensionsRead() + if m == nil { + return 0 + } + mu.Lock() + + n := 0 + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + n += ei.sizer(p, ei.tagsize) + } + mu.Unlock() + return n +} + +// appendExtensions marshals a XXX_InternalExtensions field to the end of byte slice b. +func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) { + m, mu := ext.extensionsRead() + if m == nil { + return b, nil + } + mu.Lock() + defer mu.Unlock() + + var err error + + // Fast-path for common cases: zero or one extensions. + // Don't bother sorting the keys. + if len(m) <= 1 { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + b = append(b, e.enc...) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, ei.wiretag, deterministic) + if err != nil { + return b, err + } + } + return b, nil + } + + // Sort the keys to provide a deterministic encoding. + // Not sure this is required, but the old code does it. + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + e := m[int32(k)] + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + b = append(b, e.enc...) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, ei.wiretag, deterministic) + if err != nil { + return b, err + } + } + return b, nil +} + +// message set format is: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } + +// sizeMessageSet computes the size of encoded data for a XXX_InternalExtensions field +// in message set format (above). +func (u *marshalInfo) sizeMessageSet(ext *XXX_InternalExtensions) int { + m, mu := ext.extensionsRead() + if m == nil { + return 0 + } + mu.Lock() + + n := 0 + for id, e := range m { + n += 2 // start group, end group. tag = 1 (size=1) + n += SizeVarint(uint64(id)) + 1 // type_id, tag = 2 (size=1) + + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint + siz := len(msgWithLen) + n += siz + 1 // message, tag = 3 (size=1) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + n += ei.sizer(p, 1) // message, tag = 3 (size=1) + } + mu.Unlock() + return n +} + +// appendMessageSet marshals a XXX_InternalExtensions field in message set format (above) +// to the end of byte slice b. +func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) { + m, mu := ext.extensionsRead() + if m == nil { + return b, nil + } + mu.Lock() + defer mu.Unlock() + + var err error + + // Fast-path for common cases: zero or one extensions. + // Don't bother sorting the keys. + if len(m) <= 1 { + for id, e := range m { + b = append(b, 1<<3|WireStartGroup) + b = append(b, 2<<3|WireVarint) + b = appendVarint(b, uint64(id)) + + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint + b = append(b, 3<<3|WireBytes) + b = append(b, msgWithLen...) + b = append(b, 1<<3|WireEndGroup) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) + if err != nil { + return b, err + } + b = append(b, 1<<3|WireEndGroup) + } + return b, nil + } + + // Sort the keys to provide a deterministic encoding. + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, id := range keys { + e := m[int32(id)] + b = append(b, 1<<3|WireStartGroup) + b = append(b, 2<<3|WireVarint) + b = appendVarint(b, uint64(id)) + + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint + b = append(b, 3<<3|WireBytes) + b = append(b, msgWithLen...) + b = append(b, 1<<3|WireEndGroup) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) + b = append(b, 1<<3|WireEndGroup) + if err != nil { + return b, err + } + } + return b, nil +} + +// sizeV1Extensions computes the size of encoded data for a V1-API extension field. +func (u *marshalInfo) sizeV1Extensions(m map[int32]Extension) int { + if m == nil { + return 0 + } + + n := 0 + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + n += ei.sizer(p, ei.tagsize) + } + return n +} + +// appendV1Extensions marshals a V1-API extension field to the end of byte slice b. +func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, deterministic bool) ([]byte, error) { + if m == nil { + return b, nil + } + + // Sort the keys to provide a deterministic encoding. + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + var err error + for _, k := range keys { + e := m[int32(k)] + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + b = append(b, e.enc...) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + ei := u.getExtElemInfo(e.desc) + v := e.value + p := toAddrPointer(&v, ei.isptr) + b, err = ei.marshaler(b, p, ei.wiretag, deterministic) + if err != nil { + return b, err + } + } + return b, nil +} + +// newMarshaler is the interface representing objects that can marshal themselves. +// +// This exists to support protoc-gen-go generated messages. +// The proto package will stop type-asserting to this interface in the future. +// +// DO NOT DEPEND ON THIS. +type newMarshaler interface { + XXX_Size() int + XXX_Marshal(b []byte, deterministic bool) ([]byte, error) +} + +// Size returns the encoded size of a protocol buffer message. +// This is the main entry point. +func Size(pb Message) int { + if m, ok := pb.(newMarshaler); ok { + return m.XXX_Size() + } + if m, ok := pb.(Marshaler); ok { + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + b, _ := m.Marshal() + return len(b) + } + // in case somehow we didn't generate the wrapper + if pb == nil { + return 0 + } + var info InternalMessageInfo + return info.Size(pb) +} + +// Marshal takes a protocol buffer message +// and encodes it into the wire format, returning the data. +// This is the main entry point. +func Marshal(pb Message) ([]byte, error) { + if m, ok := pb.(newMarshaler); ok { + siz := m.XXX_Size() + b := make([]byte, 0, siz) + return m.XXX_Marshal(b, false) + } + if m, ok := pb.(Marshaler); ok { + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + return m.Marshal() + } + // in case somehow we didn't generate the wrapper + if pb == nil { + return nil, ErrNil + } + var info InternalMessageInfo + siz := info.Size(pb) + b := make([]byte, 0, siz) + return info.Marshal(b, pb, false) +} + +// Marshal takes a protocol buffer message +// and encodes it into the wire format, writing the result to the +// Buffer. +// This is an alternative entry point. It is not necessary to use +// a Buffer for most applications. +func (p *Buffer) Marshal(pb Message) error { + var err error + if m, ok := pb.(newMarshaler); ok { + siz := m.XXX_Size() + p.grow(siz) // make sure buf has enough capacity + p.buf, err = m.XXX_Marshal(p.buf, p.deterministic) + return err + } + if m, ok := pb.(Marshaler); ok { + // If the message can marshal itself, let it do it, for compatibility. + // NOTE: This is not efficient. + var b []byte + b, err = m.Marshal() + p.buf = append(p.buf, b...) + return err + } + // in case somehow we didn't generate the wrapper + if pb == nil { + return ErrNil + } + var info InternalMessageInfo + siz := info.Size(pb) + p.grow(siz) // make sure buf has enough capacity + p.buf, err = info.Marshal(p.buf, pb, p.deterministic) + return err +} + +// grow grows the buffer's capacity, if necessary, to guarantee space for +// another n bytes. After grow(n), at least n bytes can be written to the +// buffer without another allocation. +func (p *Buffer) grow(n int) { + need := len(p.buf) + n + if need <= cap(p.buf) { + return + } + newCap := len(p.buf) * 2 + if newCap < need { + newCap = need + } + p.buf = append(make([]byte, 0, newCap), p.buf...) +} diff --git a/vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go b/vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go new file mode 100644 index 00000000000..997f57c1e10 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go @@ -0,0 +1,388 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "reflect" + "time" +) + +// makeMessageRefMarshaler differs a bit from makeMessageMarshaler +// It marshal a message T instead of a *T +func makeMessageRefMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + siz := u.size(ptr) + return siz + SizeVarint(uint64(siz)) + tagsize + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + b = appendVarint(b, wiretag) + siz := u.cachedsize(ptr) + b = appendVarint(b, uint64(siz)) + return u.marshal(b, ptr, deterministic) + } +} + +// makeMessageRefSliceMarshaler differs quite a lot from makeMessageSliceMarshaler +// It marshals a slice of messages []T instead of []*T +func makeMessageRefSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + e := elem.Interface() + v := toAddrPointer(&e, false) + siz := u.size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + var err, errreq error + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + e := elem.Interface() + v := toAddrPointer(&e, false) + b = appendVarint(b, wiretag) + siz := u.size(v) + b = appendVarint(b, uint64(siz)) + b, err = u.marshal(b, v, deterministic) + + if err != nil { + if _, ok := err.(*RequiredNotSetError); ok { + // Required field in submessage is not set. + // We record the error but keep going, to give a complete marshaling. + if errreq == nil { + errreq = err + } + continue + } + if err == ErrNil { + err = errRepeatedHasNil + } + return b, err + } + } + + return b, errreq + } +} + +func makeCustomPtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom) + siz := m.Size() + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom) + siz := m.Size() + buf, err := m.Marshal() + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + return b, nil + } +} + +func makeCustomMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + m := ptr.asPointerTo(u.typ).Interface().(custom) + siz := m.Size() + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + m := ptr.asPointerTo(u.typ).Interface().(custom) + siz := m.Size() + buf, err := m.Marshal() + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + return b, nil + } +} + +func makeTimeMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*time.Time) + ts, err := timestampProto(*t) + if err != nil { + return 0 + } + siz := Size(ts) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*time.Time) + ts, err := timestampProto(*t) + if err != nil { + return nil, err + } + buf, err := Marshal(ts) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeTimePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time) + ts, err := timestampProto(*t) + if err != nil { + return 0 + } + siz := Size(ts) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time) + ts, err := timestampProto(*t) + if err != nil { + return nil, err + } + buf, err := Marshal(ts) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeTimeSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(time.Time) + ts, err := timestampProto(t) + if err != nil { + return 0 + } + siz := Size(ts) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(time.Time) + ts, err := timestampProto(t) + if err != nil { + return nil, err + } + siz := Size(ts) + buf, err := Marshal(ts) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeTimePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*time.Time) + ts, err := timestampProto(*t) + if err != nil { + return 0 + } + siz := Size(ts) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*time.Time) + ts, err := timestampProto(*t) + if err != nil { + return nil, err + } + siz := Size(ts) + buf, err := Marshal(ts) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeDurationMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + d := ptr.asPointerTo(u.typ).Interface().(*time.Duration) + dur := durationProto(*d) + siz := Size(dur) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + d := ptr.asPointerTo(u.typ).Interface().(*time.Duration) + dur := durationProto(*d) + buf, err := Marshal(dur) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeDurationPtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration) + dur := durationProto(*d) + siz := Size(dur) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration) + dur := durationProto(*d) + buf, err := Marshal(dur) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeDurationSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + d := elem.Interface().(time.Duration) + dur := durationProto(d) + siz := Size(dur) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + d := elem.Interface().(time.Duration) + dur := durationProto(d) + siz := Size(dur) + buf, err := Marshal(dur) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeDurationPtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + d := elem.Interface().(*time.Duration) + dur := durationProto(*d) + siz := Size(dur) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + d := elem.Interface().(*time.Duration) + dur := durationProto(*d) + siz := Size(dur) + buf, err := Marshal(dur) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/table_merge.go b/vendor/github.com/gogo/protobuf/proto/table_merge.go new file mode 100644 index 00000000000..f520106e09f --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/table_merge.go @@ -0,0 +1,657 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "fmt" + "reflect" + "strings" + "sync" + "sync/atomic" +) + +// Merge merges the src message into dst. +// This assumes that dst and src of the same type and are non-nil. +func (a *InternalMessageInfo) Merge(dst, src Message) { + mi := atomicLoadMergeInfo(&a.merge) + if mi == nil { + mi = getMergeInfo(reflect.TypeOf(dst).Elem()) + atomicStoreMergeInfo(&a.merge, mi) + } + mi.merge(toPointer(&dst), toPointer(&src)) +} + +type mergeInfo struct { + typ reflect.Type + + initialized int32 // 0: only typ is valid, 1: everything is valid + lock sync.Mutex + + fields []mergeFieldInfo + unrecognized field // Offset of XXX_unrecognized +} + +type mergeFieldInfo struct { + field field // Offset of field, guaranteed to be valid + + // isPointer reports whether the value in the field is a pointer. + // This is true for the following situations: + // * Pointer to struct + // * Pointer to basic type (proto2 only) + // * Slice (first value in slice header is a pointer) + // * String (first value in string header is a pointer) + isPointer bool + + // basicWidth reports the width of the field assuming that it is directly + // embedded in the struct (as is the case for basic types in proto3). + // The possible values are: + // 0: invalid + // 1: bool + // 4: int32, uint32, float32 + // 8: int64, uint64, float64 + basicWidth int + + // Where dst and src are pointers to the types being merged. + merge func(dst, src pointer) +} + +var ( + mergeInfoMap = map[reflect.Type]*mergeInfo{} + mergeInfoLock sync.Mutex +) + +func getMergeInfo(t reflect.Type) *mergeInfo { + mergeInfoLock.Lock() + defer mergeInfoLock.Unlock() + mi := mergeInfoMap[t] + if mi == nil { + mi = &mergeInfo{typ: t} + mergeInfoMap[t] = mi + } + return mi +} + +// merge merges src into dst assuming they are both of type *mi.typ. +func (mi *mergeInfo) merge(dst, src pointer) { + if dst.isNil() { + panic("proto: nil destination") + } + if src.isNil() { + return // Nothing to do. + } + + if atomic.LoadInt32(&mi.initialized) == 0 { + mi.computeMergeInfo() + } + + for _, fi := range mi.fields { + sfp := src.offset(fi.field) + + // As an optimization, we can avoid the merge function call cost + // if we know for sure that the source will have no effect + // by checking if it is the zero value. + if unsafeAllowed { + if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string + continue + } + if fi.basicWidth > 0 { + switch { + case fi.basicWidth == 1 && !*sfp.toBool(): + continue + case fi.basicWidth == 4 && *sfp.toUint32() == 0: + continue + case fi.basicWidth == 8 && *sfp.toUint64() == 0: + continue + } + } + } + + dfp := dst.offset(fi.field) + fi.merge(dfp, sfp) + } + + // TODO: Make this faster? + out := dst.asPointerTo(mi.typ).Elem() + in := src.asPointerTo(mi.typ).Elem() + if emIn, err := extendable(in.Addr().Interface()); err == nil { + emOut, _ := extendable(out.Addr().Interface()) + mIn, muIn := emIn.extensionsRead() + if mIn != nil { + mOut := emOut.extensionsWrite() + muIn.Lock() + mergeExtension(mOut, mIn) + muIn.Unlock() + } + } + + if mi.unrecognized.IsValid() { + if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 { + *dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...) + } + } +} + +func (mi *mergeInfo) computeMergeInfo() { + mi.lock.Lock() + defer mi.lock.Unlock() + if mi.initialized != 0 { + return + } + t := mi.typ + n := t.NumField() + + props := GetProperties(t) + for i := 0; i < n; i++ { + f := t.Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + + mfi := mergeFieldInfo{field: toField(&f)} + tf := f.Type + + // As an optimization, we can avoid the merge function call cost + // if we know for sure that the source will have no effect + // by checking if it is the zero value. + if unsafeAllowed { + switch tf.Kind() { + case reflect.Ptr, reflect.Slice, reflect.String: + // As a special case, we assume slices and strings are pointers + // since we know that the first field in the SliceSlice or + // StringHeader is a data pointer. + mfi.isPointer = true + case reflect.Bool: + mfi.basicWidth = 1 + case reflect.Int32, reflect.Uint32, reflect.Float32: + mfi.basicWidth = 4 + case reflect.Int64, reflect.Uint64, reflect.Float64: + mfi.basicWidth = 8 + } + } + + // Unwrap tf to get at its most basic type. + var isPointer, isSlice bool + if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { + isSlice = true + tf = tf.Elem() + } + if tf.Kind() == reflect.Ptr { + isPointer = true + tf = tf.Elem() + } + if isPointer && isSlice && tf.Kind() != reflect.Struct { + panic("both pointer and slice for basic type in " + tf.Name()) + } + + switch tf.Kind() { + case reflect.Int32: + switch { + case isSlice: // E.g., []int32 + mfi.merge = func(dst, src pointer) { + // NOTE: toInt32Slice is not defined (see pointer_reflect.go). + /* + sfsp := src.toInt32Slice() + if *sfsp != nil { + dfsp := dst.toInt32Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []int64{} + } + } + */ + sfs := src.getInt32Slice() + if sfs != nil { + dfs := dst.getInt32Slice() + dfs = append(dfs, sfs...) + if dfs == nil { + dfs = []int32{} + } + dst.setInt32Slice(dfs) + } + } + case isPointer: // E.g., *int32 + mfi.merge = func(dst, src pointer) { + // NOTE: toInt32Ptr is not defined (see pointer_reflect.go). + /* + sfpp := src.toInt32Ptr() + if *sfpp != nil { + dfpp := dst.toInt32Ptr() + if *dfpp == nil { + *dfpp = Int32(**sfpp) + } else { + **dfpp = **sfpp + } + } + */ + sfp := src.getInt32Ptr() + if sfp != nil { + dfp := dst.getInt32Ptr() + if dfp == nil { + dst.setInt32Ptr(*sfp) + } else { + *dfp = *sfp + } + } + } + default: // E.g., int32 + mfi.merge = func(dst, src pointer) { + if v := *src.toInt32(); v != 0 { + *dst.toInt32() = v + } + } + } + case reflect.Int64: + switch { + case isSlice: // E.g., []int64 + mfi.merge = func(dst, src pointer) { + sfsp := src.toInt64Slice() + if *sfsp != nil { + dfsp := dst.toInt64Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []int64{} + } + } + } + case isPointer: // E.g., *int64 + mfi.merge = func(dst, src pointer) { + sfpp := src.toInt64Ptr() + if *sfpp != nil { + dfpp := dst.toInt64Ptr() + if *dfpp == nil { + *dfpp = Int64(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., int64 + mfi.merge = func(dst, src pointer) { + if v := *src.toInt64(); v != 0 { + *dst.toInt64() = v + } + } + } + case reflect.Uint32: + switch { + case isSlice: // E.g., []uint32 + mfi.merge = func(dst, src pointer) { + sfsp := src.toUint32Slice() + if *sfsp != nil { + dfsp := dst.toUint32Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []uint32{} + } + } + } + case isPointer: // E.g., *uint32 + mfi.merge = func(dst, src pointer) { + sfpp := src.toUint32Ptr() + if *sfpp != nil { + dfpp := dst.toUint32Ptr() + if *dfpp == nil { + *dfpp = Uint32(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., uint32 + mfi.merge = func(dst, src pointer) { + if v := *src.toUint32(); v != 0 { + *dst.toUint32() = v + } + } + } + case reflect.Uint64: + switch { + case isSlice: // E.g., []uint64 + mfi.merge = func(dst, src pointer) { + sfsp := src.toUint64Slice() + if *sfsp != nil { + dfsp := dst.toUint64Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []uint64{} + } + } + } + case isPointer: // E.g., *uint64 + mfi.merge = func(dst, src pointer) { + sfpp := src.toUint64Ptr() + if *sfpp != nil { + dfpp := dst.toUint64Ptr() + if *dfpp == nil { + *dfpp = Uint64(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., uint64 + mfi.merge = func(dst, src pointer) { + if v := *src.toUint64(); v != 0 { + *dst.toUint64() = v + } + } + } + case reflect.Float32: + switch { + case isSlice: // E.g., []float32 + mfi.merge = func(dst, src pointer) { + sfsp := src.toFloat32Slice() + if *sfsp != nil { + dfsp := dst.toFloat32Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []float32{} + } + } + } + case isPointer: // E.g., *float32 + mfi.merge = func(dst, src pointer) { + sfpp := src.toFloat32Ptr() + if *sfpp != nil { + dfpp := dst.toFloat32Ptr() + if *dfpp == nil { + *dfpp = Float32(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., float32 + mfi.merge = func(dst, src pointer) { + if v := *src.toFloat32(); v != 0 { + *dst.toFloat32() = v + } + } + } + case reflect.Float64: + switch { + case isSlice: // E.g., []float64 + mfi.merge = func(dst, src pointer) { + sfsp := src.toFloat64Slice() + if *sfsp != nil { + dfsp := dst.toFloat64Slice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []float64{} + } + } + } + case isPointer: // E.g., *float64 + mfi.merge = func(dst, src pointer) { + sfpp := src.toFloat64Ptr() + if *sfpp != nil { + dfpp := dst.toFloat64Ptr() + if *dfpp == nil { + *dfpp = Float64(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., float64 + mfi.merge = func(dst, src pointer) { + if v := *src.toFloat64(); v != 0 { + *dst.toFloat64() = v + } + } + } + case reflect.Bool: + switch { + case isSlice: // E.g., []bool + mfi.merge = func(dst, src pointer) { + sfsp := src.toBoolSlice() + if *sfsp != nil { + dfsp := dst.toBoolSlice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []bool{} + } + } + } + case isPointer: // E.g., *bool + mfi.merge = func(dst, src pointer) { + sfpp := src.toBoolPtr() + if *sfpp != nil { + dfpp := dst.toBoolPtr() + if *dfpp == nil { + *dfpp = Bool(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., bool + mfi.merge = func(dst, src pointer) { + if v := *src.toBool(); v { + *dst.toBool() = v + } + } + } + case reflect.String: + switch { + case isSlice: // E.g., []string + mfi.merge = func(dst, src pointer) { + sfsp := src.toStringSlice() + if *sfsp != nil { + dfsp := dst.toStringSlice() + *dfsp = append(*dfsp, *sfsp...) + if *dfsp == nil { + *dfsp = []string{} + } + } + } + case isPointer: // E.g., *string + mfi.merge = func(dst, src pointer) { + sfpp := src.toStringPtr() + if *sfpp != nil { + dfpp := dst.toStringPtr() + if *dfpp == nil { + *dfpp = String(**sfpp) + } else { + **dfpp = **sfpp + } + } + } + default: // E.g., string + mfi.merge = func(dst, src pointer) { + if v := *src.toString(); v != "" { + *dst.toString() = v + } + } + } + case reflect.Slice: + isProto3 := props.Prop[i].proto3 + switch { + case isPointer: + panic("bad pointer in byte slice case in " + tf.Name()) + case tf.Elem().Kind() != reflect.Uint8: + panic("bad element kind in byte slice case in " + tf.Name()) + case isSlice: // E.g., [][]byte + mfi.merge = func(dst, src pointer) { + sbsp := src.toBytesSlice() + if *sbsp != nil { + dbsp := dst.toBytesSlice() + for _, sb := range *sbsp { + if sb == nil { + *dbsp = append(*dbsp, nil) + } else { + *dbsp = append(*dbsp, append([]byte{}, sb...)) + } + } + if *dbsp == nil { + *dbsp = [][]byte{} + } + } + } + default: // E.g., []byte + mfi.merge = func(dst, src pointer) { + sbp := src.toBytes() + if *sbp != nil { + dbp := dst.toBytes() + if !isProto3 || len(*sbp) > 0 { + *dbp = append([]byte{}, *sbp...) + } + } + } + } + case reflect.Struct: + switch { + case !isPointer: + mergeInfo := getMergeInfo(tf) + mfi.merge = func(dst, src pointer) { + mergeInfo.merge(dst, src) + } + case isSlice: // E.g., []*pb.T + mergeInfo := getMergeInfo(tf) + mfi.merge = func(dst, src pointer) { + sps := src.getPointerSlice() + if sps != nil { + dps := dst.getPointerSlice() + for _, sp := range sps { + var dp pointer + if !sp.isNil() { + dp = valToPointer(reflect.New(tf)) + mergeInfo.merge(dp, sp) + } + dps = append(dps, dp) + } + if dps == nil { + dps = []pointer{} + } + dst.setPointerSlice(dps) + } + } + default: // E.g., *pb.T + mergeInfo := getMergeInfo(tf) + mfi.merge = func(dst, src pointer) { + sp := src.getPointer() + if !sp.isNil() { + dp := dst.getPointer() + if dp.isNil() { + dp = valToPointer(reflect.New(tf)) + dst.setPointer(dp) + } + mergeInfo.merge(dp, sp) + } + } + } + case reflect.Map: + switch { + case isPointer || isSlice: + panic("bad pointer or slice in map case in " + tf.Name()) + default: // E.g., map[K]V + mfi.merge = func(dst, src pointer) { + sm := src.asPointerTo(tf).Elem() + if sm.Len() == 0 { + return + } + dm := dst.asPointerTo(tf).Elem() + if dm.IsNil() { + dm.Set(reflect.MakeMap(tf)) + } + + switch tf.Elem().Kind() { + case reflect.Ptr: // Proto struct (e.g., *T) + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + val = reflect.ValueOf(Clone(val.Interface().(Message))) + dm.SetMapIndex(key, val) + } + case reflect.Slice: // E.g. Bytes type (e.g., []byte) + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + dm.SetMapIndex(key, val) + } + default: // Basic type (e.g., string) + for _, key := range sm.MapKeys() { + val := sm.MapIndex(key) + dm.SetMapIndex(key, val) + } + } + } + } + case reflect.Interface: + // Must be oneof field. + switch { + case isPointer || isSlice: + panic("bad pointer or slice in interface case in " + tf.Name()) + default: // E.g., interface{} + // TODO: Make this faster? + mfi.merge = func(dst, src pointer) { + su := src.asPointerTo(tf).Elem() + if !su.IsNil() { + du := dst.asPointerTo(tf).Elem() + typ := su.Elem().Type() + if du.IsNil() || du.Elem().Type() != typ { + du.Set(reflect.New(typ.Elem())) // Initialize interface if empty + } + sv := su.Elem().Elem().Field(0) + if sv.Kind() == reflect.Ptr && sv.IsNil() { + return + } + dv := du.Elem().Elem().Field(0) + if dv.Kind() == reflect.Ptr && dv.IsNil() { + dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty + } + switch sv.Type().Kind() { + case reflect.Ptr: // Proto struct (e.g., *T) + Merge(dv.Interface().(Message), sv.Interface().(Message)) + case reflect.Slice: // E.g. Bytes type (e.g., []byte) + dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...))) + default: // Basic type (e.g., string) + dv.Set(sv) + } + } + } + } + default: + panic(fmt.Sprintf("merger not found for type:%s", tf)) + } + mi.fields = append(mi.fields, mfi) + } + + mi.unrecognized = invalidField + if f, ok := t.FieldByName("XXX_unrecognized"); ok { + if f.Type != reflect.TypeOf([]byte{}) { + panic("expected XXX_unrecognized to be of type []byte") + } + mi.unrecognized = toField(&f) + } + + atomic.StoreInt32(&mi.initialized, 1) +} diff --git a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go new file mode 100644 index 00000000000..b6371bb56bd --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go @@ -0,0 +1,2058 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "errors" + "fmt" + "io" + "math" + "reflect" + "strconv" + "strings" + "sync" + "sync/atomic" + "unicode/utf8" +) + +// Unmarshal is the entry point from the generated .pb.go files. +// This function is not intended to be used by non-generated code. +// This function is not subject to any compatibility guarantee. +// msg contains a pointer to a protocol buffer struct. +// b is the data to be unmarshaled into the protocol buffer. +// a is a pointer to a place to store cached unmarshal information. +func (a *InternalMessageInfo) Unmarshal(msg Message, b []byte) error { + // Load the unmarshal information for this message type. + // The atomic load ensures memory consistency. + u := atomicLoadUnmarshalInfo(&a.unmarshal) + if u == nil { + // Slow path: find unmarshal info for msg, update a with it. + u = getUnmarshalInfo(reflect.TypeOf(msg).Elem()) + atomicStoreUnmarshalInfo(&a.unmarshal, u) + } + // Then do the unmarshaling. + err := u.unmarshal(toPointer(&msg), b) + return err +} + +type unmarshalInfo struct { + typ reflect.Type // type of the protobuf struct + + // 0 = only typ field is initialized + // 1 = completely initialized + initialized int32 + lock sync.Mutex // prevents double initialization + dense []unmarshalFieldInfo // fields indexed by tag # + sparse map[uint64]unmarshalFieldInfo // fields indexed by tag # + reqFields []string // names of required fields + reqMask uint64 // 1< 0 { + // Read tag and wire type. + // Special case 1 and 2 byte varints. + var x uint64 + if b[0] < 128 { + x = uint64(b[0]) + b = b[1:] + } else if len(b) >= 2 && b[1] < 128 { + x = uint64(b[0]&0x7f) + uint64(b[1])<<7 + b = b[2:] + } else { + var n int + x, n = decodeVarint(b) + if n == 0 { + return io.ErrUnexpectedEOF + } + b = b[n:] + } + tag := x >> 3 + wire := int(x) & 7 + + // Dispatch on the tag to one of the unmarshal* functions below. + var f unmarshalFieldInfo + if tag < uint64(len(u.dense)) { + f = u.dense[tag] + } else { + f = u.sparse[tag] + } + if fn := f.unmarshal; fn != nil { + var err error + b, err = fn(b, m.offset(f.field), wire) + if err == nil { + reqMask |= f.reqMask + continue + } + if r, ok := err.(*RequiredNotSetError); ok { + // Remember this error, but keep parsing. We need to produce + // a full parse even if a required field is missing. + rnse = r + reqMask |= f.reqMask + continue + } + if err != errInternalBadWireType { + return err + } + // Fragments with bad wire type are treated as unknown fields. + } + + // Unknown tag. + if !u.unrecognized.IsValid() { + // Don't keep unrecognized data; just skip it. + var err error + b, err = skipField(b, wire) + if err != nil { + return err + } + continue + } + // Keep unrecognized data around. + // maybe in extensions, maybe in the unrecognized field. + z := m.offset(u.unrecognized).toBytes() + var emap map[int32]Extension + var e Extension + for _, r := range u.extensionRanges { + if uint64(r.Start) <= tag && tag <= uint64(r.End) { + if u.extensions.IsValid() { + mp := m.offset(u.extensions).toExtensions() + emap = mp.extensionsWrite() + e = emap[int32(tag)] + z = &e.enc + break + } + if u.oldExtensions.IsValid() { + p := m.offset(u.oldExtensions).toOldExtensions() + emap = *p + if emap == nil { + emap = map[int32]Extension{} + *p = emap + } + e = emap[int32(tag)] + z = &e.enc + break + } + if u.bytesExtensions.IsValid() { + z = m.offset(u.bytesExtensions).toBytes() + break + } + panic("no extensions field available") + } + } + // Use wire type to skip data. + var err error + b0 := b + b, err = skipField(b, wire) + if err != nil { + return err + } + *z = encodeVarint(*z, tag<<3|uint64(wire)) + *z = append(*z, b0[:len(b0)-len(b)]...) + + if emap != nil { + emap[int32(tag)] = e + } + } + if rnse != nil { + // A required field of a submessage/group is missing. Return that error. + return rnse + } + if reqMask != u.reqMask { + // A required field of this message is missing. + for _, n := range u.reqFields { + if reqMask&1 == 0 { + return &RequiredNotSetError{n} + } + reqMask >>= 1 + } + } + return nil +} + +// computeUnmarshalInfo fills in u with information for use +// in unmarshaling protocol buffers of type u.typ. +func (u *unmarshalInfo) computeUnmarshalInfo() { + u.lock.Lock() + defer u.lock.Unlock() + if u.initialized != 0 { + return + } + t := u.typ + n := t.NumField() + + // Set up the "not found" value for the unrecognized byte buffer. + // This is the default for proto3. + u.unrecognized = invalidField + u.extensions = invalidField + u.oldExtensions = invalidField + u.bytesExtensions = invalidField + + // List of the generated type and offset for each oneof field. + type oneofField struct { + ityp reflect.Type // interface type of oneof field + field field // offset in containing message + } + var oneofFields []oneofField + + for i := 0; i < n; i++ { + f := t.Field(i) + if f.Name == "XXX_unrecognized" { + // The byte slice used to hold unrecognized input is special. + if f.Type != reflect.TypeOf(([]byte)(nil)) { + panic("bad type for XXX_unrecognized field: " + f.Type.Name()) + } + u.unrecognized = toField(&f) + continue + } + if f.Name == "XXX_InternalExtensions" { + // Ditto here. + if f.Type != reflect.TypeOf(XXX_InternalExtensions{}) { + panic("bad type for XXX_InternalExtensions field: " + f.Type.Name()) + } + u.extensions = toField(&f) + if f.Tag.Get("protobuf_messageset") == "1" { + u.isMessageSet = true + } + continue + } + if f.Name == "XXX_extensions" { + // An older form of the extensions field. + if f.Type == reflect.TypeOf((map[int32]Extension)(nil)) { + u.oldExtensions = toField(&f) + continue + } else if f.Type == reflect.TypeOf(([]byte)(nil)) { + u.bytesExtensions = toField(&f) + continue + } + panic("bad type for XXX_extensions field: " + f.Type.Name()) + } + if f.Name == "XXX_NoUnkeyedLiteral" || f.Name == "XXX_sizecache" { + continue + } + + oneof := f.Tag.Get("protobuf_oneof") + if oneof != "" { + oneofFields = append(oneofFields, oneofField{f.Type, toField(&f)}) + // The rest of oneof processing happens below. + continue + } + + tags := f.Tag.Get("protobuf") + tagArray := strings.Split(tags, ",") + if len(tagArray) < 2 { + panic("protobuf tag not enough fields in " + t.Name() + "." + f.Name + ": " + tags) + } + tag, err := strconv.Atoi(tagArray[1]) + if err != nil { + panic("protobuf tag field not an integer: " + tagArray[1]) + } + + name := "" + for _, tag := range tagArray[3:] { + if strings.HasPrefix(tag, "name=") { + name = tag[5:] + } + } + + // Extract unmarshaling function from the field (its type and tags). + unmarshal := fieldUnmarshaler(&f) + + // Required field? + var reqMask uint64 + if tagArray[2] == "req" { + bit := len(u.reqFields) + u.reqFields = append(u.reqFields, name) + reqMask = uint64(1) << uint(bit) + // TODO: if we have more than 64 required fields, we end up + // not verifying that all required fields are present. + // Fix this, perhaps using a count of required fields? + } + + // Store the info in the correct slot in the message. + u.setTag(tag, toField(&f), unmarshal, reqMask, name) + } + + // Find any types associated with oneof fields. + // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it? + fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs") + // gogo: len(oneofFields) > 0 is needed for embedded oneof messages, without a marshaler and unmarshaler + if fn.IsValid() && len(oneofFields) > 0 { + res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{} + for i := res.Len() - 1; i >= 0; i-- { + v := res.Index(i) // interface{} + tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X + typ := tptr.Elem() // Msg_X + + f := typ.Field(0) // oneof implementers have one field + baseUnmarshal := fieldUnmarshaler(&f) + tags := strings.Split(f.Tag.Get("protobuf"), ",") + fieldNum, err := strconv.Atoi(tags[1]) + if err != nil { + panic("protobuf tag field not an integer: " + tags[1]) + } + var name string + for _, tag := range tags { + if strings.HasPrefix(tag, "name=") { + name = strings.TrimPrefix(tag, "name=") + break + } + } + + // Find the oneof field that this struct implements. + // Might take O(n^2) to process all of the oneofs, but who cares. + for _, of := range oneofFields { + if tptr.Implements(of.ityp) { + // We have found the corresponding interface for this struct. + // That lets us know where this struct should be stored + // when we encounter it during unmarshaling. + unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal) + u.setTag(fieldNum, of.field, unmarshal, 0, name) + } + } + } + } + + // Get extension ranges, if any. + fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") + if fn.IsValid() { + if !u.extensions.IsValid() && !u.oldExtensions.IsValid() && !u.bytesExtensions.IsValid() { + panic("a message with extensions, but no extensions field in " + t.Name()) + } + u.extensionRanges = fn.Call(nil)[0].Interface().([]ExtensionRange) + } + + // Explicitly disallow tag 0. This will ensure we flag an error + // when decoding a buffer of all zeros. Without this code, we + // would decode and skip an all-zero buffer of even length. + // [0 0] is [tag=0/wiretype=varint varint-encoded-0]. + u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) { + return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w) + }, 0, "") + + // Set mask for required field check. + u.reqMask = uint64(1)<= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here? + for len(u.dense) <= tag { + u.dense = append(u.dense, unmarshalFieldInfo{}) + } + u.dense[tag] = i + return + } + if u.sparse == nil { + u.sparse = map[uint64]unmarshalFieldInfo{} + } + u.sparse[uint64(tag)] = i +} + +// fieldUnmarshaler returns an unmarshaler for the given field. +func fieldUnmarshaler(f *reflect.StructField) unmarshaler { + if f.Type.Kind() == reflect.Map { + return makeUnmarshalMap(f) + } + return typeUnmarshaler(f.Type, f.Tag.Get("protobuf")) +} + +// typeUnmarshaler returns an unmarshaler for the given field type / field tag pair. +func typeUnmarshaler(t reflect.Type, tags string) unmarshaler { + tagArray := strings.Split(tags, ",") + encoding := tagArray[0] + name := "unknown" + ctype := false + isTime := false + isDuration := false + for _, tag := range tagArray[3:] { + if strings.HasPrefix(tag, "name=") { + name = tag[5:] + } + if strings.HasPrefix(tag, "customtype=") { + ctype = true + } + if tag == "stdtime" { + isTime = true + } + if tag == "stdduration" { + isDuration = true + } + } + + // Figure out packaging (pointer, slice, or both) + slice := false + pointer := false + if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 { + slice = true + t = t.Elem() + } + if t.Kind() == reflect.Ptr { + pointer = true + t = t.Elem() + } + + if ctype { + if reflect.PtrTo(t).Implements(customType) { + if slice { + return makeUnmarshalCustomSlice(getUnmarshalInfo(t), name) + } + if pointer { + return makeUnmarshalCustomPtr(getUnmarshalInfo(t), name) + } + return makeUnmarshalCustom(getUnmarshalInfo(t), name) + } else { + panic(fmt.Sprintf("custom type: type: %v, does not implement the proto.custom interface", t)) + } + } + + if isTime { + if pointer { + if slice { + return makeUnmarshalTimePtrSlice(getUnmarshalInfo(t), name) + } + return makeUnmarshalTimePtr(getUnmarshalInfo(t), name) + } + if slice { + return makeUnmarshalTimeSlice(getUnmarshalInfo(t), name) + } + return makeUnmarshalTime(getUnmarshalInfo(t), name) + } + + if isDuration { + if pointer { + if slice { + return makeUnmarshalDurationPtrSlice(getUnmarshalInfo(t), name) + } + return makeUnmarshalDurationPtr(getUnmarshalInfo(t), name) + } + if slice { + return makeUnmarshalDurationSlice(getUnmarshalInfo(t), name) + } + return makeUnmarshalDuration(getUnmarshalInfo(t), name) + } + + // We'll never have both pointer and slice for basic types. + if pointer && slice && t.Kind() != reflect.Struct { + panic("both pointer and slice for basic type in " + t.Name()) + } + + switch t.Kind() { + case reflect.Bool: + if pointer { + return unmarshalBoolPtr + } + if slice { + return unmarshalBoolSlice + } + return unmarshalBoolValue + case reflect.Int32: + switch encoding { + case "fixed32": + if pointer { + return unmarshalFixedS32Ptr + } + if slice { + return unmarshalFixedS32Slice + } + return unmarshalFixedS32Value + case "varint": + // this could be int32 or enum + if pointer { + return unmarshalInt32Ptr + } + if slice { + return unmarshalInt32Slice + } + return unmarshalInt32Value + case "zigzag32": + if pointer { + return unmarshalSint32Ptr + } + if slice { + return unmarshalSint32Slice + } + return unmarshalSint32Value + } + case reflect.Int64: + switch encoding { + case "fixed64": + if pointer { + return unmarshalFixedS64Ptr + } + if slice { + return unmarshalFixedS64Slice + } + return unmarshalFixedS64Value + case "varint": + if pointer { + return unmarshalInt64Ptr + } + if slice { + return unmarshalInt64Slice + } + return unmarshalInt64Value + case "zigzag64": + if pointer { + return unmarshalSint64Ptr + } + if slice { + return unmarshalSint64Slice + } + return unmarshalSint64Value + } + case reflect.Uint32: + switch encoding { + case "fixed32": + if pointer { + return unmarshalFixed32Ptr + } + if slice { + return unmarshalFixed32Slice + } + return unmarshalFixed32Value + case "varint": + if pointer { + return unmarshalUint32Ptr + } + if slice { + return unmarshalUint32Slice + } + return unmarshalUint32Value + } + case reflect.Uint64: + switch encoding { + case "fixed64": + if pointer { + return unmarshalFixed64Ptr + } + if slice { + return unmarshalFixed64Slice + } + return unmarshalFixed64Value + case "varint": + if pointer { + return unmarshalUint64Ptr + } + if slice { + return unmarshalUint64Slice + } + return unmarshalUint64Value + } + case reflect.Float32: + if pointer { + return unmarshalFloat32Ptr + } + if slice { + return unmarshalFloat32Slice + } + return unmarshalFloat32Value + case reflect.Float64: + if pointer { + return unmarshalFloat64Ptr + } + if slice { + return unmarshalFloat64Slice + } + return unmarshalFloat64Value + case reflect.Map: + panic("map type in typeUnmarshaler in " + t.Name()) + case reflect.Slice: + if pointer { + panic("bad pointer in slice case in " + t.Name()) + } + if slice { + return unmarshalBytesSlice + } + return unmarshalBytesValue + case reflect.String: + if pointer { + return unmarshalStringPtr + } + if slice { + return unmarshalStringSlice + } + return unmarshalStringValue + case reflect.Struct: + // message or group field + if !pointer { + switch encoding { + case "bytes": + if slice { + return makeUnmarshalMessageSlice(getUnmarshalInfo(t), name) + } + return makeUnmarshalMessage(getUnmarshalInfo(t), name) + } + } + switch encoding { + case "bytes": + if slice { + return makeUnmarshalMessageSlicePtr(getUnmarshalInfo(t), name) + } + return makeUnmarshalMessagePtr(getUnmarshalInfo(t), name) + case "group": + if slice { + return makeUnmarshalGroupSlicePtr(getUnmarshalInfo(t), name) + } + return makeUnmarshalGroupPtr(getUnmarshalInfo(t), name) + } + } + panic(fmt.Sprintf("unmarshaler not found type:%s encoding:%s", t, encoding)) +} + +// Below are all the unmarshalers for individual fields of various types. + +func unmarshalInt64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + *f.toInt64() = v + return b, nil +} + +func unmarshalInt64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + *f.toInt64Ptr() = &v + return b, nil +} + +func unmarshalInt64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + s := f.toInt64Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x) + s := f.toInt64Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalSint64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + *f.toInt64() = v + return b, nil +} + +func unmarshalSint64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + *f.toInt64Ptr() = &v + return b, nil +} + +func unmarshalSint64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + s := f.toInt64Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int64(x>>1) ^ int64(x)<<63>>63 + s := f.toInt64Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalUint64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + *f.toUint64() = v + return b, nil +} + +func unmarshalUint64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + *f.toUint64Ptr() = &v + return b, nil +} + +func unmarshalUint64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + s := f.toUint64Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint64(x) + s := f.toUint64Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalInt32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + *f.toInt32() = v + return b, nil +} + +func unmarshalInt32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + f.setInt32Ptr(v) + return b, nil +} + +func unmarshalInt32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + f.appendInt32Slice(v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x) + f.appendInt32Slice(v) + return b, nil +} + +func unmarshalSint32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + *f.toInt32() = v + return b, nil +} + +func unmarshalSint32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + f.setInt32Ptr(v) + return b, nil +} + +func unmarshalSint32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + f.appendInt32Slice(v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := int32(x>>1) ^ int32(x)<<31>>31 + f.appendInt32Slice(v) + return b, nil +} + +func unmarshalUint32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + *f.toUint32() = v + return b, nil +} + +func unmarshalUint32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + *f.toUint32Ptr() = &v + return b, nil +} + +func unmarshalUint32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + s := f.toUint32Slice() + *s = append(*s, v) + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + v := uint32(x) + s := f.toUint32Slice() + *s = append(*s, v) + return b, nil +} + +func unmarshalFixed64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + *f.toUint64() = v + return b[8:], nil +} + +func unmarshalFixed64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + *f.toUint64Ptr() = &v + return b[8:], nil +} + +func unmarshalFixed64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + s := f.toUint64Slice() + *s = append(*s, v) + b = b[8:] + } + return res, nil + } + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 + s := f.toUint64Slice() + *s = append(*s, v) + return b[8:], nil +} + +func unmarshalFixedS64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + *f.toInt64() = v + return b[8:], nil +} + +func unmarshalFixedS64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + *f.toInt64Ptr() = &v + return b[8:], nil +} + +func unmarshalFixedS64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + s := f.toInt64Slice() + *s = append(*s, v) + b = b[8:] + } + return res, nil + } + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56 + s := f.toInt64Slice() + *s = append(*s, v) + return b[8:], nil +} + +func unmarshalFixed32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + *f.toUint32() = v + return b[4:], nil +} + +func unmarshalFixed32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + *f.toUint32Ptr() = &v + return b[4:], nil +} + +func unmarshalFixed32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + s := f.toUint32Slice() + *s = append(*s, v) + b = b[4:] + } + return res, nil + } + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 + s := f.toUint32Slice() + *s = append(*s, v) + return b[4:], nil +} + +func unmarshalFixedS32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + *f.toInt32() = v + return b[4:], nil +} + +func unmarshalFixedS32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + f.setInt32Ptr(v) + return b[4:], nil +} + +func unmarshalFixedS32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + f.appendInt32Slice(v) + b = b[4:] + } + return res, nil + } + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24 + f.appendInt32Slice(v) + return b[4:], nil +} + +func unmarshalBoolValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + // Note: any length varint is allowed, even though any sane + // encoder will use one byte. + // See https://github.com/golang/protobuf/issues/76 + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + // TODO: check if x>1? Tests seem to indicate no. + v := x != 0 + *f.toBool() = v + return b[n:], nil +} + +func unmarshalBoolPtr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + v := x != 0 + *f.toBoolPtr() = &v + return b[n:], nil +} + +func unmarshalBoolSlice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + x, n = decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + v := x != 0 + s := f.toBoolSlice() + *s = append(*s, v) + b = b[n:] + } + return res, nil + } + if w != WireVarint { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + v := x != 0 + s := f.toBoolSlice() + *s = append(*s, v) + return b[n:], nil +} + +func unmarshalFloat64Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + *f.toFloat64() = v + return b[8:], nil +} + +func unmarshalFloat64Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + *f.toFloat64Ptr() = &v + return b[8:], nil +} + +func unmarshalFloat64Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + s := f.toFloat64Slice() + *s = append(*s, v) + b = b[8:] + } + return res, nil + } + if w != WireFixed64 { + return b, errInternalBadWireType + } + if len(b) < 8 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56) + s := f.toFloat64Slice() + *s = append(*s, v) + return b[8:], nil +} + +func unmarshalFloat32Value(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + *f.toFloat32() = v + return b[4:], nil +} + +func unmarshalFloat32Ptr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + *f.toFloat32Ptr() = &v + return b[4:], nil +} + +func unmarshalFloat32Slice(b []byte, f pointer, w int) ([]byte, error) { + if w == WireBytes { // packed + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + res := b[x:] + b = b[:x] + for len(b) > 0 { + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + s := f.toFloat32Slice() + *s = append(*s, v) + b = b[4:] + } + return res, nil + } + if w != WireFixed32 { + return b, errInternalBadWireType + } + if len(b) < 4 { + return nil, io.ErrUnexpectedEOF + } + v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + s := f.toFloat32Slice() + *s = append(*s, v) + return b[4:], nil +} + +func unmarshalStringValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + *f.toString() = v + return b[x:], nil +} + +func unmarshalStringPtr(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + *f.toStringPtr() = &v + return b[x:], nil +} + +func unmarshalStringSlice(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := string(b[:x]) + if !utf8.ValidString(v) { + return nil, errInvalidUTF8 + } + s := f.toStringSlice() + *s = append(*s, v) + return b[x:], nil +} + +var emptyBuf [0]byte + +func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + // The use of append here is a trick which avoids the zeroing + // that would be required if we used a make/copy pair. + // We append to emptyBuf instead of nil because we want + // a non-nil result even when the length is 0. + v := append(emptyBuf[:], b[:x]...) + *f.toBytes() = v + return b[x:], nil +} + +func unmarshalBytesSlice(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := append(emptyBuf[:], b[:x]...) + s := f.toBytesSlice() + *s = append(*s, v) + return b[x:], nil +} + +func makeUnmarshalMessagePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + // First read the message field to see if something is there. + // The semantics of multiple submessages are weird. Instead of + // the last one winning (as it is for all other fields), multiple + // submessages are merged. + v := f.getPointer() + if v.isNil() { + v = valToPointer(reflect.New(sub.typ)) + f.setPointer(v) + } + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + return b[x:], err + } +} + +func makeUnmarshalMessageSlicePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return b, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := valToPointer(reflect.New(sub.typ)) + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + f.appendPointer(v) + return b[x:], err + } +} + +func makeUnmarshalGroupPtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireStartGroup { + return b, errInternalBadWireType + } + x, y := findEndGroup(b) + if x < 0 { + return nil, io.ErrUnexpectedEOF + } + v := f.getPointer() + if v.isNil() { + v = valToPointer(reflect.New(sub.typ)) + f.setPointer(v) + } + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + return b[y:], err + } +} + +func makeUnmarshalGroupSlicePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireStartGroup { + return b, errInternalBadWireType + } + x, y := findEndGroup(b) + if x < 0 { + return nil, io.ErrUnexpectedEOF + } + v := valToPointer(reflect.New(sub.typ)) + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + f.appendPointer(v) + return b[y:], err + } +} + +func makeUnmarshalMap(f *reflect.StructField) unmarshaler { + t := f.Type + kt := t.Key() + vt := t.Elem() + tagArray := strings.Split(f.Tag.Get("protobuf"), ",") + valTags := strings.Split(f.Tag.Get("protobuf_val"), ",") + for _, t := range tagArray { + if strings.HasPrefix(t, "customtype=") { + valTags = append(valTags, t) + } + if t == "stdtime" { + valTags = append(valTags, t) + } + if t == "stdduration" { + valTags = append(valTags, t) + } + } + unmarshalKey := typeUnmarshaler(kt, f.Tag.Get("protobuf_key")) + unmarshalVal := typeUnmarshaler(vt, strings.Join(valTags, ",")) + return func(b []byte, f pointer, w int) ([]byte, error) { + // The map entry is a submessage. Figure out how big it is. + if w != WireBytes { + return nil, fmt.Errorf("proto: bad wiretype for map field: got %d want %d", w, WireBytes) + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + r := b[x:] // unused data to return + b = b[:x] // data for map entry + + // Note: we could use #keys * #values ~= 200 functions + // to do map decoding without reflection. Probably not worth it. + // Maps will be somewhat slow. Oh well. + + // Read key and value from data. + k := reflect.New(kt) + v := reflect.New(vt) + for len(b) > 0 { + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + wire := int(x) & 7 + b = b[n:] + + var err error + switch x >> 3 { + case 1: + b, err = unmarshalKey(b, valToPointer(k), wire) + case 2: + b, err = unmarshalVal(b, valToPointer(v), wire) + default: + err = errInternalBadWireType // skip unknown tag + } + + if err == nil { + continue + } + if err != errInternalBadWireType { + return nil, err + } + + // Skip past unknown fields. + b, err = skipField(b, wire) + if err != nil { + return nil, err + } + } + + // Get map, allocate if needed. + m := f.asPointerTo(t).Elem() // an addressable map[K]T + if m.IsNil() { + m.Set(reflect.MakeMap(t)) + } + + // Insert into map. + m.SetMapIndex(k.Elem(), v.Elem()) + + return r, nil + } +} + +// makeUnmarshalOneof makes an unmarshaler for oneof fields. +// for: +// message Msg { +// oneof F { +// int64 X = 1; +// float64 Y = 2; +// } +// } +// typ is the type of the concrete entry for a oneof case (e.g. Msg_X). +// ityp is the interface type of the oneof field (e.g. isMsg_F). +// unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64). +// Note that this function will be called once for each case in the oneof. +func makeUnmarshalOneof(typ, ityp reflect.Type, unmarshal unmarshaler) unmarshaler { + sf := typ.Field(0) + field0 := toField(&sf) + return func(b []byte, f pointer, w int) ([]byte, error) { + // Allocate holder for value. + v := reflect.New(typ) + + // Unmarshal data into holder. + // We unmarshal into the first field of the holder object. + var err error + b, err = unmarshal(b, valToPointer(v).offset(field0), w) + if err != nil { + return nil, err + } + + // Write pointer to holder into target field. + f.asPointerTo(ityp).Elem().Set(v) + + return b, nil + } +} + +// Error used by decode internally. +var errInternalBadWireType = errors.New("proto: internal error: bad wiretype") + +// skipField skips past a field of type wire and returns the remaining bytes. +func skipField(b []byte, wire int) ([]byte, error) { + switch wire { + case WireVarint: + _, k := decodeVarint(b) + if k == 0 { + return b, io.ErrUnexpectedEOF + } + b = b[k:] + case WireFixed32: + if len(b) < 4 { + return b, io.ErrUnexpectedEOF + } + b = b[4:] + case WireFixed64: + if len(b) < 8 { + return b, io.ErrUnexpectedEOF + } + b = b[8:] + case WireBytes: + m, k := decodeVarint(b) + if k == 0 || uint64(len(b)-k) < m { + return b, io.ErrUnexpectedEOF + } + b = b[uint64(k)+m:] + case WireStartGroup: + _, i := findEndGroup(b) + if i == -1 { + return b, io.ErrUnexpectedEOF + } + b = b[i:] + default: + return b, fmt.Errorf("proto: can't skip unknown wire type %d", wire) + } + return b, nil +} + +// findEndGroup finds the index of the next EndGroup tag. +// Groups may be nested, so the "next" EndGroup tag is the first +// unpaired EndGroup. +// findEndGroup returns the indexes of the start and end of the EndGroup tag. +// Returns (-1,-1) if it can't find one. +func findEndGroup(b []byte) (int, int) { + depth := 1 + i := 0 + for { + x, n := decodeVarint(b[i:]) + if n == 0 { + return -1, -1 + } + j := i + i += n + switch x & 7 { + case WireVarint: + _, k := decodeVarint(b[i:]) + if k == 0 { + return -1, -1 + } + i += k + case WireFixed32: + if len(b)-4 < i { + return -1, -1 + } + i += 4 + case WireFixed64: + if len(b)-8 < i { + return -1, -1 + } + i += 8 + case WireBytes: + m, k := decodeVarint(b[i:]) + if k == 0 { + return -1, -1 + } + i += k + if uint64(len(b)-i) < m { + return -1, -1 + } + i += int(m) + case WireStartGroup: + depth++ + case WireEndGroup: + depth-- + if depth == 0 { + return j, i + } + default: + return -1, -1 + } + } +} + +// encodeVarint appends a varint-encoded integer to b and returns the result. +func encodeVarint(b []byte, x uint64) []byte { + for x >= 1<<7 { + b = append(b, byte(x&0x7f|0x80)) + x >>= 7 + } + return append(b, byte(x)) +} + +// decodeVarint reads a varint-encoded integer from b. +// Returns the decoded integer and the number of bytes read. +// If there is an error, it returns 0,0. +func decodeVarint(b []byte) (uint64, int) { + var x, y uint64 + if len(b) <= 0 { + goto bad + } + x = uint64(b[0]) + if x < 0x80 { + return x, 1 + } + x -= 0x80 + + if len(b) <= 1 { + goto bad + } + y = uint64(b[1]) + x += y << 7 + if y < 0x80 { + return x, 2 + } + x -= 0x80 << 7 + + if len(b) <= 2 { + goto bad + } + y = uint64(b[2]) + x += y << 14 + if y < 0x80 { + return x, 3 + } + x -= 0x80 << 14 + + if len(b) <= 3 { + goto bad + } + y = uint64(b[3]) + x += y << 21 + if y < 0x80 { + return x, 4 + } + x -= 0x80 << 21 + + if len(b) <= 4 { + goto bad + } + y = uint64(b[4]) + x += y << 28 + if y < 0x80 { + return x, 5 + } + x -= 0x80 << 28 + + if len(b) <= 5 { + goto bad + } + y = uint64(b[5]) + x += y << 35 + if y < 0x80 { + return x, 6 + } + x -= 0x80 << 35 + + if len(b) <= 6 { + goto bad + } + y = uint64(b[6]) + x += y << 42 + if y < 0x80 { + return x, 7 + } + x -= 0x80 << 42 + + if len(b) <= 7 { + goto bad + } + y = uint64(b[7]) + x += y << 49 + if y < 0x80 { + return x, 8 + } + x -= 0x80 << 49 + + if len(b) <= 8 { + goto bad + } + y = uint64(b[8]) + x += y << 56 + if y < 0x80 { + return x, 9 + } + x -= 0x80 << 56 + + if len(b) <= 9 { + goto bad + } + y = uint64(b[9]) + x += y << 63 + if y < 2 { + return x, 10 + } + +bad: + return 0, 0 +} diff --git a/vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go b/vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go new file mode 100644 index 00000000000..00d6c7ad937 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go @@ -0,0 +1,385 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "io" + "reflect" +) + +func makeUnmarshalMessage(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + // First read the message field to see if something is there. + // The semantics of multiple submessages are weird. Instead of + // the last one winning (as it is for all other fields), multiple + // submessages are merged. + v := f // gogo: changed from v := f.getPointer() + if v.isNil() { + v = valToPointer(reflect.New(sub.typ)) + f.setPointer(v) + } + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + return b[x:], err + } +} + +func makeUnmarshalMessageSlice(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + v := valToPointer(reflect.New(sub.typ)) + err := sub.unmarshal(v, b[:x]) + if err != nil { + if r, ok := err.(*RequiredNotSetError); ok { + r.field = name + "." + r.field + } else { + return nil, err + } + } + f.appendRef(v, sub.typ) // gogo: changed from f.appendPointer(v) + return b[x:], err + } +} + +func makeUnmarshalCustomPtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.New(sub.typ)) + m := s.Interface().(custom) + if err := m.Unmarshal(b[:x]); err != nil { + return nil, err + } + return b[x:], nil + } +} + +func makeUnmarshalCustomSlice(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := reflect.New(sub.typ) + c := m.Interface().(custom) + if err := c.Unmarshal(b[:x]); err != nil { + return nil, err + } + v := valToPointer(m) + f.appendRef(v, sub.typ) + return b[x:], nil + } +} + +func makeUnmarshalCustom(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + + m := f.asPointerTo(sub.typ).Interface().(custom) + if err := m.Unmarshal(b[:x]); err != nil { + return nil, err + } + return b[x:], nil + } +} + +func makeUnmarshalTime(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := ×tamp{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + t, err := timestampFromProto(m) + if err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(t)) + return b[x:], nil + } +} + +func makeUnmarshalTimePtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := ×tamp{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + t, err := timestampFromProto(m) + if err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&t)) + return b[x:], nil + } +} + +func makeUnmarshalTimePtrSlice(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := ×tamp{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + t, err := timestampFromProto(m) + if err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&t)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeUnmarshalTimeSlice(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := ×tamp{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + t, err := timestampFromProto(m) + if err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(t)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeUnmarshalDurationPtr(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &duration{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + d, err := durationFromProto(m) + if err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&d)) + return b[x:], nil + } +} + +func makeUnmarshalDuration(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &duration{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + d, err := durationFromProto(m) + if err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(d)) + return b[x:], nil + } +} + +func makeUnmarshalDurationPtrSlice(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &duration{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + d, err := durationFromProto(m) + if err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&d)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeUnmarshalDurationSlice(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &duration{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + d, err := durationFromProto(m) + if err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(d)) + slice.Set(newSlice) + return b[x:], nil + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/text.go b/vendor/github.com/gogo/protobuf/proto/text.go index 9a0490956b1..4f5706dc5f3 100644 --- a/vendor/github.com/gogo/protobuf/proto/text.go +++ b/vendor/github.com/gogo/protobuf/proto/text.go @@ -1,7 +1,7 @@ -// Extensions for Protocol Buffers to create more go like structures. +// Protocol Buffers for Go with Gadgets // -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Go support for Protocol Buffers - Google's data interchange format // @@ -50,12 +50,13 @@ import ( "reflect" "sort" "strings" + "sync" + "time" ) var ( newline = []byte("\n") spaces = []byte(" ") - gtNewline = []byte(">\n") endBraceNewline = []byte("}\n") backslashN = []byte{'\\', 'n'} backslashR = []byte{'\\', 'r'} @@ -175,12 +176,93 @@ func writeName(w *textWriter, props *Properties) error { return nil } -// raw is the interface satisfied by RawMessage. -type raw interface { - Bytes() []byte +func requiresQuotes(u string) bool { + // When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted. + for _, ch := range u { + switch { + case ch == '.' || ch == '/' || ch == '_': + continue + case '0' <= ch && ch <= '9': + continue + case 'A' <= ch && ch <= 'Z': + continue + case 'a' <= ch && ch <= 'z': + continue + default: + return true + } + } + return false +} + +// isAny reports whether sv is a google.protobuf.Any message +func isAny(sv reflect.Value) bool { + type wkt interface { + XXX_WellKnownType() string + } + t, ok := sv.Addr().Interface().(wkt) + return ok && t.XXX_WellKnownType() == "Any" } -func writeStruct(w *textWriter, sv reflect.Value) error { +// writeProto3Any writes an expanded google.protobuf.Any message. +// +// It returns (false, nil) if sv value can't be unmarshaled (e.g. because +// required messages are not linked in). +// +// It returns (true, error) when sv was written in expanded format or an error +// was encountered. +func (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) { + turl := sv.FieldByName("TypeUrl") + val := sv.FieldByName("Value") + if !turl.IsValid() || !val.IsValid() { + return true, errors.New("proto: invalid google.protobuf.Any message") + } + + b, ok := val.Interface().([]byte) + if !ok { + return true, errors.New("proto: invalid google.protobuf.Any message") + } + + parts := strings.Split(turl.String(), "/") + mt := MessageType(parts[len(parts)-1]) + if mt == nil { + return false, nil + } + m := reflect.New(mt.Elem()) + if err := Unmarshal(b, m.Interface().(Message)); err != nil { + return false, nil + } + w.Write([]byte("[")) + u := turl.String() + if requiresQuotes(u) { + writeString(w, u) + } else { + w.Write([]byte(u)) + } + if w.compact { + w.Write([]byte("]:<")) + } else { + w.Write([]byte("]: <\n")) + w.ind++ + } + if err := tm.writeStruct(w, m.Elem()); err != nil { + return true, err + } + if w.compact { + w.Write([]byte("> ")) + } else { + w.ind-- + w.Write([]byte(">\n")) + } + return true, nil +} + +func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { + if tm.ExpandAny && isAny(sv) { + if canExpand, err := tm.writeProto3Any(w, sv); canExpand { + return err + } + } st := sv.Type() sprops := GetProperties(st) for i := 0; i < sv.NumField(); i++ { @@ -188,6 +270,10 @@ func writeStruct(w *textWriter, sv reflect.Value) error { props := sprops.Prop[i] name := st.Field(i).Name + if name == "XXX_NoUnkeyedLiteral" { + continue + } + if strings.HasPrefix(name, "XXX_") { // There are two XXX_ fields: // XXX_unrecognized []byte @@ -233,10 +319,10 @@ func writeStruct(w *textWriter, sv reflect.Value) error { continue } if len(props.Enum) > 0 { - if err := writeEnum(w, v, props); err != nil { + if err := tm.writeEnum(w, v, props); err != nil { return err } - } else if err := writeAny(w, v, props); err != nil { + } else if err := tm.writeAny(w, v, props); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -278,7 +364,7 @@ func writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if err := writeAny(w, key, props.mkeyprop); err != nil { + if err := tm.writeAny(w, key, props.mkeyprop); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -295,7 +381,7 @@ func writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if err := writeAny(w, val, props.mvalprop); err != nil { + if err := tm.writeAny(w, val, props.mvalprop); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -359,18 +445,12 @@ func writeStruct(w *textWriter, sv reflect.Value) error { return err } } - if b, ok := fv.Interface().(raw); ok { - if err := writeRaw(w, b.Bytes()); err != nil { - return err - } - continue - } if len(props.Enum) > 0 { - if err := writeEnum(w, fv, props); err != nil { + if err := tm.writeEnum(w, fv, props); err != nil { return err } - } else if err := writeAny(w, fv, props); err != nil { + } else if err := tm.writeAny(w, fv, props); err != nil { return err } @@ -387,8 +467,8 @@ func writeStruct(w *textWriter, sv reflect.Value) error { pv = reflect.New(sv.Type()) pv.Elem().Set(sv) } - if pv.Type().Implements(extendableProtoType) { - if err := writeExtensions(w, pv); err != nil { + if _, err := extendable(pv.Interface()); err == nil { + if err := tm.writeExtensions(w, pv); err != nil { return err } } @@ -396,42 +476,57 @@ func writeStruct(w *textWriter, sv reflect.Value) error { return nil } -// writeRaw writes an uninterpreted raw message. -func writeRaw(w *textWriter, b []byte) error { - if err := w.WriteByte('<'); err != nil { - return err - } - if !w.compact { - if err := w.WriteByte('\n'); err != nil { - return err - } - } - w.indent() - if err := writeUnknownStruct(w, b); err != nil { - return err - } - w.unindent() - if err := w.WriteByte('>'); err != nil { - return err - } - return nil -} - // writeAny writes an arbitrary field. -func writeAny(w *textWriter, v reflect.Value, props *Properties) error { +func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error { v = reflect.Indirect(v) - if props != nil && len(props.CustomType) > 0 { - custom, ok := v.Interface().(Marshaler) - if ok { - data, err := custom.Marshal() + if props != nil { + if len(props.CustomType) > 0 { + custom, ok := v.Interface().(Marshaler) + if ok { + data, err := custom.Marshal() + if err != nil { + return err + } + if err := writeString(w, string(data)); err != nil { + return err + } + return nil + } + } else if len(props.CastType) > 0 { + if _, ok := v.Interface().(interface { + String() string + }); ok { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + _, err := fmt.Fprintf(w, "%d", v.Interface()) + return err + } + } + } else if props.StdTime { + t, ok := v.Interface().(time.Time) + if !ok { + return fmt.Errorf("stdtime is not time.Time, but %T", v.Interface()) + } + tproto, err := timestampProto(t) if err != nil { return err } - if err := writeString(w, string(data)); err != nil { - return err + propsCopy := *props // Make a copy so that this is goroutine-safe + propsCopy.StdTime = false + err = tm.writeAny(w, reflect.ValueOf(tproto), &propsCopy) + return err + } else if props.StdDuration { + d, ok := v.Interface().(time.Duration) + if !ok { + return fmt.Errorf("stdtime is not time.Duration, but %T", v.Interface()) } - return nil + dproto := durationProto(d) + propsCopy := *props // Make a copy so that this is goroutine-safe + propsCopy.StdDuration = false + err := tm.writeAny(w, reflect.ValueOf(dproto), &propsCopy) + return err } } @@ -481,16 +576,34 @@ func writeAny(w *textWriter, v reflect.Value, props *Properties) error { } } w.indent() - if tm, ok := v.Interface().(encoding.TextMarshaler); ok { - text, err := tm.MarshalText() + if v.CanAddr() { + // Calling v.Interface on a struct causes the reflect package to + // copy the entire struct. This is racy with the new Marshaler + // since we atomically update the XXX_sizecache. + // + // Thus, we retrieve a pointer to the struct if possible to avoid + // a race since v.Interface on the pointer doesn't copy the struct. + // + // If v is not addressable, then we are not worried about a race + // since it implies that the binary Marshaler cannot possibly be + // mutating this value. + v = v.Addr() + } + if etm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := etm.MarshalText() if err != nil { return err } if _, err = w.Write(text); err != nil { return err } - } else if err := writeStruct(w, v); err != nil { - return err + } else { + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if err := tm.writeStruct(w, v); err != nil { + return err + } } w.unindent() if err := w.WriteByte(ket); err != nil { @@ -633,30 +746,39 @@ func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } // writeExtensions writes all the extensions in pv. // pv is assumed to be a pointer to a protocol message struct that is extendable. -func writeExtensions(w *textWriter, pv reflect.Value) error { +func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error { emap := extensionMaps[pv.Type().Elem()] - ep := pv.Interface().(extendableProto) + e := pv.Interface().(Message) - // Order the extensions by ID. - // This isn't strictly necessary, but it will give us - // canonical output, which will also make testing easier. var m map[int32]Extension - if em, ok := ep.(extensionsMap); ok { - m = em.ExtensionMap() - } else if em, ok := ep.(extensionsBytes); ok { + var mu sync.Locker + if em, ok := e.(extensionsBytes); ok { eb := em.GetExtensions() var err error m, err = BytesToExtensionsMap(*eb) if err != nil { return err } + mu = notLocker{} + } else if _, ok := e.(extendableProto); ok { + ep, _ := extendable(e) + m, mu = ep.extensionsRead() + if m == nil { + return nil + } } + // Order the extensions by ID. + // This isn't strictly necessary, but it will give us + // canonical output, which will also make testing easier. + + mu.Lock() ids := make([]int32, 0, len(m)) for id := range m { ids = append(ids, id) } sort.Sort(int32Slice(ids)) + mu.Unlock() for _, extNum := range ids { ext := m[extNum] @@ -672,20 +794,20 @@ func writeExtensions(w *textWriter, pv reflect.Value) error { continue } - pb, err := GetExtension(ep, desc) + pb, err := GetExtension(e, desc) if err != nil { return fmt.Errorf("failed getting extension: %v", err) } // Repeated extensions will appear as a slice. if !desc.repeated() { - if err := writeExtension(w, desc.Name, pb); err != nil { + if err := tm.writeExtension(w, desc.Name, pb); err != nil { return err } } else { v := reflect.ValueOf(pb) for i := 0; i < v.Len(); i++ { - if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + if err := tm.writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { return err } } @@ -694,7 +816,7 @@ func writeExtensions(w *textWriter, pv reflect.Value) error { return nil } -func writeExtension(w *textWriter, name string, pb interface{}) error { +func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error { if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { return err } @@ -703,7 +825,7 @@ func writeExtension(w *textWriter, name string, pb interface{}) error { return err } } - if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil { + if err := tm.writeAny(w, reflect.ValueOf(pb), nil); err != nil { return err } if err := w.WriteByte('\n'); err != nil { @@ -730,12 +852,13 @@ func (w *textWriter) writeIndent() { // TextMarshaler is a configurable text format marshaler. type TextMarshaler struct { - Compact bool // use compact text format (one line). + Compact bool // use compact text format (one line). + ExpandAny bool // expand google.protobuf.Any messages of known types } // Marshal writes a given protocol buffer in text format. // The only errors returned are from w. -func (m *TextMarshaler) Marshal(w io.Writer, pb Message) error { +func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error { val := reflect.ValueOf(pb) if pb == nil || val.IsNil() { w.Write([]byte("")) @@ -750,11 +873,11 @@ func (m *TextMarshaler) Marshal(w io.Writer, pb Message) error { aw := &textWriter{ w: ww, complete: true, - compact: m.Compact, + compact: tm.Compact, } - if tm, ok := pb.(encoding.TextMarshaler); ok { - text, err := tm.MarshalText() + if etm, ok := pb.(encoding.TextMarshaler); ok { + text, err := etm.MarshalText() if err != nil { return err } @@ -768,7 +891,7 @@ func (m *TextMarshaler) Marshal(w io.Writer, pb Message) error { } // Dereference the received pointer so we don't have outer < and >. v := reflect.Indirect(val) - if err := writeStruct(aw, v); err != nil { + if err := tm.writeStruct(aw, v); err != nil { return err } if bw != nil { @@ -778,9 +901,9 @@ func (m *TextMarshaler) Marshal(w io.Writer, pb Message) error { } // Text is the same as Marshal, but returns the string directly. -func (m *TextMarshaler) Text(pb Message) string { +func (tm *TextMarshaler) Text(pb Message) string { var buf bytes.Buffer - m.Marshal(&buf, pb) + tm.Marshal(&buf, pb) return buf.String() } diff --git a/vendor/github.com/gogo/protobuf/proto/text_gogo.go b/vendor/github.com/gogo/protobuf/proto/text_gogo.go index cdb23373c39..1d6c6aa0e41 100644 --- a/vendor/github.com/gogo/protobuf/proto/text_gogo.go +++ b/vendor/github.com/gogo/protobuf/proto/text_gogo.go @@ -1,5 +1,7 @@ -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -31,10 +33,10 @@ import ( "reflect" ) -func writeEnum(w *textWriter, v reflect.Value, props *Properties) error { +func (tm *TextMarshaler) writeEnum(w *textWriter, v reflect.Value, props *Properties) error { m, ok := enumStringMaps[props.Enum] if !ok { - if err := writeAny(w, v, props); err != nil { + if err := tm.writeAny(w, v, props); err != nil { return err } } @@ -46,7 +48,7 @@ func writeEnum(w *textWriter, v reflect.Value, props *Properties) error { } s, ok := m[key] if !ok { - if err := writeAny(w, v, props); err != nil { + if err := tm.writeAny(w, v, props); err != nil { return err } } diff --git a/vendor/github.com/gogo/protobuf/proto/text_parser.go b/vendor/github.com/gogo/protobuf/proto/text_parser.go index 2940578b4ae..fbb000d3742 100644 --- a/vendor/github.com/gogo/protobuf/proto/text_parser.go +++ b/vendor/github.com/gogo/protobuf/proto/text_parser.go @@ -1,7 +1,7 @@ -// Extensions for Protocol Buffers to create more go like structures. +// Protocol Buffers for Go with Gadgets // -// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. -// http://github.com/gogo/protobuf/gogoproto +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf // // Go support for Protocol Buffers - Google's data interchange format // @@ -46,9 +46,13 @@ import ( "reflect" "strconv" "strings" + "time" "unicode/utf8" ) +// Error string emitted when deserializing Any and fields are already set +const anyRepeatedlyUnpacked = "Any message unpacked multiple times, or %q already set" + type ParseError struct { Message string Line int // 1-based line number @@ -168,7 +172,7 @@ func (p *textParser) advance() { p.cur.offset, p.cur.line = p.offset, p.line p.cur.unquoted = "" switch p.s[0] { - case '<', '>', '{', '}', ':', '[', ']', ';', ',': + case '<', '>', '{', '}', ':', '[', ']', ';', ',', '/': // Single symbol p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] case '"', '\'': @@ -208,7 +212,6 @@ func (p *textParser) advance() { var ( errBadUTF8 = errors.New("proto: bad UTF-8") - errBadHex = errors.New("proto: bad hexadecimal") ) func unquoteC(s string, quote rune) (string, error) { @@ -279,60 +282,47 @@ func unescape(s string) (ch string, tail string, err error) { return "?", s, nil // trigraph workaround case '\'', '"', '\\': return string(r), s, nil - case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + case '0', '1', '2', '3', '4', '5', '6', '7': if len(s) < 2 { return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) } - base := 8 - ss := s[:2] + ss := string(r) + s[:2] s = s[2:] - if r == 'x' || r == 'X' { - base = 16 - } else { - ss = string(r) + ss - } - i, err := strconv.ParseUint(ss, base, 8) + i, err := strconv.ParseUint(ss, 8, 8) if err != nil { - return "", "", err + return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss) } return string([]byte{byte(i)}), s, nil - case 'u', 'U': - n := 4 - if r == 'U' { + case 'x', 'X', 'u', 'U': + var n int + switch r { + case 'x', 'X': + n = 2 + case 'u': + n = 4 + case 'U': n = 8 } if len(s) < n { - return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) - } - - bs := make([]byte, n/2) - for i := 0; i < n; i += 2 { - a, ok1 := unhex(s[i]) - b, ok2 := unhex(s[i+1]) - if !ok1 || !ok2 { - return "", "", errBadHex - } - bs[i/2] = a<<4 | b + return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n) } + ss := s[:n] s = s[n:] - return string(bs), s, nil + i, err := strconv.ParseUint(ss, 16, 64) + if err != nil { + return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss) + } + if r == 'x' || r == 'X' { + return string([]byte{byte(i)}), s, nil + } + if i > utf8.MaxRune { + return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss) + } + return string(i), s, nil } return "", "", fmt.Errorf(`unknown escape \%c`, r) } -// Adapted from src/pkg/strconv/quote.go. -func unhex(b byte) (v byte, ok bool) { - switch { - case '0' <= b && b <= '9': - return b - '0', true - case 'a' <= b && b <= 'f': - return b - 'a' + 10, true - case 'A' <= b && b <= 'F': - return b - 'A' + 10, true - } - return 0, false -} - // Back off the parser by one token. Can only be done between calls to next(). // It makes the next advance() a no-op. func (p *textParser) back() { p.backed = true } @@ -456,7 +446,10 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { fieldSet := make(map[string]bool) // A struct is a sequence of "name: value", terminated by one of // '>' or '}', or the end of the input. A name may also be - // "[extension]". + // "[extension]" or "[type/url]". + // + // The whole struct can also be an expanded Any message, like: + // [type/url] < ... struct contents ... > for { tok := p.next() if tok.err != nil { @@ -466,33 +459,74 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { break } if tok.value == "[" { - // Looks like an extension. + // Looks like an extension or an Any. // // TODO: Check whether we need to handle // namespace rooted names (e.g. ".something.Foo"). - tok = p.next() - if tok.err != nil { - return tok.err + extName, err := p.consumeExtName() + if err != nil { + return err + } + + if s := strings.LastIndex(extName, "/"); s >= 0 { + // If it contains a slash, it's an Any type URL. + messageName := extName[s+1:] + mt := MessageType(messageName) + if mt == nil { + return p.errorf("unrecognized message %q in google.protobuf.Any", messageName) + } + tok = p.next() + if tok.err != nil { + return tok.err + } + // consume an optional colon + if tok.value == ":" { + tok = p.next() + if tok.err != nil { + return tok.err + } + } + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + v := reflect.New(mt.Elem()) + if pe := p.readStruct(v.Elem(), terminator); pe != nil { + return pe + } + b, err := Marshal(v.Interface().(Message)) + if err != nil { + return p.errorf("failed to marshal message of type %q: %v", messageName, err) + } + if fieldSet["type_url"] { + return p.errorf(anyRepeatedlyUnpacked, "type_url") + } + if fieldSet["value"] { + return p.errorf(anyRepeatedlyUnpacked, "value") + } + sv.FieldByName("TypeUrl").SetString(extName) + sv.FieldByName("Value").SetBytes(b) + fieldSet["type_url"] = true + fieldSet["value"] = true + continue } + var desc *ExtensionDesc // This could be faster, but it's functional. // TODO: Do something smarter than a linear scan. for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { - if d.Name == tok.value { + if d.Name == extName { desc = d break } } if desc == nil { - return p.errorf("unrecognized extension %q", tok.value) - } - // Check the extension terminator. - tok = p.next() - if tok.err != nil { - return tok.err - } - if tok.value != "]" { - return p.errorf("unrecognized extension terminator %q", tok.value) + return p.errorf("unrecognized extension %q", extName) } props := &Properties{} @@ -519,7 +553,7 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { } reqFieldErr = err } - ep := sv.Addr().Interface().(extendableProto) + ep := sv.Addr().Interface().(Message) if !rep { SetExtension(ep, desc, ext.Interface()) } else { @@ -550,7 +584,11 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { props = oop.Prop nv := reflect.New(oop.Type.Elem()) dst = nv.Elem().Field(0) - sv.Field(oop.Field).Set(nv) + field := sv.Field(oop.Field) + if !field.IsNil() { + return p.errorf("field '%s' would overwrite already parsed oneof '%s'", name, sv.Type().Field(oop.Field).Name) + } + field.Set(nv) } if !dst.IsValid() { return p.errorf("unknown field name %q in %v", name, st) @@ -657,6 +695,38 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error { return reqFieldErr } +// consumeExtName consumes extension name or expanded Any type URL and the +// following ']'. It returns the name or URL consumed. +func (p *textParser) consumeExtName() (string, error) { + tok := p.next() + if tok.err != nil { + return "", tok.err + } + + // If extension name or type url is quoted, it's a single token. + if len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] { + name, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0])) + if err != nil { + return "", err + } + return name, p.consumeToken("]") + } + + // Consume everything up to "]" + var parts []string + for tok.value != "]" { + parts = append(parts, tok.value) + tok = p.next() + if tok.err != nil { + return "", p.errorf("unrecognized type_url or extension name: %s", tok.err) + } + if p.done && tok.value != "]" { + return "", p.errorf("unclosed type_url or extension name") + } + } + return strings.Join(parts, ""), nil +} + // consumeOptionalSeparator consumes an optional semicolon or comma. // It is used in readStruct to provide backward compatibility. func (p *textParser) consumeOptionalSeparator() error { @@ -717,6 +787,80 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { } return nil } + if props.StdTime { + fv := v + p.back() + props.StdTime = false + tproto := ×tamp{} + err := p.readAny(reflect.ValueOf(tproto).Elem(), props) + props.StdTime = true + if err != nil { + return err + } + tim, err := timestampFromProto(tproto) + if err != nil { + return err + } + if props.Repeated { + t := reflect.TypeOf(v.Interface()) + if t.Kind() == reflect.Slice { + if t.Elem().Kind() == reflect.Ptr { + ts := fv.Interface().([]*time.Time) + ts = append(ts, &tim) + fv.Set(reflect.ValueOf(ts)) + return nil + } else { + ts := fv.Interface().([]time.Time) + ts = append(ts, tim) + fv.Set(reflect.ValueOf(ts)) + return nil + } + } + } + if reflect.TypeOf(v.Interface()).Kind() == reflect.Ptr { + v.Set(reflect.ValueOf(&tim)) + } else { + v.Set(reflect.Indirect(reflect.ValueOf(&tim))) + } + return nil + } + if props.StdDuration { + fv := v + p.back() + props.StdDuration = false + dproto := &duration{} + err := p.readAny(reflect.ValueOf(dproto).Elem(), props) + props.StdDuration = true + if err != nil { + return err + } + dur, err := durationFromProto(dproto) + if err != nil { + return err + } + if props.Repeated { + t := reflect.TypeOf(v.Interface()) + if t.Kind() == reflect.Slice { + if t.Elem().Kind() == reflect.Ptr { + ds := fv.Interface().([]*time.Duration) + ds = append(ds, &dur) + fv.Set(reflect.ValueOf(ds)) + return nil + } else { + ds := fv.Interface().([]time.Duration) + ds = append(ds, dur) + fv.Set(reflect.ValueOf(ds)) + return nil + } + } + } + if reflect.TypeOf(v.Interface()).Kind() == reflect.Ptr { + v.Set(reflect.ValueOf(&dur)) + } else { + v.Set(reflect.Indirect(reflect.ValueOf(&dur))) + } + return nil + } switch fv := v; fv.Kind() { case reflect.Slice: at := v.Type() @@ -759,12 +903,12 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) return p.readAny(fv.Index(fv.Len()-1), props) case reflect.Bool: - // Either "true", "false", 1 or 0. + // true/1/t/True or false/f/0/False. switch tok.value { - case "true", "1": + case "true", "1", "t", "True": fv.SetBool(true) return nil - case "false", "0": + case "false", "0", "f", "False": fv.SetBool(false) return nil } @@ -846,13 +990,9 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { // UnmarshalText returns *RequiredNotSetError. func UnmarshalText(s string, pb Message) error { if um, ok := pb.(encoding.TextUnmarshaler); ok { - err := um.UnmarshalText([]byte(s)) - return err + return um.UnmarshalText([]byte(s)) } pb.Reset() v := reflect.ValueOf(pb) - if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { - return pe - } - return nil + return newTextParser(s).readStruct(v.Elem(), "") } diff --git a/vendor/github.com/gogo/protobuf/proto/timestamp.go b/vendor/github.com/gogo/protobuf/proto/timestamp.go new file mode 100644 index 00000000000..9324f6542bc --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/timestamp.go @@ -0,0 +1,113 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +// This file implements operations on google.protobuf.Timestamp. + +import ( + "errors" + "fmt" + "time" +) + +const ( + // Seconds field of the earliest valid Timestamp. + // This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). + minValidSeconds = -62135596800 + // Seconds field just after the latest valid Timestamp. + // This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). + maxValidSeconds = 253402300800 +) + +// validateTimestamp determines whether a Timestamp is valid. +// A valid timestamp represents a time in the range +// [0001-01-01, 10000-01-01) and has a Nanos field +// in the range [0, 1e9). +// +// If the Timestamp is valid, validateTimestamp returns nil. +// Otherwise, it returns an error that describes +// the problem. +// +// Every valid Timestamp can be represented by a time.Time, but the converse is not true. +func validateTimestamp(ts *timestamp) error { + if ts == nil { + return errors.New("timestamp: nil Timestamp") + } + if ts.Seconds < minValidSeconds { + return fmt.Errorf("timestamp: %#v before 0001-01-01", ts) + } + if ts.Seconds >= maxValidSeconds { + return fmt.Errorf("timestamp: %#v after 10000-01-01", ts) + } + if ts.Nanos < 0 || ts.Nanos >= 1e9 { + return fmt.Errorf("timestamp: %#v: nanos not in range [0, 1e9)", ts) + } + return nil +} + +// TimestampFromProto converts a google.protobuf.Timestamp proto to a time.Time. +// It returns an error if the argument is invalid. +// +// Unlike most Go functions, if Timestamp returns an error, the first return value +// is not the zero time.Time. Instead, it is the value obtained from the +// time.Unix function when passed the contents of the Timestamp, in the UTC +// locale. This may or may not be a meaningful time; many invalid Timestamps +// do map to valid time.Times. +// +// A nil Timestamp returns an error. The first return value in that case is +// undefined. +func timestampFromProto(ts *timestamp) (time.Time, error) { + // Don't return the zero value on error, because corresponds to a valid + // timestamp. Instead return whatever time.Unix gives us. + var t time.Time + if ts == nil { + t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp + } else { + t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC() + } + return t, validateTimestamp(ts) +} + +// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. +// It returns an error if the resulting Timestamp is invalid. +func timestampProto(t time.Time) (*timestamp, error) { + seconds := t.Unix() + nanos := int32(t.Sub(time.Unix(seconds, 0))) + ts := ×tamp{ + Seconds: seconds, + Nanos: nanos, + } + if err := validateTimestamp(ts); err != nil { + return nil, err + } + return ts, nil +} diff --git a/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go b/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go new file mode 100644 index 00000000000..38439fa9901 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go @@ -0,0 +1,49 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2016, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "reflect" + "time" +) + +var timeType = reflect.TypeOf((*time.Time)(nil)).Elem() + +type timestamp struct { + Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` + Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` +} + +func (m *timestamp) Reset() { *m = timestamp{} } +func (*timestamp) ProtoMessage() {} +func (*timestamp) String() string { return "timestamp" } + +func init() { + RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp") +} diff --git a/vendor/github.com/gogo/protobuf/sortkeys/sortkeys.go b/vendor/github.com/gogo/protobuf/sortkeys/sortkeys.go new file mode 100644 index 00000000000..ceadde6a5e1 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/sortkeys/sortkeys.go @@ -0,0 +1,101 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2013, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package sortkeys + +import ( + "sort" +) + +func Strings(l []string) { + sort.Strings(l) +} + +func Float64s(l []float64) { + sort.Float64s(l) +} + +func Float32s(l []float32) { + sort.Sort(Float32Slice(l)) +} + +func Int64s(l []int64) { + sort.Sort(Int64Slice(l)) +} + +func Int32s(l []int32) { + sort.Sort(Int32Slice(l)) +} + +func Uint64s(l []uint64) { + sort.Sort(Uint64Slice(l)) +} + +func Uint32s(l []uint32) { + sort.Sort(Uint32Slice(l)) +} + +func Bools(l []bool) { + sort.Sort(BoolSlice(l)) +} + +type BoolSlice []bool + +func (p BoolSlice) Len() int { return len(p) } +func (p BoolSlice) Less(i, j int) bool { return p[j] } +func (p BoolSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type Int64Slice []int64 + +func (p Int64Slice) Len() int { return len(p) } +func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] } +func (p Int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type Int32Slice []int32 + +func (p Int32Slice) Len() int { return len(p) } +func (p Int32Slice) Less(i, j int) bool { return p[i] < p[j] } +func (p Int32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type Uint64Slice []uint64 + +func (p Uint64Slice) Len() int { return len(p) } +func (p Uint64Slice) Less(i, j int) bool { return p[i] < p[j] } +func (p Uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type Uint32Slice []uint32 + +func (p Uint32Slice) Len() int { return len(p) } +func (p Uint32Slice) Less(i, j int) bool { return p[i] < p[j] } +func (p Uint32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +type Float32Slice []float32 + +func (p Float32Slice) Len() int { return len(p) } +func (p Float32Slice) Less(i, j int) bool { return p[i] < p[j] } +func (p Float32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } diff --git a/vendor/github.com/gogo/protobuf/types/any.go b/vendor/github.com/gogo/protobuf/types/any.go new file mode 100644 index 00000000000..df4787de37c --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/any.go @@ -0,0 +1,140 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package types + +// This file implements functions to marshal proto.Message to/from +// google.protobuf.Any message. + +import ( + "fmt" + "reflect" + "strings" + + "github.com/gogo/protobuf/proto" +) + +const googleApis = "type.googleapis.com/" + +// AnyMessageName returns the name of the message contained in a google.protobuf.Any message. +// +// Note that regular type assertions should be done using the Is +// function. AnyMessageName is provided for less common use cases like filtering a +// sequence of Any messages based on a set of allowed message type names. +func AnyMessageName(any *Any) (string, error) { + if any == nil { + return "", fmt.Errorf("message is nil") + } + slash := strings.LastIndex(any.TypeUrl, "/") + if slash < 0 { + return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl) + } + return any.TypeUrl[slash+1:], nil +} + +// MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any. +func MarshalAny(pb proto.Message) (*Any, error) { + value, err := proto.Marshal(pb) + if err != nil { + return nil, err + } + return &Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil +} + +// DynamicAny is a value that can be passed to UnmarshalAny to automatically +// allocate a proto.Message for the type specified in a google.protobuf.Any +// message. The allocated message is stored in the embedded proto.Message. +// +// Example: +// +// var x ptypes.DynamicAny +// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... } +// fmt.Printf("unmarshaled message: %v", x.Message) +type DynamicAny struct { + proto.Message +} + +// Empty returns a new proto.Message of the type specified in a +// google.protobuf.Any message. It returns an error if corresponding message +// type isn't linked in. +func EmptyAny(any *Any) (proto.Message, error) { + aname, err := AnyMessageName(any) + if err != nil { + return nil, err + } + + t := proto.MessageType(aname) + if t == nil { + return nil, fmt.Errorf("any: message type %q isn't linked in", aname) + } + return reflect.New(t.Elem()).Interface().(proto.Message), nil +} + +// UnmarshalAny parses the protocol buffer representation in a google.protobuf.Any +// message and places the decoded result in pb. It returns an error if type of +// contents of Any message does not match type of pb message. +// +// pb can be a proto.Message, or a *DynamicAny. +func UnmarshalAny(any *Any, pb proto.Message) error { + if d, ok := pb.(*DynamicAny); ok { + if d.Message == nil { + var err error + d.Message, err = EmptyAny(any) + if err != nil { + return err + } + } + return UnmarshalAny(any, d.Message) + } + + aname, err := AnyMessageName(any) + if err != nil { + return err + } + + mname := proto.MessageName(pb) + if aname != mname { + return fmt.Errorf("mismatched message type: got %q want %q", aname, mname) + } + return proto.Unmarshal(any.Value, pb) +} + +// Is returns true if any value contains a given message type. +func Is(any *Any, pb proto.Message) bool { + // The following is equivalent to AnyMessageName(any) == proto.MessageName(pb), + // but it avoids scanning TypeUrl for the slash. + if any == nil { + return false + } + name := proto.MessageName(pb) + prefix := len(any.TypeUrl) - len(name) + return prefix >= 1 && any.TypeUrl[prefix-1] == '/' && any.TypeUrl[prefix:] == name +} diff --git a/vendor/github.com/gogo/protobuf/types/any.pb.go b/vendor/github.com/gogo/protobuf/types/any.pb.go new file mode 100644 index 00000000000..cb774dbce4a --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/any.pb.go @@ -0,0 +1,703 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/any.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// `Any` contains an arbitrary serialized protocol buffer message along with a +// URL that describes the type of the serialized message. +// +// Protobuf library provides support to pack/unpack Any values in the form +// of utility functions or additional generated methods of the Any type. +// +// Example 1: Pack and unpack a message in C++. +// +// Foo foo = ...; +// Any any; +// any.PackFrom(foo); +// ... +// if (any.UnpackTo(&foo)) { +// ... +// } +// +// Example 2: Pack and unpack a message in Java. +// +// Foo foo = ...; +// Any any = Any.pack(foo); +// ... +// if (any.is(Foo.class)) { +// foo = any.unpack(Foo.class); +// } +// +// Example 3: Pack and unpack a message in Python. +// +// foo = Foo(...) +// any = Any() +// any.Pack(foo) +// ... +// if any.Is(Foo.DESCRIPTOR): +// any.Unpack(foo) +// ... +// +// Example 4: Pack and unpack a message in Go +// +// foo := &pb.Foo{...} +// any, err := ptypes.MarshalAny(foo) +// ... +// foo := &pb.Foo{} +// if err := ptypes.UnmarshalAny(any, foo); err != nil { +// ... +// } +// +// The pack methods provided by protobuf library will by default use +// 'type.googleapis.com/full.type.name' as the type URL and the unpack +// methods only use the fully qualified type name after the last '/' +// in the type URL, for example "foo.bar.com/x/y.z" will yield type +// name "y.z". +// +// +// JSON +// ==== +// The JSON representation of an `Any` value uses the regular +// representation of the deserialized, embedded message, with an +// additional field `@type` which contains the type URL. Example: +// +// package google.profile; +// message Person { +// string first_name = 1; +// string last_name = 2; +// } +// +// { +// "@type": "type.googleapis.com/google.profile.Person", +// "firstName": , +// "lastName": +// } +// +// If the embedded message type is well-known and has a custom JSON +// representation, that representation will be embedded adding a field +// `value` which holds the custom JSON in addition to the `@type` +// field. Example (for message [google.protobuf.Duration][]): +// +// { +// "@type": "type.googleapis.com/google.protobuf.Duration", +// "value": "1.212s" +// } +// +type Any struct { + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). + // + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: + // + // * If no scheme is provided, `https` is assumed. + // * An HTTP GET on the URL must yield a [google.protobuf.Type][] + // value in binary format, or produce an error. + // * Applications are allowed to cache lookup results based on the + // URL, or have them precompiled into a binary to avoid any + // lookup. Therefore, binary compatibility needs to be preserved + // on changes to types. (Use versioned type names to manage + // breaking changes.) + // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // + // Schemes other than `http`, `https` (or the empty scheme) might be + // used with implementation specific semantics. + // + TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` + // Must be a valid serialized protocol buffer of the above specified type. + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Any) Reset() { *m = Any{} } +func (*Any) ProtoMessage() {} +func (*Any) Descriptor() ([]byte, []int) { + return fileDescriptor_any_f098d1a3c592d16a, []int{0} +} +func (*Any) XXX_WellKnownType() string { return "Any" } +func (m *Any) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Any) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Any.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Any) XXX_Merge(src proto.Message) { + xxx_messageInfo_Any.Merge(dst, src) +} +func (m *Any) XXX_Size() int { + return m.Size() +} +func (m *Any) XXX_DiscardUnknown() { + xxx_messageInfo_Any.DiscardUnknown(m) +} + +var xxx_messageInfo_Any proto.InternalMessageInfo + +func (m *Any) GetTypeUrl() string { + if m != nil { + return m.TypeUrl + } + return "" +} + +func (m *Any) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (*Any) XXX_MessageName() string { + return "google.protobuf.Any" +} +func init() { + proto.RegisterType((*Any)(nil), "google.protobuf.Any") +} +func (this *Any) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Any) + if !ok { + that2, ok := that.(Any) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.TypeUrl != that1.TypeUrl { + if this.TypeUrl < that1.TypeUrl { + return -1 + } + return 1 + } + if c := bytes.Compare(this.Value, that1.Value); c != 0 { + return c + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Any) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Any) + if !ok { + that2, ok := that.(Any) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TypeUrl != that1.TypeUrl { + return false + } + if !bytes.Equal(this.Value, that1.Value) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Any) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&types.Any{") + s = append(s, "TypeUrl: "+fmt.Sprintf("%#v", this.TypeUrl)+",\n") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringAny(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Any) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Any) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.TypeUrl) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintAny(dAtA, i, uint64(len(m.TypeUrl))) + i += copy(dAtA[i:], m.TypeUrl) + } + if len(m.Value) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintAny(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintAny(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedAny(r randyAny, easy bool) *Any { + this := &Any{} + this.TypeUrl = string(randStringAny(r)) + v1 := r.Intn(100) + this.Value = make([]byte, v1) + for i := 0; i < v1; i++ { + this.Value[i] = byte(r.Intn(256)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedAny(r, 3) + } + return this +} + +type randyAny interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneAny(r randyAny) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringAny(r randyAny) string { + v2 := r.Intn(100) + tmps := make([]rune, v2) + for i := 0; i < v2; i++ { + tmps[i] = randUTF8RuneAny(r) + } + return string(tmps) +} +func randUnrecognizedAny(r randyAny, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldAny(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldAny(dAtA []byte, r randyAny, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + v3 := r.Int63() + if r.Intn(2) == 0 { + v3 *= -1 + } + dAtA = encodeVarintPopulateAny(dAtA, uint64(v3)) + case 1: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateAny(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateAny(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateAny(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *Any) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TypeUrl) + if l > 0 { + n += 1 + l + sovAny(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovAny(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovAny(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozAny(x uint64) (n int) { + return sovAny(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Any) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Any{`, + `TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringAny(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Any) 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 ErrIntOverflowAny + } + 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: Any: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Any: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAny + } + 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 ErrInvalidLengthAny + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAny + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAny + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAny(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAny + } + 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 skipAny(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAny + } + 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, ErrIntOverflowAny + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAny + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthAny + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAny + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipAny(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthAny = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAny = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_any_f098d1a3c592d16a) } + +var fileDescriptor_any_f098d1a3c592d16a = []byte{ + // 211 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4, + 0x03, 0x73, 0x84, 0xf8, 0x21, 0x52, 0x7a, 0x30, 0x29, 0x25, 0x33, 0x2e, 0x66, 0xc7, 0xbc, 0x4a, + 0x21, 0x49, 0x2e, 0x8e, 0x92, 0xca, 0x82, 0xd4, 0xf8, 0xd2, 0xa2, 0x1c, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0xce, 0x20, 0x76, 0x10, 0x3f, 0xb4, 0x28, 0x47, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, + 0x34, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0xc2, 0x71, 0xaa, 0xbf, 0xf1, 0x50, 0x8e, + 0xe1, 0xc3, 0x43, 0x39, 0xc6, 0x1f, 0x0f, 0xe5, 0x18, 0x1b, 0x1e, 0xc9, 0x31, 0xae, 0x78, 0x24, + 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xbe, 0x78, + 0x24, 0xc7, 0xf0, 0x01, 0x24, 0xfe, 0x58, 0x8e, 0xf1, 0xc4, 0x63, 0x39, 0x46, 0x2e, 0xe1, 0xe4, + 0xfc, 0x5c, 0x3d, 0x34, 0xeb, 0x9d, 0x38, 0x1c, 0xf3, 0x2a, 0x03, 0x40, 0x9c, 0x00, 0xc6, 0x28, + 0x56, 0x90, 0x8d, 0xc5, 0x8b, 0x98, 0x98, 0xdd, 0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x94, + 0x06, 0x40, 0x95, 0xea, 0x85, 0xa7, 0xe6, 0xe4, 0x78, 0xe7, 0xe5, 0x97, 0xe7, 0x85, 0x80, 0x94, + 0x25, 0xb1, 0x81, 0xcd, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x81, 0x82, 0xd3, 0xed, + 0x00, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/api.pb.go b/vendor/github.com/gogo/protobuf/types/api.pb.go new file mode 100644 index 00000000000..bdc44958851 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/api.pb.go @@ -0,0 +1,2067 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/api.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// Api is a light-weight descriptor for an API Interface. +// +// Interfaces are also described as "protocol buffer services" in some contexts, +// such as by the "service" keyword in a .proto file, but they are different +// from API Services, which represent a concrete implementation of an interface +// as opposed to simply a description of methods and bindings. They are also +// sometimes simply referred to as "APIs" in other contexts, such as the name of +// this message itself. See https://cloud.google.com/apis/design/glossary for +// detailed terminology. +type Api struct { + // The fully qualified name of this interface, including package name + // followed by the interface's simple name. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The methods of this interface, in unspecified order. + Methods []*Method `protobuf:"bytes,2,rep,name=methods" json:"methods,omitempty"` + // Any metadata attached to the interface. + Options []*Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` + // A version string for this interface. If specified, must have the form + // `major-version.minor-version`, as in `1.10`. If the minor version is + // omitted, it defaults to zero. If the entire version field is empty, the + // major version is derived from the package name, as outlined below. If the + // field is not empty, the version in the package name will be verified to be + // consistent with what is provided here. + // + // The versioning schema uses [semantic + // versioning](http://semver.org) where the major version number + // indicates a breaking change and the minor version an additive, + // non-breaking change. Both version numbers are signals to users + // what to expect from different versions, and should be carefully + // chosen based on the product plan. + // + // The major version is also reflected in the package name of the + // interface, which must end in `v`, as in + // `google.feature.v1`. For major versions 0 and 1, the suffix can + // be omitted. Zero major versions must only be used for + // experimental, non-GA interfaces. + // + // + Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` + // Source context for the protocol buffer service represented by this + // message. + SourceContext *SourceContext `protobuf:"bytes,5,opt,name=source_context,json=sourceContext" json:"source_context,omitempty"` + // Included interfaces. See [Mixin][]. + Mixins []*Mixin `protobuf:"bytes,6,rep,name=mixins" json:"mixins,omitempty"` + // The source syntax of the service. + Syntax Syntax `protobuf:"varint,7,opt,name=syntax,proto3,enum=google.protobuf.Syntax" json:"syntax,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Api) Reset() { *m = Api{} } +func (*Api) ProtoMessage() {} +func (*Api) Descriptor() ([]byte, []int) { + return fileDescriptor_api_a4406062c749da1f, []int{0} +} +func (m *Api) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Api) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Api.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Api) XXX_Merge(src proto.Message) { + xxx_messageInfo_Api.Merge(dst, src) +} +func (m *Api) XXX_Size() int { + return m.Size() +} +func (m *Api) XXX_DiscardUnknown() { + xxx_messageInfo_Api.DiscardUnknown(m) +} + +var xxx_messageInfo_Api proto.InternalMessageInfo + +func (m *Api) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Api) GetMethods() []*Method { + if m != nil { + return m.Methods + } + return nil +} + +func (m *Api) GetOptions() []*Option { + if m != nil { + return m.Options + } + return nil +} + +func (m *Api) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *Api) GetSourceContext() *SourceContext { + if m != nil { + return m.SourceContext + } + return nil +} + +func (m *Api) GetMixins() []*Mixin { + if m != nil { + return m.Mixins + } + return nil +} + +func (m *Api) GetSyntax() Syntax { + if m != nil { + return m.Syntax + } + return Syntax_SYNTAX_PROTO2 +} + +func (*Api) XXX_MessageName() string { + return "google.protobuf.Api" +} + +// Method represents a method of an API interface. +type Method struct { + // The simple name of this method. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // A URL of the input message type. + RequestTypeUrl string `protobuf:"bytes,2,opt,name=request_type_url,json=requestTypeUrl,proto3" json:"request_type_url,omitempty"` + // If true, the request is streamed. + RequestStreaming bool `protobuf:"varint,3,opt,name=request_streaming,json=requestStreaming,proto3" json:"request_streaming,omitempty"` + // The URL of the output message type. + ResponseTypeUrl string `protobuf:"bytes,4,opt,name=response_type_url,json=responseTypeUrl,proto3" json:"response_type_url,omitempty"` + // If true, the response is streamed. + ResponseStreaming bool `protobuf:"varint,5,opt,name=response_streaming,json=responseStreaming,proto3" json:"response_streaming,omitempty"` + // Any metadata attached to the method. + Options []*Option `protobuf:"bytes,6,rep,name=options" json:"options,omitempty"` + // The source syntax of this method. + Syntax Syntax `protobuf:"varint,7,opt,name=syntax,proto3,enum=google.protobuf.Syntax" json:"syntax,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Method) Reset() { *m = Method{} } +func (*Method) ProtoMessage() {} +func (*Method) Descriptor() ([]byte, []int) { + return fileDescriptor_api_a4406062c749da1f, []int{1} +} +func (m *Method) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Method) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Method.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Method) XXX_Merge(src proto.Message) { + xxx_messageInfo_Method.Merge(dst, src) +} +func (m *Method) XXX_Size() int { + return m.Size() +} +func (m *Method) XXX_DiscardUnknown() { + xxx_messageInfo_Method.DiscardUnknown(m) +} + +var xxx_messageInfo_Method proto.InternalMessageInfo + +func (m *Method) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Method) GetRequestTypeUrl() string { + if m != nil { + return m.RequestTypeUrl + } + return "" +} + +func (m *Method) GetRequestStreaming() bool { + if m != nil { + return m.RequestStreaming + } + return false +} + +func (m *Method) GetResponseTypeUrl() string { + if m != nil { + return m.ResponseTypeUrl + } + return "" +} + +func (m *Method) GetResponseStreaming() bool { + if m != nil { + return m.ResponseStreaming + } + return false +} + +func (m *Method) GetOptions() []*Option { + if m != nil { + return m.Options + } + return nil +} + +func (m *Method) GetSyntax() Syntax { + if m != nil { + return m.Syntax + } + return Syntax_SYNTAX_PROTO2 +} + +func (*Method) XXX_MessageName() string { + return "google.protobuf.Method" +} + +// Declares an API Interface to be included in this interface. The including +// interface must redeclare all the methods from the included interface, but +// documentation and options are inherited as follows: +// +// - If after comment and whitespace stripping, the documentation +// string of the redeclared method is empty, it will be inherited +// from the original method. +// +// - Each annotation belonging to the service config (http, +// visibility) which is not set in the redeclared method will be +// inherited. +// +// - If an http annotation is inherited, the path pattern will be +// modified as follows. Any version prefix will be replaced by the +// version of the including interface plus the [root][] path if +// specified. +// +// Example of a simple mixin: +// +// package google.acl.v1; +// service AccessControl { +// // Get the underlying ACL object. +// rpc GetAcl(GetAclRequest) returns (Acl) { +// option (google.api.http).get = "/v1/{resource=**}:getAcl"; +// } +// } +// +// package google.storage.v2; +// service Storage { +// rpc GetAcl(GetAclRequest) returns (Acl); +// +// // Get a data record. +// rpc GetData(GetDataRequest) returns (Data) { +// option (google.api.http).get = "/v2/{resource=**}"; +// } +// } +// +// Example of a mixin configuration: +// +// apis: +// - name: google.storage.v2.Storage +// mixins: +// - name: google.acl.v1.AccessControl +// +// The mixin construct implies that all methods in `AccessControl` are +// also declared with same name and request/response types in +// `Storage`. A documentation generator or annotation processor will +// see the effective `Storage.GetAcl` method after inherting +// documentation and annotations as follows: +// +// service Storage { +// // Get the underlying ACL object. +// rpc GetAcl(GetAclRequest) returns (Acl) { +// option (google.api.http).get = "/v2/{resource=**}:getAcl"; +// } +// ... +// } +// +// Note how the version in the path pattern changed from `v1` to `v2`. +// +// If the `root` field in the mixin is specified, it should be a +// relative path under which inherited HTTP paths are placed. Example: +// +// apis: +// - name: google.storage.v2.Storage +// mixins: +// - name: google.acl.v1.AccessControl +// root: acls +// +// This implies the following inherited HTTP annotation: +// +// service Storage { +// // Get the underlying ACL object. +// rpc GetAcl(GetAclRequest) returns (Acl) { +// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; +// } +// ... +// } +type Mixin struct { + // The fully qualified name of the interface which is included. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // If non-empty specifies a path under which inherited HTTP paths + // are rooted. + Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Mixin) Reset() { *m = Mixin{} } +func (*Mixin) ProtoMessage() {} +func (*Mixin) Descriptor() ([]byte, []int) { + return fileDescriptor_api_a4406062c749da1f, []int{2} +} +func (m *Mixin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Mixin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Mixin.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Mixin) XXX_Merge(src proto.Message) { + xxx_messageInfo_Mixin.Merge(dst, src) +} +func (m *Mixin) XXX_Size() int { + return m.Size() +} +func (m *Mixin) XXX_DiscardUnknown() { + xxx_messageInfo_Mixin.DiscardUnknown(m) +} + +var xxx_messageInfo_Mixin proto.InternalMessageInfo + +func (m *Mixin) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Mixin) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +func (*Mixin) XXX_MessageName() string { + return "google.protobuf.Mixin" +} +func init() { + proto.RegisterType((*Api)(nil), "google.protobuf.Api") + proto.RegisterType((*Method)(nil), "google.protobuf.Method") + proto.RegisterType((*Mixin)(nil), "google.protobuf.Mixin") +} +func (this *Api) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Api) + if !ok { + that2, ok := that.(Api) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if len(this.Methods) != len(that1.Methods) { + if len(this.Methods) < len(that1.Methods) { + return -1 + } + return 1 + } + for i := range this.Methods { + if c := this.Methods[i].Compare(that1.Methods[i]); c != 0 { + return c + } + } + if len(this.Options) != len(that1.Options) { + if len(this.Options) < len(that1.Options) { + return -1 + } + return 1 + } + for i := range this.Options { + if c := this.Options[i].Compare(that1.Options[i]); c != 0 { + return c + } + } + if this.Version != that1.Version { + if this.Version < that1.Version { + return -1 + } + return 1 + } + if c := this.SourceContext.Compare(that1.SourceContext); c != 0 { + return c + } + if len(this.Mixins) != len(that1.Mixins) { + if len(this.Mixins) < len(that1.Mixins) { + return -1 + } + return 1 + } + for i := range this.Mixins { + if c := this.Mixins[i].Compare(that1.Mixins[i]); c != 0 { + return c + } + } + if this.Syntax != that1.Syntax { + if this.Syntax < that1.Syntax { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Method) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Method) + if !ok { + that2, ok := that.(Method) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if this.RequestTypeUrl != that1.RequestTypeUrl { + if this.RequestTypeUrl < that1.RequestTypeUrl { + return -1 + } + return 1 + } + if this.RequestStreaming != that1.RequestStreaming { + if !this.RequestStreaming { + return -1 + } + return 1 + } + if this.ResponseTypeUrl != that1.ResponseTypeUrl { + if this.ResponseTypeUrl < that1.ResponseTypeUrl { + return -1 + } + return 1 + } + if this.ResponseStreaming != that1.ResponseStreaming { + if !this.ResponseStreaming { + return -1 + } + return 1 + } + if len(this.Options) != len(that1.Options) { + if len(this.Options) < len(that1.Options) { + return -1 + } + return 1 + } + for i := range this.Options { + if c := this.Options[i].Compare(that1.Options[i]); c != 0 { + return c + } + } + if this.Syntax != that1.Syntax { + if this.Syntax < that1.Syntax { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Mixin) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Mixin) + if !ok { + that2, ok := that.(Mixin) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if this.Root != that1.Root { + if this.Root < that1.Root { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Api) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Api) + if !ok { + that2, ok := that.(Api) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if len(this.Methods) != len(that1.Methods) { + return false + } + for i := range this.Methods { + if !this.Methods[i].Equal(that1.Methods[i]) { + return false + } + } + if len(this.Options) != len(that1.Options) { + return false + } + for i := range this.Options { + if !this.Options[i].Equal(that1.Options[i]) { + return false + } + } + if this.Version != that1.Version { + return false + } + if !this.SourceContext.Equal(that1.SourceContext) { + return false + } + if len(this.Mixins) != len(that1.Mixins) { + return false + } + for i := range this.Mixins { + if !this.Mixins[i].Equal(that1.Mixins[i]) { + return false + } + } + if this.Syntax != that1.Syntax { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Method) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Method) + if !ok { + that2, ok := that.(Method) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.RequestTypeUrl != that1.RequestTypeUrl { + return false + } + if this.RequestStreaming != that1.RequestStreaming { + return false + } + if this.ResponseTypeUrl != that1.ResponseTypeUrl { + return false + } + if this.ResponseStreaming != that1.ResponseStreaming { + return false + } + if len(this.Options) != len(that1.Options) { + return false + } + for i := range this.Options { + if !this.Options[i].Equal(that1.Options[i]) { + return false + } + } + if this.Syntax != that1.Syntax { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Mixin) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Mixin) + if !ok { + that2, ok := that.(Mixin) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Root != that1.Root { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Api) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 11) + s = append(s, "&types.Api{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + if this.Methods != nil { + s = append(s, "Methods: "+fmt.Sprintf("%#v", this.Methods)+",\n") + } + if this.Options != nil { + s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") + } + s = append(s, "Version: "+fmt.Sprintf("%#v", this.Version)+",\n") + if this.SourceContext != nil { + s = append(s, "SourceContext: "+fmt.Sprintf("%#v", this.SourceContext)+",\n") + } + if this.Mixins != nil { + s = append(s, "Mixins: "+fmt.Sprintf("%#v", this.Mixins)+",\n") + } + s = append(s, "Syntax: "+fmt.Sprintf("%#v", this.Syntax)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Method) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 11) + s = append(s, "&types.Method{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "RequestTypeUrl: "+fmt.Sprintf("%#v", this.RequestTypeUrl)+",\n") + s = append(s, "RequestStreaming: "+fmt.Sprintf("%#v", this.RequestStreaming)+",\n") + s = append(s, "ResponseTypeUrl: "+fmt.Sprintf("%#v", this.ResponseTypeUrl)+",\n") + s = append(s, "ResponseStreaming: "+fmt.Sprintf("%#v", this.ResponseStreaming)+",\n") + if this.Options != nil { + s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") + } + s = append(s, "Syntax: "+fmt.Sprintf("%#v", this.Syntax)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Mixin) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&types.Mixin{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "Root: "+fmt.Sprintf("%#v", this.Root)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringApi(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Api) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Api) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Methods) > 0 { + for _, msg := range m.Methods { + dAtA[i] = 0x12 + i++ + i = encodeVarintApi(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.Options) > 0 { + for _, msg := range m.Options { + dAtA[i] = 0x1a + i++ + i = encodeVarintApi(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.Version) > 0 { + dAtA[i] = 0x22 + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.Version))) + i += copy(dAtA[i:], m.Version) + } + if m.SourceContext != nil { + dAtA[i] = 0x2a + i++ + i = encodeVarintApi(dAtA, i, uint64(m.SourceContext.Size())) + n1, err := m.SourceContext.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + if len(m.Mixins) > 0 { + for _, msg := range m.Mixins { + dAtA[i] = 0x32 + i++ + i = encodeVarintApi(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.Syntax != 0 { + dAtA[i] = 0x38 + i++ + i = encodeVarintApi(dAtA, i, uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Method) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Method) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.RequestTypeUrl) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.RequestTypeUrl))) + i += copy(dAtA[i:], m.RequestTypeUrl) + } + if m.RequestStreaming { + dAtA[i] = 0x18 + i++ + if m.RequestStreaming { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if len(m.ResponseTypeUrl) > 0 { + dAtA[i] = 0x22 + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.ResponseTypeUrl))) + i += copy(dAtA[i:], m.ResponseTypeUrl) + } + if m.ResponseStreaming { + dAtA[i] = 0x28 + i++ + if m.ResponseStreaming { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if len(m.Options) > 0 { + for _, msg := range m.Options { + dAtA[i] = 0x32 + i++ + i = encodeVarintApi(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.Syntax != 0 { + dAtA[i] = 0x38 + i++ + i = encodeVarintApi(dAtA, i, uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Mixin) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Mixin) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Root) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintApi(dAtA, i, uint64(len(m.Root))) + i += copy(dAtA[i:], m.Root) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintApi(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedApi(r randyApi, easy bool) *Api { + this := &Api{} + this.Name = string(randStringApi(r)) + if r.Intn(10) != 0 { + v1 := r.Intn(5) + this.Methods = make([]*Method, v1) + for i := 0; i < v1; i++ { + this.Methods[i] = NewPopulatedMethod(r, easy) + } + } + if r.Intn(10) != 0 { + v2 := r.Intn(5) + this.Options = make([]*Option, v2) + for i := 0; i < v2; i++ { + this.Options[i] = NewPopulatedOption(r, easy) + } + } + this.Version = string(randStringApi(r)) + if r.Intn(10) != 0 { + this.SourceContext = NewPopulatedSourceContext(r, easy) + } + if r.Intn(10) != 0 { + v3 := r.Intn(5) + this.Mixins = make([]*Mixin, v3) + for i := 0; i < v3; i++ { + this.Mixins[i] = NewPopulatedMixin(r, easy) + } + } + this.Syntax = Syntax([]int32{0, 1}[r.Intn(2)]) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedApi(r, 8) + } + return this +} + +func NewPopulatedMethod(r randyApi, easy bool) *Method { + this := &Method{} + this.Name = string(randStringApi(r)) + this.RequestTypeUrl = string(randStringApi(r)) + this.RequestStreaming = bool(bool(r.Intn(2) == 0)) + this.ResponseTypeUrl = string(randStringApi(r)) + this.ResponseStreaming = bool(bool(r.Intn(2) == 0)) + if r.Intn(10) != 0 { + v4 := r.Intn(5) + this.Options = make([]*Option, v4) + for i := 0; i < v4; i++ { + this.Options[i] = NewPopulatedOption(r, easy) + } + } + this.Syntax = Syntax([]int32{0, 1}[r.Intn(2)]) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedApi(r, 8) + } + return this +} + +func NewPopulatedMixin(r randyApi, easy bool) *Mixin { + this := &Mixin{} + this.Name = string(randStringApi(r)) + this.Root = string(randStringApi(r)) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedApi(r, 3) + } + return this +} + +type randyApi interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneApi(r randyApi) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringApi(r randyApi) string { + v5 := r.Intn(100) + tmps := make([]rune, v5) + for i := 0; i < v5; i++ { + tmps[i] = randUTF8RuneApi(r) + } + return string(tmps) +} +func randUnrecognizedApi(r randyApi, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldApi(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldApi(dAtA []byte, r randyApi, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateApi(dAtA, uint64(key)) + v6 := r.Int63() + if r.Intn(2) == 0 { + v6 *= -1 + } + dAtA = encodeVarintPopulateApi(dAtA, uint64(v6)) + case 1: + dAtA = encodeVarintPopulateApi(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateApi(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateApi(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateApi(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateApi(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *Api) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + if len(m.Methods) > 0 { + for _, e := range m.Methods { + l = e.Size() + n += 1 + l + sovApi(uint64(l)) + } + } + if len(m.Options) > 0 { + for _, e := range m.Options { + l = e.Size() + n += 1 + l + sovApi(uint64(l)) + } + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + if m.SourceContext != nil { + l = m.SourceContext.Size() + n += 1 + l + sovApi(uint64(l)) + } + if len(m.Mixins) > 0 { + for _, e := range m.Mixins { + l = e.Size() + n += 1 + l + sovApi(uint64(l)) + } + } + if m.Syntax != 0 { + n += 1 + sovApi(uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Method) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.RequestTypeUrl) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + if m.RequestStreaming { + n += 2 + } + l = len(m.ResponseTypeUrl) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + if m.ResponseStreaming { + n += 2 + } + if len(m.Options) > 0 { + for _, e := range m.Options { + l = e.Size() + n += 1 + l + sovApi(uint64(l)) + } + } + if m.Syntax != 0 { + n += 1 + sovApi(uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Mixin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.Root) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovApi(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozApi(x uint64) (n int) { + return sovApi(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Api) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Api{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Methods:` + strings.Replace(fmt.Sprintf("%v", this.Methods), "Method", "Method", 1) + `,`, + `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Option", "Option", 1) + `,`, + `Version:` + fmt.Sprintf("%v", this.Version) + `,`, + `SourceContext:` + strings.Replace(fmt.Sprintf("%v", this.SourceContext), "SourceContext", "SourceContext", 1) + `,`, + `Mixins:` + strings.Replace(fmt.Sprintf("%v", this.Mixins), "Mixin", "Mixin", 1) + `,`, + `Syntax:` + fmt.Sprintf("%v", this.Syntax) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Method) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Method{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `RequestTypeUrl:` + fmt.Sprintf("%v", this.RequestTypeUrl) + `,`, + `RequestStreaming:` + fmt.Sprintf("%v", this.RequestStreaming) + `,`, + `ResponseTypeUrl:` + fmt.Sprintf("%v", this.ResponseTypeUrl) + `,`, + `ResponseStreaming:` + fmt.Sprintf("%v", this.ResponseStreaming) + `,`, + `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Option", "Option", 1) + `,`, + `Syntax:` + fmt.Sprintf("%v", this.Syntax) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Mixin) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Mixin{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Root:` + fmt.Sprintf("%v", this.Root) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringApi(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Api) 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 ErrIntOverflowApi + } + 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: Api: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Api: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Methods", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Methods = append(m.Methods, &Method{}) + if err := m.Methods[len(m.Methods)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Options = append(m.Options, &Option{}) + if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceContext", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceContext == nil { + m.SourceContext = &SourceContext{} + } + if err := m.SourceContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Mixins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Mixins = append(m.Mixins, &Mixin{}) + if err := m.Mixins[len(m.Mixins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Syntax", wireType) + } + m.Syntax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Syntax |= (Syntax(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthApi + } + 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 *Method) 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 ErrIntOverflowApi + } + 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: Method: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Method: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RequestTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestStreaming", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.RequestStreaming = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResponseTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResponseTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResponseStreaming", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.ResponseStreaming = bool(v != 0) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Options = append(m.Options, &Option{}) + if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Syntax", wireType) + } + m.Syntax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Syntax |= (Syntax(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthApi + } + 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 *Mixin) 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 ErrIntOverflowApi + } + 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: Mixin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Mixin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + 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 ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthApi + } + 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 skipApi(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowApi + } + 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, ErrIntOverflowApi + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowApi + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthApi + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowApi + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipApi(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthApi = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("google/protobuf/api.proto", fileDescriptor_api_a4406062c749da1f) } + +var fileDescriptor_api_a4406062c749da1f = []byte{ + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0xc7, 0xeb, 0xbb, 0xe4, 0x52, 0x5c, 0x91, 0x82, 0x91, 0xc0, 0x64, 0xb0, 0x4e, 0x15, 0xc3, + 0x09, 0xc4, 0x45, 0x94, 0x4f, 0xd0, 0x20, 0xd4, 0x01, 0x21, 0xa2, 0x0b, 0x08, 0x89, 0x25, 0x4a, + 0x83, 0x09, 0x96, 0xee, 0x6c, 0x63, 0x3b, 0x90, 0x4c, 0xf0, 0x59, 0x98, 0x10, 0x23, 0xdf, 0x80, + 0xad, 0x23, 0x23, 0x23, 0xb9, 0x2e, 0x8c, 0x1d, 0x19, 0x91, 0x7d, 0xe7, 0xa6, 0x5c, 0x83, 0x04, + 0x9b, 0xdf, 0xfb, 0xff, 0xfc, 0xf7, 0x7b, 0x7f, 0xc3, 0x9b, 0x33, 0x21, 0x66, 0x39, 0xed, 0x4b, + 0x25, 0x8c, 0x38, 0x9a, 0xbf, 0xea, 0x4f, 0x24, 0x4b, 0x5d, 0x81, 0x76, 0x2b, 0x29, 0xf5, 0x52, + 0xef, 0x56, 0x93, 0xd5, 0x62, 0xae, 0xa6, 0x74, 0x3c, 0x15, 0xdc, 0xd0, 0x85, 0xa9, 0xc0, 0x5e, + 0xaf, 0x49, 0x99, 0xa5, 0xac, 0x4d, 0xf6, 0xbe, 0x06, 0x30, 0x3c, 0x90, 0x0c, 0x21, 0xd8, 0xe2, + 0x93, 0x82, 0x62, 0x10, 0x83, 0xe4, 0x52, 0xe6, 0xce, 0xe8, 0x1e, 0xec, 0x14, 0xd4, 0xbc, 0x16, + 0x2f, 0x35, 0x0e, 0xe2, 0x30, 0xd9, 0xd9, 0xbf, 0x91, 0x36, 0x06, 0x48, 0x1f, 0x3b, 0x3d, 0xf3, + 0x9c, 0xbd, 0x22, 0xa4, 0x61, 0x82, 0x6b, 0x1c, 0xfe, 0xe5, 0xca, 0x13, 0xa7, 0x67, 0x9e, 0x43, + 0x18, 0x76, 0xde, 0x52, 0xa5, 0x99, 0xe0, 0xb8, 0xe5, 0x1e, 0xf7, 0x25, 0x7a, 0x08, 0xbb, 0x7f, + 0xee, 0x83, 0xdb, 0x31, 0x48, 0x76, 0xf6, 0xc9, 0x05, 0xcf, 0x91, 0xc3, 0x1e, 0x54, 0x54, 0x76, + 0x59, 0x9f, 0x2f, 0x51, 0x0a, 0xa3, 0x82, 0x2d, 0x18, 0xd7, 0x38, 0x72, 0x23, 0x5d, 0xbf, 0xb8, + 0x85, 0x95, 0xb3, 0x9a, 0x42, 0x7d, 0x18, 0xe9, 0x25, 0x37, 0x93, 0x05, 0xee, 0xc4, 0x20, 0xe9, + 0x6e, 0x58, 0x61, 0xe4, 0xe4, 0xac, 0xc6, 0xf6, 0xbe, 0x04, 0x30, 0xaa, 0x82, 0xd8, 0x18, 0x63, + 0x02, 0xaf, 0x28, 0xfa, 0x66, 0x4e, 0xb5, 0x19, 0xdb, 0xe0, 0xc7, 0x73, 0x95, 0xe3, 0xc0, 0xe9, + 0xdd, 0xba, 0xff, 0x74, 0x29, 0xe9, 0x33, 0x95, 0xa3, 0x3b, 0xf0, 0xaa, 0x27, 0xb5, 0x51, 0x74, + 0x52, 0x30, 0x3e, 0xc3, 0x61, 0x0c, 0x92, 0xed, 0xcc, 0x5b, 0x8c, 0x7c, 0x1f, 0xdd, 0xb6, 0xb0, + 0x96, 0x82, 0x6b, 0xba, 0xf6, 0xad, 0x12, 0xdc, 0xf5, 0x82, 0x37, 0xbe, 0x0b, 0xd1, 0x19, 0xbb, + 0x76, 0x6e, 0x3b, 0xe7, 0x33, 0x97, 0xb5, 0xf5, 0xb9, 0x5f, 0x8c, 0xfe, 0xf1, 0x17, 0xff, 0x3b, + 0xb4, 0x3e, 0x6c, 0xbb, 0xd8, 0x37, 0x46, 0x86, 0x60, 0x4b, 0x09, 0x61, 0xea, 0x98, 0xdc, 0x79, + 0xf0, 0xfe, 0xfb, 0x8a, 0x6c, 0x9d, 0xae, 0x08, 0xf8, 0xb5, 0x22, 0xe0, 0x43, 0x49, 0xc0, 0xa7, + 0x92, 0x80, 0xe3, 0x92, 0x80, 0x6f, 0x25, 0x01, 0x3f, 0x4a, 0x02, 0x7e, 0x96, 0x64, 0xeb, 0xd4, + 0xf6, 0x4f, 0x08, 0x38, 0x3e, 0x21, 0x00, 0x5e, 0x9b, 0x8a, 0xa2, 0x39, 0xc6, 0x60, 0xfb, 0x40, + 0xb2, 0xa1, 0x2d, 0x86, 0xe0, 0x45, 0xdb, 0xe6, 0xa6, 0x3f, 0x06, 0xe1, 0xe1, 0x70, 0xf0, 0x39, + 0x20, 0x87, 0x15, 0x3a, 0xf4, 0x13, 0x3f, 0xa7, 0x79, 0xfe, 0x88, 0x8b, 0x77, 0xdc, 0xc6, 0xa8, + 0x8f, 0x22, 0xe7, 0x71, 0xff, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x64, 0x40, 0x40, 0xa1, + 0x03, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/doc.go b/vendor/github.com/gogo/protobuf/types/doc.go new file mode 100644 index 00000000000..ff2810af1ee --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/doc.go @@ -0,0 +1,35 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* +Package types contains code for interacting with well-known types. +*/ +package types diff --git a/vendor/github.com/gogo/protobuf/types/duration.go b/vendor/github.com/gogo/protobuf/types/duration.go new file mode 100644 index 00000000000..475d61f1db2 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/duration.go @@ -0,0 +1,100 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package types + +// This file implements conversions between google.protobuf.Duration +// and time.Duration. + +import ( + "errors" + "fmt" + "time" +) + +const ( + // Range of a Duration in seconds, as specified in + // google/protobuf/duration.proto. This is about 10,000 years in seconds. + maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60) + minSeconds = -maxSeconds +) + +// validateDuration determines whether the Duration is valid according to the +// definition in google/protobuf/duration.proto. A valid Duration +// may still be too large to fit into a time.Duration (the range of Duration +// is about 10,000 years, and the range of time.Duration is about 290). +func validateDuration(d *Duration) error { + if d == nil { + return errors.New("duration: nil Duration") + } + if d.Seconds < minSeconds || d.Seconds > maxSeconds { + return fmt.Errorf("duration: %#v: seconds out of range", d) + } + if d.Nanos <= -1e9 || d.Nanos >= 1e9 { + return fmt.Errorf("duration: %#v: nanos out of range", d) + } + // Seconds and Nanos must have the same sign, unless d.Nanos is zero. + if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) { + return fmt.Errorf("duration: %#v: seconds and nanos have different signs", d) + } + return nil +} + +// DurationFromProto converts a Duration to a time.Duration. DurationFromProto +// returns an error if the Duration is invalid or is too large to be +// represented in a time.Duration. +func DurationFromProto(p *Duration) (time.Duration, error) { + if err := validateDuration(p); err != nil { + return 0, err + } + d := time.Duration(p.Seconds) * time.Second + if int64(d/time.Second) != p.Seconds { + return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p) + } + if p.Nanos != 0 { + d += time.Duration(p.Nanos) + if (d < 0) != (p.Nanos < 0) { + return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p) + } + } + return d, nil +} + +// DurationProto converts a time.Duration to a Duration. +func DurationProto(d time.Duration) *Duration { + nanos := d.Nanoseconds() + secs := nanos / 1e9 + nanos -= secs * 1e9 + return &Duration{ + Seconds: secs, + Nanos: int32(nanos), + } +} diff --git a/vendor/github.com/gogo/protobuf/types/duration.pb.go b/vendor/github.com/gogo/protobuf/types/duration.pb.go new file mode 100644 index 00000000000..545ef962e60 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/duration.pb.go @@ -0,0 +1,537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/duration.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// A Duration represents a signed, fixed-length span of time represented +// as a count of seconds and fractions of seconds at nanosecond +// resolution. It is independent of any calendar and concepts like "day" +// or "month". It is related to Timestamp in that the difference between +// two Timestamp values is a Duration and it can be added or subtracted +// from a Timestamp. Range is approximately +-10,000 years. +// +// # Examples +// +// Example 1: Compute Duration from two Timestamps in pseudo code. +// +// Timestamp start = ...; +// Timestamp end = ...; +// Duration duration = ...; +// +// duration.seconds = end.seconds - start.seconds; +// duration.nanos = end.nanos - start.nanos; +// +// if (duration.seconds < 0 && duration.nanos > 0) { +// duration.seconds += 1; +// duration.nanos -= 1000000000; +// } else if (durations.seconds > 0 && duration.nanos < 0) { +// duration.seconds -= 1; +// duration.nanos += 1000000000; +// } +// +// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. +// +// Timestamp start = ...; +// Duration duration = ...; +// Timestamp end = ...; +// +// end.seconds = start.seconds + duration.seconds; +// end.nanos = start.nanos + duration.nanos; +// +// if (end.nanos < 0) { +// end.seconds -= 1; +// end.nanos += 1000000000; +// } else if (end.nanos >= 1000000000) { +// end.seconds += 1; +// end.nanos -= 1000000000; +// } +// +// Example 3: Compute Duration from datetime.timedelta in Python. +// +// td = datetime.timedelta(days=3, minutes=10) +// duration = Duration() +// duration.FromTimedelta(td) +// +// # JSON Mapping +// +// In JSON format, the Duration type is encoded as a string rather than an +// object, where the string ends in the suffix "s" (indicating seconds) and +// is preceded by the number of seconds, with nanoseconds expressed as +// fractional seconds. For example, 3 seconds with 0 nanoseconds should be +// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should +// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 +// microsecond should be expressed in JSON format as "3.000001s". +// +// +type Duration struct { + // Signed seconds of the span of time. Must be from -315,576,000,000 + // to +315,576,000,000 inclusive. Note: these bounds are computed from: + // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` + // Signed fractions of a second at nanosecond resolution of the span + // of time. Durations less than one second are represented with a 0 + // `seconds` field and a positive or negative `nanos` field. For durations + // of one second or more, a non-zero value for the `nanos` field must be + // of the same sign as the `seconds` field. Must be from -999,999,999 + // to +999,999,999 inclusive. + Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Duration) Reset() { *m = Duration{} } +func (*Duration) ProtoMessage() {} +func (*Duration) Descriptor() ([]byte, []int) { + return fileDescriptor_duration_187e4d5f80a83848, []int{0} +} +func (*Duration) XXX_WellKnownType() string { return "Duration" } +func (m *Duration) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Duration.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Duration) XXX_Merge(src proto.Message) { + xxx_messageInfo_Duration.Merge(dst, src) +} +func (m *Duration) XXX_Size() int { + return m.Size() +} +func (m *Duration) XXX_DiscardUnknown() { + xxx_messageInfo_Duration.DiscardUnknown(m) +} + +var xxx_messageInfo_Duration proto.InternalMessageInfo + +func (m *Duration) GetSeconds() int64 { + if m != nil { + return m.Seconds + } + return 0 +} + +func (m *Duration) GetNanos() int32 { + if m != nil { + return m.Nanos + } + return 0 +} + +func (*Duration) XXX_MessageName() string { + return "google.protobuf.Duration" +} +func init() { + proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") +} +func (this *Duration) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Duration) + if !ok { + that2, ok := that.(Duration) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Seconds != that1.Seconds { + if this.Seconds < that1.Seconds { + return -1 + } + return 1 + } + if this.Nanos != that1.Nanos { + if this.Nanos < that1.Nanos { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Duration) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Duration) + if !ok { + that2, ok := that.(Duration) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Seconds != that1.Seconds { + return false + } + if this.Nanos != that1.Nanos { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Duration) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&types.Duration{") + s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n") + s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringDuration(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Duration) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Duration) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Seconds != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintDuration(dAtA, i, uint64(m.Seconds)) + } + if m.Nanos != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintDuration(dAtA, i, uint64(m.Nanos)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintDuration(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *Duration) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Seconds != 0 { + n += 1 + sovDuration(uint64(m.Seconds)) + } + if m.Nanos != 0 { + n += 1 + sovDuration(uint64(m.Nanos)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovDuration(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozDuration(x uint64) (n int) { + return sovDuration(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Duration) 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 ErrIntOverflowDuration + } + 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: Duration: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) + } + m.Seconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDuration + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Seconds |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) + } + m.Nanos = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDuration + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nanos |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipDuration(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDuration + } + 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 skipDuration(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDuration + } + 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, ErrIntOverflowDuration + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDuration + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthDuration + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDuration + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipDuration(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthDuration = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDuration = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_187e4d5f80a83848) +} + +var fileDescriptor_duration_187e4d5f80a83848 = []byte{ + // 209 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, + 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56, + 0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5, + 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e, + 0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0x54, 0x7f, 0xe3, 0xa1, 0x1c, + 0xc3, 0x87, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, + 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e, 0xc9, 0x31, 0x7c, 0x78, 0x24, 0xc7, 0xb8, 0xe2, + 0xb1, 0x1c, 0xe3, 0x89, 0xc7, 0x72, 0x8c, 0x5c, 0xc2, 0xc9, 0xf9, 0xb9, 0x7a, 0x68, 0x56, 0x3b, + 0xf1, 0xc2, 0x2c, 0x0e, 0x00, 0x89, 0x04, 0x30, 0x46, 0xb1, 0x96, 0x54, 0x16, 0xa4, 0x16, 0xff, + 0x60, 0x64, 0x5c, 0xc4, 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0xa2, 0x25, 0x00, + 0xaa, 0x45, 0x2f, 0x3c, 0x35, 0x27, 0xc7, 0x3b, 0x2f, 0xbf, 0x3c, 0x2f, 0x04, 0xa4, 0x32, 0x89, + 0x0d, 0x6c, 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x1c, 0x64, 0x4e, 0xf6, 0x00, 0x00, + 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/duration_gogo.go b/vendor/github.com/gogo/protobuf/types/duration_gogo.go new file mode 100644 index 00000000000..90e7670e21d --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/duration_gogo.go @@ -0,0 +1,100 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2016, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package types + +import ( + "fmt" + "time" +) + +func NewPopulatedDuration(r interface { + Int63() int64 +}, easy bool) *Duration { + this := &Duration{} + maxSecs := time.Hour.Nanoseconds() / 1e9 + max := 2 * maxSecs + s := int64(r.Int63()) % max + s -= maxSecs + neg := int64(1) + if s < 0 { + neg = -1 + } + this.Seconds = s + this.Nanos = int32(neg * (r.Int63() % 1e9)) + return this +} + +func (d *Duration) String() string { + td, err := DurationFromProto(d) + if err != nil { + return fmt.Sprintf("(%v)", err) + } + return td.String() +} + +func NewPopulatedStdDuration(r interface { + Int63() int64 +}, easy bool) *time.Duration { + dur := NewPopulatedDuration(r, easy) + d, err := DurationFromProto(dur) + if err != nil { + return nil + } + return &d +} + +func SizeOfStdDuration(d time.Duration) int { + dur := DurationProto(d) + return dur.Size() +} + +func StdDurationMarshal(d time.Duration) ([]byte, error) { + size := SizeOfStdDuration(d) + buf := make([]byte, size) + _, err := StdDurationMarshalTo(d, buf) + return buf, err +} + +func StdDurationMarshalTo(d time.Duration, data []byte) (int, error) { + dur := DurationProto(d) + return dur.MarshalTo(data) +} + +func StdDurationUnmarshal(d *time.Duration, data []byte) error { + dur := &Duration{} + if err := dur.Unmarshal(data); err != nil { + return err + } + dd, err := DurationFromProto(dur) + if err != nil { + return err + } + *d = dd + return nil +} diff --git a/vendor/github.com/gogo/protobuf/types/empty.pb.go b/vendor/github.com/gogo/protobuf/types/empty.pb.go new file mode 100644 index 00000000000..323b246a680 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/empty.pb.go @@ -0,0 +1,480 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/empty.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// A generic empty message that you can re-use to avoid defining duplicated +// empty messages in your APIs. A typical example is to use it as the request +// or the response type of an API method. For instance: +// +// service Foo { +// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); +// } +// +// The JSON representation for `Empty` is empty JSON object `{}`. +type Empty struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Empty) Reset() { *m = Empty{} } +func (*Empty) ProtoMessage() {} +func (*Empty) Descriptor() ([]byte, []int) { + return fileDescriptor_empty_b366a5cbb7c614df, []int{0} +} +func (*Empty) XXX_WellKnownType() string { return "Empty" } +func (m *Empty) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Empty.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Empty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Empty.Merge(dst, src) +} +func (m *Empty) XXX_Size() int { + return m.Size() +} +func (m *Empty) XXX_DiscardUnknown() { + xxx_messageInfo_Empty.DiscardUnknown(m) +} + +var xxx_messageInfo_Empty proto.InternalMessageInfo + +func (*Empty) XXX_MessageName() string { + return "google.protobuf.Empty" +} +func init() { + proto.RegisterType((*Empty)(nil), "google.protobuf.Empty") +} +func (this *Empty) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Empty) + if !ok { + that2, ok := that.(Empty) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Empty) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Empty) + if !ok { + that2, ok := that.(Empty) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Empty) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 4) + s = append(s, "&types.Empty{") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringEmpty(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Empty) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Empty) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintEmpty(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedEmpty(r randyEmpty, easy bool) *Empty { + this := &Empty{} + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedEmpty(r, 1) + } + return this +} + +type randyEmpty interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneEmpty(r randyEmpty) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringEmpty(r randyEmpty) string { + v1 := r.Intn(100) + tmps := make([]rune, v1) + for i := 0; i < v1; i++ { + tmps[i] = randUTF8RuneEmpty(r) + } + return string(tmps) +} +func randUnrecognizedEmpty(r randyEmpty, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldEmpty(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldEmpty(dAtA []byte, r randyEmpty, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateEmpty(dAtA, uint64(key)) + v2 := r.Int63() + if r.Intn(2) == 0 { + v2 *= -1 + } + dAtA = encodeVarintPopulateEmpty(dAtA, uint64(v2)) + case 1: + dAtA = encodeVarintPopulateEmpty(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateEmpty(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateEmpty(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateEmpty(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateEmpty(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *Empty) 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 sovEmpty(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozEmpty(x uint64) (n int) { + return sovEmpty(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Empty) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Empty{`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringEmpty(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Empty) 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 ErrIntOverflowEmpty + } + 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: Empty: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Empty: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipEmpty(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEmpty + } + 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 skipEmpty(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEmpty + } + 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, ErrIntOverflowEmpty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEmpty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthEmpty + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEmpty + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipEmpty(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthEmpty = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEmpty = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("google/protobuf/empty.proto", fileDescriptor_empty_b366a5cbb7c614df) } + +var fileDescriptor_empty_b366a5cbb7c614df = []byte{ + // 176 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcd, 0x2d, 0x28, + 0xa9, 0xd4, 0x03, 0x73, 0x85, 0xf8, 0x21, 0x92, 0x7a, 0x30, 0x49, 0x25, 0x76, 0x2e, 0x56, 0x57, + 0x90, 0xbc, 0x53, 0x0b, 0xe3, 0x8d, 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xfe, 0x78, 0x28, + 0xc7, 0xd8, 0xf0, 0x48, 0x8e, 0x71, 0xc5, 0x23, 0x39, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0xf1, 0xc5, 0x23, 0x39, 0x86, 0x0f, 0x20, 0xf1, 0xc7, 0x72, + 0x8c, 0x27, 0x1e, 0xcb, 0x31, 0x72, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 0x19, 0xe8, 0xc4, 0x05, + 0x36, 0x2e, 0x00, 0xc4, 0x0d, 0x60, 0x8c, 0x62, 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0xfe, 0xc1, 0xc8, + 0xb8, 0x88, 0x89, 0xd9, 0x3d, 0xc0, 0x69, 0x15, 0x93, 0x9c, 0x3b, 0x44, 0x7d, 0x00, 0x54, 0xbd, + 0x5e, 0x78, 0x6a, 0x4e, 0x8e, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x65, 0x12, 0x1b, 0xd8, + 0x20, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x21, 0xbe, 0xb6, 0x31, 0xc6, 0x00, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/field_mask.pb.go b/vendor/github.com/gogo/protobuf/types/field_mask.pb.go new file mode 100644 index 00000000000..78ab41b742e --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/field_mask.pb.go @@ -0,0 +1,769 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/field_mask.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// `FieldMask` represents a set of symbolic field paths, for example: +// +// paths: "f.a" +// paths: "f.b.d" +// +// Here `f` represents a field in some root message, `a` and `b` +// fields in the message found in `f`, and `d` a field found in the +// message in `f.b`. +// +// Field masks are used to specify a subset of fields that should be +// returned by a get operation or modified by an update operation. +// Field masks also have a custom JSON encoding (see below). +// +// # Field Masks in Projections +// +// When used in the context of a projection, a response message or +// sub-message is filtered by the API to only contain those fields as +// specified in the mask. For example, if the mask in the previous +// example is applied to a response message as follows: +// +// f { +// a : 22 +// b { +// d : 1 +// x : 2 +// } +// y : 13 +// } +// z: 8 +// +// The result will not contain specific values for fields x,y and z +// (their value will be set to the default, and omitted in proto text +// output): +// +// +// f { +// a : 22 +// b { +// d : 1 +// } +// } +// +// A repeated field is not allowed except at the last position of a +// paths string. +// +// If a FieldMask object is not present in a get operation, the +// operation applies to all fields (as if a FieldMask of all fields +// had been specified). +// +// Note that a field mask does not necessarily apply to the +// top-level response message. In case of a REST get operation, the +// field mask applies directly to the response, but in case of a REST +// list operation, the mask instead applies to each individual message +// in the returned resource list. In case of a REST custom method, +// other definitions may be used. Where the mask applies will be +// clearly documented together with its declaration in the API. In +// any case, the effect on the returned resource/resources is required +// behavior for APIs. +// +// # Field Masks in Update Operations +// +// A field mask in update operations specifies which fields of the +// targeted resource are going to be updated. The API is required +// to only change the values of the fields as specified in the mask +// and leave the others untouched. If a resource is passed in to +// describe the updated values, the API ignores the values of all +// fields not covered by the mask. +// +// If a repeated field is specified for an update operation, the existing +// repeated values in the target resource will be overwritten by the new values. +// Note that a repeated field is only allowed in the last position of a `paths` +// string. +// +// If a sub-message is specified in the last position of the field mask for an +// update operation, then the existing sub-message in the target resource is +// overwritten. Given the target message: +// +// f { +// b { +// d : 1 +// x : 2 +// } +// c : 1 +// } +// +// And an update message: +// +// f { +// b { +// d : 10 +// } +// } +// +// then if the field mask is: +// +// paths: "f.b" +// +// then the result will be: +// +// f { +// b { +// d : 10 +// } +// c : 1 +// } +// +// However, if the update mask was: +// +// paths: "f.b.d" +// +// then the result would be: +// +// f { +// b { +// d : 10 +// x : 2 +// } +// c : 1 +// } +// +// In order to reset a field's value to the default, the field must +// be in the mask and set to the default value in the provided resource. +// Hence, in order to reset all fields of a resource, provide a default +// instance of the resource and set all fields in the mask, or do +// not provide a mask as described below. +// +// If a field mask is not present on update, the operation applies to +// all fields (as if a field mask of all fields has been specified). +// Note that in the presence of schema evolution, this may mean that +// fields the client does not know and has therefore not filled into +// the request will be reset to their default. If this is unwanted +// behavior, a specific service may require a client to always specify +// a field mask, producing an error if not. +// +// As with get operations, the location of the resource which +// describes the updated values in the request message depends on the +// operation kind. In any case, the effect of the field mask is +// required to be honored by the API. +// +// ## Considerations for HTTP REST +// +// The HTTP kind of an update operation which uses a field mask must +// be set to PATCH instead of PUT in order to satisfy HTTP semantics +// (PUT must only be used for full updates). +// +// # JSON Encoding of Field Masks +// +// In JSON, a field mask is encoded as a single string where paths are +// separated by a comma. Fields name in each path are converted +// to/from lower-camel naming conventions. +// +// As an example, consider the following message declarations: +// +// message Profile { +// User user = 1; +// Photo photo = 2; +// } +// message User { +// string display_name = 1; +// string address = 2; +// } +// +// In proto a field mask for `Profile` may look as such: +// +// mask { +// paths: "user.display_name" +// paths: "photo" +// } +// +// In JSON, the same mask is represented as below: +// +// { +// mask: "user.displayName,photo" +// } +// +// # Field Masks and Oneof Fields +// +// Field masks treat fields in oneofs just as regular fields. Consider the +// following message: +// +// message SampleMessage { +// oneof test_oneof { +// string name = 4; +// SubMessage sub_message = 9; +// } +// } +// +// The field mask can be: +// +// mask { +// paths: "name" +// } +// +// Or: +// +// mask { +// paths: "sub_message" +// } +// +// Note that oneof type names ("test_oneof" in this case) cannot be used in +// paths. +// +// ## Field Mask Verification +// +// The implementation of the all the API methods, which have any FieldMask type +// field in the request, should verify the included field paths, and return +// `INVALID_ARGUMENT` error if any path is duplicated or unmappable. +type FieldMask struct { + // The set of field mask paths. + Paths []string `protobuf:"bytes,1,rep,name=paths" json:"paths,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FieldMask) Reset() { *m = FieldMask{} } +func (*FieldMask) ProtoMessage() {} +func (*FieldMask) Descriptor() ([]byte, []int) { + return fileDescriptor_field_mask_f1676d06eb3d88ba, []int{0} +} +func (m *FieldMask) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FieldMask) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FieldMask.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *FieldMask) XXX_Merge(src proto.Message) { + xxx_messageInfo_FieldMask.Merge(dst, src) +} +func (m *FieldMask) XXX_Size() int { + return m.Size() +} +func (m *FieldMask) XXX_DiscardUnknown() { + xxx_messageInfo_FieldMask.DiscardUnknown(m) +} + +var xxx_messageInfo_FieldMask proto.InternalMessageInfo + +func (m *FieldMask) GetPaths() []string { + if m != nil { + return m.Paths + } + return nil +} + +func (*FieldMask) XXX_MessageName() string { + return "google.protobuf.FieldMask" +} +func init() { + proto.RegisterType((*FieldMask)(nil), "google.protobuf.FieldMask") +} +func (this *FieldMask) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*FieldMask) + if !ok { + that2, ok := that.(FieldMask) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if len(this.Paths) != len(that1.Paths) { + if len(this.Paths) < len(that1.Paths) { + return -1 + } + return 1 + } + for i := range this.Paths { + if this.Paths[i] != that1.Paths[i] { + if this.Paths[i] < that1.Paths[i] { + return -1 + } + return 1 + } + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *FieldMask) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FieldMask) + if !ok { + that2, ok := that.(FieldMask) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Paths) != len(that1.Paths) { + return false + } + for i := range this.Paths { + if this.Paths[i] != that1.Paths[i] { + return false + } + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *FieldMask) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.FieldMask{") + s = append(s, "Paths: "+fmt.Sprintf("%#v", this.Paths)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringFieldMask(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *FieldMask) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FieldMask) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Paths) > 0 { + for _, s := range m.Paths { + dAtA[i] = 0xa + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintFieldMask(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedFieldMask(r randyFieldMask, easy bool) *FieldMask { + this := &FieldMask{} + v1 := r.Intn(10) + this.Paths = make([]string, v1) + for i := 0; i < v1; i++ { + this.Paths[i] = string(randStringFieldMask(r)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedFieldMask(r, 2) + } + return this +} + +type randyFieldMask interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneFieldMask(r randyFieldMask) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringFieldMask(r randyFieldMask) string { + v2 := r.Intn(100) + tmps := make([]rune, v2) + for i := 0; i < v2; i++ { + tmps[i] = randUTF8RuneFieldMask(r) + } + return string(tmps) +} +func randUnrecognizedFieldMask(r randyFieldMask, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldFieldMask(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldFieldMask(dAtA []byte, r randyFieldMask, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateFieldMask(dAtA, uint64(key)) + v3 := r.Int63() + if r.Intn(2) == 0 { + v3 *= -1 + } + dAtA = encodeVarintPopulateFieldMask(dAtA, uint64(v3)) + case 1: + dAtA = encodeVarintPopulateFieldMask(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateFieldMask(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateFieldMask(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateFieldMask(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateFieldMask(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *FieldMask) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Paths) > 0 { + for _, s := range m.Paths { + l = len(s) + n += 1 + l + sovFieldMask(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovFieldMask(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozFieldMask(x uint64) (n int) { + return sovFieldMask(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *FieldMask) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&FieldMask{`, + `Paths:` + fmt.Sprintf("%v", this.Paths) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringFieldMask(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *FieldMask) 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 ErrIntOverflowFieldMask + } + 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: FieldMask: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FieldMask: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Paths", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFieldMask + } + 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 ErrInvalidLengthFieldMask + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Paths = append(m.Paths, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFieldMask(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthFieldMask + } + 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 skipFieldMask(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFieldMask + } + 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, ErrIntOverflowFieldMask + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFieldMask + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthFieldMask + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFieldMask + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipFieldMask(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthFieldMask = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFieldMask = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("google/protobuf/field_mask.proto", fileDescriptor_field_mask_f1676d06eb3d88ba) +} + +var fileDescriptor_field_mask_f1676d06eb3d88ba = []byte{ + // 200 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcb, 0x4c, 0xcd, + 0x49, 0x89, 0xcf, 0x4d, 0x2c, 0xce, 0xd6, 0x03, 0x8b, 0x09, 0xf1, 0x43, 0x54, 0xe8, 0xc1, 0x54, + 0x28, 0x29, 0x72, 0x71, 0xba, 0x81, 0x14, 0xf9, 0x26, 0x16, 0x67, 0x0b, 0x89, 0x70, 0xb1, 0x16, + 0x24, 0x96, 0x64, 0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x06, 0x41, 0x38, 0x4e, 0xad, 0x8c, + 0x37, 0x1e, 0xca, 0x31, 0x7c, 0x78, 0x28, 0xc7, 0xf8, 0xe3, 0xa1, 0x1c, 0x63, 0xc3, 0x23, 0x39, + 0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, + 0x39, 0xc6, 0x17, 0x8f, 0xe4, 0x18, 0x3e, 0x80, 0xc4, 0x1f, 0xcb, 0x31, 0x9e, 0x78, 0x2c, 0xc7, + 0xc8, 0x25, 0x9c, 0x9c, 0x9f, 0xab, 0x87, 0x66, 0x95, 0x13, 0x1f, 0xdc, 0xa2, 0x00, 0x90, 0x50, + 0x00, 0x63, 0x14, 0x6b, 0x49, 0x65, 0x41, 0x6a, 0xf1, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, + 0x4c, 0x72, 0xee, 0x10, 0x0d, 0x01, 0x50, 0x0d, 0x7a, 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, + 0xe5, 0x79, 0x21, 0x20, 0x65, 0x49, 0x6c, 0x60, 0x93, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xcf, 0xae, 0x5b, 0xec, 0xe6, 0x00, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/protosize.go b/vendor/github.com/gogo/protobuf/types/protosize.go new file mode 100644 index 00000000000..3a2d1b7e111 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/protosize.go @@ -0,0 +1,34 @@ +package types + +func (m *Any) ProtoSize() (n int) { return m.Size() } +func (m *Api) ProtoSize() (n int) { return m.Size() } +func (m *Method) ProtoSize() (n int) { return m.Size() } +func (m *Mixin) ProtoSize() (n int) { return m.Size() } +func (m *Duration) ProtoSize() (n int) { return m.Size() } +func (m *Empty) ProtoSize() (n int) { return m.Size() } +func (m *FieldMask) ProtoSize() (n int) { return m.Size() } +func (m *SourceContext) ProtoSize() (n int) { return m.Size() } +func (m *Struct) ProtoSize() (n int) { return m.Size() } +func (m *Value) ProtoSize() (n int) { return m.Size() } +func (m *Value_NullValue) ProtoSize() (n int) { return m.Size() } +func (m *Value_NumberValue) ProtoSize() (n int) { return m.Size() } +func (m *Value_StringValue) ProtoSize() (n int) { return m.Size() } +func (m *Value_BoolValue) ProtoSize() (n int) { return m.Size() } +func (m *Value_StructValue) ProtoSize() (n int) { return m.Size() } +func (m *Value_ListValue) ProtoSize() (n int) { return m.Size() } +func (m *ListValue) ProtoSize() (n int) { return m.Size() } +func (m *Timestamp) ProtoSize() (n int) { return m.Size() } +func (m *Type) ProtoSize() (n int) { return m.Size() } +func (m *Field) ProtoSize() (n int) { return m.Size() } +func (m *Enum) ProtoSize() (n int) { return m.Size() } +func (m *EnumValue) ProtoSize() (n int) { return m.Size() } +func (m *Option) ProtoSize() (n int) { return m.Size() } +func (m *DoubleValue) ProtoSize() (n int) { return m.Size() } +func (m *FloatValue) ProtoSize() (n int) { return m.Size() } +func (m *Int64Value) ProtoSize() (n int) { return m.Size() } +func (m *UInt64Value) ProtoSize() (n int) { return m.Size() } +func (m *Int32Value) ProtoSize() (n int) { return m.Size() } +func (m *UInt32Value) ProtoSize() (n int) { return m.Size() } +func (m *BoolValue) ProtoSize() (n int) { return m.Size() } +func (m *StringValue) ProtoSize() (n int) { return m.Size() } +func (m *BytesValue) ProtoSize() (n int) { return m.Size() } diff --git a/vendor/github.com/gogo/protobuf/types/source_context.pb.go b/vendor/github.com/gogo/protobuf/types/source_context.pb.go new file mode 100644 index 00000000000..97b6d62abd6 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/source_context.pb.go @@ -0,0 +1,538 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/source_context.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// `SourceContext` represents information about the source of a +// protobuf element, like the file in which it is defined. +type SourceContext struct { + // The path-qualified name of the .proto file that contained the associated + // protobuf element. For example: `"google/protobuf/source_context.proto"`. + FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SourceContext) Reset() { *m = SourceContext{} } +func (*SourceContext) ProtoMessage() {} +func (*SourceContext) Descriptor() ([]byte, []int) { + return fileDescriptor_source_context_b387e69fb08d10e5, []int{0} +} +func (m *SourceContext) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SourceContext) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SourceContext.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *SourceContext) XXX_Merge(src proto.Message) { + xxx_messageInfo_SourceContext.Merge(dst, src) +} +func (m *SourceContext) XXX_Size() int { + return m.Size() +} +func (m *SourceContext) XXX_DiscardUnknown() { + xxx_messageInfo_SourceContext.DiscardUnknown(m) +} + +var xxx_messageInfo_SourceContext proto.InternalMessageInfo + +func (m *SourceContext) GetFileName() string { + if m != nil { + return m.FileName + } + return "" +} + +func (*SourceContext) XXX_MessageName() string { + return "google.protobuf.SourceContext" +} +func init() { + proto.RegisterType((*SourceContext)(nil), "google.protobuf.SourceContext") +} +func (this *SourceContext) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*SourceContext) + if !ok { + that2, ok := that.(SourceContext) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.FileName != that1.FileName { + if this.FileName < that1.FileName { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *SourceContext) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SourceContext) + if !ok { + that2, ok := that.(SourceContext) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.FileName != that1.FileName { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *SourceContext) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.SourceContext{") + s = append(s, "FileName: "+fmt.Sprintf("%#v", this.FileName)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringSourceContext(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *SourceContext) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SourceContext) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.FileName) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSourceContext(dAtA, i, uint64(len(m.FileName))) + i += copy(dAtA[i:], m.FileName) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintSourceContext(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedSourceContext(r randySourceContext, easy bool) *SourceContext { + this := &SourceContext{} + this.FileName = string(randStringSourceContext(r)) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedSourceContext(r, 2) + } + return this +} + +type randySourceContext interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneSourceContext(r randySourceContext) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringSourceContext(r randySourceContext) string { + v1 := r.Intn(100) + tmps := make([]rune, v1) + for i := 0; i < v1; i++ { + tmps[i] = randUTF8RuneSourceContext(r) + } + return string(tmps) +} +func randUnrecognizedSourceContext(r randySourceContext, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldSourceContext(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldSourceContext(dAtA []byte, r randySourceContext, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key)) + v2 := r.Int63() + if r.Intn(2) == 0 { + v2 *= -1 + } + dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(v2)) + case 1: + dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateSourceContext(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateSourceContext(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *SourceContext) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FileName) + if l > 0 { + n += 1 + l + sovSourceContext(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovSourceContext(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozSourceContext(x uint64) (n int) { + return sovSourceContext(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *SourceContext) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SourceContext{`, + `FileName:` + fmt.Sprintf("%v", this.FileName) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringSourceContext(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *SourceContext) 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 ErrIntOverflowSourceContext + } + 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: SourceContext: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SourceContext: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FileName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSourceContext + } + 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 ErrInvalidLengthSourceContext + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FileName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSourceContext(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSourceContext + } + 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 skipSourceContext(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSourceContext + } + 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, ErrIntOverflowSourceContext + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSourceContext + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthSourceContext + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSourceContext + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipSourceContext(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthSourceContext = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSourceContext = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("google/protobuf/source_context.proto", fileDescriptor_source_context_b387e69fb08d10e5) +} + +var fileDescriptor_source_context_b387e69fb08d10e5 = []byte{ + // 212 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xce, 0x2f, 0x2d, + 0x4a, 0x4e, 0x8d, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xad, 0x28, 0xd1, 0x03, 0x8b, 0x0b, 0xf1, 0x43, + 0x54, 0xe9, 0xc1, 0x54, 0x29, 0xe9, 0x70, 0xf1, 0x06, 0x83, 0x15, 0x3a, 0x43, 0xd4, 0x09, 0x49, + 0x73, 0x71, 0xa6, 0x65, 0xe6, 0xa4, 0xc6, 0xe7, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30, 0x6a, + 0x70, 0x06, 0x71, 0x80, 0x04, 0xfc, 0x12, 0x73, 0x53, 0x9d, 0x3a, 0x19, 0x6f, 0x3c, 0x94, 0x63, + 0xf8, 0xf0, 0x50, 0x8e, 0xf1, 0xc7, 0x43, 0x39, 0xc6, 0x86, 0x47, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, + 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e, + 0xc9, 0x31, 0x7c, 0x00, 0x89, 0x3f, 0x96, 0x63, 0x3c, 0xf1, 0x58, 0x8e, 0x91, 0x4b, 0x38, 0x39, + 0x3f, 0x57, 0x0f, 0xcd, 0x56, 0x27, 0x21, 0x14, 0x3b, 0x03, 0x40, 0xc2, 0x01, 0x8c, 0x51, 0xac, + 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x8b, 0x98, 0x98, 0xdd, 0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43, + 0x34, 0x05, 0x40, 0x35, 0xe9, 0x85, 0xa7, 0xe6, 0xe4, 0x78, 0xe7, 0xe5, 0x97, 0xe7, 0x85, 0x80, + 0x94, 0x25, 0xb1, 0x81, 0x4d, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x37, 0x2a, 0xa1, + 0xf9, 0x00, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/struct.pb.go b/vendor/github.com/gogo/protobuf/types/struct.pb.go new file mode 100644 index 00000000000..ee7b77a7dbb --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/struct.pb.go @@ -0,0 +1,1986 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/struct.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import strconv "strconv" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" +import github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + +import encoding_binary "encoding/binary" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// `NullValue` is a singleton enumeration to represent the null value for the +// `Value` type union. +// +// The JSON representation for `NullValue` is JSON `null`. +type NullValue int32 + +const ( + // Null value. + NullValue_NULL_VALUE NullValue = 0 +) + +var NullValue_name = map[int32]string{ + 0: "NULL_VALUE", +} +var NullValue_value = map[string]int32{ + "NULL_VALUE": 0, +} + +func (NullValue) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_struct_7f9d36853146434f, []int{0} +} +func (NullValue) XXX_WellKnownType() string { return "NullValue" } + +// `Struct` represents a structured data value, consisting of fields +// which map to dynamically typed values. In some languages, `Struct` +// might be supported by a native representation. For example, in +// scripting languages like JS a struct is represented as an +// object. The details of that representation are described together +// with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object. +type Struct struct { + // Unordered map of dynamically typed values. + Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Struct) Reset() { *m = Struct{} } +func (*Struct) ProtoMessage() {} +func (*Struct) Descriptor() ([]byte, []int) { + return fileDescriptor_struct_7f9d36853146434f, []int{0} +} +func (*Struct) XXX_WellKnownType() string { return "Struct" } +func (m *Struct) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Struct) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Struct.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Struct) XXX_Merge(src proto.Message) { + xxx_messageInfo_Struct.Merge(dst, src) +} +func (m *Struct) XXX_Size() int { + return m.Size() +} +func (m *Struct) XXX_DiscardUnknown() { + xxx_messageInfo_Struct.DiscardUnknown(m) +} + +var xxx_messageInfo_Struct proto.InternalMessageInfo + +func (m *Struct) GetFields() map[string]*Value { + if m != nil { + return m.Fields + } + return nil +} + +func (*Struct) XXX_MessageName() string { + return "google.protobuf.Struct" +} + +// `Value` represents a dynamically typed value which can be either +// null, a number, a string, a boolean, a recursive struct value, or a +// list of values. A producer of value is expected to set one of that +// variants, absence of any variant indicates an error. +// +// The JSON representation for `Value` is JSON value. +type Value struct { + // The kind of value. + // + // Types that are valid to be assigned to Kind: + // *Value_NullValue + // *Value_NumberValue + // *Value_StringValue + // *Value_BoolValue + // *Value_StructValue + // *Value_ListValue + 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 (*Value) ProtoMessage() {} +func (*Value) Descriptor() ([]byte, []int) { + return fileDescriptor_struct_7f9d36853146434f, []int{1} +} +func (*Value) XXX_WellKnownType() string { return "Value" } +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.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_Value.Merge(dst, 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() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type Value_NullValue struct { + NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"` +} +type Value_NumberValue struct { + NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,proto3,oneof"` +} +type Value_StringValue struct { + StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"` +} +type Value_BoolValue struct { + BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"` +} +type Value_StructValue struct { + StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,oneof"` +} +type Value_ListValue struct { + ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,oneof"` +} + +func (*Value_NullValue) isValue_Kind() {} +func (*Value_NumberValue) isValue_Kind() {} +func (*Value_StringValue) isValue_Kind() {} +func (*Value_BoolValue) isValue_Kind() {} +func (*Value_StructValue) isValue_Kind() {} +func (*Value_ListValue) isValue_Kind() {} + +func (m *Value) GetKind() isValue_Kind { + if m != nil { + return m.Kind + } + return nil +} + +func (m *Value) GetNullValue() NullValue { + if x, ok := m.GetKind().(*Value_NullValue); ok { + return x.NullValue + } + return NullValue_NULL_VALUE +} + +func (m *Value) GetNumberValue() float64 { + if x, ok := m.GetKind().(*Value_NumberValue); ok { + return x.NumberValue + } + return 0 +} + +func (m *Value) GetStringValue() string { + if x, ok := m.GetKind().(*Value_StringValue); ok { + return x.StringValue + } + return "" +} + +func (m *Value) GetBoolValue() bool { + if x, ok := m.GetKind().(*Value_BoolValue); ok { + return x.BoolValue + } + return false +} + +func (m *Value) GetStructValue() *Struct { + if x, ok := m.GetKind().(*Value_StructValue); ok { + return x.StructValue + } + return nil +} + +func (m *Value) GetListValue() *ListValue { + if x, ok := m.GetKind().(*Value_ListValue); ok { + return x.ListValue + } + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*Value) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _Value_OneofMarshaler, _Value_OneofUnmarshaler, _Value_OneofSizer, []interface{}{ + (*Value_NullValue)(nil), + (*Value_NumberValue)(nil), + (*Value_StringValue)(nil), + (*Value_BoolValue)(nil), + (*Value_StructValue)(nil), + (*Value_ListValue)(nil), + } +} + +func _Value_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*Value) + // kind + switch x := m.Kind.(type) { + case *Value_NullValue: + _ = b.EncodeVarint(1<<3 | proto.WireVarint) + _ = b.EncodeVarint(uint64(x.NullValue)) + case *Value_NumberValue: + _ = b.EncodeVarint(2<<3 | proto.WireFixed64) + _ = b.EncodeFixed64(math.Float64bits(x.NumberValue)) + case *Value_StringValue: + _ = b.EncodeVarint(3<<3 | proto.WireBytes) + _ = b.EncodeStringBytes(x.StringValue) + case *Value_BoolValue: + t := uint64(0) + if x.BoolValue { + t = 1 + } + _ = b.EncodeVarint(4<<3 | proto.WireVarint) + _ = b.EncodeVarint(t) + case *Value_StructValue: + _ = b.EncodeVarint(5<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.StructValue); err != nil { + return err + } + case *Value_ListValue: + _ = b.EncodeVarint(6<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.ListValue); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("Value.Kind has unexpected type %T", x) + } + return nil +} + +func _Value_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*Value) + switch tag { + case 1: // kind.null_value + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.Kind = &Value_NullValue{NullValue(x)} + return true, err + case 2: // kind.number_value + if wire != proto.WireFixed64 { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeFixed64() + m.Kind = &Value_NumberValue{math.Float64frombits(x)} + return true, err + case 3: // kind.string_value + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeStringBytes() + m.Kind = &Value_StringValue{x} + return true, err + case 4: // kind.bool_value + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.Kind = &Value_BoolValue{x != 0} + return true, err + case 5: // kind.struct_value + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(Struct) + err := b.DecodeMessage(msg) + m.Kind = &Value_StructValue{msg} + return true, err + case 6: // kind.list_value + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(ListValue) + err := b.DecodeMessage(msg) + m.Kind = &Value_ListValue{msg} + return true, err + default: + return false, nil + } +} + +func _Value_OneofSizer(msg proto.Message) (n int) { + m := msg.(*Value) + // kind + switch x := m.Kind.(type) { + case *Value_NullValue: + n += 1 // tag and wire + n += proto.SizeVarint(uint64(x.NullValue)) + case *Value_NumberValue: + n += 1 // tag and wire + n += 8 + case *Value_StringValue: + n += 1 // tag and wire + n += proto.SizeVarint(uint64(len(x.StringValue))) + n += len(x.StringValue) + case *Value_BoolValue: + n += 1 // tag and wire + n += 1 + case *Value_StructValue: + s := proto.Size(x.StructValue) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case *Value_ListValue: + s := proto.Size(x.ListValue) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +func (*Value) XXX_MessageName() string { + return "google.protobuf.Value" +} + +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array. +type ListValue struct { + // Repeated field of dynamically typed values. + Values []*Value `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListValue) Reset() { *m = ListValue{} } +func (*ListValue) ProtoMessage() {} +func (*ListValue) Descriptor() ([]byte, []int) { + return fileDescriptor_struct_7f9d36853146434f, []int{2} +} +func (*ListValue) XXX_WellKnownType() string { return "ListValue" } +func (m *ListValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ListValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListValue.Merge(dst, src) +} +func (m *ListValue) XXX_Size() int { + return m.Size() +} +func (m *ListValue) XXX_DiscardUnknown() { + xxx_messageInfo_ListValue.DiscardUnknown(m) +} + +var xxx_messageInfo_ListValue proto.InternalMessageInfo + +func (m *ListValue) GetValues() []*Value { + if m != nil { + return m.Values + } + return nil +} + +func (*ListValue) XXX_MessageName() string { + return "google.protobuf.ListValue" +} +func init() { + proto.RegisterType((*Struct)(nil), "google.protobuf.Struct") + proto.RegisterMapType((map[string]*Value)(nil), "google.protobuf.Struct.FieldsEntry") + proto.RegisterType((*Value)(nil), "google.protobuf.Value") + proto.RegisterType((*ListValue)(nil), "google.protobuf.ListValue") + proto.RegisterEnum("google.protobuf.NullValue", NullValue_name, NullValue_value) +} +func (x NullValue) String() string { + s, ok := NullValue_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} +func (this *Struct) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Struct) + if !ok { + that2, ok := that.(Struct) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Fields) != len(that1.Fields) { + return false + } + for i := range this.Fields { + if !this.Fields[i].Equal(that1.Fields[i]) { + return false + } + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Value) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value) + if !ok { + that2, ok := that.(Value) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if that1.Kind == nil { + if this.Kind != nil { + return false + } + } else if this.Kind == nil { + return false + } else if !this.Kind.Equal(that1.Kind) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Value_NullValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value_NullValue) + if !ok { + that2, ok := that.(Value_NullValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.NullValue != that1.NullValue { + return false + } + return true +} +func (this *Value_NumberValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value_NumberValue) + if !ok { + that2, ok := that.(Value_NumberValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.NumberValue != that1.NumberValue { + return false + } + return true +} +func (this *Value_StringValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value_StringValue) + if !ok { + that2, ok := that.(Value_StringValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.StringValue != that1.StringValue { + return false + } + return true +} +func (this *Value_BoolValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value_BoolValue) + if !ok { + that2, ok := that.(Value_BoolValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.BoolValue != that1.BoolValue { + return false + } + return true +} +func (this *Value_StructValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value_StructValue) + if !ok { + that2, ok := that.(Value_StructValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.StructValue.Equal(that1.StructValue) { + return false + } + return true +} +func (this *Value_ListValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Value_ListValue) + if !ok { + that2, ok := that.(Value_ListValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.ListValue.Equal(that1.ListValue) { + return false + } + return true +} +func (this *ListValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ListValue) + if !ok { + that2, ok := that.(ListValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Values) != len(that1.Values) { + return false + } + for i := range this.Values { + if !this.Values[i].Equal(that1.Values[i]) { + return false + } + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Struct) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.Struct{") + keysForFields := make([]string, 0, len(this.Fields)) + for k := range this.Fields { + keysForFields = append(keysForFields, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForFields) + mapStringForFields := "map[string]*Value{" + for _, k := range keysForFields { + mapStringForFields += fmt.Sprintf("%#v: %#v,", k, this.Fields[k]) + } + mapStringForFields += "}" + if this.Fields != nil { + s = append(s, "Fields: "+mapStringForFields+",\n") + } + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Value) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&types.Value{") + if this.Kind != nil { + s = append(s, "Kind: "+fmt.Sprintf("%#v", this.Kind)+",\n") + } + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Value_NullValue) GoString() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&types.Value_NullValue{` + + `NullValue:` + fmt.Sprintf("%#v", this.NullValue) + `}`}, ", ") + return s +} +func (this *Value_NumberValue) GoString() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&types.Value_NumberValue{` + + `NumberValue:` + fmt.Sprintf("%#v", this.NumberValue) + `}`}, ", ") + return s +} +func (this *Value_StringValue) GoString() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&types.Value_StringValue{` + + `StringValue:` + fmt.Sprintf("%#v", this.StringValue) + `}`}, ", ") + return s +} +func (this *Value_BoolValue) GoString() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&types.Value_BoolValue{` + + `BoolValue:` + fmt.Sprintf("%#v", this.BoolValue) + `}`}, ", ") + return s +} +func (this *Value_StructValue) GoString() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&types.Value_StructValue{` + + `StructValue:` + fmt.Sprintf("%#v", this.StructValue) + `}`}, ", ") + return s +} +func (this *Value_ListValue) GoString() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&types.Value_ListValue{` + + `ListValue:` + fmt.Sprintf("%#v", this.ListValue) + `}`}, ", ") + return s +} +func (this *ListValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.ListValue{") + if this.Values != nil { + s = append(s, "Values: "+fmt.Sprintf("%#v", this.Values)+",\n") + } + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringStruct(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Struct) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Struct) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Fields) > 0 { + for k := range m.Fields { + dAtA[i] = 0xa + i++ + v := m.Fields[k] + msgSize := 0 + if v != nil { + msgSize = v.Size() + msgSize += 1 + sovStruct(uint64(msgSize)) + } + mapSize := 1 + len(k) + sovStruct(uint64(len(k))) + msgSize + i = encodeVarintStruct(dAtA, i, uint64(mapSize)) + dAtA[i] = 0xa + i++ + i = encodeVarintStruct(dAtA, i, uint64(len(k))) + i += copy(dAtA[i:], k) + if v != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintStruct(dAtA, i, uint64(v.Size())) + n1, err := v.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Value) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Value) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Kind != nil { + nn2, err := m.Kind.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += nn2 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Value_NullValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0x8 + i++ + i = encodeVarintStruct(dAtA, i, uint64(m.NullValue)) + return i, nil +} +func (m *Value_NumberValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0x11 + i++ + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.NumberValue)))) + i += 8 + return i, nil +} +func (m *Value_StringValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0x1a + i++ + i = encodeVarintStruct(dAtA, i, uint64(len(m.StringValue))) + i += copy(dAtA[i:], m.StringValue) + return i, nil +} +func (m *Value_BoolValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + dAtA[i] = 0x20 + i++ + if m.BoolValue { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + return i, nil +} +func (m *Value_StructValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.StructValue != nil { + dAtA[i] = 0x2a + i++ + i = encodeVarintStruct(dAtA, i, uint64(m.StructValue.Size())) + n3, err := m.StructValue.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + } + return i, nil +} +func (m *Value_ListValue) MarshalTo(dAtA []byte) (int, error) { + i := 0 + if m.ListValue != nil { + dAtA[i] = 0x32 + i++ + i = encodeVarintStruct(dAtA, i, uint64(m.ListValue.Size())) + n4, err := m.ListValue.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + } + return i, nil +} +func (m *ListValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Values) > 0 { + for _, msg := range m.Values { + dAtA[i] = 0xa + i++ + i = encodeVarintStruct(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintStruct(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedStruct(r randyStruct, easy bool) *Struct { + this := &Struct{} + if r.Intn(10) == 0 { + v1 := r.Intn(10) + this.Fields = make(map[string]*Value) + for i := 0; i < v1; i++ { + this.Fields[randStringStruct(r)] = NewPopulatedValue(r, easy) + } + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedStruct(r, 2) + } + return this +} + +func NewPopulatedValue(r randyStruct, easy bool) *Value { + this := &Value{} + oneofNumber_Kind := []int32{1, 2, 3, 4, 5, 6}[r.Intn(6)] + switch oneofNumber_Kind { + case 1: + this.Kind = NewPopulatedValue_NullValue(r, easy) + case 2: + this.Kind = NewPopulatedValue_NumberValue(r, easy) + case 3: + this.Kind = NewPopulatedValue_StringValue(r, easy) + case 4: + this.Kind = NewPopulatedValue_BoolValue(r, easy) + case 5: + this.Kind = NewPopulatedValue_StructValue(r, easy) + case 6: + this.Kind = NewPopulatedValue_ListValue(r, easy) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedStruct(r, 7) + } + return this +} + +func NewPopulatedValue_NullValue(r randyStruct, easy bool) *Value_NullValue { + this := &Value_NullValue{} + this.NullValue = NullValue([]int32{0}[r.Intn(1)]) + return this +} +func NewPopulatedValue_NumberValue(r randyStruct, easy bool) *Value_NumberValue { + this := &Value_NumberValue{} + this.NumberValue = float64(r.Float64()) + if r.Intn(2) == 0 { + this.NumberValue *= -1 + } + return this +} +func NewPopulatedValue_StringValue(r randyStruct, easy bool) *Value_StringValue { + this := &Value_StringValue{} + this.StringValue = string(randStringStruct(r)) + return this +} +func NewPopulatedValue_BoolValue(r randyStruct, easy bool) *Value_BoolValue { + this := &Value_BoolValue{} + this.BoolValue = bool(bool(r.Intn(2) == 0)) + return this +} +func NewPopulatedValue_StructValue(r randyStruct, easy bool) *Value_StructValue { + this := &Value_StructValue{} + this.StructValue = NewPopulatedStruct(r, easy) + return this +} +func NewPopulatedValue_ListValue(r randyStruct, easy bool) *Value_ListValue { + this := &Value_ListValue{} + this.ListValue = NewPopulatedListValue(r, easy) + return this +} +func NewPopulatedListValue(r randyStruct, easy bool) *ListValue { + this := &ListValue{} + if r.Intn(10) == 0 { + v2 := r.Intn(5) + this.Values = make([]*Value, v2) + for i := 0; i < v2; i++ { + this.Values[i] = NewPopulatedValue(r, easy) + } + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedStruct(r, 2) + } + return this +} + +type randyStruct interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneStruct(r randyStruct) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringStruct(r randyStruct) string { + v3 := r.Intn(100) + tmps := make([]rune, v3) + for i := 0; i < v3; i++ { + tmps[i] = randUTF8RuneStruct(r) + } + return string(tmps) +} +func randUnrecognizedStruct(r randyStruct, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldStruct(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldStruct(dAtA []byte, r randyStruct, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateStruct(dAtA, uint64(key)) + v4 := r.Int63() + if r.Intn(2) == 0 { + v4 *= -1 + } + dAtA = encodeVarintPopulateStruct(dAtA, uint64(v4)) + case 1: + dAtA = encodeVarintPopulateStruct(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateStruct(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateStruct(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateStruct(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateStruct(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *Struct) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Fields) > 0 { + for k, v := range m.Fields { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovStruct(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovStruct(uint64(len(k))) + l + n += mapEntrySize + 1 + sovStruct(uint64(mapEntrySize)) + } + } + 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_NullValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovStruct(uint64(m.NullValue)) + return n +} +func (m *Value_NumberValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 9 + return n +} +func (m *Value_StringValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StringValue) + n += 1 + l + sovStruct(uint64(l)) + return n +} +func (m *Value_BoolValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 2 + return n +} +func (m *Value_StructValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StructValue != nil { + l = m.StructValue.Size() + n += 1 + l + sovStruct(uint64(l)) + } + return n +} +func (m *Value_ListValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ListValue != nil { + l = m.ListValue.Size() + n += 1 + l + sovStruct(uint64(l)) + } + return n +} +func (m *ListValue) 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 + sovStruct(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovStruct(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozStruct(x uint64) (n int) { + return sovStruct(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Struct) String() string { + if this == nil { + return "nil" + } + keysForFields := make([]string, 0, len(this.Fields)) + for k := range this.Fields { + keysForFields = append(keysForFields, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForFields) + mapStringForFields := "map[string]*Value{" + for _, k := range keysForFields { + mapStringForFields += fmt.Sprintf("%v: %v,", k, this.Fields[k]) + } + mapStringForFields += "}" + s := strings.Join([]string{`&Struct{`, + `Fields:` + mapStringForFields + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Value) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value{`, + `Kind:` + fmt.Sprintf("%v", this.Kind) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Value_NullValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value_NullValue{`, + `NullValue:` + fmt.Sprintf("%v", this.NullValue) + `,`, + `}`, + }, "") + return s +} +func (this *Value_NumberValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value_NumberValue{`, + `NumberValue:` + fmt.Sprintf("%v", this.NumberValue) + `,`, + `}`, + }, "") + return s +} +func (this *Value_StringValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value_StringValue{`, + `StringValue:` + fmt.Sprintf("%v", this.StringValue) + `,`, + `}`, + }, "") + return s +} +func (this *Value_BoolValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value_BoolValue{`, + `BoolValue:` + fmt.Sprintf("%v", this.BoolValue) + `,`, + `}`, + }, "") + return s +} +func (this *Value_StructValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value_StructValue{`, + `StructValue:` + strings.Replace(fmt.Sprintf("%v", this.StructValue), "Struct", "Struct", 1) + `,`, + `}`, + }, "") + return s +} +func (this *Value_ListValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Value_ListValue{`, + `ListValue:` + strings.Replace(fmt.Sprintf("%v", this.ListValue), "ListValue", "ListValue", 1) + `,`, + `}`, + }, "") + return s +} +func (this *ListValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ListValue{`, + `Values:` + strings.Replace(fmt.Sprintf("%v", this.Values), "Value", "Value", 1) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringStruct(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Struct) 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 ErrIntOverflowStruct + } + 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: Struct: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Struct: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStruct + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fields == nil { + m.Fields = make(map[string]*Value) + } + var mapkey string + var mapvalue *Value + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthStruct + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthStruct + } + postmsgIndex := iNdEx + mapmsglen + if mapmsglen < 0 { + return ErrInvalidLengthStruct + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Value{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipStruct(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthStruct + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Fields[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStruct(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthStruct + } + 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 ErrIntOverflowStruct + } + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NullValue", wireType) + } + var v NullValue + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (NullValue(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Kind = &Value_NullValue{v} + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberValue", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Kind = &Value_NumberValue{float64(math.Float64frombits(v))} + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StringValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + 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 ErrInvalidLengthStruct + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Kind = &Value_StringValue{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BoolValue", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + b := bool(v != 0) + m.Kind = &Value_BoolValue{b} + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StructValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStruct + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &Struct{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_StructValue{v} + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ListValue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStruct + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ListValue{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Kind = &Value_ListValue{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStruct(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthStruct + } + 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 *ListValue) 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 ErrIntOverflowStruct + } + 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: ListValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListValue: 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 ErrIntOverflowStruct + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStruct + } + postIndex := iNdEx + msglen + 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 := skipStruct(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthStruct + } + 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 skipStruct(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStruct + } + 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, ErrIntOverflowStruct + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStruct + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthStruct + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStruct + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipStruct(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthStruct = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStruct = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("google/protobuf/struct.proto", fileDescriptor_struct_7f9d36853146434f) +} + +var fileDescriptor_struct_7f9d36853146434f = []byte{ + // 439 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x6b, 0xd4, 0x40, + 0x14, 0xc6, 0xf3, 0xb2, 0xdd, 0xe0, 0xbe, 0x48, 0x2d, 0x23, 0xe8, 0x52, 0x65, 0x5c, 0xb6, 0x97, + 0x45, 0x24, 0x85, 0xf5, 0x22, 0xae, 0x17, 0x17, 0x6a, 0x0b, 0x86, 0x12, 0xa3, 0xad, 0xe0, 0x65, + 0x31, 0x69, 0xba, 0x84, 0x4e, 0x67, 0x4a, 0x32, 0xa3, 0xec, 0x4d, 0xff, 0x0b, 0xcf, 0x9e, 0xc4, + 0xa3, 0x7f, 0x85, 0x47, 0x8f, 0x1e, 0xdd, 0x78, 0xf1, 0xd8, 0x63, 0x8f, 0x32, 0x33, 0x49, 0x94, + 0x2e, 0xbd, 0xe5, 0x7d, 0xf3, 0x7b, 0xdf, 0x7b, 0xdf, 0x0b, 0xde, 0x9d, 0x0b, 0x31, 0x67, 0xd9, + 0xf6, 0x59, 0x21, 0xa4, 0x48, 0xd4, 0xf1, 0x76, 0x29, 0x0b, 0x95, 0xca, 0xc0, 0xd4, 0xe4, 0x86, + 0x7d, 0x0d, 0x9a, 0xd7, 0xe1, 0x27, 0x40, 0xef, 0xa5, 0x21, 0xc8, 0x04, 0xbd, 0xe3, 0x3c, 0x63, + 0x47, 0x65, 0x1f, 0x06, 0x9d, 0x91, 0x3f, 0xde, 0x0a, 0x2e, 0xc1, 0x81, 0x05, 0x83, 0x67, 0x86, + 0xda, 0xe1, 0xb2, 0x58, 0xc4, 0x75, 0xcb, 0xe6, 0x0b, 0xf4, 0xff, 0x93, 0xc9, 0x06, 0x76, 0x4e, + 0xb2, 0x45, 0x1f, 0x06, 0x30, 0xea, 0xc5, 0xfa, 0x93, 0x3c, 0xc0, 0xee, 0xbb, 0xb7, 0x4c, 0x65, + 0x7d, 0x77, 0x00, 0x23, 0x7f, 0x7c, 0x6b, 0xc5, 0xfc, 0x50, 0xbf, 0xc6, 0x16, 0x7a, 0xec, 0x3e, + 0x82, 0xe1, 0x37, 0x17, 0xbb, 0x46, 0x24, 0x13, 0x44, 0xae, 0x18, 0x9b, 0x59, 0x03, 0x6d, 0xba, + 0x3e, 0xde, 0x5c, 0x31, 0xd8, 0x57, 0x8c, 0x19, 0x7e, 0xcf, 0x89, 0x7b, 0xbc, 0x29, 0xc8, 0x16, + 0x5e, 0xe7, 0xea, 0x34, 0xc9, 0x8a, 0xd9, 0xbf, 0xf9, 0xb0, 0xe7, 0xc4, 0xbe, 0x55, 0x5b, 0xa8, + 0x94, 0x45, 0xce, 0xe7, 0x35, 0xd4, 0xd1, 0x8b, 0x6b, 0xc8, 0xaa, 0x16, 0xba, 0x87, 0x98, 0x08, + 0xd1, 0xac, 0xb1, 0x36, 0x80, 0xd1, 0x35, 0x3d, 0x4a, 0x6b, 0x16, 0x78, 0x62, 0x5c, 0x54, 0x2a, + 0x6b, 0xa4, 0x6b, 0xa2, 0xde, 0xbe, 0xe2, 0x8e, 0xb5, 0xbd, 0x4a, 0x65, 0x9b, 0x92, 0xe5, 0x65, + 0xd3, 0xeb, 0x99, 0xde, 0xd5, 0x94, 0x61, 0x5e, 0xca, 0x36, 0x25, 0x6b, 0x8a, 0xa9, 0x87, 0x6b, + 0x27, 0x39, 0x3f, 0x1a, 0x4e, 0xb0, 0xd7, 0x12, 0x24, 0x40, 0xcf, 0x98, 0x35, 0x7f, 0xf4, 0xaa, + 0xa3, 0xd7, 0xd4, 0xfd, 0x3b, 0xd8, 0x6b, 0x8f, 0x48, 0xd6, 0x11, 0xf7, 0x0f, 0xc2, 0x70, 0x76, + 0xf8, 0x34, 0x3c, 0xd8, 0xd9, 0x70, 0xa6, 0x1f, 0xe1, 0xe7, 0x92, 0x3a, 0xe7, 0x4b, 0x0a, 0x17, + 0x4b, 0x0a, 0x1f, 0x2a, 0x0a, 0x5f, 0x2a, 0x0a, 0xdf, 0x2b, 0x0a, 0x3f, 0x2a, 0x0a, 0xbf, 0x2a, + 0x0a, 0x7f, 0x2a, 0xea, 0x9c, 0x6b, 0xed, 0x37, 0x05, 0xbc, 0x99, 0x8a, 0xd3, 0xcb, 0xe3, 0xa6, + 0xbe, 0x4d, 0x1e, 0xe9, 0x3a, 0x82, 0x37, 0x5d, 0xb9, 0x38, 0xcb, 0xca, 0x0b, 0x80, 0xcf, 0x6e, + 0x67, 0x37, 0x9a, 0x7e, 0x75, 0xe9, 0xae, 0x6d, 0x88, 0x9a, 0xfd, 0x5e, 0x67, 0x8c, 0x3d, 0xe7, + 0xe2, 0x3d, 0x7f, 0xa5, 0xc9, 0xc4, 0x33, 0x4e, 0x0f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xad, + 0x84, 0x08, 0xae, 0xe5, 0x02, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/timestamp.go b/vendor/github.com/gogo/protobuf/types/timestamp.go new file mode 100644 index 00000000000..7ae54d8b3ff --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/timestamp.go @@ -0,0 +1,132 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2016 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package types + +// This file implements operations on google.protobuf.Timestamp. + +import ( + "errors" + "fmt" + "time" +) + +const ( + // Seconds field of the earliest valid Timestamp. + // This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). + minValidSeconds = -62135596800 + // Seconds field just after the latest valid Timestamp. + // This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix(). + maxValidSeconds = 253402300800 +) + +// validateTimestamp determines whether a Timestamp is valid. +// A valid timestamp represents a time in the range +// [0001-01-01, 10000-01-01) and has a Nanos field +// in the range [0, 1e9). +// +// If the Timestamp is valid, validateTimestamp returns nil. +// Otherwise, it returns an error that describes +// the problem. +// +// Every valid Timestamp can be represented by a time.Time, but the converse is not true. +func validateTimestamp(ts *Timestamp) error { + if ts == nil { + return errors.New("timestamp: nil Timestamp") + } + if ts.Seconds < minValidSeconds { + return fmt.Errorf("timestamp: %#v before 0001-01-01", ts) + } + if ts.Seconds >= maxValidSeconds { + return fmt.Errorf("timestamp: %#v after 10000-01-01", ts) + } + if ts.Nanos < 0 || ts.Nanos >= 1e9 { + return fmt.Errorf("timestamp: %#v: nanos not in range [0, 1e9)", ts) + } + return nil +} + +// TimestampFromProto converts a google.protobuf.Timestamp proto to a time.Time. +// It returns an error if the argument is invalid. +// +// Unlike most Go functions, if Timestamp returns an error, the first return value +// is not the zero time.Time. Instead, it is the value obtained from the +// time.Unix function when passed the contents of the Timestamp, in the UTC +// locale. This may or may not be a meaningful time; many invalid Timestamps +// do map to valid time.Times. +// +// A nil Timestamp returns an error. The first return value in that case is +// undefined. +func TimestampFromProto(ts *Timestamp) (time.Time, error) { + // Don't return the zero value on error, because corresponds to a valid + // timestamp. Instead return whatever time.Unix gives us. + var t time.Time + if ts == nil { + t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp + } else { + t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC() + } + return t, validateTimestamp(ts) +} + +// TimestampNow returns a google.protobuf.Timestamp for the current time. +func TimestampNow() *Timestamp { + ts, err := TimestampProto(time.Now()) + if err != nil { + panic("ptypes: time.Now() out of Timestamp range") + } + return ts +} + +// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. +// It returns an error if the resulting Timestamp is invalid. +func TimestampProto(t time.Time) (*Timestamp, error) { + seconds := t.Unix() + nanos := int32(t.Sub(time.Unix(seconds, 0))) + ts := &Timestamp{ + Seconds: seconds, + Nanos: nanos, + } + if err := validateTimestamp(ts); err != nil { + return nil, err + } + return ts, nil +} + +// TimestampString returns the RFC 3339 string for valid Timestamps. For invalid +// Timestamps, it returns an error message in parentheses. +func TimestampString(ts *Timestamp) string { + t, err := TimestampFromProto(ts) + if err != nil { + return fmt.Sprintf("(%v)", err) + } + return t.Format(time.RFC3339Nano) +} diff --git a/vendor/github.com/gogo/protobuf/types/timestamp.pb.go b/vendor/github.com/gogo/protobuf/types/timestamp.pb.go new file mode 100644 index 00000000000..b6c9100127d --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/timestamp.pb.go @@ -0,0 +1,555 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/timestamp.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// A Timestamp represents a point in time independent of any time zone +// or calendar, represented as seconds and fractions of seconds at +// nanosecond resolution in UTC Epoch time. It is encoded using the +// Proleptic Gregorian Calendar which extends the Gregorian calendar +// backwards to year one. It is encoded assuming all minutes are 60 +// seconds long, i.e. leap seconds are "smeared" so that no leap second +// table is needed for interpretation. Range is from +// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. +// By restricting to that range, we ensure that we can convert to +// and from RFC 3339 date strings. +// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). +// +// # Examples +// +// Example 1: Compute Timestamp from POSIX `time()`. +// +// Timestamp timestamp; +// timestamp.set_seconds(time(NULL)); +// timestamp.set_nanos(0); +// +// Example 2: Compute Timestamp from POSIX `gettimeofday()`. +// +// struct timeval tv; +// gettimeofday(&tv, NULL); +// +// Timestamp timestamp; +// timestamp.set_seconds(tv.tv_sec); +// timestamp.set_nanos(tv.tv_usec * 1000); +// +// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. +// +// FILETIME ft; +// GetSystemTimeAsFileTime(&ft); +// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; +// +// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z +// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. +// Timestamp timestamp; +// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); +// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); +// +// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. +// +// long millis = System.currentTimeMillis(); +// +// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) +// .setNanos((int) ((millis % 1000) * 1000000)).build(); +// +// +// Example 5: Compute Timestamp from current time in Python. +// +// timestamp = Timestamp() +// timestamp.GetCurrentTime() +// +// # JSON Mapping +// +// In JSON format, the Timestamp type is encoded as a string in the +// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the +// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" +// where {year} is always expressed using four digits while {month}, {day}, +// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional +// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), +// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone +// is required. A proto3 JSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// able to accept both UTC and other timezones (as indicated by an offset). +// +// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past +// 01:30 UTC on January 15, 2017. +// +// In JavaScript, one can convert a Date object to this format using the +// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] +// method. In Python, a standard `datetime.datetime` object can be converted +// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) +// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one +// can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime-- +// ) to obtain a formatter capable of generating timestamps in this format. +// +// +type Timestamp struct { + // Represents seconds of UTC time since Unix epoch + // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + // 9999-12-31T23:59:59Z inclusive. + Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` + // Non-negative fractions of a second at nanosecond resolution. Negative + // second values with fractions must still have non-negative nanos values + // that count forward in time. Must be from 0 to 999,999,999 + // inclusive. + Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Timestamp) Reset() { *m = Timestamp{} } +func (*Timestamp) ProtoMessage() {} +func (*Timestamp) Descriptor() ([]byte, []int) { + return fileDescriptor_timestamp_820f61227bd8f1e8, []int{0} +} +func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } +func (m *Timestamp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Timestamp) XXX_Merge(src proto.Message) { + xxx_messageInfo_Timestamp.Merge(dst, src) +} +func (m *Timestamp) XXX_Size() int { + return m.Size() +} +func (m *Timestamp) XXX_DiscardUnknown() { + xxx_messageInfo_Timestamp.DiscardUnknown(m) +} + +var xxx_messageInfo_Timestamp proto.InternalMessageInfo + +func (m *Timestamp) GetSeconds() int64 { + if m != nil { + return m.Seconds + } + return 0 +} + +func (m *Timestamp) GetNanos() int32 { + if m != nil { + return m.Nanos + } + return 0 +} + +func (*Timestamp) XXX_MessageName() string { + return "google.protobuf.Timestamp" +} +func init() { + proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") +} +func (this *Timestamp) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Timestamp) + if !ok { + that2, ok := that.(Timestamp) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Seconds != that1.Seconds { + if this.Seconds < that1.Seconds { + return -1 + } + return 1 + } + if this.Nanos != that1.Nanos { + if this.Nanos < that1.Nanos { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Timestamp) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Timestamp) + if !ok { + that2, ok := that.(Timestamp) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Seconds != that1.Seconds { + return false + } + if this.Nanos != that1.Nanos { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Timestamp) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&types.Timestamp{") + s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n") + s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringTimestamp(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Timestamp) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Timestamp) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Seconds != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintTimestamp(dAtA, i, uint64(m.Seconds)) + } + if m.Nanos != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintTimestamp(dAtA, i, uint64(m.Nanos)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintTimestamp(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *Timestamp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Seconds != 0 { + n += 1 + sovTimestamp(uint64(m.Seconds)) + } + if m.Nanos != 0 { + n += 1 + sovTimestamp(uint64(m.Nanos)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovTimestamp(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozTimestamp(x uint64) (n int) { + return sovTimestamp(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Timestamp) 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 ErrIntOverflowTimestamp + } + 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: Timestamp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Timestamp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) + } + m.Seconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTimestamp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Seconds |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) + } + m.Nanos = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTimestamp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nanos |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTimestamp(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTimestamp + } + 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 skipTimestamp(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTimestamp + } + 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, ErrIntOverflowTimestamp + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTimestamp + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthTimestamp + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTimestamp + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipTimestamp(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthTimestamp = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTimestamp = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor_timestamp_820f61227bd8f1e8) +} + +var fileDescriptor_timestamp_820f61227bd8f1e8 = []byte{ + // 212 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0xc9, 0xcc, 0x4d, + 0x2d, 0x2e, 0x49, 0xcc, 0x2d, 0xd0, 0x03, 0x0b, 0x09, 0xf1, 0x43, 0x14, 0xe8, 0xc1, 0x14, 0x28, + 0x59, 0x73, 0x71, 0x86, 0xc0, 0xd4, 0x08, 0x49, 0x70, 0xb1, 0x17, 0xa7, 0x26, 0xe7, 0xe7, 0xa5, + 0x14, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, 0x42, 0x22, 0x5c, 0xac, 0x79, 0x89, + 0x79, 0xf9, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xac, 0x41, 0x10, 0x8e, 0x53, 0x03, 0xe3, 0x8d, + 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xae, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, + 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xbe, 0x78, 0x24, 0xc7, 0xf0, 0xe1, 0x91, 0x1c, + 0xe3, 0x8a, 0xc7, 0x72, 0x8c, 0x27, 0x1e, 0xcb, 0x31, 0x72, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, + 0x59, 0xee, 0xc4, 0x07, 0xb7, 0x3a, 0x00, 0x24, 0x14, 0xc0, 0x18, 0xc5, 0x5a, 0x52, 0x59, 0x90, + 0x5a, 0xfc, 0x83, 0x91, 0x71, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, + 0x9e, 0x00, 0xa8, 0x1e, 0xbd, 0xf0, 0xd4, 0x9c, 0x1c, 0xef, 0xbc, 0xfc, 0xf2, 0xbc, 0x10, 0x90, + 0xca, 0x24, 0x36, 0xb0, 0x61, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x23, 0x83, 0xdd, + 0xfa, 0x00, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/timestamp_gogo.go b/vendor/github.com/gogo/protobuf/types/timestamp_gogo.go new file mode 100644 index 00000000000..e03fa131583 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/timestamp_gogo.go @@ -0,0 +1,94 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2016, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package types + +import ( + "time" +) + +func NewPopulatedTimestamp(r interface { + Int63() int64 +}, easy bool) *Timestamp { + this := &Timestamp{} + ns := int64(r.Int63()) + this.Seconds = ns / 1e9 + this.Nanos = int32(ns % 1e9) + return this +} + +func (ts *Timestamp) String() string { + return TimestampString(ts) +} + +func NewPopulatedStdTime(r interface { + Int63() int64 +}, easy bool) *time.Time { + timestamp := NewPopulatedTimestamp(r, easy) + t, err := TimestampFromProto(timestamp) + if err != nil { + return nil + } + return &t +} + +func SizeOfStdTime(t time.Time) int { + ts, err := TimestampProto(t) + if err != nil { + return 0 + } + return ts.Size() +} + +func StdTimeMarshal(t time.Time) ([]byte, error) { + size := SizeOfStdTime(t) + buf := make([]byte, size) + _, err := StdTimeMarshalTo(t, buf) + return buf, err +} + +func StdTimeMarshalTo(t time.Time, data []byte) (int, error) { + ts, err := TimestampProto(t) + if err != nil { + return 0, err + } + return ts.MarshalTo(data) +} + +func StdTimeUnmarshal(t *time.Time, data []byte) error { + ts := &Timestamp{} + if err := ts.Unmarshal(data); err != nil { + return err + } + tt, err := TimestampFromProto(ts) + if err != nil { + return err + } + *t = tt + return nil +} diff --git a/vendor/github.com/gogo/protobuf/types/type.pb.go b/vendor/github.com/gogo/protobuf/types/type.pb.go new file mode 100644 index 00000000000..3f057646180 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/type.pb.go @@ -0,0 +1,3243 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/type.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strconv "strconv" + +import strings "strings" +import reflect "reflect" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// The syntax in which a protocol buffer element is defined. +type Syntax int32 + +const ( + // Syntax `proto2`. + Syntax_SYNTAX_PROTO2 Syntax = 0 + // Syntax `proto3`. + Syntax_SYNTAX_PROTO3 Syntax = 1 +) + +var Syntax_name = map[int32]string{ + 0: "SYNTAX_PROTO2", + 1: "SYNTAX_PROTO3", +} +var Syntax_value = map[string]int32{ + "SYNTAX_PROTO2": 0, + "SYNTAX_PROTO3": 1, +} + +func (Syntax) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{0} +} + +// Basic field types. +type Field_Kind int32 + +const ( + // Field type unknown. + Field_TYPE_UNKNOWN Field_Kind = 0 + // Field type double. + Field_TYPE_DOUBLE Field_Kind = 1 + // Field type float. + Field_TYPE_FLOAT Field_Kind = 2 + // Field type int64. + Field_TYPE_INT64 Field_Kind = 3 + // Field type uint64. + Field_TYPE_UINT64 Field_Kind = 4 + // Field type int32. + Field_TYPE_INT32 Field_Kind = 5 + // Field type fixed64. + Field_TYPE_FIXED64 Field_Kind = 6 + // Field type fixed32. + Field_TYPE_FIXED32 Field_Kind = 7 + // Field type bool. + Field_TYPE_BOOL Field_Kind = 8 + // Field type string. + Field_TYPE_STRING Field_Kind = 9 + // Field type group. Proto2 syntax only, and deprecated. + Field_TYPE_GROUP Field_Kind = 10 + // Field type message. + Field_TYPE_MESSAGE Field_Kind = 11 + // Field type bytes. + Field_TYPE_BYTES Field_Kind = 12 + // Field type uint32. + Field_TYPE_UINT32 Field_Kind = 13 + // Field type enum. + Field_TYPE_ENUM Field_Kind = 14 + // Field type sfixed32. + Field_TYPE_SFIXED32 Field_Kind = 15 + // Field type sfixed64. + Field_TYPE_SFIXED64 Field_Kind = 16 + // Field type sint32. + Field_TYPE_SINT32 Field_Kind = 17 + // Field type sint64. + Field_TYPE_SINT64 Field_Kind = 18 +) + +var Field_Kind_name = map[int32]string{ + 0: "TYPE_UNKNOWN", + 1: "TYPE_DOUBLE", + 2: "TYPE_FLOAT", + 3: "TYPE_INT64", + 4: "TYPE_UINT64", + 5: "TYPE_INT32", + 6: "TYPE_FIXED64", + 7: "TYPE_FIXED32", + 8: "TYPE_BOOL", + 9: "TYPE_STRING", + 10: "TYPE_GROUP", + 11: "TYPE_MESSAGE", + 12: "TYPE_BYTES", + 13: "TYPE_UINT32", + 14: "TYPE_ENUM", + 15: "TYPE_SFIXED32", + 16: "TYPE_SFIXED64", + 17: "TYPE_SINT32", + 18: "TYPE_SINT64", +} +var Field_Kind_value = map[string]int32{ + "TYPE_UNKNOWN": 0, + "TYPE_DOUBLE": 1, + "TYPE_FLOAT": 2, + "TYPE_INT64": 3, + "TYPE_UINT64": 4, + "TYPE_INT32": 5, + "TYPE_FIXED64": 6, + "TYPE_FIXED32": 7, + "TYPE_BOOL": 8, + "TYPE_STRING": 9, + "TYPE_GROUP": 10, + "TYPE_MESSAGE": 11, + "TYPE_BYTES": 12, + "TYPE_UINT32": 13, + "TYPE_ENUM": 14, + "TYPE_SFIXED32": 15, + "TYPE_SFIXED64": 16, + "TYPE_SINT32": 17, + "TYPE_SINT64": 18, +} + +func (Field_Kind) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{1, 0} +} + +// Whether a field is optional, required, or repeated. +type Field_Cardinality int32 + +const ( + // For fields with unknown cardinality. + Field_CARDINALITY_UNKNOWN Field_Cardinality = 0 + // For optional fields. + Field_CARDINALITY_OPTIONAL Field_Cardinality = 1 + // For required fields. Proto2 syntax only. + Field_CARDINALITY_REQUIRED Field_Cardinality = 2 + // For repeated fields. + Field_CARDINALITY_REPEATED Field_Cardinality = 3 +) + +var Field_Cardinality_name = map[int32]string{ + 0: "CARDINALITY_UNKNOWN", + 1: "CARDINALITY_OPTIONAL", + 2: "CARDINALITY_REQUIRED", + 3: "CARDINALITY_REPEATED", +} +var Field_Cardinality_value = map[string]int32{ + "CARDINALITY_UNKNOWN": 0, + "CARDINALITY_OPTIONAL": 1, + "CARDINALITY_REQUIRED": 2, + "CARDINALITY_REPEATED": 3, +} + +func (Field_Cardinality) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{1, 1} +} + +// A protocol buffer message type. +type Type struct { + // The fully qualified message name. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The list of fields. + Fields []*Field `protobuf:"bytes,2,rep,name=fields" json:"fields,omitempty"` + // The list of types appearing in `oneof` definitions in this type. + Oneofs []string `protobuf:"bytes,3,rep,name=oneofs" json:"oneofs,omitempty"` + // The protocol buffer options. + Options []*Option `protobuf:"bytes,4,rep,name=options" json:"options,omitempty"` + // The source context. + SourceContext *SourceContext `protobuf:"bytes,5,opt,name=source_context,json=sourceContext" json:"source_context,omitempty"` + // The source syntax. + Syntax Syntax `protobuf:"varint,6,opt,name=syntax,proto3,enum=google.protobuf.Syntax" json:"syntax,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Type) Reset() { *m = Type{} } +func (*Type) ProtoMessage() {} +func (*Type) Descriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{0} +} +func (m *Type) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Type) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Type.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Type) XXX_Merge(src proto.Message) { + xxx_messageInfo_Type.Merge(dst, src) +} +func (m *Type) XXX_Size() int { + return m.Size() +} +func (m *Type) XXX_DiscardUnknown() { + xxx_messageInfo_Type.DiscardUnknown(m) +} + +var xxx_messageInfo_Type proto.InternalMessageInfo + +func (m *Type) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Type) GetFields() []*Field { + if m != nil { + return m.Fields + } + return nil +} + +func (m *Type) GetOneofs() []string { + if m != nil { + return m.Oneofs + } + return nil +} + +func (m *Type) GetOptions() []*Option { + if m != nil { + return m.Options + } + return nil +} + +func (m *Type) GetSourceContext() *SourceContext { + if m != nil { + return m.SourceContext + } + return nil +} + +func (m *Type) GetSyntax() Syntax { + if m != nil { + return m.Syntax + } + return Syntax_SYNTAX_PROTO2 +} + +func (*Type) XXX_MessageName() string { + return "google.protobuf.Type" +} + +// A single field of a message type. +type Field struct { + // The field type. + Kind Field_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=google.protobuf.Field_Kind" json:"kind,omitempty"` + // The field cardinality. + Cardinality Field_Cardinality `protobuf:"varint,2,opt,name=cardinality,proto3,enum=google.protobuf.Field_Cardinality" json:"cardinality,omitempty"` + // The field number. + Number int32 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"` + // The field name. + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // The field type URL, without the scheme, for message or enumeration + // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + TypeUrl string `protobuf:"bytes,6,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` + // The index of the field type in `Type.oneofs`, for message or enumeration + // types. The first type has index 1; zero means the type is not in the list. + OneofIndex int32 `protobuf:"varint,7,opt,name=oneof_index,json=oneofIndex,proto3" json:"oneof_index,omitempty"` + // Whether to use alternative packed wire representation. + Packed bool `protobuf:"varint,8,opt,name=packed,proto3" json:"packed,omitempty"` + // The protocol buffer options. + Options []*Option `protobuf:"bytes,9,rep,name=options" json:"options,omitempty"` + // The field JSON name. + JsonName string `protobuf:"bytes,10,opt,name=json_name,json=jsonName,proto3" json:"json_name,omitempty"` + // The string value of the default value of this field. Proto2 syntax only. + DefaultValue string `protobuf:"bytes,11,opt,name=default_value,json=defaultValue,proto3" json:"default_value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Field) Reset() { *m = Field{} } +func (*Field) ProtoMessage() {} +func (*Field) Descriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{1} +} +func (m *Field) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Field) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Field.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Field) XXX_Merge(src proto.Message) { + xxx_messageInfo_Field.Merge(dst, src) +} +func (m *Field) XXX_Size() int { + return m.Size() +} +func (m *Field) XXX_DiscardUnknown() { + xxx_messageInfo_Field.DiscardUnknown(m) +} + +var xxx_messageInfo_Field proto.InternalMessageInfo + +func (m *Field) GetKind() Field_Kind { + if m != nil { + return m.Kind + } + return Field_TYPE_UNKNOWN +} + +func (m *Field) GetCardinality() Field_Cardinality { + if m != nil { + return m.Cardinality + } + return Field_CARDINALITY_UNKNOWN +} + +func (m *Field) GetNumber() int32 { + if m != nil { + return m.Number + } + return 0 +} + +func (m *Field) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Field) GetTypeUrl() string { + if m != nil { + return m.TypeUrl + } + return "" +} + +func (m *Field) GetOneofIndex() int32 { + if m != nil { + return m.OneofIndex + } + return 0 +} + +func (m *Field) GetPacked() bool { + if m != nil { + return m.Packed + } + return false +} + +func (m *Field) GetOptions() []*Option { + if m != nil { + return m.Options + } + return nil +} + +func (m *Field) GetJsonName() string { + if m != nil { + return m.JsonName + } + return "" +} + +func (m *Field) GetDefaultValue() string { + if m != nil { + return m.DefaultValue + } + return "" +} + +func (*Field) XXX_MessageName() string { + return "google.protobuf.Field" +} + +// Enum type definition. +type Enum struct { + // Enum type name. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Enum value definitions. + Enumvalue []*EnumValue `protobuf:"bytes,2,rep,name=enumvalue" json:"enumvalue,omitempty"` + // Protocol buffer options. + Options []*Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` + // The source context. + SourceContext *SourceContext `protobuf:"bytes,4,opt,name=source_context,json=sourceContext" json:"source_context,omitempty"` + // The source syntax. + Syntax Syntax `protobuf:"varint,5,opt,name=syntax,proto3,enum=google.protobuf.Syntax" json:"syntax,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Enum) Reset() { *m = Enum{} } +func (*Enum) ProtoMessage() {} +func (*Enum) Descriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{2} +} +func (m *Enum) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Enum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Enum.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Enum) XXX_Merge(src proto.Message) { + xxx_messageInfo_Enum.Merge(dst, src) +} +func (m *Enum) XXX_Size() int { + return m.Size() +} +func (m *Enum) XXX_DiscardUnknown() { + xxx_messageInfo_Enum.DiscardUnknown(m) +} + +var xxx_messageInfo_Enum proto.InternalMessageInfo + +func (m *Enum) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Enum) GetEnumvalue() []*EnumValue { + if m != nil { + return m.Enumvalue + } + return nil +} + +func (m *Enum) GetOptions() []*Option { + if m != nil { + return m.Options + } + return nil +} + +func (m *Enum) GetSourceContext() *SourceContext { + if m != nil { + return m.SourceContext + } + return nil +} + +func (m *Enum) GetSyntax() Syntax { + if m != nil { + return m.Syntax + } + return Syntax_SYNTAX_PROTO2 +} + +func (*Enum) XXX_MessageName() string { + return "google.protobuf.Enum" +} + +// Enum value definition. +type EnumValue struct { + // Enum value name. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Enum value number. + Number int32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` + // Protocol buffer options. + Options []*Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EnumValue) Reset() { *m = EnumValue{} } +func (*EnumValue) ProtoMessage() {} +func (*EnumValue) Descriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{3} +} +func (m *EnumValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EnumValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EnumValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *EnumValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnumValue.Merge(dst, src) +} +func (m *EnumValue) XXX_Size() int { + return m.Size() +} +func (m *EnumValue) XXX_DiscardUnknown() { + xxx_messageInfo_EnumValue.DiscardUnknown(m) +} + +var xxx_messageInfo_EnumValue proto.InternalMessageInfo + +func (m *EnumValue) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *EnumValue) GetNumber() int32 { + if m != nil { + return m.Number + } + return 0 +} + +func (m *EnumValue) GetOptions() []*Option { + if m != nil { + return m.Options + } + return nil +} + +func (*EnumValue) XXX_MessageName() string { + return "google.protobuf.EnumValue" +} + +// A protocol buffer option, which can be attached to a message, field, +// enumeration, etc. +type Option struct { + // The option's name. For protobuf built-in options (options defined in + // descriptor.proto), this is the short name. For example, `"map_entry"`. + // For custom options, it should be the fully-qualified name. For example, + // `"google.api.http"`. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The option's value packed in an Any message. If the value is a primitive, + // the corresponding wrapper type defined in google/protobuf/wrappers.proto + // should be used. If the value is an enum, it should be stored as an int32 + // value using the google.protobuf.Int32Value type. + Value *Any `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Option) Reset() { *m = Option{} } +func (*Option) ProtoMessage() {} +func (*Option) Descriptor() ([]byte, []int) { + return fileDescriptor_type_0082d870c49329d7, []int{4} +} +func (m *Option) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Option) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Option.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Option) XXX_Merge(src proto.Message) { + xxx_messageInfo_Option.Merge(dst, src) +} +func (m *Option) XXX_Size() int { + return m.Size() +} +func (m *Option) XXX_DiscardUnknown() { + xxx_messageInfo_Option.DiscardUnknown(m) +} + +var xxx_messageInfo_Option proto.InternalMessageInfo + +func (m *Option) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Option) GetValue() *Any { + if m != nil { + return m.Value + } + return nil +} + +func (*Option) XXX_MessageName() string { + return "google.protobuf.Option" +} +func init() { + proto.RegisterType((*Type)(nil), "google.protobuf.Type") + proto.RegisterType((*Field)(nil), "google.protobuf.Field") + proto.RegisterType((*Enum)(nil), "google.protobuf.Enum") + proto.RegisterType((*EnumValue)(nil), "google.protobuf.EnumValue") + proto.RegisterType((*Option)(nil), "google.protobuf.Option") + proto.RegisterEnum("google.protobuf.Syntax", Syntax_name, Syntax_value) + proto.RegisterEnum("google.protobuf.Field_Kind", Field_Kind_name, Field_Kind_value) + proto.RegisterEnum("google.protobuf.Field_Cardinality", Field_Cardinality_name, Field_Cardinality_value) +} +func (this *Type) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Type) + if !ok { + that2, ok := that.(Type) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if len(this.Fields) != len(that1.Fields) { + if len(this.Fields) < len(that1.Fields) { + return -1 + } + return 1 + } + for i := range this.Fields { + if c := this.Fields[i].Compare(that1.Fields[i]); c != 0 { + return c + } + } + if len(this.Oneofs) != len(that1.Oneofs) { + if len(this.Oneofs) < len(that1.Oneofs) { + return -1 + } + return 1 + } + for i := range this.Oneofs { + if this.Oneofs[i] != that1.Oneofs[i] { + if this.Oneofs[i] < that1.Oneofs[i] { + return -1 + } + return 1 + } + } + if len(this.Options) != len(that1.Options) { + if len(this.Options) < len(that1.Options) { + return -1 + } + return 1 + } + for i := range this.Options { + if c := this.Options[i].Compare(that1.Options[i]); c != 0 { + return c + } + } + if c := this.SourceContext.Compare(that1.SourceContext); c != 0 { + return c + } + if this.Syntax != that1.Syntax { + if this.Syntax < that1.Syntax { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Field) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Field) + if !ok { + that2, ok := that.(Field) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Kind != that1.Kind { + if this.Kind < that1.Kind { + return -1 + } + return 1 + } + if this.Cardinality != that1.Cardinality { + if this.Cardinality < that1.Cardinality { + return -1 + } + return 1 + } + if this.Number != that1.Number { + if this.Number < that1.Number { + return -1 + } + return 1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if this.TypeUrl != that1.TypeUrl { + if this.TypeUrl < that1.TypeUrl { + return -1 + } + return 1 + } + if this.OneofIndex != that1.OneofIndex { + if this.OneofIndex < that1.OneofIndex { + return -1 + } + return 1 + } + if this.Packed != that1.Packed { + if !this.Packed { + return -1 + } + return 1 + } + if len(this.Options) != len(that1.Options) { + if len(this.Options) < len(that1.Options) { + return -1 + } + return 1 + } + for i := range this.Options { + if c := this.Options[i].Compare(that1.Options[i]); c != 0 { + return c + } + } + if this.JsonName != that1.JsonName { + if this.JsonName < that1.JsonName { + return -1 + } + return 1 + } + if this.DefaultValue != that1.DefaultValue { + if this.DefaultValue < that1.DefaultValue { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Enum) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Enum) + if !ok { + that2, ok := that.(Enum) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if len(this.Enumvalue) != len(that1.Enumvalue) { + if len(this.Enumvalue) < len(that1.Enumvalue) { + return -1 + } + return 1 + } + for i := range this.Enumvalue { + if c := this.Enumvalue[i].Compare(that1.Enumvalue[i]); c != 0 { + return c + } + } + if len(this.Options) != len(that1.Options) { + if len(this.Options) < len(that1.Options) { + return -1 + } + return 1 + } + for i := range this.Options { + if c := this.Options[i].Compare(that1.Options[i]); c != 0 { + return c + } + } + if c := this.SourceContext.Compare(that1.SourceContext); c != 0 { + return c + } + if this.Syntax != that1.Syntax { + if this.Syntax < that1.Syntax { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *EnumValue) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*EnumValue) + if !ok { + that2, ok := that.(EnumValue) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if this.Number != that1.Number { + if this.Number < that1.Number { + return -1 + } + return 1 + } + if len(this.Options) != len(that1.Options) { + if len(this.Options) < len(that1.Options) { + return -1 + } + return 1 + } + for i := range this.Options { + if c := this.Options[i].Compare(that1.Options[i]); c != 0 { + return c + } + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Option) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Option) + if !ok { + that2, ok := that.(Option) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Name != that1.Name { + if this.Name < that1.Name { + return -1 + } + return 1 + } + if c := this.Value.Compare(that1.Value); c != 0 { + return c + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (x Syntax) String() string { + s, ok := Syntax_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} +func (x Field_Kind) String() string { + s, ok := Field_Kind_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} +func (x Field_Cardinality) String() string { + s, ok := Field_Cardinality_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} +func (this *Type) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Type) + if !ok { + that2, ok := that.(Type) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if len(this.Fields) != len(that1.Fields) { + return false + } + for i := range this.Fields { + if !this.Fields[i].Equal(that1.Fields[i]) { + return false + } + } + if len(this.Oneofs) != len(that1.Oneofs) { + return false + } + for i := range this.Oneofs { + if this.Oneofs[i] != that1.Oneofs[i] { + return false + } + } + if len(this.Options) != len(that1.Options) { + return false + } + for i := range this.Options { + if !this.Options[i].Equal(that1.Options[i]) { + return false + } + } + if !this.SourceContext.Equal(that1.SourceContext) { + return false + } + if this.Syntax != that1.Syntax { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Field) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Field) + if !ok { + that2, ok := that.(Field) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Kind != that1.Kind { + return false + } + if this.Cardinality != that1.Cardinality { + return false + } + if this.Number != that1.Number { + return false + } + if this.Name != that1.Name { + return false + } + if this.TypeUrl != that1.TypeUrl { + return false + } + if this.OneofIndex != that1.OneofIndex { + return false + } + if this.Packed != that1.Packed { + return false + } + if len(this.Options) != len(that1.Options) { + return false + } + for i := range this.Options { + if !this.Options[i].Equal(that1.Options[i]) { + return false + } + } + if this.JsonName != that1.JsonName { + return false + } + if this.DefaultValue != that1.DefaultValue { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Enum) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Enum) + if !ok { + that2, ok := that.(Enum) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if len(this.Enumvalue) != len(that1.Enumvalue) { + return false + } + for i := range this.Enumvalue { + if !this.Enumvalue[i].Equal(that1.Enumvalue[i]) { + return false + } + } + if len(this.Options) != len(that1.Options) { + return false + } + for i := range this.Options { + if !this.Options[i].Equal(that1.Options[i]) { + return false + } + } + if !this.SourceContext.Equal(that1.SourceContext) { + return false + } + if this.Syntax != that1.Syntax { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *EnumValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*EnumValue) + if !ok { + that2, ok := that.(EnumValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Number != that1.Number { + return false + } + if len(this.Options) != len(that1.Options) { + return false + } + for i := range this.Options { + if !this.Options[i].Equal(that1.Options[i]) { + return false + } + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Option) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Option) + if !ok { + that2, ok := that.(Option) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if !this.Value.Equal(that1.Value) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Type) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&types.Type{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + if this.Fields != nil { + s = append(s, "Fields: "+fmt.Sprintf("%#v", this.Fields)+",\n") + } + s = append(s, "Oneofs: "+fmt.Sprintf("%#v", this.Oneofs)+",\n") + if this.Options != nil { + s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") + } + if this.SourceContext != nil { + s = append(s, "SourceContext: "+fmt.Sprintf("%#v", this.SourceContext)+",\n") + } + s = append(s, "Syntax: "+fmt.Sprintf("%#v", this.Syntax)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Field) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 14) + s = append(s, "&types.Field{") + s = append(s, "Kind: "+fmt.Sprintf("%#v", this.Kind)+",\n") + s = append(s, "Cardinality: "+fmt.Sprintf("%#v", this.Cardinality)+",\n") + s = append(s, "Number: "+fmt.Sprintf("%#v", this.Number)+",\n") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "TypeUrl: "+fmt.Sprintf("%#v", this.TypeUrl)+",\n") + s = append(s, "OneofIndex: "+fmt.Sprintf("%#v", this.OneofIndex)+",\n") + s = append(s, "Packed: "+fmt.Sprintf("%#v", this.Packed)+",\n") + if this.Options != nil { + s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") + } + s = append(s, "JsonName: "+fmt.Sprintf("%#v", this.JsonName)+",\n") + s = append(s, "DefaultValue: "+fmt.Sprintf("%#v", this.DefaultValue)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Enum) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 9) + s = append(s, "&types.Enum{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + if this.Enumvalue != nil { + s = append(s, "Enumvalue: "+fmt.Sprintf("%#v", this.Enumvalue)+",\n") + } + if this.Options != nil { + s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") + } + if this.SourceContext != nil { + s = append(s, "SourceContext: "+fmt.Sprintf("%#v", this.SourceContext)+",\n") + } + s = append(s, "Syntax: "+fmt.Sprintf("%#v", this.Syntax)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *EnumValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&types.EnumValue{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "Number: "+fmt.Sprintf("%#v", this.Number)+",\n") + if this.Options != nil { + s = append(s, "Options: "+fmt.Sprintf("%#v", this.Options)+",\n") + } + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Option) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&types.Option{") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + if this.Value != nil { + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + } + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringType(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Type) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Type) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Fields) > 0 { + for _, msg := range m.Fields { + dAtA[i] = 0x12 + i++ + i = encodeVarintType(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.Oneofs) > 0 { + for _, s := range m.Oneofs { + dAtA[i] = 0x1a + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if len(m.Options) > 0 { + for _, msg := range m.Options { + dAtA[i] = 0x22 + i++ + i = encodeVarintType(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.SourceContext != nil { + dAtA[i] = 0x2a + i++ + i = encodeVarintType(dAtA, i, uint64(m.SourceContext.Size())) + n1, err := m.SourceContext.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + if m.Syntax != 0 { + dAtA[i] = 0x30 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Field) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Field) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Kind != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Kind)) + } + if m.Cardinality != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Cardinality)) + } + if m.Number != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Number)) + } + if len(m.Name) > 0 { + dAtA[i] = 0x22 + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.TypeUrl) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.TypeUrl))) + i += copy(dAtA[i:], m.TypeUrl) + } + if m.OneofIndex != 0 { + dAtA[i] = 0x38 + i++ + i = encodeVarintType(dAtA, i, uint64(m.OneofIndex)) + } + if m.Packed { + dAtA[i] = 0x40 + i++ + if m.Packed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if len(m.Options) > 0 { + for _, msg := range m.Options { + dAtA[i] = 0x4a + i++ + i = encodeVarintType(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.JsonName) > 0 { + dAtA[i] = 0x52 + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.JsonName))) + i += copy(dAtA[i:], m.JsonName) + } + if len(m.DefaultValue) > 0 { + dAtA[i] = 0x5a + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.DefaultValue))) + i += copy(dAtA[i:], m.DefaultValue) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Enum) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Enum) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Enumvalue) > 0 { + for _, msg := range m.Enumvalue { + dAtA[i] = 0x12 + i++ + i = encodeVarintType(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if len(m.Options) > 0 { + for _, msg := range m.Options { + dAtA[i] = 0x1a + i++ + i = encodeVarintType(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.SourceContext != nil { + dAtA[i] = 0x22 + i++ + i = encodeVarintType(dAtA, i, uint64(m.SourceContext.Size())) + n2, err := m.SourceContext.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n2 + } + if m.Syntax != 0 { + dAtA[i] = 0x28 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *EnumValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EnumValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if m.Number != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Number)) + } + if len(m.Options) > 0 { + for _, msg := range m.Options { + dAtA[i] = 0x1a + i++ + i = encodeVarintType(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Option) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Option) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintType(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if m.Value != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintType(dAtA, i, uint64(m.Value.Size())) + n3, err := m.Value.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintType(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedType(r randyType, easy bool) *Type { + this := &Type{} + this.Name = string(randStringType(r)) + if r.Intn(10) != 0 { + v1 := r.Intn(5) + this.Fields = make([]*Field, v1) + for i := 0; i < v1; i++ { + this.Fields[i] = NewPopulatedField(r, easy) + } + } + v2 := r.Intn(10) + this.Oneofs = make([]string, v2) + for i := 0; i < v2; i++ { + this.Oneofs[i] = string(randStringType(r)) + } + if r.Intn(10) != 0 { + v3 := r.Intn(5) + this.Options = make([]*Option, v3) + for i := 0; i < v3; i++ { + this.Options[i] = NewPopulatedOption(r, easy) + } + } + if r.Intn(10) != 0 { + this.SourceContext = NewPopulatedSourceContext(r, easy) + } + this.Syntax = Syntax([]int32{0, 1}[r.Intn(2)]) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedType(r, 7) + } + return this +} + +func NewPopulatedField(r randyType, easy bool) *Field { + this := &Field{} + this.Kind = Field_Kind([]int32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}[r.Intn(19)]) + this.Cardinality = Field_Cardinality([]int32{0, 1, 2, 3}[r.Intn(4)]) + this.Number = int32(r.Int31()) + if r.Intn(2) == 0 { + this.Number *= -1 + } + this.Name = string(randStringType(r)) + this.TypeUrl = string(randStringType(r)) + this.OneofIndex = int32(r.Int31()) + if r.Intn(2) == 0 { + this.OneofIndex *= -1 + } + this.Packed = bool(bool(r.Intn(2) == 0)) + if r.Intn(10) != 0 { + v4 := r.Intn(5) + this.Options = make([]*Option, v4) + for i := 0; i < v4; i++ { + this.Options[i] = NewPopulatedOption(r, easy) + } + } + this.JsonName = string(randStringType(r)) + this.DefaultValue = string(randStringType(r)) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedType(r, 12) + } + return this +} + +func NewPopulatedEnum(r randyType, easy bool) *Enum { + this := &Enum{} + this.Name = string(randStringType(r)) + if r.Intn(10) != 0 { + v5 := r.Intn(5) + this.Enumvalue = make([]*EnumValue, v5) + for i := 0; i < v5; i++ { + this.Enumvalue[i] = NewPopulatedEnumValue(r, easy) + } + } + if r.Intn(10) != 0 { + v6 := r.Intn(5) + this.Options = make([]*Option, v6) + for i := 0; i < v6; i++ { + this.Options[i] = NewPopulatedOption(r, easy) + } + } + if r.Intn(10) != 0 { + this.SourceContext = NewPopulatedSourceContext(r, easy) + } + this.Syntax = Syntax([]int32{0, 1}[r.Intn(2)]) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedType(r, 6) + } + return this +} + +func NewPopulatedEnumValue(r randyType, easy bool) *EnumValue { + this := &EnumValue{} + this.Name = string(randStringType(r)) + this.Number = int32(r.Int31()) + if r.Intn(2) == 0 { + this.Number *= -1 + } + if r.Intn(10) != 0 { + v7 := r.Intn(5) + this.Options = make([]*Option, v7) + for i := 0; i < v7; i++ { + this.Options[i] = NewPopulatedOption(r, easy) + } + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedType(r, 4) + } + return this +} + +func NewPopulatedOption(r randyType, easy bool) *Option { + this := &Option{} + this.Name = string(randStringType(r)) + if r.Intn(10) != 0 { + this.Value = NewPopulatedAny(r, easy) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedType(r, 3) + } + return this +} + +type randyType interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneType(r randyType) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringType(r randyType) string { + v8 := r.Intn(100) + tmps := make([]rune, v8) + for i := 0; i < v8; i++ { + tmps[i] = randUTF8RuneType(r) + } + return string(tmps) +} +func randUnrecognizedType(r randyType, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldType(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldType(dAtA []byte, r randyType, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateType(dAtA, uint64(key)) + v9 := r.Int63() + if r.Intn(2) == 0 { + v9 *= -1 + } + dAtA = encodeVarintPopulateType(dAtA, uint64(v9)) + case 1: + dAtA = encodeVarintPopulateType(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateType(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateType(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateType(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateType(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *Type) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + if len(m.Fields) > 0 { + for _, e := range m.Fields { + l = e.Size() + n += 1 + l + sovType(uint64(l)) + } + } + if len(m.Oneofs) > 0 { + for _, s := range m.Oneofs { + l = len(s) + n += 1 + l + sovType(uint64(l)) + } + } + if len(m.Options) > 0 { + for _, e := range m.Options { + l = e.Size() + n += 1 + l + sovType(uint64(l)) + } + } + if m.SourceContext != nil { + l = m.SourceContext.Size() + n += 1 + l + sovType(uint64(l)) + } + if m.Syntax != 0 { + n += 1 + sovType(uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Field) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Kind != 0 { + n += 1 + sovType(uint64(m.Kind)) + } + if m.Cardinality != 0 { + n += 1 + sovType(uint64(m.Cardinality)) + } + if m.Number != 0 { + n += 1 + sovType(uint64(m.Number)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + l = len(m.TypeUrl) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + if m.OneofIndex != 0 { + n += 1 + sovType(uint64(m.OneofIndex)) + } + if m.Packed { + n += 2 + } + if len(m.Options) > 0 { + for _, e := range m.Options { + l = e.Size() + n += 1 + l + sovType(uint64(l)) + } + } + l = len(m.JsonName) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + l = len(m.DefaultValue) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Enum) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + if len(m.Enumvalue) > 0 { + for _, e := range m.Enumvalue { + l = e.Size() + n += 1 + l + sovType(uint64(l)) + } + } + if len(m.Options) > 0 { + for _, e := range m.Options { + l = e.Size() + n += 1 + l + sovType(uint64(l)) + } + } + if m.SourceContext != nil { + l = m.SourceContext.Size() + n += 1 + l + sovType(uint64(l)) + } + if m.Syntax != 0 { + n += 1 + sovType(uint64(m.Syntax)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *EnumValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + if m.Number != 0 { + n += 1 + sovType(uint64(m.Number)) + } + if len(m.Options) > 0 { + for _, e := range m.Options { + l = e.Size() + n += 1 + l + sovType(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Option) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovType(uint64(l)) + } + if m.Value != nil { + l = m.Value.Size() + n += 1 + l + sovType(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovType(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozType(x uint64) (n int) { + return sovType(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Type) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Type{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Fields:` + strings.Replace(fmt.Sprintf("%v", this.Fields), "Field", "Field", 1) + `,`, + `Oneofs:` + fmt.Sprintf("%v", this.Oneofs) + `,`, + `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Option", "Option", 1) + `,`, + `SourceContext:` + strings.Replace(fmt.Sprintf("%v", this.SourceContext), "SourceContext", "SourceContext", 1) + `,`, + `Syntax:` + fmt.Sprintf("%v", this.Syntax) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Field) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Field{`, + `Kind:` + fmt.Sprintf("%v", this.Kind) + `,`, + `Cardinality:` + fmt.Sprintf("%v", this.Cardinality) + `,`, + `Number:` + fmt.Sprintf("%v", this.Number) + `,`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `TypeUrl:` + fmt.Sprintf("%v", this.TypeUrl) + `,`, + `OneofIndex:` + fmt.Sprintf("%v", this.OneofIndex) + `,`, + `Packed:` + fmt.Sprintf("%v", this.Packed) + `,`, + `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Option", "Option", 1) + `,`, + `JsonName:` + fmt.Sprintf("%v", this.JsonName) + `,`, + `DefaultValue:` + fmt.Sprintf("%v", this.DefaultValue) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Enum) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Enum{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Enumvalue:` + strings.Replace(fmt.Sprintf("%v", this.Enumvalue), "EnumValue", "EnumValue", 1) + `,`, + `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Option", "Option", 1) + `,`, + `SourceContext:` + strings.Replace(fmt.Sprintf("%v", this.SourceContext), "SourceContext", "SourceContext", 1) + `,`, + `Syntax:` + fmt.Sprintf("%v", this.Syntax) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *EnumValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&EnumValue{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Number:` + fmt.Sprintf("%v", this.Number) + `,`, + `Options:` + strings.Replace(fmt.Sprintf("%v", this.Options), "Option", "Option", 1) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Option) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Option{`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Value:` + strings.Replace(fmt.Sprintf("%v", this.Value), "Any", "Any", 1) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringType(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Type) 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 ErrIntOverflowType + } + 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: Type: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Type: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fields", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fields = append(m.Fields, &Field{}) + if err := m.Fields[len(m.Fields)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Oneofs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Oneofs = append(m.Oneofs, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Options = append(m.Options, &Option{}) + if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceContext", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceContext == nil { + m.SourceContext = &SourceContext{} + } + if err := m.SourceContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Syntax", wireType) + } + m.Syntax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Syntax |= (Syntax(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipType(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthType + } + 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 *Field) 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 ErrIntOverflowType + } + 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: Field: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Field: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + m.Kind = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Kind |= (Field_Kind(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Cardinality", wireType) + } + m.Cardinality = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Cardinality |= (Field_Cardinality(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OneofIndex", wireType) + } + m.OneofIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OneofIndex |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Packed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Packed = bool(v != 0) + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Options = append(m.Options, &Option{}) + if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JsonName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.JsonName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DefaultValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DefaultValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipType(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthType + } + 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 *Enum) 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 ErrIntOverflowType + } + 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: Enum: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Enum: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Enumvalue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Enumvalue = append(m.Enumvalue, &EnumValue{}) + if err := m.Enumvalue[len(m.Enumvalue)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Options = append(m.Options, &Option{}) + if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceContext", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourceContext == nil { + m.SourceContext = &SourceContext{} + } + if err := m.SourceContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Syntax", wireType) + } + m.Syntax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Syntax |= (Syntax(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipType(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthType + } + 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 *EnumValue) 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 ErrIntOverflowType + } + 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: EnumValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EnumValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Options = append(m.Options, &Option{}) + if err := m.Options[len(m.Options)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipType(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthType + } + 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 *Option) 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 ErrIntOverflowType + } + 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: Option: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Option: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowType + } + 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 ErrInvalidLengthType + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowType + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthType + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Value == nil { + m.Value = &Any{} + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipType(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthType + } + 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 skipType(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowType + } + 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, ErrIntOverflowType + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowType + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthType + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowType + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipType(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthType = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowType = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("google/protobuf/type.proto", fileDescriptor_type_0082d870c49329d7) } + +var fileDescriptor_type_0082d870c49329d7 = []byte{ + // 840 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x73, 0xda, 0x46, + 0x14, 0xf6, 0x0a, 0x21, 0xa3, 0x87, 0xc1, 0x9b, 0x4d, 0x26, 0x51, 0x9c, 0x19, 0x95, 0xa1, 0x3d, + 0x30, 0x39, 0xe0, 0x29, 0x78, 0x3c, 0xbd, 0x82, 0x91, 0x29, 0x63, 0x22, 0xa9, 0x8b, 0x68, 0xe2, + 0x5e, 0x18, 0x0c, 0x72, 0x86, 0x44, 0xac, 0x18, 0x24, 0x5a, 0x73, 0xeb, 0x4c, 0xcf, 0xfd, 0x27, + 0x7a, 0xea, 0xf4, 0xdc, 0x3f, 0xc2, 0xc7, 0x1e, 0x7b, 0xac, 0xc9, 0xa5, 0xc7, 0x1c, 0x73, 0x6b, + 0x67, 0x57, 0x20, 0x8b, 0x1f, 0x9d, 0x49, 0xdb, 0x1b, 0xef, 0xfb, 0xbe, 0xf7, 0x73, 0x9f, 0x1e, + 0x70, 0xf4, 0xda, 0xf7, 0x5f, 0x7b, 0xee, 0xf1, 0x64, 0xea, 0x87, 0xfe, 0xd5, 0xec, 0xfa, 0x38, + 0x9c, 0x4f, 0xdc, 0xb2, 0xb0, 0xc8, 0x61, 0xc4, 0x95, 0x57, 0xdc, 0xd1, 0xd3, 0x4d, 0x71, 0x9f, + 0xcd, 0x23, 0xf6, 0xe8, 0xb3, 0x4d, 0x2a, 0xf0, 0x67, 0xd3, 0x81, 0xdb, 0x1b, 0xf8, 0x2c, 0x74, + 0x6f, 0xc2, 0x48, 0x55, 0xfc, 0x51, 0x02, 0xd9, 0x99, 0x4f, 0x5c, 0x42, 0x40, 0x66, 0xfd, 0xb1, + 0xab, 0xa1, 0x02, 0x2a, 0xa9, 0x54, 0xfc, 0x26, 0x65, 0x50, 0xae, 0x47, 0xae, 0x37, 0x0c, 0x34, + 0xa9, 0x90, 0x2a, 0x65, 0x2b, 0x8f, 0xcb, 0x1b, 0xf9, 0xcb, 0xe7, 0x9c, 0xa6, 0x4b, 0x15, 0x79, + 0x0c, 0x8a, 0xcf, 0x5c, 0xff, 0x3a, 0xd0, 0x52, 0x85, 0x54, 0x49, 0xa5, 0x4b, 0x8b, 0x7c, 0x0e, + 0xfb, 0xfe, 0x24, 0x1c, 0xf9, 0x2c, 0xd0, 0x64, 0x11, 0xe8, 0xc9, 0x56, 0x20, 0x4b, 0xf0, 0x74, + 0xa5, 0x23, 0x06, 0xe4, 0xd7, 0xeb, 0xd5, 0xd2, 0x05, 0x54, 0xca, 0x56, 0xf4, 0x2d, 0xcf, 0x8e, + 0x90, 0x9d, 0x45, 0x2a, 0x9a, 0x0b, 0x92, 0x26, 0x39, 0x06, 0x25, 0x98, 0xb3, 0xb0, 0x7f, 0xa3, + 0x29, 0x05, 0x54, 0xca, 0xef, 0x48, 0xdc, 0x11, 0x34, 0x5d, 0xca, 0x8a, 0xbf, 0x2a, 0x90, 0x16, + 0x4d, 0x91, 0x63, 0x90, 0xdf, 0x8e, 0xd8, 0x50, 0x0c, 0x24, 0x5f, 0x79, 0xb6, 0xbb, 0xf5, 0xf2, + 0xc5, 0x88, 0x0d, 0xa9, 0x10, 0x92, 0x06, 0x64, 0x07, 0xfd, 0xe9, 0x70, 0xc4, 0xfa, 0xde, 0x28, + 0x9c, 0x6b, 0x92, 0xf0, 0x2b, 0xfe, 0x83, 0xdf, 0xd9, 0xbd, 0x92, 0x26, 0xdd, 0xf8, 0x0c, 0xd9, + 0x6c, 0x7c, 0xe5, 0x4e, 0xb5, 0x54, 0x01, 0x95, 0xd2, 0x74, 0x69, 0xc5, 0xef, 0x23, 0x27, 0xde, + 0xe7, 0x29, 0x64, 0xf8, 0x72, 0xf4, 0x66, 0x53, 0x4f, 0xf4, 0xa7, 0xd2, 0x7d, 0x6e, 0x77, 0xa7, + 0x1e, 0xf9, 0x04, 0xb2, 0x62, 0xf8, 0xbd, 0x11, 0x1b, 0xba, 0x37, 0xda, 0xbe, 0x88, 0x05, 0x02, + 0x6a, 0x71, 0x84, 0xe7, 0x99, 0xf4, 0x07, 0x6f, 0xdd, 0xa1, 0x96, 0x29, 0xa0, 0x52, 0x86, 0x2e, + 0xad, 0xe4, 0x5b, 0xa9, 0x1f, 0xf9, 0x56, 0xcf, 0x40, 0x7d, 0x13, 0xf8, 0xac, 0x27, 0xea, 0x03, + 0x51, 0x47, 0x86, 0x03, 0x26, 0xaf, 0xf1, 0x53, 0xc8, 0x0d, 0xdd, 0xeb, 0xfe, 0xcc, 0x0b, 0x7b, + 0xdf, 0xf6, 0xbd, 0x99, 0xab, 0x65, 0x85, 0xe0, 0x60, 0x09, 0x7e, 0xcd, 0xb1, 0xe2, 0xad, 0x04, + 0x32, 0x9f, 0x24, 0xc1, 0x70, 0xe0, 0x5c, 0xda, 0x46, 0xaf, 0x6b, 0x5e, 0x98, 0xd6, 0x4b, 0x13, + 0xef, 0x91, 0x43, 0xc8, 0x0a, 0xa4, 0x61, 0x75, 0xeb, 0x6d, 0x03, 0x23, 0x92, 0x07, 0x10, 0xc0, + 0x79, 0xdb, 0xaa, 0x39, 0x58, 0x8a, 0xed, 0x96, 0xe9, 0x9c, 0x9e, 0xe0, 0x54, 0xec, 0xd0, 0x8d, + 0x00, 0x39, 0x29, 0xa8, 0x56, 0x70, 0x3a, 0xce, 0x71, 0xde, 0x7a, 0x65, 0x34, 0x4e, 0x4f, 0xb0, + 0xb2, 0x8e, 0x54, 0x2b, 0x78, 0x9f, 0xe4, 0x40, 0x15, 0x48, 0xdd, 0xb2, 0xda, 0x38, 0x13, 0xc7, + 0xec, 0x38, 0xb4, 0x65, 0x36, 0xb1, 0x1a, 0xc7, 0x6c, 0x52, 0xab, 0x6b, 0x63, 0x88, 0x23, 0xbc, + 0x30, 0x3a, 0x9d, 0x5a, 0xd3, 0xc0, 0xd9, 0x58, 0x51, 0xbf, 0x74, 0x8c, 0x0e, 0x3e, 0x58, 0x2b, + 0xab, 0x5a, 0xc1, 0xb9, 0x38, 0x85, 0x61, 0x76, 0x5f, 0xe0, 0x3c, 0x79, 0x00, 0xb9, 0x28, 0xc5, + 0xaa, 0x88, 0xc3, 0x0d, 0xe8, 0xf4, 0x04, 0xe3, 0xfb, 0x42, 0xa2, 0x28, 0x0f, 0xd6, 0x80, 0xd3, + 0x13, 0x4c, 0x8a, 0x21, 0x64, 0x13, 0xbb, 0x45, 0x9e, 0xc0, 0xc3, 0xb3, 0x1a, 0x6d, 0xb4, 0xcc, + 0x5a, 0xbb, 0xe5, 0x5c, 0x26, 0xe6, 0xaa, 0xc1, 0xa3, 0x24, 0x61, 0xd9, 0x4e, 0xcb, 0x32, 0x6b, + 0x6d, 0x8c, 0x36, 0x19, 0x6a, 0x7c, 0xd5, 0x6d, 0x51, 0xa3, 0x81, 0xa5, 0x6d, 0xc6, 0x36, 0x6a, + 0x8e, 0xd1, 0xc0, 0xa9, 0xe2, 0x5f, 0x08, 0x64, 0x83, 0xcd, 0xc6, 0x3b, 0xcf, 0xc8, 0x17, 0xa0, + 0xba, 0x6c, 0x36, 0x8e, 0x9e, 0x3f, 0xba, 0x24, 0x47, 0x5b, 0x4b, 0xc5, 0xbd, 0xc5, 0x32, 0xd0, + 0x7b, 0x71, 0x72, 0x19, 0x53, 0xff, 0xf9, 0x70, 0xc8, 0xff, 0xef, 0x70, 0xa4, 0x3f, 0xee, 0x70, + 0xbc, 0x01, 0x35, 0x6e, 0x61, 0xe7, 0x14, 0xee, 0x3f, 0x6c, 0x69, 0xed, 0xc3, 0xfe, 0xf7, 0x3d, + 0x16, 0xbf, 0x04, 0x25, 0x82, 0x76, 0x26, 0x7a, 0x0e, 0xe9, 0xd5, 0xa8, 0x79, 0xe3, 0x8f, 0xb6, + 0xc2, 0xd5, 0xd8, 0x9c, 0x46, 0x92, 0xe7, 0x65, 0x50, 0xa2, 0x3e, 0xf8, 0xb2, 0x75, 0x2e, 0x4d, + 0xa7, 0xf6, 0xaa, 0x67, 0x53, 0xcb, 0xb1, 0x2a, 0x78, 0x6f, 0x13, 0xaa, 0x62, 0x54, 0xff, 0x01, + 0xfd, 0x7e, 0xa7, 0xef, 0xbd, 0xbf, 0xd3, 0xd1, 0x87, 0x3b, 0x1d, 0x7d, 0xbf, 0xd0, 0xd1, 0xcf, + 0x0b, 0x1d, 0xdd, 0x2e, 0x74, 0xf4, 0xdb, 0x42, 0x47, 0x7f, 0x2c, 0x74, 0xf4, 0xe7, 0x42, 0xdf, + 0x7b, 0xcf, 0xf1, 0x77, 0x3a, 0xba, 0x7d, 0xa7, 0x23, 0x78, 0x38, 0xf0, 0xc7, 0x9b, 0x25, 0xd4, + 0x55, 0xfe, 0x9f, 0x63, 0x73, 0xcb, 0x46, 0xdf, 0xa4, 0xf9, 0xd1, 0x0a, 0x3e, 0x20, 0xf4, 0x93, + 0x94, 0x6a, 0xda, 0xf5, 0x5f, 0x24, 0xbd, 0x19, 0xc9, 0xed, 0x55, 0xc5, 0x2f, 0x5d, 0xcf, 0xbb, + 0x60, 0xfe, 0x77, 0x8c, 0xbb, 0x05, 0x57, 0x8a, 0x88, 0x53, 0xfd, 0x3b, 0x00, 0x00, 0xff, 0xff, + 0xbc, 0x2a, 0x5e, 0x82, 0x2b, 0x07, 0x00, 0x00, +} diff --git a/vendor/github.com/gogo/protobuf/types/wrappers.pb.go b/vendor/github.com/gogo/protobuf/types/wrappers.pb.go new file mode 100644 index 00000000000..7516cc98960 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/types/wrappers.pb.go @@ -0,0 +1,2668 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: google/protobuf/wrappers.proto + +package types + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import bytes "bytes" + +import strings "strings" +import reflect "reflect" + +import encoding_binary "encoding/binary" + +import io "io" + +// 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +// Wrapper message for `double`. +// +// The JSON representation for `DoubleValue` is JSON number. +type DoubleValue struct { + // The double value. + Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DoubleValue) Reset() { *m = DoubleValue{} } +func (*DoubleValue) ProtoMessage() {} +func (*DoubleValue) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{0} +} +func (*DoubleValue) XXX_WellKnownType() string { return "DoubleValue" } +func (m *DoubleValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DoubleValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DoubleValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *DoubleValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_DoubleValue.Merge(dst, src) +} +func (m *DoubleValue) XXX_Size() int { + return m.Size() +} +func (m *DoubleValue) XXX_DiscardUnknown() { + xxx_messageInfo_DoubleValue.DiscardUnknown(m) +} + +var xxx_messageInfo_DoubleValue proto.InternalMessageInfo + +func (m *DoubleValue) GetValue() float64 { + if m != nil { + return m.Value + } + return 0 +} + +func (*DoubleValue) XXX_MessageName() string { + return "google.protobuf.DoubleValue" +} + +// Wrapper message for `float`. +// +// The JSON representation for `FloatValue` is JSON number. +type FloatValue struct { + // The float value. + Value float32 `protobuf:"fixed32,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FloatValue) Reset() { *m = FloatValue{} } +func (*FloatValue) ProtoMessage() {} +func (*FloatValue) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{1} +} +func (*FloatValue) XXX_WellKnownType() string { return "FloatValue" } +func (m *FloatValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FloatValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FloatValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *FloatValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_FloatValue.Merge(dst, src) +} +func (m *FloatValue) XXX_Size() int { + return m.Size() +} +func (m *FloatValue) XXX_DiscardUnknown() { + xxx_messageInfo_FloatValue.DiscardUnknown(m) +} + +var xxx_messageInfo_FloatValue proto.InternalMessageInfo + +func (m *FloatValue) GetValue() float32 { + if m != nil { + return m.Value + } + return 0 +} + +func (*FloatValue) XXX_MessageName() string { + return "google.protobuf.FloatValue" +} + +// Wrapper message for `int64`. +// +// The JSON representation for `Int64Value` is JSON string. +type Int64Value struct { + // The int64 value. + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Int64Value) Reset() { *m = Int64Value{} } +func (*Int64Value) ProtoMessage() {} +func (*Int64Value) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{2} +} +func (*Int64Value) XXX_WellKnownType() string { return "Int64Value" } +func (m *Int64Value) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Int64Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Int64Value.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Int64Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_Int64Value.Merge(dst, src) +} +func (m *Int64Value) XXX_Size() int { + return m.Size() +} +func (m *Int64Value) XXX_DiscardUnknown() { + xxx_messageInfo_Int64Value.DiscardUnknown(m) +} + +var xxx_messageInfo_Int64Value proto.InternalMessageInfo + +func (m *Int64Value) GetValue() int64 { + if m != nil { + return m.Value + } + return 0 +} + +func (*Int64Value) XXX_MessageName() string { + return "google.protobuf.Int64Value" +} + +// Wrapper message for `uint64`. +// +// The JSON representation for `UInt64Value` is JSON string. +type UInt64Value struct { + // The uint64 value. + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UInt64Value) Reset() { *m = UInt64Value{} } +func (*UInt64Value) ProtoMessage() {} +func (*UInt64Value) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{3} +} +func (*UInt64Value) XXX_WellKnownType() string { return "UInt64Value" } +func (m *UInt64Value) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UInt64Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UInt64Value.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *UInt64Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_UInt64Value.Merge(dst, src) +} +func (m *UInt64Value) XXX_Size() int { + return m.Size() +} +func (m *UInt64Value) XXX_DiscardUnknown() { + xxx_messageInfo_UInt64Value.DiscardUnknown(m) +} + +var xxx_messageInfo_UInt64Value proto.InternalMessageInfo + +func (m *UInt64Value) GetValue() uint64 { + if m != nil { + return m.Value + } + return 0 +} + +func (*UInt64Value) XXX_MessageName() string { + return "google.protobuf.UInt64Value" +} + +// Wrapper message for `int32`. +// +// The JSON representation for `Int32Value` is JSON number. +type Int32Value struct { + // The int32 value. + Value int32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Int32Value) Reset() { *m = Int32Value{} } +func (*Int32Value) ProtoMessage() {} +func (*Int32Value) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{4} +} +func (*Int32Value) XXX_WellKnownType() string { return "Int32Value" } +func (m *Int32Value) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Int32Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Int32Value.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Int32Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_Int32Value.Merge(dst, src) +} +func (m *Int32Value) XXX_Size() int { + return m.Size() +} +func (m *Int32Value) XXX_DiscardUnknown() { + xxx_messageInfo_Int32Value.DiscardUnknown(m) +} + +var xxx_messageInfo_Int32Value proto.InternalMessageInfo + +func (m *Int32Value) GetValue() int32 { + if m != nil { + return m.Value + } + return 0 +} + +func (*Int32Value) XXX_MessageName() string { + return "google.protobuf.Int32Value" +} + +// Wrapper message for `uint32`. +// +// The JSON representation for `UInt32Value` is JSON number. +type UInt32Value struct { + // The uint32 value. + Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UInt32Value) Reset() { *m = UInt32Value{} } +func (*UInt32Value) ProtoMessage() {} +func (*UInt32Value) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{5} +} +func (*UInt32Value) XXX_WellKnownType() string { return "UInt32Value" } +func (m *UInt32Value) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UInt32Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UInt32Value.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *UInt32Value) XXX_Merge(src proto.Message) { + xxx_messageInfo_UInt32Value.Merge(dst, src) +} +func (m *UInt32Value) XXX_Size() int { + return m.Size() +} +func (m *UInt32Value) XXX_DiscardUnknown() { + xxx_messageInfo_UInt32Value.DiscardUnknown(m) +} + +var xxx_messageInfo_UInt32Value proto.InternalMessageInfo + +func (m *UInt32Value) GetValue() uint32 { + if m != nil { + return m.Value + } + return 0 +} + +func (*UInt32Value) XXX_MessageName() string { + return "google.protobuf.UInt32Value" +} + +// Wrapper message for `bool`. +// +// The JSON representation for `BoolValue` is JSON `true` and `false`. +type BoolValue struct { + // The bool value. + Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BoolValue) Reset() { *m = BoolValue{} } +func (*BoolValue) ProtoMessage() {} +func (*BoolValue) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{6} +} +func (*BoolValue) XXX_WellKnownType() string { return "BoolValue" } +func (m *BoolValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BoolValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BoolValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *BoolValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_BoolValue.Merge(dst, src) +} +func (m *BoolValue) XXX_Size() int { + return m.Size() +} +func (m *BoolValue) XXX_DiscardUnknown() { + xxx_messageInfo_BoolValue.DiscardUnknown(m) +} + +var xxx_messageInfo_BoolValue proto.InternalMessageInfo + +func (m *BoolValue) GetValue() bool { + if m != nil { + return m.Value + } + return false +} + +func (*BoolValue) XXX_MessageName() string { + return "google.protobuf.BoolValue" +} + +// Wrapper message for `string`. +// +// The JSON representation for `StringValue` is JSON string. +type StringValue struct { + // The string value. + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StringValue) Reset() { *m = StringValue{} } +func (*StringValue) ProtoMessage() {} +func (*StringValue) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{7} +} +func (*StringValue) XXX_WellKnownType() string { return "StringValue" } +func (m *StringValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StringValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StringValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *StringValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_StringValue.Merge(dst, src) +} +func (m *StringValue) XXX_Size() int { + return m.Size() +} +func (m *StringValue) XXX_DiscardUnknown() { + xxx_messageInfo_StringValue.DiscardUnknown(m) +} + +var xxx_messageInfo_StringValue proto.InternalMessageInfo + +func (m *StringValue) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func (*StringValue) XXX_MessageName() string { + return "google.protobuf.StringValue" +} + +// Wrapper message for `bytes`. +// +// The JSON representation for `BytesValue` is JSON string. +type BytesValue struct { + // The bytes value. + Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *BytesValue) Reset() { *m = BytesValue{} } +func (*BytesValue) ProtoMessage() {} +func (*BytesValue) Descriptor() ([]byte, []int) { + return fileDescriptor_wrappers_c5239a825c7dfb53, []int{8} +} +func (*BytesValue) XXX_WellKnownType() string { return "BytesValue" } +func (m *BytesValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BytesValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BytesValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *BytesValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_BytesValue.Merge(dst, src) +} +func (m *BytesValue) XXX_Size() int { + return m.Size() +} +func (m *BytesValue) XXX_DiscardUnknown() { + xxx_messageInfo_BytesValue.DiscardUnknown(m) +} + +var xxx_messageInfo_BytesValue proto.InternalMessageInfo + +func (m *BytesValue) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (*BytesValue) XXX_MessageName() string { + return "google.protobuf.BytesValue" +} +func init() { + proto.RegisterType((*DoubleValue)(nil), "google.protobuf.DoubleValue") + proto.RegisterType((*FloatValue)(nil), "google.protobuf.FloatValue") + proto.RegisterType((*Int64Value)(nil), "google.protobuf.Int64Value") + proto.RegisterType((*UInt64Value)(nil), "google.protobuf.UInt64Value") + proto.RegisterType((*Int32Value)(nil), "google.protobuf.Int32Value") + proto.RegisterType((*UInt32Value)(nil), "google.protobuf.UInt32Value") + proto.RegisterType((*BoolValue)(nil), "google.protobuf.BoolValue") + proto.RegisterType((*StringValue)(nil), "google.protobuf.StringValue") + proto.RegisterType((*BytesValue)(nil), "google.protobuf.BytesValue") +} +func (this *DoubleValue) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*DoubleValue) + if !ok { + that2, ok := that.(DoubleValue) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *FloatValue) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*FloatValue) + if !ok { + that2, ok := that.(FloatValue) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Int64Value) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Int64Value) + if !ok { + that2, ok := that.(Int64Value) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *UInt64Value) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*UInt64Value) + if !ok { + that2, ok := that.(UInt64Value) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *Int32Value) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*Int32Value) + if !ok { + that2, ok := that.(Int32Value) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *UInt32Value) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*UInt32Value) + if !ok { + that2, ok := that.(UInt32Value) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *BoolValue) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*BoolValue) + if !ok { + that2, ok := that.(BoolValue) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if !this.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *StringValue) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*StringValue) + if !ok { + that2, ok := that.(StringValue) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if this.Value != that1.Value { + if this.Value < that1.Value { + return -1 + } + return 1 + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *BytesValue) Compare(that interface{}) int { + if that == nil { + if this == nil { + return 0 + } + return 1 + } + + that1, ok := that.(*BytesValue) + if !ok { + that2, ok := that.(BytesValue) + if ok { + that1 = &that2 + } else { + return 1 + } + } + if that1 == nil { + if this == nil { + return 0 + } + return 1 + } else if this == nil { + return -1 + } + if c := bytes.Compare(this.Value, that1.Value); c != 0 { + return c + } + if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { + return c + } + return 0 +} +func (this *DoubleValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DoubleValue) + if !ok { + that2, ok := that.(DoubleValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *FloatValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FloatValue) + if !ok { + that2, ok := that.(FloatValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Int64Value) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Int64Value) + if !ok { + that2, ok := that.(Int64Value) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *UInt64Value) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UInt64Value) + if !ok { + that2, ok := that.(UInt64Value) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *Int32Value) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Int32Value) + if !ok { + that2, ok := that.(Int32Value) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *UInt32Value) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UInt32Value) + if !ok { + that2, ok := that.(UInt32Value) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *BoolValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BoolValue) + if !ok { + that2, ok := that.(BoolValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *StringValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*StringValue) + if !ok { + that2, ok := that.(StringValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Value != that1.Value { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *BytesValue) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BytesValue) + if !ok { + that2, ok := that.(BytesValue) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.Value, that1.Value) { + return false + } + if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { + return false + } + return true +} +func (this *DoubleValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.DoubleValue{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *FloatValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.FloatValue{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Int64Value) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.Int64Value{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *UInt64Value) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.UInt64Value{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Int32Value) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.Int32Value{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *UInt32Value) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.UInt32Value{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *BoolValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.BoolValue{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *StringValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.StringValue{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *BytesValue) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&types.BytesValue{") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + if this.XXX_unrecognized != nil { + s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringWrappers(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *DoubleValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DoubleValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != 0 { + dAtA[i] = 0x9 + i++ + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i += 8 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *FloatValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FloatValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != 0 { + dAtA[i] = 0xd + i++ + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Value)))) + i += 4 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Int64Value) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Int64Value) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintWrappers(dAtA, i, uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *UInt64Value) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UInt64Value) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintWrappers(dAtA, i, uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *Int32Value) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Int32Value) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintWrappers(dAtA, i, uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *UInt32Value) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UInt32Value) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintWrappers(dAtA, i, uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *BoolValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BoolValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Value { + dAtA[i] = 0x8 + i++ + if m.Value { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *StringValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StringValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Value) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintWrappers(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *BytesValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BytesValue) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Value) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintWrappers(dAtA, i, uint64(len(m.Value))) + i += copy(dAtA[i:], m.Value) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func encodeVarintWrappers(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func NewPopulatedDoubleValue(r randyWrappers, easy bool) *DoubleValue { + this := &DoubleValue{} + this.Value = float64(r.Float64()) + if r.Intn(2) == 0 { + this.Value *= -1 + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedFloatValue(r randyWrappers, easy bool) *FloatValue { + this := &FloatValue{} + this.Value = float32(r.Float32()) + if r.Intn(2) == 0 { + this.Value *= -1 + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedInt64Value(r randyWrappers, easy bool) *Int64Value { + this := &Int64Value{} + this.Value = int64(r.Int63()) + if r.Intn(2) == 0 { + this.Value *= -1 + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedUInt64Value(r randyWrappers, easy bool) *UInt64Value { + this := &UInt64Value{} + this.Value = uint64(uint64(r.Uint32())) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedInt32Value(r randyWrappers, easy bool) *Int32Value { + this := &Int32Value{} + this.Value = int32(r.Int31()) + if r.Intn(2) == 0 { + this.Value *= -1 + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedUInt32Value(r randyWrappers, easy bool) *UInt32Value { + this := &UInt32Value{} + this.Value = uint32(r.Uint32()) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedBoolValue(r randyWrappers, easy bool) *BoolValue { + this := &BoolValue{} + this.Value = bool(bool(r.Intn(2) == 0)) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedStringValue(r randyWrappers, easy bool) *StringValue { + this := &StringValue{} + this.Value = string(randStringWrappers(r)) + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +func NewPopulatedBytesValue(r randyWrappers, easy bool) *BytesValue { + this := &BytesValue{} + v1 := r.Intn(100) + this.Value = make([]byte, v1) + for i := 0; i < v1; i++ { + this.Value[i] = byte(r.Intn(256)) + } + if !easy && r.Intn(10) != 0 { + this.XXX_unrecognized = randUnrecognizedWrappers(r, 2) + } + return this +} + +type randyWrappers interface { + Float32() float32 + Float64() float64 + Int63() int64 + Int31() int32 + Uint32() uint32 + Intn(n int) int +} + +func randUTF8RuneWrappers(r randyWrappers) rune { + ru := r.Intn(62) + if ru < 10 { + return rune(ru + 48) + } else if ru < 36 { + return rune(ru + 55) + } + return rune(ru + 61) +} +func randStringWrappers(r randyWrappers) string { + v2 := r.Intn(100) + tmps := make([]rune, v2) + for i := 0; i < v2; i++ { + tmps[i] = randUTF8RuneWrappers(r) + } + return string(tmps) +} +func randUnrecognizedWrappers(r randyWrappers, maxFieldNumber int) (dAtA []byte) { + l := r.Intn(5) + for i := 0; i < l; i++ { + wire := r.Intn(4) + if wire == 3 { + wire = 5 + } + fieldNumber := maxFieldNumber + r.Intn(100) + dAtA = randFieldWrappers(dAtA, r, fieldNumber, wire) + } + return dAtA +} +func randFieldWrappers(dAtA []byte, r randyWrappers, fieldNumber int, wire int) []byte { + key := uint32(fieldNumber)<<3 | uint32(wire) + switch wire { + case 0: + dAtA = encodeVarintPopulateWrappers(dAtA, uint64(key)) + v3 := r.Int63() + if r.Intn(2) == 0 { + v3 *= -1 + } + dAtA = encodeVarintPopulateWrappers(dAtA, uint64(v3)) + case 1: + dAtA = encodeVarintPopulateWrappers(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + case 2: + dAtA = encodeVarintPopulateWrappers(dAtA, uint64(key)) + ll := r.Intn(100) + dAtA = encodeVarintPopulateWrappers(dAtA, uint64(ll)) + for j := 0; j < ll; j++ { + dAtA = append(dAtA, byte(r.Intn(256))) + } + default: + dAtA = encodeVarintPopulateWrappers(dAtA, uint64(key)) + dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) + } + return dAtA +} +func encodeVarintPopulateWrappers(dAtA []byte, v uint64) []byte { + for v >= 1<<7 { + dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80)) + v >>= 7 + } + dAtA = append(dAtA, uint8(v)) + return dAtA +} +func (m *DoubleValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 9 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *FloatValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 5 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Int64Value) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sovWrappers(uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UInt64Value) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sovWrappers(uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *Int32Value) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sovWrappers(uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *UInt32Value) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != 0 { + n += 1 + sovWrappers(uint64(m.Value)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *BoolValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value { + n += 2 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *StringValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovWrappers(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *BytesValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Value) + if l > 0 { + n += 1 + l + sovWrappers(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovWrappers(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozWrappers(x uint64) (n int) { + return sovWrappers(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *DoubleValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&DoubleValue{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *FloatValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&FloatValue{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Int64Value) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Int64Value{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *UInt64Value) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&UInt64Value{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *Int32Value) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Int32Value{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *UInt32Value) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&UInt32Value{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *BoolValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&BoolValue{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *StringValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StringValue{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *BytesValue) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&BytesValue{`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func valueToStringWrappers(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *DoubleValue) 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 ErrIntOverflowWrappers + } + 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: DoubleValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DoubleValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *FloatValue) 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 ErrIntOverflowWrappers + } + 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: FloatValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FloatValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Value = float32(math.Float32frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *Int64Value) 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 ErrIntOverflowWrappers + } + 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: Int64Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Int64Value: 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 ErrIntOverflowWrappers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *UInt64Value) 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 ErrIntOverflowWrappers + } + 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: UInt64Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UInt64Value: 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 ErrIntOverflowWrappers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *Int32Value) 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 ErrIntOverflowWrappers + } + 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: Int32Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Int32Value: 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 ErrIntOverflowWrappers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *UInt32Value) 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 ErrIntOverflowWrappers + } + 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: UInt32Value: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UInt32Value: 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 ErrIntOverflowWrappers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Value |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *BoolValue) 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 ErrIntOverflowWrappers + } + 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: BoolValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BoolValue: 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) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWrappers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.Value = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *StringValue) 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 ErrIntOverflowWrappers + } + 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: StringValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StringValue: 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 ErrIntOverflowWrappers + } + 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 ErrInvalidLengthWrappers + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 *BytesValue) 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 ErrIntOverflowWrappers + } + 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: BytesValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BytesValue: 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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWrappers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWrappers + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWrappers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthWrappers + } + 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 skipWrappers(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWrappers + } + 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, ErrIntOverflowWrappers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWrappers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthWrappers + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWrappers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipWrappers(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthWrappers = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWrappers = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("google/protobuf/wrappers.proto", fileDescriptor_wrappers_c5239a825c7dfb53) +} + +var fileDescriptor_wrappers_c5239a825c7dfb53 = []byte{ + // 285 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x2f, 0x4a, 0x2c, + 0x28, 0x48, 0x2d, 0x2a, 0xd6, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0xca, + 0x5c, 0xdc, 0x2e, 0xf9, 0xa5, 0x49, 0x39, 0xa9, 0x61, 0x89, 0x39, 0xa5, 0xa9, 0x42, 0x22, 0x5c, + 0xac, 0x65, 0x20, 0x86, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x63, 0x10, 0x84, 0xa3, 0xa4, 0xc4, 0xc5, + 0xe5, 0x96, 0x93, 0x9f, 0x58, 0x82, 0x45, 0x0d, 0x13, 0x92, 0x1a, 0xcf, 0xbc, 0x12, 0x33, 0x13, + 0x2c, 0x6a, 0x98, 0x61, 0x6a, 0x94, 0xb9, 0xb8, 0x43, 0x71, 0x29, 0x62, 0x41, 0x35, 0xc8, 0xd8, + 0x08, 0x8b, 0x1a, 0x56, 0x34, 0x83, 0xb0, 0x2a, 0xe2, 0x85, 0x29, 0x52, 0xe4, 0xe2, 0x74, 0xca, + 0xcf, 0xcf, 0xc1, 0xa2, 0x84, 0x03, 0xc9, 0x9c, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0x74, 0x2c, 0x8a, + 0x38, 0x91, 0x1c, 0xe4, 0x54, 0x59, 0x92, 0x5a, 0x8c, 0x45, 0x0d, 0x0f, 0x54, 0x8d, 0x53, 0x3b, + 0xe3, 0x8d, 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xfe, 0x78, 0x28, 0xc7, 0xd8, 0xf0, 0x48, + 0x8e, 0x71, 0xc5, 0x23, 0x39, 0xc6, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, + 0x48, 0x8e, 0xf1, 0xc5, 0x23, 0x39, 0x86, 0x0f, 0x20, 0xf1, 0xc7, 0x72, 0x8c, 0x27, 0x1e, 0xcb, + 0x31, 0x72, 0x09, 0x27, 0xe7, 0xe7, 0xea, 0xa1, 0x45, 0x87, 0x13, 0x6f, 0x38, 0x34, 0xbe, 0x02, + 0x40, 0x22, 0x01, 0x8c, 0x51, 0xac, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x3f, 0x18, 0x19, 0x17, 0x31, + 0x31, 0xbb, 0x07, 0x38, 0xad, 0x62, 0x92, 0x73, 0x87, 0x68, 0x09, 0x80, 0x6a, 0xd1, 0x0b, 0x4f, + 0xcd, 0xc9, 0xf1, 0xce, 0xcb, 0x2f, 0xcf, 0x0b, 0x01, 0xa9, 0x4c, 0x62, 0x03, 0x9b, 0x65, 0x0c, + 0x08, 0x00, 0x00, 0xff, 0xff, 0x31, 0x55, 0x64, 0x90, 0x0a, 0x02, 0x00, 0x00, +} diff --git a/vendor/vendor.json b/vendor/vendor.json index b305ee1836e..555f6985af7 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -229,16 +229,28 @@ "revisionTime": "2017-03-29T04:21:07Z" }, { - "checksumSHA1": "aZgc99rAVaEA9gYf6D4n1iF8oHs=", + "checksumSHA1": "ElpAMJyh/b5cUiFCJ+MjtKYfFAo=", "path": "github.com/gogo/protobuf/jsonpb", - "revision": "e57a569e1882958f6b188cb42231d6db87701f2a", - "revisionTime": "2016-07-19T14:39:48Z" + "revision": "e14cafb6a2c249986e51c4b65c3206bf18578715", + "revisionTime": "2018-09-14T05:40:05Z" }, { - "checksumSHA1": "HIXTnq2r3h/9X1lc7Td4AopDmZs=", + "checksumSHA1": "47nJ3iu1bVvK9jPXwAinFYr4mBU=", "path": "github.com/gogo/protobuf/proto", - "revision": "e57a569e1882958f6b188cb42231d6db87701f2a", - "revisionTime": "2016-07-19T14:39:48Z" + "revision": "e14cafb6a2c249986e51c4b65c3206bf18578715", + "revisionTime": "2018-09-14T05:40:05Z" + }, + { + "checksumSHA1": "HPVQZu059/Rfw2bAWM538bVTcUc=", + "path": "github.com/gogo/protobuf/sortkeys", + "revision": "e14cafb6a2c249986e51c4b65c3206bf18578715", + "revisionTime": "2018-09-14T05:40:05Z" + }, + { + "checksumSHA1": "yK31P3hm7p5eA5PczMByhK0Tj2U=", + "path": "github.com/gogo/protobuf/types", + "revision": "e14cafb6a2c249986e51c4b65c3206bf18578715", + "revisionTime": "2018-09-14T05:40:05Z" }, { "checksumSHA1": "ewUc/AddabJQQ6xmSgRTY+T5cRg=", diff --git a/worker/draft.go b/worker/draft.go index a66f137c3a2..f48165ddb8c 100644 --- a/worker/draft.go +++ b/worker/draft.go @@ -27,7 +27,7 @@ import ( dy "github.com/dgraph-io/dgo/y" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" @@ -60,7 +60,7 @@ type node struct { func newNode(store *raftwal.DiskStorage, gid uint32, id uint64, myAddr string) *node { x.Printf("Node ID: %v with GroupID: %v\n", id, gid) - rc := &intern.RaftContext{ + rc := &pb.RaftContext{ Addr: myAddr, Group: gid, Id: id, @@ -105,7 +105,7 @@ var errInternalRetry = errors.New("Retry Raft proposal internally") // proposeAndWait sends a proposal through RAFT. It waits on a channel for the proposal // to be applied(written to WAL) to all the nodes in the group. -func (n *node) proposeAndWait(ctx context.Context, proposal *intern.Proposal) error { +func (n *node) proposeAndWait(ctx context.Context, proposal *pb.Proposal) error { if n.Raft() == nil { return x.Errorf("Raft isn't initialized yet") } @@ -224,7 +224,7 @@ func (n *node) applyConfChange(e raftpb.Entry) { if cc.Type == raftpb.ConfChangeRemoveNode { n.DeletePeer(cc.NodeID) } else if len(cc.Context) > 0 { - var rc intern.RaftContext + var rc pb.RaftContext x.Check(rc.Unmarshal(cc.Context)) n.Connect(rc.Id, rc.Addr) } @@ -254,7 +254,7 @@ func detectPendingTxns(attr string) error { // We don't support schema mutations across nodes in a transaction. // Wait for all transactions to either abort or complete and all write transactions // involving the predicate are aborted until schema mutations are done. -func (n *node) applyMutations(proposal *intern.Proposal, index uint64) error { +func (n *node) applyMutations(proposal *pb.Proposal, index uint64) error { tr := trace.New("Dgraph.Node", "ApplyMutations") defer tr.Finish() @@ -322,7 +322,7 @@ func (n *node) applyMutations(proposal *intern.Proposal, index uint64) error { return posting.DeletePredicate(ctx, edge.Attr) } // Dont derive schema when doing deletion. - if edge.Op == intern.DirectedEdge_DEL { + if edge.Op == pb.DirectedEdge_DEL { continue } if _, ok := schemaMap[edge.Attr]; !ok { @@ -366,7 +366,7 @@ func (n *node) applyMutations(proposal *intern.Proposal, index uint64) error { return nil } -func (n *node) applyCommitted(proposal *intern.Proposal, index uint64) error { +func (n *node) applyCommitted(proposal *pb.Proposal, index uint64) error { if proposal.Mutations != nil { // syncmarks for this shouldn't be marked done until it's comitted. n.elog.Printf("Applying mutations for key: %s", proposal.Key) @@ -439,7 +439,7 @@ func (n *node) processApplyCh() { n.elog.Printf("Found empty data at index: %d", e.Index) n.Applied.Done(e.Index) default: - proposal := &intern.Proposal{} + proposal := &pb.Proposal{} if err := proposal.Unmarshal(e.Data); err != nil { x.Fatalf("Unable to unmarshal proposal: %v %q\n", err, e.Data) } @@ -454,7 +454,7 @@ func (n *node) processApplyCh() { } } -func (n *node) commitOrAbort(pkey string, delta *intern.OracleDelta) error { +func (n *node) commitOrAbort(pkey string, delta *pb.OracleDelta) error { // First let's commit all mutations to disk. writer := x.TxnWriter{DB: pstore} toDisk := func(start, commit uint64) { @@ -518,7 +518,7 @@ func (n *node) leaderBlocking() (*conn.Pool, error) { return pool, nil } -func (n *node) Snapshot() (*intern.Snapshot, error) { +func (n *node) Snapshot() (*pb.Snapshot, error) { if n == nil || n.Store == nil { return nil, conn.ErrNoNode } @@ -526,7 +526,7 @@ func (n *node) Snapshot() (*intern.Snapshot, error) { if err != nil { return nil, err } - res := &intern.Snapshot{} + res := &pb.Snapshot{} if err := res.Unmarshal(snap.Data); err != nil { return nil, err } @@ -569,7 +569,7 @@ func (n *node) proposeSnapshot() error { if err != nil || snap == nil { return err } - proposal := &intern.Proposal{ + proposal := &pb.Proposal{ Snapshot: snap, } n.elog.Printf("Proposing snapshot: %+v\n", snap) @@ -659,7 +659,7 @@ func (n *node) Run() { // We don't send snapshots to other nodes. But, if we get one, that means // either the leader is trying to bring us up to state; or this is the // snapshot that I created. Only the former case should be handled. - var snap intern.Snapshot + var snap pb.Snapshot x.Check(snap.Unmarshal(rd.Snapshot.Data)) rc := snap.GetContext() x.AssertTrue(rc.GetGroup() == n.gid) @@ -733,12 +733,12 @@ func (n *node) Run() { var errConnection = errors.New("No connection exists") -func (n *node) blockingAbort(req *intern.TxnTimestamps) error { +func (n *node) blockingAbort(req *pb.TxnTimestamps) error { pl := groups().Leader(0) if pl == nil { return errConnection } - zc := intern.NewZeroClient(pl.Get()) + zc := pb.NewZeroClient(pl.Get()) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -751,7 +751,7 @@ func (n *node) blockingAbort(req *intern.TxnTimestamps) error { // Let's propose the txn updates received from Zero. This is important because there are edge // cases where a txn status might have been missed by the group. n.elog.Printf("Proposing abort txn delta: %+v\n", delta) - proposal := &intern.Proposal{Delta: delta} + proposal := &pb.Proposal{Delta: delta} return n.proposeAndWait(n.ctx, proposal) } @@ -767,7 +767,7 @@ func (n *node) abortOldTransactions() { return } x.Printf("Found %d old transactions. Acting to abort them.\n", len(starts)) - req := &intern.TxnTimestamps{Ts: starts} + req := &pb.TxnTimestamps{Ts: starts} err := n.blockingAbort(req) x.Printf("abortOldTransactions for %d txns. Error: %+v\n", len(req.Ts), err) } @@ -795,7 +795,7 @@ func (n *node) abortOldTransactions() { // // At i7, min pending start ts = S3, therefore snapshotIdx = i5 - 1 = i4. // At i7, max commit ts = C1, therefore readTs = C1. -func (n *node) calculateSnapshot(discardN int) (*intern.Snapshot, error) { +func (n *node) calculateSnapshot(discardN int) (*pb.Snapshot, error) { tr := trace.New("Dgraph.Internal", "Propose.Snapshot") defer tr.Finish() @@ -843,7 +843,7 @@ func (n *node) calculateSnapshot(discardN int) (*intern.Snapshot, error) { if entry.Type != raftpb.EntryNormal { continue } - var proposal intern.Proposal + var proposal pb.Proposal if err := proposal.Unmarshal(entry.Data); err != nil { tr.LazyPrintf("Error: %v", err) tr.SetError() @@ -883,7 +883,7 @@ func (n *node) calculateSnapshot(discardN int) (*intern.Snapshot, error) { return nil, nil } - snap := &intern.Snapshot{ + snap := &pb.Snapshot{ Context: n.RaftContext, Index: snapshotIdx, ReadTs: maxCommitTs, @@ -899,7 +899,7 @@ func (n *node) joinPeers() error { } gconn := pl.Get() - c := intern.NewRaftClient(gconn) + c := pb.NewRaftClient(gconn) x.Printf("Calling JoinCluster via leader: %s", pl.Addr) if _, err := c.JoinCluster(n.ctx, n.RaftContext); err != nil { return x.Errorf("Error while joining cluster: %+v\n", err) @@ -916,7 +916,7 @@ func (n *node) isMember() (bool, error) { } gconn := pl.Get() - c := intern.NewRaftClient(gconn) + c := pb.NewRaftClient(gconn) x.Printf("Calling IsPeer") pr, err := c.IsPeer(n.ctx, n.RaftContext) if err != nil { diff --git a/worker/draft_test.go b/worker/draft_test.go index 36141e901cc..e31b21944d5 100644 --- a/worker/draft_test.go +++ b/worker/draft_test.go @@ -8,7 +8,7 @@ import ( pb "github.com/coreos/etcd/raft/raftpb" "github.com/dgraph-io/badger" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" @@ -23,16 +23,16 @@ func openBadger(dir string) (*badger.DB, error) { } func getEntryForMutation(index, startTs uint64) pb.Entry { - proposal := intern.Proposal{Mutations: &intern.Mutations{StartTs: startTs}} + proposal := pb.Proposal{Mutations: &pb.Mutations{StartTs: startTs}} data, err := proposal.Marshal() x.Check(err) return pb.Entry{Index: index, Term: 1, Type: pb.EntryNormal, Data: data} } func getEntryForCommit(index, startTs, commitTs uint64) pb.Entry { - delta := &intern.OracleDelta{} - delta.Txns = append(delta.Txns, &intern.TxnStatus{StartTs: startTs, CommitTs: commitTs}) - proposal := intern.Proposal{Delta: delta} + delta := &pb.OracleDelta{} + delta.Txns = append(delta.Txns, &pb.TxnStatus{StartTs: startTs, CommitTs: commitTs}) + proposal := pb.Proposal{Delta: delta} data, err := proposal.Marshal() x.Check(err) return pb.Entry{Index: index, Term: 1, Type: pb.EntryNormal, Data: data} diff --git a/worker/export.go b/worker/export.go index c0ed7810733..f3fa34b9b03 100644 --- a/worker/export.go +++ b/worker/export.go @@ -25,7 +25,7 @@ import ( "golang.org/x/net/context" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" @@ -42,7 +42,7 @@ type kv struct { type skv struct { attr string - schema *intern.SchemaUpdate + schema *pb.SchemaUpdate } // Map from our types to RDF type. Useful when writing storage types @@ -65,9 +65,9 @@ func toRDF(buf *bytes.Buffer, item kv, readTs uint64) { x.Printf("Error while retrieving list for key %X. Error: %v\n", item.key, err) return } - err = l.Iterate(readTs, 0, func(p *intern.Posting) bool { + err = l.Iterate(readTs, 0, func(p *pb.Posting) bool { buf.WriteString(item.prefix) - if p.PostingType != intern.Posting_REF { + if p.PostingType != pb.Posting_REF { // Value posting // Convert to appropriate type vID := types.TypeID(p.ValType) @@ -79,7 +79,7 @@ func toRDF(buf *bytes.Buffer, item kv, readTs uint64) { // trim null character at end trimmed := strings.TrimRight(str.Value.(string), "\x00") buf.WriteString(strconv.Quote(trimmed)) - if p.PostingType == intern.Posting_VALUE_LANG { + if p.PostingType == pb.Posting_VALUE_LANG { buf.WriteByte('@') buf.WriteString(string(p.LangTag)) } else if vID != types.DefaultID { @@ -147,9 +147,9 @@ func toSchema(buf *bytes.Buffer, s *skv) { if isList { buf.WriteRune(']') } - if s.schema.Directive == intern.SchemaUpdate_REVERSE { + if s.schema.Directive == pb.SchemaUpdate_REVERSE { buf.WriteString(" @reverse") - } else if s.schema.Directive == intern.SchemaUpdate_INDEX && len(s.schema.Tokenizer) > 0 { + } else if s.schema.Directive == pb.SchemaUpdate_INDEX && len(s.schema.Tokenizer) > 0 { buf.WriteString(" @index(") buf.WriteString(strings.Join(s.schema.Tokenizer, ",")) buf.WriteByte(')') @@ -318,7 +318,7 @@ func export(bdir string, readTs uint64) error { } if pk.IsSchema() { - s := &intern.SchemaUpdate{} + s := &pb.SchemaUpdate{} val, err := item.Value() if err != nil { return err @@ -362,7 +362,7 @@ func export(bdir string, readTs uint64) error { // TODO: How do we want to handle export for group, do we pause mutations, sync all and then export ? // TODO: Should we move export logic to dgraphzero? -func handleExportForGroupOverNetwork(ctx context.Context, in *intern.ExportPayload) *intern.ExportPayload { +func handleExportForGroupOverNetwork(ctx context.Context, in *pb.ExportPayload) *pb.ExportPayload { n := groups().Node if in.GroupId == groups().groupId() && n != nil && n.AmLeader() { return handleExportForGroup(ctx, in) @@ -375,29 +375,29 @@ func handleExportForGroupOverNetwork(ctx context.Context, in *intern.ExportPaylo if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("Unable to find a server to export group: %d", in.GroupId) } - in.Status = intern.ExportPayload_FAILED + in.Status = pb.ExportPayload_FAILED return in } - c := intern.NewWorkerClient(pl.Get()) + c := pb.NewWorkerClient(pl.Get()) nrep, err := c.Export(ctx, in) if err != nil { if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf(err.Error()) } - in.Status = intern.ExportPayload_FAILED + in.Status = pb.ExportPayload_FAILED return in } return nrep } -func handleExportForGroup(ctx context.Context, in *intern.ExportPayload) *intern.ExportPayload { +func handleExportForGroup(ctx context.Context, in *pb.ExportPayload) *pb.ExportPayload { n := groups().Node if in.GroupId != groups().groupId() || !n.AmLeader() { if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("I am not leader of group %d.", in.GroupId) } - in.Status = intern.ExportPayload_FAILED + in.Status = pb.ExportPayload_FAILED return in } n.applyAllMarks(n.ctx) @@ -408,32 +408,32 @@ func handleExportForGroup(ctx context.Context, in *intern.ExportPayload) *intern if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf(err.Error()) } - in.Status = intern.ExportPayload_FAILED + in.Status = pb.ExportPayload_FAILED return in } if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("Export done for group: %d.", in.GroupId) } - in.Status = intern.ExportPayload_SUCCESS + in.Status = pb.ExportPayload_SUCCESS return in } // Export request is used to trigger exports for the request list of groups. // If a server receives request to export a group that it doesn't handle, it would // automatically relay that request to the server that it thinks should handle the request. -func (w *grpcWorker) Export(ctx context.Context, req *intern.ExportPayload) (*intern.ExportPayload, error) { - reply := &intern.ExportPayload{ReqId: req.ReqId, GroupId: req.GroupId} - reply.Status = intern.ExportPayload_FAILED // Set by default. +func (w *grpcWorker) Export(ctx context.Context, req *pb.ExportPayload) (*pb.ExportPayload, error) { + reply := &pb.ExportPayload{ReqId: req.ReqId, GroupId: req.GroupId} + reply.Status = pb.ExportPayload_FAILED // Set by default. if ctx.Err() != nil { return reply, ctx.Err() } if !w.addIfNotPresent(req.ReqId) { - reply.Status = intern.ExportPayload_DUPLICATE + reply.Status = pb.ExportPayload_DUPLICATE return reply, nil } - chb := make(chan *intern.ExportPayload, 1) + chb := make(chan *pb.ExportPayload, 1) go func() { chb <- handleExportForGroup(ctx, req) }() @@ -455,7 +455,7 @@ func ExportOverNetwork(ctx context.Context) error { return err } // Get ReadTs from zero and wait for stream to catch up. - ts, err := Timestamps(ctx, &intern.Num{Val: 1}) + ts, err := Timestamps(ctx, &pb.Num{Val: 1}) if err != nil { return err } @@ -465,10 +465,10 @@ func ExportOverNetwork(ctx context.Context) error { // Let's first collect all groups. gids := groups().KnownGroups() - ch := make(chan *intern.ExportPayload, len(gids)) + ch := make(chan *pb.ExportPayload, len(gids)) for _, gid := range gids { go func(group uint32) { - req := &intern.ExportPayload{ + req := &pb.ExportPayload{ ReqId: uint64(rand.Int63()), GroupId: group, ReadTs: readTs, @@ -479,7 +479,7 @@ func ExportOverNetwork(ctx context.Context) error { for i := 0; i < len(gids); i++ { bp := <-ch - if bp.Status != intern.ExportPayload_SUCCESS { + if bp.Status != pb.ExportPayload_SUCCESS { if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("Export status: %v for group id: %d", bp.Status, bp.GroupId) } diff --git a/worker/export_test.go b/worker/export_test.go index 40e264a9088..3c25a89e16d 100644 --- a/worker/export_test.go +++ b/worker/export_test.go @@ -23,7 +23,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/gql" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/types/facets" @@ -68,7 +68,7 @@ func populateGraphExport(t *testing.T) { func initTestExport(t *testing.T, schemaStr string) { schema.ParseBytes([]byte(schemaStr), 1) - val, err := (&intern.SchemaUpdate{ValueType: intern.Posting_UID}).Marshal() + val, err := (&pb.SchemaUpdate{ValueType: pb.Posting_UID}).Marshal() require.NoError(t, err) txn := pstore.NewTransactionAt(math.MaxUint64, true) @@ -78,7 +78,7 @@ func initTestExport(t *testing.T, schemaStr string) { txn.Discard() require.NoError(t, err) - val, err = (&intern.SchemaUpdate{ValueType: intern.Posting_UID}).Marshal() + val, err = (&pb.SchemaUpdate{ValueType: pb.Posting_UID}).Marshal() require.NoError(t, err) txn = pstore.NewTransactionAt(math.MaxUint64, true) @@ -229,10 +229,10 @@ func TestToSchema(t *testing.T) { { skv: &skv{ attr: "Alice", - schema: &intern.SchemaUpdate{ + schema: &pb.SchemaUpdate{ Predicate: "mother", - ValueType: intern.Posting_STRING, - Directive: intern.SchemaUpdate_REVERSE, + ValueType: pb.Posting_STRING, + Directive: pb.SchemaUpdate_REVERSE, List: false, Count: true, Upsert: true, @@ -244,10 +244,10 @@ func TestToSchema(t *testing.T) { { skv: &skv{ attr: "Alice:best", - schema: &intern.SchemaUpdate{ + schema: &pb.SchemaUpdate{ Predicate: "mother", - ValueType: intern.Posting_STRING, - Directive: intern.SchemaUpdate_REVERSE, + ValueType: pb.Posting_STRING, + Directive: pb.SchemaUpdate_REVERSE, List: false, Count: false, Upsert: false, @@ -289,9 +289,9 @@ func TestToSchema(t *testing.T) { // benchItems := []kv{ // { // prefix: "testString", -// list: &intern.PostingList{ -// Postings: []*intern.Posting{{ -// ValType: intern.Posting_STRING, +// list: &pb.PostingList{ +// Postings: []*pb.Posting{{ +// ValType: pb.Posting_STRING, // Value: []byte("手機裡的眼淚"), // Uid: uint64(65454), // Facets: fac, @@ -299,36 +299,36 @@ func TestToSchema(t *testing.T) { // }, // }, // {prefix: "testGeo", -// list: &intern.PostingList{ -// Postings: []*intern.Posting{{ -// ValType: intern.Posting_GEO, +// list: &pb.PostingList{ +// Postings: []*pb.Posting{{ +// ValType: pb.Posting_GEO, // Value: geoData, // Uid: uint64(65454), // Facets: fac, // }}, // }}, // {prefix: "testPassword", -// list: &intern.PostingList{ -// Postings: []*intern.Posting{{ -// ValType: intern.Posting_PASSWORD, +// list: &pb.PostingList{ +// Postings: []*pb.Posting{{ +// ValType: pb.Posting_PASSWORD, // Value: []byte("test"), // Uid: uint64(65454), // Facets: fac, // }}, // }}, // {prefix: "testInt", -// list: &intern.PostingList{ -// Postings: []*intern.Posting{{ -// ValType: intern.Posting_INT, +// list: &pb.PostingList{ +// Postings: []*pb.Posting{{ +// ValType: pb.Posting_INT, // Value: byteInt, // Uid: uint64(65454), // Facets: fac, // }}, // }}, // {prefix: "testUid", -// list: &intern.PostingList{ -// Postings: []*intern.Posting{{ -// ValType: intern.Posting_INT, +// list: &pb.PostingList{ +// Postings: []*pb.Posting{{ +// ValType: pb.Posting_INT, // Uid: uint64(65454), // Facets: fac, // }}, diff --git a/worker/groups.go b/worker/groups.go index f8fb80c5285..cc9eac0c4f9 100644 --- a/worker/groups.go +++ b/worker/groups.go @@ -23,7 +23,7 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" @@ -34,10 +34,10 @@ type groupi struct { // TODO: Is this context being used? ctx context.Context cancel context.CancelFunc - state *intern.MembershipState + state *pb.MembershipState Node *node gid uint32 - tablets map[string]*intern.Tablet + tablets map[string]*pb.Tablet triggerCh chan struct{} // Used to trigger membership sync delPred chan struct{} // Ensures that predicate move doesn't happen when deletion is ongoing. closer *y.Closer @@ -83,9 +83,9 @@ func StartRaftNodes(walStore *badger.DB, bindall bool) { p := conn.Get().Connect(Config.ZeroAddr) // Connect with dgraphzero and figure out what group we should belong to. - zc := intern.NewZeroClient(p.Get()) - var connState *intern.ConnectionState - m := &intern.Member{Id: Config.RaftId, Addr: Config.MyAddr} + zc := pb.NewZeroClient(p.Get()) + var connState *pb.ConnectionState + m := &pb.Member{Id: Config.RaftId, Addr: Config.MyAddr} delay := 50 * time.Millisecond maxHalfDelay := 3 * time.Second var err error @@ -145,12 +145,12 @@ func (g *groupi) proposeInitialSchema() { } // Propose schema mutation. - var m intern.Mutations + var m pb.Mutations // schema for _predicate_ is not changed once set. m.StartTs = 1 - m.Schema = append(m.Schema, &intern.SchemaUpdate{ + m.Schema = append(m.Schema, &pb.SchemaUpdate{ Predicate: x.PredicateListAttr, - ValueType: intern.Posting_STRING, + ValueType: pb.Posting_STRING, List: true, }) @@ -174,7 +174,7 @@ func (g *groupi) groupId() uint32 { // calculateTabletSizes iterates through badger and gets a size of the space occupied by each // predicate (including data and indexes). All data for a predicate forms a Tablet. -func (g *groupi) calculateTabletSizes() map[string]*intern.Tablet { +func (g *groupi) calculateTabletSizes() map[string]*pb.Tablet { opt := badger.DefaultIteratorOptions opt.PrefetchValues = false txn := pstore.NewTransactionAt(math.MaxUint64, false) @@ -183,7 +183,7 @@ func (g *groupi) calculateTabletSizes() map[string]*intern.Tablet { defer itr.Close() gid := g.groupId() - tablets := make(map[string]*intern.Tablet) + tablets := make(map[string]*pb.Tablet) for itr.Rewind(); itr.Valid(); { item := itr.Item() @@ -208,7 +208,7 @@ func (g *groupi) calculateTabletSizes() map[string]*intern.Tablet { } continue } - tablet = &intern.Tablet{GroupId: gid, Predicate: pk.Attr} + tablet = &pb.Tablet{GroupId: gid, Predicate: pk.Attr} tablets[pk.Attr] = tablet } tablet.Space += item.EstimatedSize() @@ -234,8 +234,8 @@ func UpdateMembershipState(ctx context.Context) error { return x.Errorf("don't have the address of any dgraphzero server") } - c := intern.NewZeroClient(p.Get()) - state, err := c.Connect(ctx, &intern.Member{ClusterInfoOnly: true}) + c := pb.NewZeroClient(p.Get()) + state, err := c.Connect(ctx, &pb.Member{ClusterInfoOnly: true}) if err != nil { return err } @@ -243,7 +243,7 @@ func UpdateMembershipState(ctx context.Context) error { return nil } -func (g *groupi) applyState(state *intern.MembershipState) { +func (g *groupi) applyState(state *pb.MembershipState) { x.AssertTrue(state != nil) g.Lock() defer g.Unlock() @@ -270,7 +270,7 @@ func (g *groupi) applyState(state *intern.MembershipState) { } // Sometimes this can cause us to lose latest tablet info, but that shouldn't cause any issues. - g.tablets = make(map[string]*intern.Tablet) + g.tablets = make(map[string]*pb.Tablet) for gid, group := range g.state.Groups { for _, member := range group.Members { if Config.RaftId == member.Id { @@ -330,7 +330,7 @@ func (g *groupi) ServesTablet(key string) bool { } // Do not modify the returned Tablet -func (g *groupi) Tablet(key string) *intern.Tablet { +func (g *groupi) Tablet(key string) *pb.Tablet { // TODO: Remove all this later, create a membership state and apply it g.RLock() tablet, ok := g.tablets[key] @@ -345,9 +345,9 @@ func (g *groupi) Tablet(key string) *intern.Tablet { if pl == nil { return nil } - zc := intern.NewZeroClient(pl.Get()) + zc := pb.NewZeroClient(pl.Get()) - tablet = &intern.Tablet{GroupId: g.groupId(), Predicate: key} + tablet = &pb.Tablet{GroupId: g.groupId(), Predicate: key} out, err := zc.ShouldServe(context.Background(), tablet) if err != nil { x.Printf("Error while ShouldServe grpc call %v", err) @@ -401,7 +401,7 @@ func (g *groupi) AnyTwoServers(gid uint32) []string { return res } -func (g *groupi) members(gid uint32) map[uint64]*intern.Member { +func (g *groupi) members(gid uint32) map[uint64]*pb.Member { g.RLock() defer g.RUnlock() @@ -506,7 +506,7 @@ START: } x.Printf("Got address of a Zero server: %s", pl.Addr) - c := intern.NewZeroClient(pl.Get()) + c := pb.NewZeroClient(pl.Get()) ctx, cancel := context.WithCancel(context.Background()) stream, err := c.Update(ctx) if err != nil { @@ -555,16 +555,16 @@ OUTER: // dgraphzero just adds to the map so check that no data is present for the tablet // before we remove it to avoid the race condition where a tablet is added recently // and mutation has not been persisted to disk. - var allTablets map[string]*intern.Tablet + var allTablets map[string]*pb.Tablet if g.Node.AmLeader() { prevTablets := tablets tablets = g.calculateTabletSizes() if prevTablets != nil { - allTablets = make(map[string]*intern.Tablet) + allTablets = make(map[string]*pb.Tablet) g.RLock() for attr := range g.tablets { if tablets[attr] == nil && prevTablets[attr] == nil { - allTablets[attr] = &intern.Tablet{ + allTablets[attr] = &pb.Tablet{ GroupId: g.gid, Predicate: attr, Remove: true, @@ -670,18 +670,18 @@ func (g *groupi) cleanupTablets() { } } -func (g *groupi) sendMembership(tablets map[string]*intern.Tablet, - stream intern.Zero_UpdateClient) error { +func (g *groupi) sendMembership(tablets map[string]*pb.Tablet, + stream pb.Zero_UpdateClient) error { leader := g.Node.AmLeader() - member := &intern.Member{ + member := &pb.Member{ Id: Config.RaftId, GroupId: g.groupId(), Addr: Config.MyAddr, Leader: leader, LastUpdate: uint64(time.Now().Unix()), } - group := &intern.Group{ - Members: make(map[uint64]*intern.Member), + group := &pb.Group{ + Members: make(map[uint64]*pb.Member), } group.Members[member.Id] = member if leader { @@ -717,7 +717,7 @@ func (g *groupi) processOracleDeltaStream() { // code base). ctx, cancel := context.WithCancel(context.Background()) defer cancel() - c := intern.NewZeroClient(pl.Get()) + c := pb.NewZeroClient(pl.Get()) // The first entry send by Zero contains the entire state of transactions. Zero periodically // confirms receipt from the group, and truncates its state. This 2-way acknowledgement is a // safe way to get the status of all the transactions. @@ -729,7 +729,7 @@ func (g *groupi) processOracleDeltaStream() { return } - deltaCh := make(chan *intern.OracleDelta, 100) + deltaCh := make(chan *pb.OracleDelta, 100) go func() { // This would exit when either a Recv() returns error. Or, cancel() is called by // something outside of this goroutine. @@ -752,7 +752,7 @@ func (g *groupi) processOracleDeltaStream() { }() for { - var delta *intern.OracleDelta + var delta *pb.OracleDelta var batch int select { case delta = <-deltaCh: @@ -793,7 +793,7 @@ func (g *groupi) processOracleDeltaStream() { } // Block forever trying to propose this. elog.Printf("Batched %d updates. Proposing Delta: %v.", batch, delta) - g.Node.proposeAndWait(context.Background(), &intern.Proposal{Delta: delta}) + g.Node.proposeAndWait(context.Background(), &pb.Proposal{Delta: delta}) } } diff --git a/worker/mutation.go b/worker/mutation.go index 70a37df40d7..a0e252f7a8b 100644 --- a/worker/mutation.go +++ b/worker/mutation.go @@ -23,7 +23,7 @@ import ( "github.com/dgraph-io/dgo/y" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" @@ -34,12 +34,12 @@ var ( errPredicateMoving = x.Errorf("Predicate is being moved, please retry later") ) -func deletePredicateEdge(edge *intern.DirectedEdge) bool { +func deletePredicateEdge(edge *pb.DirectedEdge) bool { return edge.Entity == 0 && bytes.Equal(edge.Value, []byte(x.Star)) } // runMutation goes through all the edges and applies them. -func runMutation(ctx context.Context, edge *intern.DirectedEdge, txn *posting.Txn) error { +func runMutation(ctx context.Context, edge *pb.DirectedEdge, txn *posting.Txn) error { if !groups().ServesTabletRW(edge.Attr) { // Don't assert, can happen during replay of raft logs if server crashes immediately // after predicate move and before snapshot. @@ -47,7 +47,7 @@ func runMutation(ctx context.Context, edge *intern.DirectedEdge, txn *posting.Tx } su, ok := schema.State().Get(edge.Attr) - if edge.Op == intern.DirectedEdge_SET { + if edge.Op == pb.DirectedEdge_SET { x.AssertTruef(ok, "Schema is not present for predicate %s", edge.Attr) } @@ -79,7 +79,7 @@ func runMutation(ctx context.Context, edge *intern.DirectedEdge, txn *posting.Tx // This is serialized with mutations, called after applied watermarks catch up // and further mutations are blocked until this is done. -func runSchemaMutation(ctx context.Context, update *intern.SchemaUpdate, startTs uint64) error { +func runSchemaMutation(ctx context.Context, update *pb.SchemaUpdate, startTs uint64) error { if err := runSchemaMutationHelper(ctx, update, startTs); err != nil { return err } @@ -96,7 +96,7 @@ func runSchemaMutation(ctx context.Context, update *intern.SchemaUpdate, startTs return nil } -func runSchemaMutationHelper(ctx context.Context, update *intern.SchemaUpdate, startTs uint64) error { +func runSchemaMutationHelper(ctx context.Context, update *pb.SchemaUpdate, startTs uint64) error { n := groups().Node if !groups().ServesTablet(update.Predicate) { return errUnservedTablet @@ -123,11 +123,11 @@ func runSchemaMutationHelper(ctx context.Context, update *intern.SchemaUpdate, s // (both applied and synced watermarks). defer x.Printf("Done schema update %+v\n", update) if !ok { - if current.Directive == intern.SchemaUpdate_INDEX { + if current.Directive == pb.SchemaUpdate_INDEX { if err := n.rebuildOrDelIndex(ctx, update.Predicate, true, startTs); err != nil { return err } - } else if current.Directive == intern.SchemaUpdate_REVERSE { + } else if current.Directive == pb.SchemaUpdate_REVERSE { if err := n.rebuildOrDelRevEdge(ctx, update.Predicate, true, startTs); err != nil { return err } @@ -154,13 +154,13 @@ func runSchemaMutationHelper(ctx context.Context, update *intern.SchemaUpdate, s if needReindexing(old, current) { // Reindex if update.Index is true or remove index if err := n.rebuildOrDelIndex(ctx, update.Predicate, - current.Directive == intern.SchemaUpdate_INDEX, startTs); err != nil { + current.Directive == pb.SchemaUpdate_INDEX, startTs); err != nil { return err } } else if needsRebuildingReverses(old, current) { // Add or remove reverse edge based on update.Reverse if err := n.rebuildOrDelRevEdge(ctx, update.Predicate, - current.Directive == intern.SchemaUpdate_REVERSE, startTs); err != nil { + current.Directive == pb.SchemaUpdate_REVERSE, startTs); err != nil { return err } } @@ -174,17 +174,17 @@ func runSchemaMutationHelper(ctx context.Context, update *intern.SchemaUpdate, s return nil } -func needsRebuildingReverses(old intern.SchemaUpdate, current intern.SchemaUpdate) bool { - return (current.Directive == intern.SchemaUpdate_REVERSE) != - (old.Directive == intern.SchemaUpdate_REVERSE) +func needsRebuildingReverses(old pb.SchemaUpdate, current pb.SchemaUpdate) bool { + return (current.Directive == pb.SchemaUpdate_REVERSE) != + (old.Directive == pb.SchemaUpdate_REVERSE) } -func needReindexing(old intern.SchemaUpdate, current intern.SchemaUpdate) bool { - if (current.Directive == intern.SchemaUpdate_INDEX) != (old.Directive == intern.SchemaUpdate_INDEX) { +func needReindexing(old pb.SchemaUpdate, current pb.SchemaUpdate) bool { + if (current.Directive == pb.SchemaUpdate_INDEX) != (old.Directive == pb.SchemaUpdate_INDEX) { return true } // if value types has changed - if current.Directive == intern.SchemaUpdate_INDEX && current.ValueType != old.ValueType { + if current.Directive == pb.SchemaUpdate_INDEX && current.ValueType != old.ValueType { return true } // if tokenizer has changed - if same tokenizer works differently @@ -203,7 +203,7 @@ func needReindexing(old intern.SchemaUpdate, current intern.SchemaUpdate) bool { // We commit schema to disk in blocking way, should be ok because this happens // only during schema mutations or we see a new predicate. -func updateSchema(attr string, s intern.SchemaUpdate) error { +func updateSchema(attr string, s pb.SchemaUpdate) error { schema.State().Set(attr, s) txn := pstore.NewTransactionAt(1, true) defer txn.Discard() @@ -222,7 +222,7 @@ func updateSchemaType(attr string, typ types.TypeID, index uint64) { if ok { s.ValueType = typ.Enum() } else { - s = intern.SchemaUpdate{ValueType: typ.Enum(), Predicate: attr} + s = pb.SchemaUpdate{ValueType: typ.Enum(), Predicate: attr} } updateSchema(attr, s) } @@ -250,25 +250,25 @@ func hasEdges(attr string, startTs uint64) bool { return false } -func checkSchema(s *intern.SchemaUpdate) error { +func checkSchema(s *pb.SchemaUpdate) error { if len(s.Predicate) == 0 { return x.Errorf("No predicate specified in schema mutation") } - if s.Directive == intern.SchemaUpdate_INDEX && len(s.Tokenizer) == 0 { + if s.Directive == pb.SchemaUpdate_INDEX && len(s.Tokenizer) == 0 { return x.Errorf("Tokenizer must be specified while indexing a predicate: %+v", s) } - if len(s.Tokenizer) > 0 && s.Directive != intern.SchemaUpdate_INDEX { + if len(s.Tokenizer) > 0 && s.Directive != pb.SchemaUpdate_INDEX { return x.Errorf("Directive must be SchemaUpdate_INDEX when a tokenizer is specified") } typ := types.TypeID(s.ValueType) - if typ == types.UidID && s.Directive == intern.SchemaUpdate_INDEX { + if typ == types.UidID && s.Directive == pb.SchemaUpdate_INDEX { // index on uid type return x.Errorf("Index not allowed on predicate of type uid on predicate %s", s.Predicate) - } else if typ != types.UidID && s.Directive == intern.SchemaUpdate_REVERSE { + } else if typ != types.UidID && s.Directive == pb.SchemaUpdate_REVERSE { // reverse on non-uid type return x.Errorf("Cannot reverse for non-uid type on predicate %s", s.Predicate) } @@ -286,7 +286,7 @@ func checkSchema(s *intern.SchemaUpdate) error { } // schema was defined already - if t.IsScalar() && t.Enum() != intern.Posting_PASSWORD && s.ValueType == intern.Posting_PASSWORD { + if t.IsScalar() && t.Enum() != pb.Posting_PASSWORD && s.ValueType == pb.Posting_PASSWORD { return x.Errorf("Schema change not allowed from %s to PASSWORD", t.Enum().String()) } if t.IsScalar() == typ.IsScalar() { @@ -308,7 +308,7 @@ func checkSchema(s *intern.SchemaUpdate) error { // If storage type is specified, then check compatibility or convert to schema type // if no storage type is specified then convert to schema type. -func ValidateAndConvert(edge *intern.DirectedEdge, su *intern.SchemaUpdate) error { +func ValidateAndConvert(edge *pb.DirectedEdge, su *pb.SchemaUpdate) error { if deletePredicateEdge(edge) { return nil } @@ -317,7 +317,7 @@ func ValidateAndConvert(edge *intern.DirectedEdge, su *intern.SchemaUpdate) erro } //

Del on non list scalar type. if edge.ValueId == 0 && !bytes.Equal(edge.Value, []byte(x.Star)) && - edge.Op == intern.DirectedEdge_DEL { + edge.Op == pb.DirectedEdge_DEL { if !su.GetList() { return x.Errorf("Please use * with delete operation for non-list type: [%v]", edge.Attr) } @@ -369,25 +369,25 @@ func ValidateAndConvert(edge *intern.DirectedEdge, su *intern.SchemaUpdate) erro return nil } -func AssignUidsOverNetwork(ctx context.Context, num *intern.Num) (*intern.AssignedIds, error) { +func AssignUidsOverNetwork(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error) { pl := groups().Leader(0) if pl == nil { return nil, conn.ErrNoConnection } conn := pl.Get() - c := intern.NewZeroClient(conn) + c := pb.NewZeroClient(conn) return c.AssignUids(ctx, num) } -func Timestamps(ctx context.Context, num *intern.Num) (*intern.AssignedIds, error) { +func Timestamps(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error) { pl := groups().Leader(0) if pl == nil { return nil, conn.ErrNoConnection } conn := pl.Get() - c := intern.NewZeroClient(conn) + c := pb.NewZeroClient(conn) return c.Timestamps(ctx, num) } @@ -401,12 +401,12 @@ func fillTxnContext(tctx *api.TxnContext, startTs uint64) { // proposeOrSend either proposes the mutation if the node serves the group gid or sends it to // the leader of the group gid for proposing. -func proposeOrSend(ctx context.Context, gid uint32, m *intern.Mutations, chr chan res) { +func proposeOrSend(ctx context.Context, gid uint32, m *pb.Mutations, chr chan res) { res := res{} if groups().ServesGroup(gid) { node := groups().Node // we don't timeout after proposing - res.err = node.proposeAndWait(ctx, &intern.Proposal{Mutations: m}) + res.err = node.proposeAndWait(ctx, &pb.Proposal{Mutations: m}) res.ctx = &api.TxnContext{} fillTxnContext(res.ctx, m.StartTs) chr <- res @@ -425,7 +425,7 @@ func proposeOrSend(ctx context.Context, gid uint32, m *intern.Mutations, chr cha conn := pl.Get() var tc *api.TxnContext - c := intern.NewWorkerClient(conn) + c := pb.NewWorkerClient(conn) ch := make(chan error, 1) go func() { @@ -447,13 +447,13 @@ func proposeOrSend(ctx context.Context, gid uint32, m *intern.Mutations, chr cha // populateMutationMap populates a map from group id to the mutation that // should be sent to that group. -func populateMutationMap(src *intern.Mutations) map[uint32]*intern.Mutations { - mm := make(map[uint32]*intern.Mutations) +func populateMutationMap(src *pb.Mutations) map[uint32]*pb.Mutations { + mm := make(map[uint32]*pb.Mutations) for _, edge := range src.Edges { gid := groups().BelongsTo(edge.Attr) mu := mm[gid] if mu == nil { - mu = &intern.Mutations{GroupId: gid} + mu = &pb.Mutations{GroupId: gid} mm[gid] = mu } mu.Edges = append(mu.Edges, edge) @@ -462,7 +462,7 @@ func populateMutationMap(src *intern.Mutations) map[uint32]*intern.Mutations { gid := groups().BelongsTo(schema.Predicate) mu := mm[gid] if mu == nil { - mu = &intern.Mutations{GroupId: gid} + mu = &pb.Mutations{GroupId: gid} mm[gid] = mu } mu.Schema = append(mu.Schema, schema) @@ -471,7 +471,7 @@ func populateMutationMap(src *intern.Mutations) map[uint32]*intern.Mutations { for _, gid := range groups().KnownGroups() { mu := mm[gid] if mu == nil { - mu = &intern.Mutations{GroupId: gid} + mu = &pb.Mutations{GroupId: gid} mm[gid] = mu } mu.DropAll = true @@ -496,7 +496,7 @@ type res struct { // MutateOverNetwork checks which group should be running the mutations // according to the group config and sends it to that instance. -func MutateOverNetwork(ctx context.Context, m *intern.Mutations) (*api.TxnContext, error) { +func MutateOverNetwork(ctx context.Context, m *pb.Mutations) (*api.TxnContext, error) { tctx := &api.TxnContext{StartTs: m.StartTs} mutationMap := populateMutationMap(m) @@ -534,7 +534,7 @@ func CommitOverNetwork(ctx context.Context, tc *api.TxnContext) (uint64, error) if pl == nil { return 0, conn.ErrNoConnection } - zc := intern.NewZeroClient(pl.Get()) + zc := pb.NewZeroClient(pl.Get()) tctx, err := zc.CommitOrAbort(ctx, tc) if err != nil { return 0, err @@ -546,14 +546,14 @@ func CommitOverNetwork(ctx context.Context, tc *api.TxnContext) (uint64, error) } func (w *grpcWorker) PurgeTs(ctx context.Context, - payload *api.Payload) (*intern.Num, error) { - n := &intern.Num{} + payload *api.Payload) (*pb.Num, error) { + n := &pb.Num{} n.Val = posting.Oracle().PurgeTs() return n, nil } // Mutate is used to apply mutations over the network on other instances. -func (w *grpcWorker) Mutate(ctx context.Context, m *intern.Mutations) (*api.TxnContext, error) { +func (w *grpcWorker) Mutate(ctx context.Context, m *pb.Mutations) (*api.TxnContext, error) { txnCtx := &api.TxnContext{} if ctx.Err() != nil { return txnCtx, ctx.Err() @@ -569,14 +569,14 @@ func (w *grpcWorker) Mutate(ctx context.Context, m *intern.Mutations) (*api.TxnC defer tr.Finish() } - err := node.proposeAndWait(ctx, &intern.Proposal{Mutations: m}) + err := node.proposeAndWait(ctx, &pb.Proposal{Mutations: m}) fillTxnContext(txnCtx, m.StartTs) return txnCtx, err } func tryAbortTransactions(startTimestamps []uint64) { // Aborts if not already committed. - req := &intern.TxnTimestamps{Ts: startTimestamps} + req := &pb.TxnTimestamps{Ts: startTimestamps} err := groups().Node.blockingAbort(req) x.Printf("tryAbortTransactions for %d txns. Error: %+v\n", len(req.Ts), err) diff --git a/worker/mutation_test.go b/worker/mutation_test.go index 67f062be06a..fbaa04b281d 100644 --- a/worker/mutation_test.go +++ b/worker/mutation_test.go @@ -14,27 +14,27 @@ import ( "github.com/stretchr/testify/require" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" ) func TestConvertEdgeType(t *testing.T) { var testEdges = []struct { - input *intern.DirectedEdge + input *pb.DirectedEdge to types.TypeID expectErr bool - output *intern.DirectedEdge + output *pb.DirectedEdge }{ { - input: &intern.DirectedEdge{ + input: &pb.DirectedEdge{ Value: []byte("set edge"), Label: "test-mutation", Attr: "name", }, to: types.StringID, expectErr: false, - output: &intern.DirectedEdge{ + output: &pb.DirectedEdge{ Value: []byte("set edge"), Label: "test-mutation", Attr: "name", @@ -42,17 +42,17 @@ func TestConvertEdgeType(t *testing.T) { }, }, { - input: &intern.DirectedEdge{ + input: &pb.DirectedEdge{ Value: []byte("set edge"), Label: "test-mutation", Attr: "name", - Op: intern.DirectedEdge_DEL, + Op: pb.DirectedEdge_DEL, }, to: types.StringID, expectErr: true, }, { - input: &intern.DirectedEdge{ + input: &pb.DirectedEdge{ ValueId: 123, Label: "test-mutation", Attr: "name", @@ -61,7 +61,7 @@ func TestConvertEdgeType(t *testing.T) { expectErr: true, }, { - input: &intern.DirectedEdge{ + input: &pb.DirectedEdge{ Value: []byte("set edge"), Label: "test-mutation", Attr: "name", @@ -73,8 +73,8 @@ func TestConvertEdgeType(t *testing.T) { for _, testEdge := range testEdges { err := ValidateAndConvert(testEdge.input, - &intern.SchemaUpdate{ - ValueType: intern.Posting_ValType(testEdge.to), + &pb.SchemaUpdate{ + ValueType: pb.Posting_ValType(testEdge.to), }) if testEdge.expectErr { require.Error(t, err) @@ -87,28 +87,28 @@ func TestConvertEdgeType(t *testing.T) { } func TestValidateEdgeTypeError(t *testing.T) { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("set edge"), Label: "test-mutation", Attr: "name", } err := ValidateAndConvert(edge, - &intern.SchemaUpdate{ - ValueType: intern.Posting_ValType(types.DateTimeID), + &pb.SchemaUpdate{ + ValueType: pb.Posting_ValType(types.DateTimeID), }) require.Error(t, err) } func TestPopulateMutationMap(t *testing.T) { - edges := []*intern.DirectedEdge{{ + edges := []*pb.DirectedEdge{{ Value: []byte("set edge"), Label: "test-mutation", }} - schema := []*intern.SchemaUpdate{{ + schema := []*pb.SchemaUpdate{{ Predicate: "name", }} - m := &intern.Mutations{Edges: edges, Schema: schema} + m := &pb.Mutations{Edges: edges, Schema: schema} mutationsMap := populateMutationMap(m) mu := mutationsMap[1] @@ -121,51 +121,51 @@ func TestCheckSchema(t *testing.T) { posting.DeleteAll() initTest(t, "name:string @index(term) .") // non uid to uid - s1 := &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_UID} + s1 := &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_UID} require.NoError(t, checkSchema(s1)) // uid to non uid err := schema.ParseBytes([]byte("name:uid ."), 1) require.NoError(t, err) - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_STRING} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_STRING} require.NoError(t, checkSchema(s1)) // string to password err = schema.ParseBytes([]byte("name:string ."), 1) require.NoError(t, err) - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_PASSWORD} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_PASSWORD} require.Error(t, checkSchema(s1)) // int to password err = schema.ParseBytes([]byte("name:int ."), 1) require.NoError(t, err) - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_PASSWORD} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_PASSWORD} require.Error(t, checkSchema(s1)) // password to password err = schema.ParseBytes([]byte("name:password ."), 1) require.NoError(t, err) - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_PASSWORD} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_PASSWORD} require.NoError(t, checkSchema(s1)) // string to int err = schema.ParseBytes([]byte("name:string ."), 1) require.NoError(t, err) - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_FLOAT} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_FLOAT} require.NoError(t, checkSchema(s1)) // index on uid type - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_UID, Directive: intern.SchemaUpdate_INDEX} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_INDEX} require.Error(t, checkSchema(s1)) // reverse on non-uid type - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_REVERSE} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_REVERSE} require.Error(t, checkSchema(s1)) - s1 = &intern.SchemaUpdate{Predicate: "name", ValueType: intern.Posting_FLOAT, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"term"}} + s1 = &pb.SchemaUpdate{Predicate: "name", ValueType: pb.Posting_FLOAT, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"term"}} require.NoError(t, checkSchema(s1)) - s1 = &intern.SchemaUpdate{Predicate: "friend", ValueType: intern.Posting_UID, Directive: intern.SchemaUpdate_REVERSE} + s1 = &pb.SchemaUpdate{Predicate: "friend", ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_REVERSE} require.NoError(t, checkSchema(s1)) s := `jobs: string @upsert .` @@ -188,23 +188,23 @@ func TestCheckSchema(t *testing.T) { } func TestNeedReindexing(t *testing.T) { - s1 := intern.SchemaUpdate{ValueType: intern.Posting_UID} - s2 := intern.SchemaUpdate{ValueType: intern.Posting_UID} + s1 := pb.SchemaUpdate{ValueType: pb.Posting_UID} + s2 := pb.SchemaUpdate{ValueType: pb.Posting_UID} require.False(t, needReindexing(s1, s2)) - s1 = intern.SchemaUpdate{ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} - s2 = intern.SchemaUpdate{ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} + s1 = pb.SchemaUpdate{ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} + s2 = pb.SchemaUpdate{ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} require.False(t, needReindexing(s1, s2)) - s1 = intern.SchemaUpdate{ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"term"}} - s2 = intern.SchemaUpdate{ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_INDEX} + s1 = pb.SchemaUpdate{ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"term"}} + s2 = pb.SchemaUpdate{ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX} require.True(t, needReindexing(s1, s2)) - s1 = intern.SchemaUpdate{ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} - s2 = intern.SchemaUpdate{ValueType: intern.Posting_FLOAT, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} + s1 = pb.SchemaUpdate{ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} + s2 = pb.SchemaUpdate{ValueType: pb.Posting_FLOAT, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} require.True(t, needReindexing(s1, s2)) - s1 = intern.SchemaUpdate{ValueType: intern.Posting_STRING, Directive: intern.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} - s2 = intern.SchemaUpdate{ValueType: intern.Posting_FLOAT, Directive: intern.SchemaUpdate_NONE} + s1 = pb.SchemaUpdate{ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"exact"}} + s2 = pb.SchemaUpdate{ValueType: pb.Posting_FLOAT, Directive: pb.SchemaUpdate_NONE} require.True(t, needReindexing(s1, s2)) } diff --git a/worker/predicate.go b/worker/predicate.go index b5d3f60d6da..fc532aa21a5 100644 --- a/worker/predicate.go +++ b/worker/predicate.go @@ -22,7 +22,7 @@ import ( "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" humanize "github.com/dustin/go-humanize" ) @@ -33,7 +33,7 @@ const ( ) // writeBatch performs a batch write of key value pairs to BadgerDB. -func writeBatch(ctx context.Context, pstore *badger.DB, kvChan chan *intern.KVS, che chan error) { +func writeBatch(ctx context.Context, pstore *badger.DB, kvChan chan *pb.KVS, che chan error) { var bytesWritten uint64 t := time.NewTicker(time.Second) defer t.Stop() @@ -100,7 +100,7 @@ OUTER: // populateShard gets data for a shard from the leader and writes it to BadgerDB on the follower. func (n *node) populateShard(ps *badger.DB, pl *conn.Pool) (int, error) { conn := pl.Get() - c := intern.NewWorkerClient(conn) + c := pb.NewWorkerClient(conn) ctx := n.ctx snap, err := n.Snapshot() @@ -116,7 +116,7 @@ func (n *node) populateShard(ps *badger.DB, pl *conn.Pool) (int, error) { return 0, err } - kvChan := make(chan *intern.KVS, 100) + kvChan := make(chan *pb.KVS, 100) che := make(chan error, 1) go writeBatch(ctx, ps, kvChan, che) @@ -158,8 +158,8 @@ func (n *node) populateShard(ps *badger.DB, pl *conn.Pool) (int, error) { return count, nil } -func (w *grpcWorker) StreamSnapshot(reqSnap *intern.Snapshot, - stream intern.Worker_StreamSnapshotServer) error { +func (w *grpcWorker) StreamSnapshot(reqSnap *pb.Snapshot, + stream pb.Worker_StreamSnapshotServer) error { n := groups().Node if n == nil { return conn.ErrNoNode @@ -204,7 +204,7 @@ func (w *grpcWorker) StreamSnapshot(reqSnap *intern.Snapshot, // Pick all keys. return true } - sl.itemToKv = func(key []byte, itr *badger.Iterator) (*intern.KV, error) { + sl.itemToKv = func(key []byte, itr *badger.Iterator) (*pb.KV, error) { item := itr.Item() pk := x.Parse(key) if pk.IsSchema() { @@ -212,7 +212,7 @@ func (w *grpcWorker) StreamSnapshot(reqSnap *intern.Snapshot, if err != nil { return nil, err } - kv := &intern.KV{ + kv := &pb.KV{ Key: key, Val: val, UserMeta: []byte{item.UserMeta()}, diff --git a/worker/predicate_move.go b/worker/predicate_move.go index ad5a9d9e93d..34867ab2142 100644 --- a/worker/predicate_move.go +++ b/worker/predicate_move.go @@ -20,7 +20,7 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" ) @@ -33,7 +33,7 @@ var ( ) // size of kvs won't be too big, we would take care before proposing. -func populateKeyValues(ctx context.Context, kvs []*intern.KV) error { +func populateKeyValues(ctx context.Context, kvs []*pb.KV) error { // No new deletion/background cleanup would start after we start streaming tablet, // so all the proposals for a particular tablet would atmost wait for deletion of // single tablet. @@ -78,7 +78,7 @@ func movePredicateHelper(ctx context.Context, predicate string, gid uint32) erro if pl == nil { return x.Errorf("Unable to find a connection for group: %d\n", gid) } - c := intern.NewWorkerClient(pl.Get()) + c := pb.NewWorkerClient(pl.Get()) stream, err := c.ReceivePredicate(ctx) if err != nil { return fmt.Errorf("While calling ReceivePredicate: %+v", err) @@ -87,7 +87,7 @@ func movePredicateHelper(ctx context.Context, predicate string, gid uint32) erro // sends all data except schema, schema key has different prefix // Read the predicate keys and stream to keysCh. sl := streamLists{stream: stream, predicate: predicate, db: pstore} - sl.itemToKv = func(key []byte, itr *badger.Iterator) (*intern.KV, error) { + sl.itemToKv = func(key []byte, itr *badger.Iterator) (*pb.KV, error) { l, err := posting.ReadPostingList(key, itr) if err != nil { return nil, err @@ -115,8 +115,8 @@ func movePredicateHelper(ctx context.Context, predicate string, gid uint32) erro if err != nil { return err } - kvs := &intern.KVS{} - kv := &intern.KV{} + kvs := &pb.KVS{} + kv := &pb.KV{} kv.Key = schemaKey kv.Val = val kv.Version = 1 @@ -139,10 +139,10 @@ func movePredicateHelper(ctx context.Context, predicate string, gid uint32) erro return nil } -func batchAndProposeKeyValues(ctx context.Context, kvs chan *intern.KVS) error { +func batchAndProposeKeyValues(ctx context.Context, kvs chan *pb.KVS) error { x.Println("Receiving predicate. Batching and proposing key values") n := groups().Node - proposal := &intern.Proposal{} + proposal := &pb.Proposal{} size := 0 var pk *x.ParsedKey @@ -159,7 +159,7 @@ func batchAndProposeKeyValues(ctx context.Context, kvs chan *intern.KVS) error { if pk == nil { pk = x.Parse(kv.Key) // Delete on all nodes. - p := &intern.Proposal{CleanPredicate: pk.Attr} + p := &pb.Proposal{CleanPredicate: pk.Attr} x.Printf("Predicate being received: %v", pk.Attr) err := groups().Node.proposeAndWait(ctx, p) if err != nil { @@ -182,9 +182,9 @@ func batchAndProposeKeyValues(ctx context.Context, kvs chan *intern.KVS) error { // Returns count which can be used to verify whether we have moved all keys // for a predicate or not. -func (w *grpcWorker) ReceivePredicate(stream intern.Worker_ReceivePredicateServer) error { +func (w *grpcWorker) ReceivePredicate(stream pb.Worker_ReceivePredicateServer) error { // Values can be pretty big so having less buffer is safer. - kvs := make(chan *intern.KVS, 10) + kvs := make(chan *pb.KVS, 10) che := make(chan error, 1) // We can use count to check the number of posting lists returned in tests. count := 0 @@ -230,7 +230,7 @@ func (w *grpcWorker) ReceivePredicate(stream intern.Worker_ReceivePredicateServe } func (w *grpcWorker) MovePredicate(ctx context.Context, - in *intern.MovePredicatePayload) (*api.Payload, error) { + in *pb.MovePredicatePayload) (*api.Payload, error) { if groups().gid != in.SourceGroupId { return &emptyPayload, x.Errorf("Group id doesn't match, received request for %d, my gid: %d", @@ -251,7 +251,7 @@ func (w *grpcWorker) MovePredicate(ctx context.Context, in.SourceGroupId, in.DestGroupId) // Ensures that all future mutations beyond this point are rejected. - if err := n.proposeAndWait(ctx, &intern.Proposal{State: in.State}); err != nil { + if err := n.proposeAndWait(ctx, &pb.Proposal{State: in.State}); err != nil { return &emptyPayload, err } aborted := false diff --git a/worker/predicate_test.go b/worker/predicate_test.go index e1abec01648..d189a3e5f24 100644 --- a/worker/predicate_test.go +++ b/worker/predicate_test.go @@ -20,7 +20,7 @@ import ( "google.golang.org/grpc" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" ) @@ -46,15 +46,15 @@ func checkShard(ps *badger.DB) (int, []byte) { func commitTs(startTs uint64) uint64 { commit := timestamp() - od := &intern.OracleDelta{ + od := &pb.OracleDelta{ MaxAssigned: atomic.LoadUint64(&ts), } - od.Txns = append(od.Txns, &intern.TxnStatus{startTs, commit}) + od.Txns = append(od.Txns, &pb.TxnStatus{startTs, commit}) posting.Oracle().ProcessDelta(od) return commit } -func commitTransaction(t *testing.T, edge *intern.DirectedEdge, l *posting.List) { +func commitTransaction(t *testing.T, edge *pb.DirectedEdge, l *posting.List) { startTs := timestamp() txn := posting.Oracle().RegisterStartTs(startTs) err := l.AddMutationWithIndex(context.Background(), edge, txn) @@ -75,10 +75,10 @@ func writePLs(t *testing.T, pred string, startIdx int, count int, vid uint64) { list, err := posting.Get(k) require.NoError(t, err) - de := &intern.DirectedEdge{ + de := &pb.DirectedEdge{ ValueId: vid, Label: "test", - Op: intern.DirectedEdge_SET, + Op: pb.DirectedEdge_SET, } commitTransaction(t, de, list) } @@ -97,7 +97,7 @@ func deletePLs(t *testing.T, pred string, startIdx int, count int, ps *badger.DB func writeToBadger(t *testing.T, pred string, startIdx int, count int, ps *badger.DB) { for i := 0; i < count; i++ { k := x.DataKey(pred, uint64(i+startIdx)) - pl := new(intern.PostingList) + pl := new(pb.PostingList) data, err := pl.Marshal() if err != nil { t.Errorf("Error while marshing pl") @@ -127,7 +127,7 @@ func newServer(port string) (*grpc.Server, net.Listener, error) { } func serve(s *grpc.Server, ln net.Listener) { - intern.RegisterWorkerServer(s, &grpcWorker{}) + pb.RegisterWorkerServer(s, &grpcWorker{}) s.Serve(ln) } @@ -198,7 +198,7 @@ func TestPopulateShard(t *testing.T) { // t.Error("Unable to find added elements in posting list") // } // var found bool - // l.Iterate(math.MaxUint64, 0, func(p *intern.Posting) bool { + // l.Iterate(math.MaxUint64, 0, func(p *pb.Posting) bool { // if p.Uid != 2 { // t.Errorf("Expected 2. Got: %v", p.Uid) // } diff --git a/worker/schema.go b/worker/schema.go index 54d4219b800..a831186cd13 100644 --- a/worker/schema.go +++ b/worker/schema.go @@ -13,26 +13,26 @@ import ( "github.com/dgraph-io/dgo/protos/api" "github.com/dgraph-io/dgraph/conn" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" ) var ( - emptySchemaResult intern.SchemaResult + emptySchemaResult pb.SchemaResult ) type resultErr struct { - result *intern.SchemaResult + result *pb.SchemaResult err error } // getSchema iterates over all predicates and populates the asked fields, if list of // predicates is not specified, then all the predicates belonging to the group // are returned -func getSchema(ctx context.Context, s *intern.SchemaRequest) (*intern.SchemaResult, error) { - var result intern.SchemaResult +func getSchema(ctx context.Context, s *pb.SchemaRequest) (*pb.SchemaResult, error) { + var result pb.SchemaResult var predicates []string var fields []string if len(s.Predicates) > 0 { @@ -99,12 +99,12 @@ func populateSchema(attr string, fields []string) *api.SchemaNode { // addToSchemaMap groups the predicates by group id, if list of predicates is // empty then it adds all known groups -func addToSchemaMap(schemaMap map[uint32]*intern.SchemaRequest, schema *intern.SchemaRequest) { +func addToSchemaMap(schemaMap map[uint32]*pb.SchemaRequest, schema *pb.SchemaRequest) { for _, attr := range schema.Predicates { gid := groups().BelongsTo(attr) s := schemaMap[gid] if s == nil { - s = &intern.SchemaRequest{GroupId: gid} + s = &pb.SchemaRequest{GroupId: gid} s.Fields = schema.Fields schemaMap[gid] = s } @@ -122,7 +122,7 @@ func addToSchemaMap(schemaMap map[uint32]*intern.SchemaRequest, schema *intern.S } s := schemaMap[gid] if s == nil { - s = &intern.SchemaRequest{GroupId: gid} + s = &pb.SchemaRequest{GroupId: gid} s.Fields = schema.Fields schemaMap[gid] = s } @@ -132,7 +132,7 @@ func addToSchemaMap(schemaMap map[uint32]*intern.SchemaRequest, schema *intern.S // If the current node serves the group serve the schema or forward // to relevant node // TODO: Janardhan - if read fails try other servers serving same group -func getSchemaOverNetwork(ctx context.Context, gid uint32, s *intern.SchemaRequest, ch chan resultErr) { +func getSchemaOverNetwork(ctx context.Context, gid uint32, s *pb.SchemaRequest, ch chan resultErr) { if groups().ServesGroup(gid) { schema, e := getSchema(ctx, s) ch <- resultErr{result: schema, err: e} @@ -145,14 +145,14 @@ func getSchemaOverNetwork(ctx context.Context, gid uint32, s *intern.SchemaReque return } conn := pl.Get() - c := intern.NewWorkerClient(conn) + c := pb.NewWorkerClient(conn) schema, e := c.Schema(ctx, s) ch <- resultErr{result: schema, err: e} } // GetSchemaOverNetwork checks which group should be serving the schema // according to fingerprint of the predicate and sends it to that instance. -func GetSchemaOverNetwork(ctx context.Context, schema *intern.SchemaRequest) ([]*api.SchemaNode, error) { +func GetSchemaOverNetwork(ctx context.Context, schema *pb.SchemaRequest) ([]*api.SchemaNode, error) { if err := x.HealthCheck(); err != nil { if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("Request rejected %v", err) @@ -161,7 +161,7 @@ func GetSchemaOverNetwork(ctx context.Context, schema *intern.SchemaRequest) ([] } // Map of groupd id => Predicates for that group. - schemaMap := make(map[uint32]*intern.SchemaRequest) + schemaMap := make(map[uint32]*pb.SchemaRequest) addToSchemaMap(schemaMap, schema) results := make(chan resultErr, len(schemaMap)) @@ -193,7 +193,7 @@ func GetSchemaOverNetwork(ctx context.Context, schema *intern.SchemaRequest) ([] } // Schema is used to get schema information over the network on other instances. -func (w *grpcWorker) Schema(ctx context.Context, s *intern.SchemaRequest) (*intern.SchemaResult, error) { +func (w *grpcWorker) Schema(ctx context.Context, s *pb.SchemaRequest) (*pb.SchemaResult, error) { if ctx.Err() != nil { return &emptySchemaResult, ctx.Err() } diff --git a/worker/sort.go b/worker/sort.go index 4db451ea1d9..889bfc0ea24 100644 --- a/worker/sort.go +++ b/worker/sort.go @@ -19,23 +19,23 @@ import ( "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" ) -var emptySortResult intern.SortResult +var emptySortResult pb.SortResult type sortresult struct { - reply *intern.SortResult + reply *pb.SortResult vals [][]types.Val err error } // SortOverNetwork sends sort query over the network. -func SortOverNetwork(ctx context.Context, q *intern.SortMessage) (*intern.SortResult, error) { +func SortOverNetwork(ctx context.Context, q *pb.SortMessage) (*pb.SortResult, error) { gid := groups().BelongsTo(q.Order[0].Attr) if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("worker.Sort attr: %v groupId: %v", q.Order[0].Attr, gid) @@ -46,7 +46,7 @@ func SortOverNetwork(ctx context.Context, q *intern.SortMessage) (*intern.SortRe return processSort(ctx, q) } - result, err := processWithBackupRequest(ctx, gid, func(ctx context.Context, c intern.WorkerClient) (interface{}, error) { + result, err := processWithBackupRequest(ctx, gid, func(ctx context.Context, c pb.WorkerClient) (interface{}, error) { return c.Sort(ctx, q) }) if err != nil { @@ -55,11 +55,11 @@ func SortOverNetwork(ctx context.Context, q *intern.SortMessage) (*intern.SortRe } return nil, err } - return result.(*intern.SortResult), nil + return result.(*pb.SortResult), nil } // Sort is used to sort given UID matrix. -func (w *grpcWorker) Sort(ctx context.Context, s *intern.SortMessage) (*intern.SortResult, error) { +func (w *grpcWorker) Sort(ctx context.Context, s *pb.SortMessage) (*pb.SortResult, error) { if ctx.Err() != nil { return &emptySortResult, ctx.Err() } @@ -69,7 +69,7 @@ func (w *grpcWorker) Sort(ctx context.Context, s *intern.SortMessage) (*intern.S tr.LazyPrintf("Sorting: Attribute: %q groupId: %v Sort", s.Order[0].Attr, gid) } - var reply *intern.SortResult + var reply *pb.SortResult x.AssertTruef(groups().ServesGroup(gid), "attr: %q groupId: %v Request sent to wrong server.", s.Order[0].Attr, gid) @@ -93,9 +93,9 @@ var ( errDone = x.Errorf("Done processing buckets") ) -func sortWithoutIndex(ctx context.Context, ts *intern.SortMessage) *sortresult { +func sortWithoutIndex(ctx context.Context, ts *pb.SortMessage) *sortresult { n := len(ts.UidMatrix) - r := new(intern.SortResult) + r := new(pb.SortResult) multiSortVals := make([][]types.Val, n) // Sort and paginate directly as it'd be expensive to iterate over the index which // might have millions of keys just for retrieving some values. @@ -111,7 +111,7 @@ func sortWithoutIndex(ctx context.Context, ts *intern.SortMessage) *sortresult { return &sortresult{&emptySortResult, nil, ctx.Err()} default: // Copy, otherwise it'd affect the destUids and hence the srcUids of Next level. - tempList := &intern.List{ts.UidMatrix[i].Uids} + tempList := &pb.List{ts.UidMatrix[i].Uids} var vals []types.Val if vals, err = sortByValue(ctx, ts, tempList, sType); err != nil { return &sortresult{&emptySortResult, nil, err} @@ -129,7 +129,7 @@ func sortWithoutIndex(ctx context.Context, ts *intern.SortMessage) *sortresult { return &sortresult{r, multiSortVals, nil} } -func sortWithIndex(ctx context.Context, ts *intern.SortMessage) *sortresult { +func sortWithIndex(ctx context.Context, ts *pb.SortMessage) *sortresult { n := len(ts.UidMatrix) out := make([]intersectedList, n) values := make([][]types.Val, 0, n) // Values corresponding to uids in the uid matrix. @@ -137,13 +137,13 @@ func sortWithIndex(ctx context.Context, ts *intern.SortMessage) *sortresult { // offsets[i] is the offset for i-th posting list. It gets decremented as we // iterate over buckets. out[i].offset = int(ts.Offset) - var emptyList intern.List + var emptyList pb.List out[i].ulist = &emptyList out[i].uset = map[uint64]struct{}{} } order := ts.Order[0] - r := new(intern.SortResult) + r := new(pb.SortResult) // Iterate over every bucket / token. iterOpt := badger.DefaultIteratorOptions iterOpt.PrefetchValues = false @@ -248,11 +248,11 @@ BUCKETS: type orderResult struct { idx int - r *intern.Result + r *pb.Result err error } -func multiSort(ctx context.Context, r *sortresult, ts *intern.SortMessage) error { +func multiSort(ctx context.Context, r *sortresult, ts *pb.SortMessage) error { // SrcUids for other queries are all the uids present in the response of the first sort. dest := destUids(r.reply.UidMatrix) @@ -284,7 +284,7 @@ func multiSort(ctx context.Context, r *sortresult, ts *intern.SortMessage) error // Execute rest of the sorts concurrently. och := make(chan orderResult, len(ts.Order)-1) for i := 1; i < len(ts.Order); i++ { - in := &intern.Query{ + in := &pb.Query{ Attr: ts.Order[i].Attr, UidList: dest, Langs: ts.Order[i].Langs, @@ -362,7 +362,7 @@ func multiSort(ctx context.Context, r *sortresult, ts *intern.SortMessage) error // bucket if we haven't hit the offset. We stop getting results when we got // enough for our pagination params. When all the UID lists are done, we stop // iterating over the index. -func processSort(ctx context.Context, ts *intern.SortMessage) (*intern.SortResult, error) { +func processSort(ctx context.Context, ts *pb.SortMessage) (*pb.SortResult, error) { if err := posting.Oracle().WaitForTs(ctx, ts.ReadTs); err != nil { return &emptySortResult, err } @@ -417,7 +417,7 @@ func processSort(ctx context.Context, ts *intern.SortMessage) (*intern.SortResul return r.reply, err } -func destUids(uidMatrix []*intern.List) *intern.List { +func destUids(uidMatrix []*pb.List) *pb.List { included := make(map[uint64]struct{}) for _, ul := range uidMatrix { for _, uid := range ul.Uids { @@ -425,7 +425,7 @@ func destUids(uidMatrix []*intern.List) *intern.List { } } - res := &intern.List{Uids: make([]uint64, 0, len(included))} + res := &pb.List{Uids: make([]uint64, 0, len(included))} for uid := range included { res.Uids = append(res.Uids, uid) } @@ -433,7 +433,7 @@ func destUids(uidMatrix []*intern.List) *intern.List { return res } -func fetchValues(ctx context.Context, in *intern.Query, idx int, or chan orderResult) { +func fetchValues(ctx context.Context, in *pb.Query, idx int, or chan orderResult) { var err error in.Reverse = strings.HasPrefix(in.Attr, "~") if in.Reverse { @@ -449,14 +449,14 @@ func fetchValues(ctx context.Context, in *intern.Query, idx int, or chan orderRe type intersectedList struct { offset int - ulist *intern.List + ulist *pb.List values []types.Val uset map[uint64]struct{} } // intersectBucket intersects every UID list in the UID matrix with the // indexed bucket. -func intersectBucket(ctx context.Context, ts *intern.SortMessage, token string, +func intersectBucket(ctx context.Context, ts *pb.SortMessage, token string, out []intersectedList) error { count := int(ts.Count) order := ts.Order[0] @@ -571,7 +571,7 @@ func removeDuplicates(uids []uint64, set map[uint64]struct{}) []uint64 { return uids } -func paginate(ts *intern.SortMessage, dest *intern.List, vals []types.Val) (int, int, error) { +func paginate(ts *pb.SortMessage, dest *pb.List, vals []types.Val) (int, int, error) { count := int(ts.Count) offset := int(ts.Offset) start, end := x.PageRange(count, offset, len(dest.Uids)) @@ -592,7 +592,7 @@ func paginate(ts *intern.SortMessage, dest *intern.List, vals []types.Val) (int, } // sortByValue fetches values and sort UIDList. -func sortByValue(ctx context.Context, ts *intern.SortMessage, ul *intern.List, +func sortByValue(ctx context.Context, ts *pb.SortMessage, ul *pb.List, typ types.TypeID) ([]types.Val, error) { lenList := len(ul.Uids) uids := make([]uint64, 0, lenList) @@ -616,7 +616,7 @@ func sortByValue(ctx context.Context, ts *intern.SortMessage, ul *intern.List, values = append(values, []types.Val{val}) } } - err := types.Sort(values, &intern.List{uids}, []bool{order.Desc}) + err := types.Sort(values, &pb.List{uids}, []bool{order.Desc}) ul.Uids = uids if len(ts.Order) > 1 { for _, v := range values { diff --git a/worker/stream_lists.go b/worker/stream_lists.go index f1b84afce87..40bd28e71f0 100644 --- a/worker/stream_lists.go +++ b/worker/stream_lists.go @@ -13,14 +13,14 @@ import ( "time" "github.com/dgraph-io/badger" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" humanize "github.com/dustin/go-humanize" "golang.org/x/net/context" ) type kvStream interface { - Send(*intern.KVS) error + Send(*pb.KVS) error } type streamLists struct { @@ -28,7 +28,7 @@ type streamLists struct { predicate string db *badger.DB chooseKey func(key []byte, version uint64) bool - itemToKv func(key []byte, itr *badger.Iterator) (*intern.KV, error) + itemToKv func(key []byte, itr *badger.Iterator) (*pb.KV, error) } // keyRange is [start, end), including start, excluding end. Do ensure that the start, @@ -39,9 +39,9 @@ type keyRange struct { } func (sl *streamLists) orchestrate(ctx context.Context, prefix string, ts uint64) error { - keyCh := make(chan keyRange, 100) // Contains keys for posting lists. - kvChan := make(chan *intern.KVS, 100) // Contains marshaled posting lists. - errCh := make(chan error, 1) // Stores error by consumeKeys. + keyCh := make(chan keyRange, 100) // Contains keys for posting lists. + kvChan := make(chan *pb.KVS, 100) // Contains marshaled posting lists. + errCh := make(chan error, 1) // Stores error by consumeKeys. // Read the predicate keys and stream to keysCh. go sl.produceRanges(ctx, ts, keyCh) @@ -117,7 +117,7 @@ func (sl *streamLists) produceRanges(ctx context.Context, ts uint64, keyCh chan } func (sl *streamLists) produceKVs(ctx context.Context, ts uint64, - keyCh chan keyRange, kvChan chan *intern.KVS) error { + keyCh chan keyRange, kvChan chan *pb.KVS) error { var prefix []byte if len(sl.predicate) > 0 { prefix = x.PredicatePrefix(sl.predicate) @@ -132,7 +132,7 @@ func (sl *streamLists) produceKVs(ctx context.Context, ts uint64, it := txn.NewIterator(iterOpts) defer it.Close() - kvs := new(intern.KVS) + kvs := new(pb.KVS) var prevKey []byte for it.Seek(kr.start); it.ValidForPrefix(prefix); { item := it.Item() @@ -181,14 +181,14 @@ func (sl *streamLists) produceKVs(ctx context.Context, ts uint64, } func (sl *streamLists) streamKVs(ctx context.Context, prefix string, - kvChan chan *intern.KVS) error { + kvChan chan *pb.KVS) error { var count int var bytesSent uint64 t := time.NewTicker(time.Second) defer t.Stop() now := time.Now() - slurp := func(batch *intern.KVS) error { + slurp := func(batch *pb.KVS) error { loop: for { select { @@ -215,7 +215,7 @@ func (sl *streamLists) streamKVs(ctx context.Context, prefix string, outer: for { - var batch *intern.KVS + var batch *pb.KVS select { case <-ctx.Done(): return ctx.Err() diff --git a/worker/stream_lists_test.go b/worker/stream_lists_test.go index ed2431821c8..8dd37fe14b2 100644 --- a/worker/stream_lists_test.go +++ b/worker/stream_lists_test.go @@ -16,7 +16,7 @@ import ( "testing" "github.com/dgraph-io/badger" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" ) @@ -34,10 +34,10 @@ func value(k int) []byte { } type collector struct { - kv []*intern.KV + kv []*pb.KV } -func (c *collector) Send(kvs *intern.KVS) error { +func (c *collector) Send(kvs *pb.KVS) error { c.kv = append(c.kv, kvs.Kv...) return nil } @@ -61,13 +61,13 @@ func TestOrchestrate(t *testing.T) { require.NoError(t, txn.CommitAt(5, nil)) } - c := &collector{kv: make([]*intern.KV, 0, 100)} + c := &collector{kv: make([]*pb.KV, 0, 100)} sl := streamLists{stream: c, db: db} - sl.itemToKv = func(key []byte, itr *badger.Iterator) (*intern.KV, error) { + sl.itemToKv = func(key []byte, itr *badger.Iterator) (*pb.KV, error) { item := itr.Item() val, err := item.ValueCopy(nil) require.NoError(t, err) - kv := &intern.KV{Key: item.KeyCopy(nil), Val: val, Version: item.Version()} + kv := &pb.KV{Key: item.KeyCopy(nil), Val: val, Version: item.Version()} itr.Next() // Just for fun. return kv, nil } diff --git a/worker/stringfilter.go b/worker/stringfilter.go index 2234aed3c5b..fab8ba1365e 100644 --- a/worker/stringfilter.go +++ b/worker/stringfilter.go @@ -10,7 +10,7 @@ package worker import ( "strings" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" @@ -28,8 +28,8 @@ type stringFilter struct { eqVals []types.Val } -func matchStrings(uids *intern.List, values [][]types.Val, filter stringFilter) *intern.List { - rv := &intern.List{} +func matchStrings(uids *pb.List, values [][]types.Val, filter stringFilter) *pb.List { + rv := &pb.List{} for i := 0; i < len(values); i++ { for j := 0; j < len(values[i]); j++ { if filter.match(values[i][j], filter) { diff --git a/worker/task.go b/worker/task.go index dcb442188cf..1cef5eb307a 100644 --- a/worker/task.go +++ b/worker/task.go @@ -28,7 +28,7 @@ import ( "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" ctask "github.com/dgraph-io/dgraph/task" "github.com/dgraph-io/dgraph/tok" @@ -41,13 +41,13 @@ import ( ) var ( - emptyUIDList intern.List - emptyResult intern.Result - emptyValueList = intern.ValueList{Values: []*intern.TaskValue{}} + emptyUIDList pb.List + emptyResult pb.Result + emptyValueList = pb.ValueList{Values: []*pb.TaskValue{}} ) func invokeNetworkRequest( - ctx context.Context, addr string, f func(context.Context, intern.WorkerClient) (interface{}, error)) (interface{}, error) { + ctx context.Context, addr string, f func(context.Context, pb.WorkerClient) (interface{}, error)) (interface{}, error) { pl, err := conn.Get().Get(addr) if err != nil { return &emptyResult, x.Wrapf(err, "dispatchTaskOverNetwork: while retrieving connection.") @@ -57,7 +57,7 @@ func invokeNetworkRequest( if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("Sending request to %v", addr) } - c := intern.NewWorkerClient(conn) + c := pb.NewWorkerClient(conn) return f(ctx, c) } @@ -67,7 +67,7 @@ const backupRequestGracePeriod = time.Second func processWithBackupRequest( ctx context.Context, gid uint32, - f func(context.Context, intern.WorkerClient) (interface{}, error)) (interface{}, error) { + f func(context.Context, pb.WorkerClient) (interface{}, error)) (interface{}, error) { addrs := groups().AnyTwoServers(gid) if len(addrs) == 0 { return nil, errors.New("no network connection") @@ -126,11 +126,11 @@ func processWithBackupRequest( // ProcessTaskOverNetwork is used to process the query and get the result from // the instance which stores posting list corresponding to the predicate in the // query. -func ProcessTaskOverNetwork(ctx context.Context, q *intern.Query) (*intern.Result, error) { +func ProcessTaskOverNetwork(ctx context.Context, q *pb.Query) (*pb.Result, error) { attr := q.Attr gid := groups().BelongsTo(attr) if gid == 0 { - return &intern.Result{}, errUnservedTablet + return &pb.Result{}, errUnservedTablet } if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("attr: %v groupId: %v, readTs: %d", attr, gid, q.ReadTs) @@ -141,7 +141,7 @@ func ProcessTaskOverNetwork(ctx context.Context, q *intern.Query) (*intern.Resul return processTask(ctx, q, gid) } - result, err := processWithBackupRequest(ctx, gid, func(ctx context.Context, c intern.WorkerClient) (interface{}, error) { + result, err := processWithBackupRequest(ctx, gid, func(ctx context.Context, c pb.WorkerClient) (interface{}, error) { if tr, ok := trace.FromContext(ctx); ok { id := fmt.Sprintf("%d", rand.Int()) tr.LazyPrintf("Sending request to server, id: %s", id) @@ -155,7 +155,7 @@ func ProcessTaskOverNetwork(ctx context.Context, q *intern.Query) (*intern.Resul } return nil, err } - reply := result.(*intern.Result) + reply := result.(*pb.Result) if tr, ok := trace.FromContext(ctx); ok { tr.LazyPrintf("Reply from server. length: %v Group: %v Attr: %v", len(reply.UidMatrix), gid, attr) } @@ -178,8 +178,8 @@ func convertValue(attr, data string) (types.Val, error) { } // Returns nil byte on error -func convertToType(v types.Val, typ types.TypeID) (*intern.TaskValue, error) { - result := &intern.TaskValue{ValType: typ.Enum(), Val: x.Nilbyte} +func convertToType(v types.Val, typ types.TypeID) (*pb.TaskValue, error) { + result := &pb.TaskValue{ValType: typ.Enum(), Val: x.Nilbyte} if v.Tid == typ { result.Val = v.Value.([]byte) return result, nil @@ -217,7 +217,7 @@ const ( StandardFn = 100 ) -func parseFuncType(srcFunc *intern.SrcFunction) (FuncType, string) { +func parseFuncType(srcFunc *pb.SrcFunction) (FuncType, string) { if srcFunc == nil { return NotAFunction, "" } @@ -277,10 +277,10 @@ type result struct { } type funcArgs struct { - q *intern.Query + q *pb.Query gid uint32 srcFn *functionContext - out *intern.Result + out *pb.Result } // The function tells us whether we want to fetch value posting lists or uid posting lists. @@ -365,10 +365,10 @@ func handleValuePostings(ctx context.Context, args funcArgs) error { out.Counts = append(out.Counts, 0) } else { out.ValueMatrix = append(out.ValueMatrix, &emptyValueList) - out.FacetMatrix = append(out.FacetMatrix, &intern.FacetsList{}) + out.FacetMatrix = append(out.FacetMatrix, &pb.FacetsList{}) if q.ExpandAll { // To keep the cardinality same as that of ValueMatrix. - out.LangMatrix = append(out.LangMatrix, &intern.LangList{}) + out.LangMatrix = append(out.LangMatrix, &pb.LangList{}) } } continue @@ -381,13 +381,13 @@ func handleValuePostings(ctx context.Context, args funcArgs) error { if err != nil { return err } - out.LangMatrix = append(out.LangMatrix, &intern.LangList{langTags}) + out.LangMatrix = append(out.LangMatrix, &pb.LangList{langTags}) } valTid := vals[0].Tid - newValue := &intern.TaskValue{ValType: valTid.Enum(), Val: x.Nilbyte} - uidList := new(intern.List) - var vl intern.ValueList + newValue := &pb.TaskValue{ValType: valTid.Enum(), Val: x.Nilbyte} + uidList := new(pb.List) + var vl pb.ValueList for _, val := range vals { newValue, err = convertToType(val, srcFn.atype) if err != nil { @@ -423,7 +423,7 @@ func handleValuePostings(ctx context.Context, args funcArgs) error { fs = []*api.Facet{} } out.FacetMatrix = append(out.FacetMatrix, - &intern.FacetsList{[]*intern.Facets{{fs}}}) + &pb.FacetsList{[]*pb.Facets{{fs}}}) } switch { @@ -509,7 +509,7 @@ func handleUidPostings(ctx context.Context, args funcArgs, opts posting.ListOpti var perr error filteredRes = make([]*result, 0) - err = pl.Postings(opts, func(p *intern.Posting) bool { + err = pl.Postings(opts, func(p *pb.Posting) bool { res := true res, perr = applyFacetsTree(p.Facets, facetsTree) if perr != nil { @@ -530,11 +530,11 @@ func handleUidPostings(ctx context.Context, args funcArgs, opts posting.ListOpti // add facets to result. if q.FacetParam != nil { - var fcsList []*intern.Facets + var fcsList []*pb.Facets for _, fres := range filteredRes { - fcsList = append(fcsList, &intern.Facets{fres.facets}) + fcsList = append(fcsList, &pb.Facets{fres.facets}) } - out.FacetMatrix = append(out.FacetMatrix, &intern.FacetsList{fcsList}) + out.FacetMatrix = append(out.FacetMatrix, &pb.FacetsList{fcsList}) } switch { @@ -553,7 +553,7 @@ func handleUidPostings(ctx context.Context, args funcArgs, opts posting.ListOpti } count := int64(len) if EvalCompare(srcFn.fname, count, srcFn.threshold) { - tlist := &intern.List{[]uint64{q.UidList.Uids[i]}} + tlist := &pb.List{[]uint64{q.UidList.Uids[i]}} out.UidMatrix = append(out.UidMatrix, tlist) } case srcFn.fnType == HasFn: @@ -563,11 +563,11 @@ func handleUidPostings(ctx context.Context, args funcArgs, opts posting.ListOpti } count := int64(len) if EvalCompare("gt", count, 0) { - tlist := &intern.List{[]uint64{q.UidList.Uids[i]}} + tlist := &pb.List{[]uint64{q.UidList.Uids[i]}} out.UidMatrix = append(out.UidMatrix, tlist) } case srcFn.fnType == UidInFn: - reqList := &intern.List{[]uint64{srcFn.uidPresent}} + reqList := &pb.List{[]uint64{srcFn.uidPresent}} topts := posting.ListOptions{ ReadTs: args.q.ReadTs, AfterUID: 0, @@ -578,12 +578,12 @@ func handleUidPostings(ctx context.Context, args funcArgs, opts posting.ListOpti return err } if len(plist.Uids) > 0 { - tlist := &intern.List{[]uint64{q.UidList.Uids[i]}} + tlist := &pb.List{[]uint64{q.UidList.Uids[i]}} out.UidMatrix = append(out.UidMatrix, tlist) } default: // The more usual case: Getting the UIDs. - uidList := new(intern.List) + uidList := new(pb.List) for _, fres := range filteredRes { uidList.Uids = append(uidList.Uids, fres.uid) } @@ -594,7 +594,7 @@ func handleUidPostings(ctx context.Context, args funcArgs, opts posting.ListOpti } // processTask processes the query, accumulates and returns the result. -func processTask(ctx context.Context, q *intern.Query, gid uint32) (*intern.Result, error) { +func processTask(ctx context.Context, q *pb.Query, gid uint32) (*pb.Result, error) { if err := posting.Oracle().WaitForTs(ctx, q.ReadTs); err != nil { return &emptyResult, err } @@ -617,8 +617,8 @@ func processTask(ctx context.Context, q *intern.Query, gid uint32) (*intern.Resu return out, nil } -func helpProcessTask(ctx context.Context, q *intern.Query, gid uint32) (*intern.Result, error) { - out := new(intern.Result) +func helpProcessTask(ctx context.Context, q *pb.Query, gid uint32) (*pb.Result, error) { + out := new(pb.Result) attr := q.Attr srcFn, err := parseSrcFn(q) @@ -771,14 +771,14 @@ func handleRegexFunction(ctx context.Context, arg funcArgs) error { } query := cindex.RegexpQuery(arg.srcFn.regex.Syntax) - empty := intern.List{} + empty := pb.List{} uids, err := uidsForRegex(attr, arg, query, &empty) isList := schema.State().IsList(attr) lang := langForFunc(arg.q.Langs) if uids != nil { arg.out.UidMatrix = append(arg.out.UidMatrix, uids) - filtered := &intern.List{} + filtered := &pb.List{} for _, uid := range uids.Uids { select { case <-ctx.Done(): @@ -956,7 +956,7 @@ func filterGeoFunction(arg funcArgs) error { attr := arg.q.Attr uids := algo.MergeSorted(arg.out.UidMatrix) isList := schema.State().IsList(attr) - filtered := &intern.List{} + filtered := &pb.List{} for _, uid := range uids.Uids { pl, err := posting.Get(x.DataKey(attr, uid)) if err != nil { @@ -969,7 +969,7 @@ func filterGeoFunction(arg funcArgs) error { } else if err != nil { return err } - newValue := &intern.TaskValue{ValType: val.Tid.Enum(), Val: val.Value.([]byte)} + newValue := &pb.TaskValue{ValType: val.Tid.Enum(), Val: val.Value.([]byte)} if types.MatchGeo(newValue, arg.srcFn.geoQuery) { filtered.Uids = append(filtered.Uids, uid) } @@ -985,7 +985,7 @@ func filterGeoFunction(arg funcArgs) error { return err } for _, val := range vals { - newValue := &intern.TaskValue{ValType: val.Tid.Enum(), Val: val.Value.([]byte)} + newValue := &pb.TaskValue{ValType: val.Tid.Enum(), Val: val.Value.([]byte)} if types.MatchGeo(newValue, arg.srcFn.geoQuery) { filtered.Uids = append(filtered.Uids, uid) break @@ -1046,7 +1046,7 @@ func filterStringFunction(arg funcArgs) error { } } - filtered := &intern.List{Uids: filteredUids} + filtered := &pb.List{Uids: filteredUids} filter := stringFilter{ funcName: arg.srcFn.fname, funcType: arg.srcFn.fnType, @@ -1100,7 +1100,7 @@ const ( eq = "eq" // equal ) -func ensureArgsCount(srcFunc *intern.SrcFunction, expected int) error { +func ensureArgsCount(srcFunc *pb.SrcFunction, expected int) error { if len(srcFunc.Args) != expected { return x.Errorf("Function '%s' requires %d arguments, but got %d (%v)", srcFunc.Name, expected, len(srcFunc.Args), srcFunc.Args) @@ -1108,7 +1108,7 @@ func ensureArgsCount(srcFunc *intern.SrcFunction, expected int) error { return nil } -func checkRoot(q *intern.Query, fc *functionContext) { +func checkRoot(q *pb.Query, fc *functionContext) { if q.UidList == nil { // Fetch Uids from Store and populate in q.UidList. fc.n = 0 @@ -1127,7 +1127,7 @@ func langForFunc(langs []string) string { return langs[0] } -func parseSrcFn(q *intern.Query) (*functionContext, error) { +func parseSrcFn(q *pb.Query) (*functionContext, error) { fnType, f := parseFuncType(q.SrcFunc) attr := q.Attr fc := &functionContext{fnType: fnType, fname: f} @@ -1300,7 +1300,7 @@ func parseSrcFn(q *intern.Query) (*functionContext, error) { } // ServeTask is used to respond to a query. -func (w *grpcWorker) ServeTask(ctx context.Context, q *intern.Query) (*intern.Result, error) { +func (w *grpcWorker) ServeTask(ctx context.Context, q *pb.Query) (*pb.Result, error) { if ctx.Err() != nil { return &emptyResult, ctx.Err() } @@ -1321,7 +1321,7 @@ func (w *grpcWorker) ServeTask(ctx context.Context, q *intern.Query) (*intern.Re } type reply struct { - result *intern.Result + result *pb.Result err error } c := make(chan reply, 1) @@ -1465,7 +1465,7 @@ type facetsTree struct { function *facetsFunc } -func preprocessFilter(tree *intern.FilterTree) (*facetsTree, error) { +func preprocessFilter(tree *pb.FilterTree) (*facetsTree, error) { if tree == nil { return nil, nil } @@ -1537,7 +1537,7 @@ type countParams struct { fn string // function name } -func (cp *countParams) evaluate(out *intern.Result) error { +func (cp *countParams) evaluate(out *pb.Result) error { count := cp.count var illegal bool switch cp.fn { @@ -1615,7 +1615,7 @@ func (cp *countParams) evaluate(out *intern.Result) error { // posting/lists.go, and Badger. Thus, it can capture both committed // transactions and in-progress transactions. It also accounts for transaction // start ts. -func handleHasFunction(ctx context.Context, q *intern.Query, out *intern.Result) error { +func handleHasFunction(ctx context.Context, q *pb.Query, out *pb.Result) error { txn := pstore.NewTransactionAt(q.ReadTs, false) defer txn.Discard() @@ -1641,7 +1641,7 @@ func handleHasFunction(ctx context.Context, q *intern.Query, out *intern.Result) } pk := x.Parse(key) var num int - if err := pl.Iterate(q.ReadTs, 0, func(_ *intern.Posting) bool { + if err := pl.Iterate(q.ReadTs, 0, func(_ *pb.Posting) bool { num++ return false }); err != nil { @@ -1652,7 +1652,7 @@ func handleHasFunction(ctx context.Context, q *intern.Query, out *intern.Result) } } - result := &intern.List{} + result := &pb.List{} var prevKey []byte var cidx, w int itOpt := badger.DefaultIteratorOptions @@ -1692,7 +1692,7 @@ func handleHasFunction(ctx context.Context, q *intern.Query, out *intern.Result) return err } var num int - if err = l.Iterate(q.ReadTs, 0, func(_ *intern.Posting) bool { + if err = l.Iterate(q.ReadTs, 0, func(_ *pb.Posting) bool { num++ return false }); err != nil { diff --git a/worker/trigram.go b/worker/trigram.go index 113d4b04205..960ab026ea1 100644 --- a/worker/trigram.go +++ b/worker/trigram.go @@ -14,7 +14,7 @@ import ( "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/x" ) @@ -22,8 +22,8 @@ import ( var regexTooWideErr = errors.New("Regular expression is too wide-ranging and can't be executed efficiently.") func uidsForRegex(attr string, arg funcArgs, - query *cindex.Query, intersect *intern.List) (*intern.List, error) { - var results *intern.List + query *cindex.Query, intersect *pb.List) (*pb.List, error) { + var results *pb.List opts := posting.ListOptions{ ReadTs: arg.q.ReadTs, } @@ -31,7 +31,7 @@ func uidsForRegex(attr string, arg funcArgs, opts.Intersect = intersect } - uidsForTrigram := func(trigram string) (*intern.List, error) { + uidsForTrigram := func(trigram string) (*pb.List, error) { key := x.IndexKey(attr, trigram) pl, err := posting.Get(key) if err != nil { @@ -74,7 +74,7 @@ func uidsForRegex(attr string, arg funcArgs, } case cindex.QOr: tok.EncodeRegexTokens(query.Trigram) - uidMatrix := make([]*intern.List, len(query.Trigram)) + uidMatrix := make([]*pb.List, len(query.Trigram)) var err error for i, t := range query.Trigram { uidMatrix[i], err = uidsForTrigram(t) @@ -91,7 +91,7 @@ func uidsForRegex(attr string, arg funcArgs, if err != nil { return nil, err } - results = algo.MergeSorted([]*intern.List{results, subUids}) + results = algo.MergeSorted([]*pb.List{results, subUids}) } default: return nil, regexTooWideErr diff --git a/worker/worker.go b/worker/worker.go index 52073def1ea..19e306f1dfe 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -5,7 +5,7 @@ * with the Commons Clause restriction. */ -// Package worker contains code for intern.worker communication to perform +// Package worker contains code for pb.worker communication to perform // queries and mutations. package worker @@ -19,7 +19,7 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" "google.golang.org/grpc" @@ -71,7 +71,7 @@ func (w *grpcWorker) addIfNotPresent(reqid uint64) bool { } // RunServer initializes a tcp server on port which listens to requests from -// other workers for intern.communication. +// other workers for pb.communication. func RunServer(bindall bool) { laddr := "localhost" if bindall { @@ -84,8 +84,8 @@ func RunServer(bindall bool) { } x.Printf("Worker listening at address: %v", ln.Addr()) - intern.RegisterWorkerServer(workerServer, &grpcWorker{}) - intern.RegisterRaftServer(workerServer, &raftServer) + pb.RegisterWorkerServer(workerServer, &grpcWorker{}) + pb.RegisterRaftServer(workerServer, &raftServer) workerServer.Serve(ln) } diff --git a/worker/worker_test.go b/worker/worker_test.go index 730bec7a987..f84f3084f61 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -19,7 +19,7 @@ import ( "github.com/dgraph-io/dgraph/algo" "github.com/dgraph-io/dgraph/posting" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" ) @@ -31,13 +31,13 @@ func timestamp() uint64 { return atomic.AddUint64(&ts, 1) } -func addEdge(t *testing.T, edge *intern.DirectedEdge, l *posting.List) { - edge.Op = intern.DirectedEdge_SET +func addEdge(t *testing.T, edge *pb.DirectedEdge, l *posting.List) { + edge.Op = pb.DirectedEdge_SET commitTransaction(t, edge, l) } -func delEdge(t *testing.T, edge *intern.DirectedEdge, l *posting.List) { - edge.Op = intern.DirectedEdge_DEL +func delEdge(t *testing.T, edge *pb.DirectedEdge, l *posting.List) { + edge.Op = pb.DirectedEdge_DEL commitTransaction(t, edge, l) } @@ -49,7 +49,7 @@ func getOrCreate(key []byte) *posting.List { func populateGraph(t *testing.T) { // Add uid edges : predicate neightbour. - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ ValueId: 23, Label: "author0", Attr: "neighbour", @@ -87,7 +87,7 @@ func populateGraph(t *testing.T) { addEdge(t, edge, getOrCreate(x.DataKey("friend", 10))) } -func taskValues(t *testing.T, v []*intern.TaskValue) []string { +func taskValues(t *testing.T, v []*pb.TaskValue) []string { out := make([]string, len(v)) for i, tv := range v { out[i] = string(tv.Val) @@ -116,17 +116,17 @@ func TestProcessTask(t *testing.T) { } // newQuery creates a Query task and returns it. -func newQuery(attr string, uids []uint64, srcFunc []string) *intern.Query { +func newQuery(attr string, uids []uint64, srcFunc []string) *pb.Query { x.AssertTrue(uids == nil || srcFunc == nil) // TODO: Change later, hacky way to make the tests work - var srcFun *intern.SrcFunction + var srcFun *pb.SrcFunction if len(srcFunc) > 0 { - srcFun = new(intern.SrcFunction) + srcFun = new(pb.SrcFunction) srcFun.Name = srcFunc[0] srcFun.Args = append(srcFun.Args, srcFunc[2:]...) } - q := &intern.Query{ - UidList: &intern.List{uids}, + q := &pb.Query{ + UidList: &pb.List{uids}, SrcFunc: srcFun, Attr: attr, ReadTs: timestamp(), @@ -155,7 +155,7 @@ func TestProcessTaskIndexMLayer(t *testing.T) { // Now try changing 12's friend value from "photon" to "notphotonExtra" to // "notphoton". - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("notphotonExtra"), Label: "author0", Attr: "friend", @@ -178,7 +178,7 @@ func TestProcessTaskIndexMLayer(t *testing.T) { }, algo.ToUintsListForTest(r.UidMatrix)) // Try deleting. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("photon"), Label: "author0", Attr: "friend", @@ -233,7 +233,7 @@ func TestProcessTaskIndex(t *testing.T) { // Now try changing 12's friend value from "photon" to "notphotonExtra" to // "notphoton". - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Value: []byte("notphotonExtra"), Label: "author0", Attr: "friend", @@ -256,7 +256,7 @@ func TestProcessTaskIndex(t *testing.T) { }, algo.ToUintsListForTest(r.UidMatrix)) // Try deleting. - edge = &intern.DirectedEdge{ + edge = &pb.DirectedEdge{ Value: []byte("photon"), Label: "author0", Attr: "friend", @@ -287,7 +287,7 @@ func TestProcessTaskIndex(t *testing.T) { /* func populateGraphForSort(t *testing.T, ps store.Store) { - edge := &intern.DirectedEdge{ + edge := &pb.DirectedEdge{ Label: "author1", Attr: "dob", } @@ -317,14 +317,14 @@ func populateGraphForSort(t *testing.T, ps store.Store) { time.Sleep(200 * time.Millisecond) // Let indexing finish. } -// newSort creates a intern.Sort for sorting. -func newSort(uids [][]uint64, offset, count int) *intern.Sort { +// newSort creates a pb.Sort for sorting. +func newSort(uids [][]uint64, offset, count int) *pb.Sort { x.AssertTrue(uids != nil) - uidMatrix := make([]*intern.List, len(uids)) + uidMatrix := make([]*pb.List, len(uids)) for i, l := range uids { - uidMatrix[i] = &intern.List{Uids: l} + uidMatrix[i] = &pb.List{Uids: l} } - return &intern.Sort{ + return &pb.Sort{ Attr: "dob", Offset: int32(offset), Count: int32(count), @@ -592,14 +592,14 @@ func TestMain(m *testing.M) { posting.Config.CommitFraction = 0.10 gr = new(groupi) gr.gid = 1 - gr.tablets = make(map[string]*intern.Tablet) - gr.tablets["name"] = &intern.Tablet{GroupId: 1} - gr.tablets["name2"] = &intern.Tablet{GroupId: 1} - gr.tablets["age"] = &intern.Tablet{GroupId: 1} - gr.tablets["friend"] = &intern.Tablet{GroupId: 1} - gr.tablets["http://www.w3.org/2000/01/rdf-schema#range"] = &intern.Tablet{GroupId: 1} - gr.tablets["friend_not_served"] = &intern.Tablet{GroupId: 2} - gr.tablets[""] = &intern.Tablet{GroupId: 1} + gr.tablets = make(map[string]*pb.Tablet) + gr.tablets["name"] = &pb.Tablet{GroupId: 1} + gr.tablets["name2"] = &pb.Tablet{GroupId: 1} + gr.tablets["age"] = &pb.Tablet{GroupId: 1} + gr.tablets["friend"] = &pb.Tablet{GroupId: 1} + gr.tablets["http://www.w3.org/2000/01/rdf-schema#range"] = &pb.Tablet{GroupId: 1} + gr.tablets["friend_not_served"] = &pb.Tablet{GroupId: 2} + gr.tablets[""] = &pb.Tablet{GroupId: 1} dir, err := ioutil.TempDir("", "storetest_") x.Check(err) diff --git a/x/histogram.go b/x/histogram.go index c4f9376081e..56adc43e443 100644 --- a/x/histogram.go +++ b/x/histogram.go @@ -71,7 +71,7 @@ func (h *slidingHistogram) RecordValue(v int64) error { } // A Histogram collects observed values by keeping bucketed counts. For -// convenience, intern.y two sets of buckets are kept: A cumulative set (i.e. +// convenience, pb.y two sets of buckets are kept: A cumulative set (i.e. // data is never evicted) and a windowed set (which keeps only recently // collected samples). // diff --git a/x/x.go b/x/x.go index c75d019c03c..a360137d30a 100644 --- a/x/x.go +++ b/x/x.go @@ -180,7 +180,7 @@ func ReadLine(r *bufio.Reader, buf *bytes.Buffer) error { buf.Reset() for isPrefix && err == nil { var line []byte - // The returned line is an intern.buffer in bufio and is only + // The returned line is an pb.buffer in bufio and is only // valid until the next call to ReadLine. It needs to be copied // over to our own buffer. line, isPrefix, err = r.ReadLine() diff --git a/xidmap/xidmap.go b/xidmap/xidmap.go index 3a70775eddf..0128522ff27 100644 --- a/xidmap/xidmap.go +++ b/xidmap/xidmap.go @@ -17,7 +17,7 @@ import ( "google.golang.org/grpc" "github.com/dgraph-io/badger" - "github.com/dgraph-io/dgraph/protos/intern" + "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" farm "github.com/dgryski/go-farm" ) @@ -40,7 +40,7 @@ type XidMap struct { shards []shard kv *badger.DB opt Options - newRanges chan *intern.AssignedIds + newRanges chan *pb.AssignedIds noMapMu sync.Mutex noMap block // block for allocating uids without an xid to uid mapping @@ -67,7 +67,7 @@ type block struct { start, end uint64 } -func (b *block) assign(ch <-chan *intern.AssignedIds) uint64 { +func (b *block) assign(ch <-chan *pb.AssignedIds) uint64 { if b.end == 0 || b.start > b.end { newRange := <-ch b.start, b.end = newRange.StartId, newRange.EndId @@ -86,7 +86,7 @@ func New(kv *badger.DB, zero *grpc.ClientConn, opt Options) *XidMap { shards: make([]shard, opt.NumShards), kv: kv, opt: opt, - newRanges: make(chan *intern.AssignedIds), + newRanges: make(chan *pb.AssignedIds), } for i := range xm.shards { xm.shards[i].elems = make(map[string]*list.Element) @@ -94,13 +94,13 @@ func New(kv *badger.DB, zero *grpc.ClientConn, opt Options) *XidMap { xm.shards[i].xm = xm } go func() { - zc := intern.NewZeroClient(zero) + zc := pb.NewZeroClient(zero) const initBackoff = 10 * time.Millisecond const maxBackoff = 5 * time.Second backoff := initBackoff for { ctx, cancel := context.WithTimeout(context.Background(), time.Second) - assigned, err := zc.AssignUids(ctx, &intern.Num{Val: 10000}) + assigned, err := zc.AssignUids(ctx, &pb.Num{Val: 10000}) cancel() if err == nil { backoff = initBackoff From 27616887445a8b3099c845ad885b4b8298f24997 Mon Sep 17 00:00:00 2001 From: srfrog Date: Mon, 24 Sep 2018 18:20:03 -0700 Subject: [PATCH 2/2] fixed test that used pb as alias for raftpb pkg --- worker/draft_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/worker/draft_test.go b/worker/draft_test.go index e31b21944d5..30bc40f2b6f 100644 --- a/worker/draft_test.go +++ b/worker/draft_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - pb "github.com/coreos/etcd/raft/raftpb" + "github.com/coreos/etcd/raft/raftpb" "github.com/dgraph-io/badger" "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" @@ -22,20 +22,20 @@ func openBadger(dir string) (*badger.DB, error) { return badger.Open(opt) } -func getEntryForMutation(index, startTs uint64) pb.Entry { +func getEntryForMutation(index, startTs uint64) raftpb.Entry { proposal := pb.Proposal{Mutations: &pb.Mutations{StartTs: startTs}} data, err := proposal.Marshal() x.Check(err) - return pb.Entry{Index: index, Term: 1, Type: pb.EntryNormal, Data: data} + return raftpb.Entry{Index: index, Term: 1, Type: raftpb.EntryNormal, Data: data} } -func getEntryForCommit(index, startTs, commitTs uint64) pb.Entry { +func getEntryForCommit(index, startTs, commitTs uint64) raftpb.Entry { delta := &pb.OracleDelta{} delta.Txns = append(delta.Txns, &pb.TxnStatus{StartTs: startTs, CommitTs: commitTs}) proposal := pb.Proposal{Delta: delta} data, err := proposal.Marshal() x.Check(err) - return pb.Entry{Index: index, Term: 1, Type: pb.EntryNormal, Data: data} + return raftpb.Entry{Index: index, Term: 1, Type: raftpb.EntryNormal, Data: data} } func TestCalculateSnapshot(t *testing.T) { @@ -48,7 +48,7 @@ func TestCalculateSnapshot(t *testing.T) { ds := raftwal.Init(db, 0, 0) n := newNode(ds, 1, 1, "") - var entries []pb.Entry + var entries []raftpb.Entry // Txn: 1 -> 5 // 5 should be the ReadTs. // Txn: 2 // Should correspond to the index. Subtract 1 from the index. // Txn: 3 -> 4 @@ -57,7 +57,7 @@ func TestCalculateSnapshot(t *testing.T) { entries = append(entries, getEntryForMutation(3, 2)) // Start ts can be jumbled. entries = append(entries, getEntryForCommit(4, 3, 4)) // But commit ts would be serial. entries = append(entries, getEntryForCommit(5, 1, 5)) - require.NoError(t, n.Store.Save(pb.HardState{}, entries, pb.Snapshot{})) + require.NoError(t, n.Store.Save(raftpb.HardState{}, entries, raftpb.Snapshot{})) n.Applied.SetDoneUntil(5) posting.Oracle().RegisterStartTs(2) snap, err := n.calculateSnapshot(1) @@ -66,7 +66,7 @@ func TestCalculateSnapshot(t *testing.T) { require.Equal(t, uint64(1), snap.Index) // Check state of Raft store. - var cs pb.ConfState + var cs raftpb.ConfState err = n.Store.CreateSnapshot(snap.Index, &cs, nil) require.NoError(t, err) @@ -85,7 +85,7 @@ func TestCalculateSnapshot(t *testing.T) { entries = append(entries, getEntryForMutation(6, 7)) entries = append(entries, getEntryForCommit(7, 7, 8)) entries = append(entries, getEntryForCommit(8, 2, 9)) - require.NoError(t, n.Store.Save(pb.HardState{}, entries, pb.Snapshot{})) + require.NoError(t, n.Store.Save(raftpb.HardState{}, entries, raftpb.Snapshot{})) n.Applied.SetDoneUntil(8) posting.Oracle().ResetTxns() snap, err = n.calculateSnapshot(1) @@ -102,7 +102,7 @@ func TestCalculateSnapshot(t *testing.T) { entries = entries[:0] entries = append(entries, getEntryForMutation(9, 11)) - require.NoError(t, n.Store.Save(pb.HardState{}, entries, pb.Snapshot{})) + require.NoError(t, n.Store.Save(raftpb.HardState{}, entries, raftpb.Snapshot{})) n.Applied.SetDoneUntil(9) snap, err = n.calculateSnapshot(0) require.NoError(t, err)