Skip to content

Commit a8b350d

Browse files
Gusdna2github
Gus
authored andcommitted
rename intern pkg to pb (hypermodeinc#2608)
* 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.
1 parent 8cddaef commit a8b350d

File tree

133 files changed

+27735
-6269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+27735
-6269
lines changed

Diff for: algo/uidlist.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212
"sort"
1313

1414
"github.com/dgraph-io/dgraph/bp128"
15-
"github.com/dgraph-io/dgraph/protos/intern"
15+
"github.com/dgraph-io/dgraph/protos/pb"
1616
)
1717

1818
const jump = 32 // Jump size in InsersectWithJump.
1919

2020
// ApplyFilter applies a filter to our UIDList.
21-
func ApplyFilter(u *intern.List, f func(uint64, int) bool) {
21+
func ApplyFilter(u *pb.List, f func(uint64, int) bool) {
2222
out := u.Uids[:0]
2323
for i, uid := range u.Uids {
2424
if f(uid, i) {
@@ -28,7 +28,7 @@ func ApplyFilter(u *intern.List, f func(uint64, int) bool) {
2828
u.Uids = out
2929
}
3030

31-
func IntersectCompressedWith(u []byte, afterUID uint64, v, o *intern.List) {
31+
func IntersectCompressedWith(u []byte, afterUID uint64, v, o *pb.List) {
3232
var bi bp128.BPackIterator
3333
bi.Init(u, afterUID)
3434
n := bi.Length() - bi.StartIdx()
@@ -120,7 +120,7 @@ func IntersectCompressedWithBin(bi *bp128.BPackIterator, q []uint64, o *[]uint64
120120

121121
// IntersectWith intersects u with v. The update is made to o.
122122
// u, v should be sorted.
123-
func IntersectWith(u, v, o *intern.List) {
123+
func IntersectWith(u, v, o *pb.List) {
124124
n := len(u.Uids)
125125
m := len(v.Uids)
126126

@@ -261,13 +261,13 @@ func binIntersect(d, q []uint64, final *[]uint64) {
261261
}
262262

263263
type listInfo struct {
264-
l *intern.List
264+
l *pb.List
265265
length int
266266
}
267267

268-
func IntersectSorted(lists []*intern.List) *intern.List {
268+
func IntersectSorted(lists []*pb.List) *pb.List {
269269
if len(lists) == 0 {
270-
return &intern.List{}
270+
return &pb.List{}
271271
}
272272
ls := make([]listInfo, 0, len(lists))
273273
for _, list := range lists {
@@ -280,7 +280,7 @@ func IntersectSorted(lists []*intern.List) *intern.List {
280280
sort.Slice(ls, func(i, j int) bool {
281281
return ls[i].length < ls[j].length
282282
})
283-
out := &intern.List{Uids: make([]uint64, ls[0].length)}
283+
out := &pb.List{Uids: make([]uint64, ls[0].length)}
284284
if len(ls) == 1 {
285285
copy(out.Uids, ls[0].l.Uids)
286286
return out
@@ -299,9 +299,9 @@ func IntersectSorted(lists []*intern.List) *intern.List {
299299
return out
300300
}
301301

302-
func Difference(u, v *intern.List) *intern.List {
302+
func Difference(u, v *pb.List) *pb.List {
303303
if u == nil || v == nil {
304-
return &intern.List{Uids: make([]uint64, 0)}
304+
return &pb.List{Uids: make([]uint64, 0)}
305305
}
306306
n := len(u.Uids)
307307
m := len(v.Uids)
@@ -327,13 +327,13 @@ func Difference(u, v *intern.List) *intern.List {
327327
out = append(out, u.Uids[i])
328328
i++
329329
}
330-
return &intern.List{Uids: out}
330+
return &pb.List{Uids: out}
331331
}
332332

333333
// MergeSorted merges sorted lists.
334-
func MergeSorted(lists []*intern.List) *intern.List {
334+
func MergeSorted(lists []*pb.List) *pb.List {
335335
if len(lists) == 0 {
336-
return new(intern.List)
336+
return new(pb.List)
337337
}
338338

339339
h := &uint64Heap{}
@@ -377,12 +377,12 @@ func MergeSorted(lists []*intern.List) *intern.List {
377377
heap.Fix(h, 0) // Faster than Pop() followed by Push().
378378
}
379379
}
380-
return &intern.List{Uids: output}
380+
return &pb.List{Uids: output}
381381
}
382382

383383
// IndexOf performs a binary search on the uids slice and returns the index at
384384
// which it finds the uid, else returns -1
385-
func IndexOf(u *intern.List, uid uint64) int {
385+
func IndexOf(u *pb.List, uid uint64) int {
386386
i := sort.Search(len(u.Uids), func(i int) bool { return u.Uids[i] >= uid })
387387
if i < len(u.Uids) && u.Uids[i] == uid {
388388
return i
@@ -391,7 +391,7 @@ func IndexOf(u *intern.List, uid uint64) int {
391391
}
392392

393393
// ToUintsListForTest converts to list of uints for testing purpose only.
394-
func ToUintsListForTest(ul []*intern.List) [][]uint64 {
394+
func ToUintsListForTest(ul []*pb.List) [][]uint64 {
395395
out := make([][]uint64, 0, len(ul))
396396
for _, u := range ul {
397397
out = append(out, u.Uids)

Diff for: algo/uidlist_test.go

+32-32
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ import (
1414
"testing"
1515

1616
"github.com/dgraph-io/dgraph/bp128"
17-
"github.com/dgraph-io/dgraph/protos/intern"
17+
"github.com/dgraph-io/dgraph/protos/pb"
1818
"github.com/stretchr/testify/require"
1919
)
2020

21-
func newList(data []uint64) *intern.List {
22-
return &intern.List{data}
21+
func newList(data []uint64) *pb.List {
22+
return &pb.List{data}
2323
}
2424

2525
func TestMergeSorted1(t *testing.T) {
26-
input := []*intern.List{
26+
input := []*pb.List{
2727
newList([]uint64{55}),
2828
}
2929
require.Equal(t, MergeSorted(input).Uids, []uint64{55})
3030
}
3131

3232
func TestMergeSorted2(t *testing.T) {
33-
input := []*intern.List{
33+
input := []*pb.List{
3434
newList([]uint64{1, 3, 6, 8, 10}),
3535
newList([]uint64{2, 4, 5, 7, 15}),
3636
}
@@ -39,31 +39,31 @@ func TestMergeSorted2(t *testing.T) {
3939
}
4040

4141
func TestMergeSorted3(t *testing.T) {
42-
input := []*intern.List{
42+
input := []*pb.List{
4343
newList([]uint64{1, 3, 6, 8, 10}),
4444
newList([]uint64{}),
4545
}
4646
require.Equal(t, MergeSorted(input).Uids, []uint64{1, 3, 6, 8, 10})
4747
}
4848

4949
func TestMergeSorted4(t *testing.T) {
50-
input := []*intern.List{
50+
input := []*pb.List{
5151
newList([]uint64{}),
5252
newList([]uint64{1, 3, 6, 8, 10}),
5353
}
5454
require.Equal(t, MergeSorted(input).Uids, []uint64{1, 3, 6, 8, 10})
5555
}
5656

5757
func TestMergeSorted5(t *testing.T) {
58-
input := []*intern.List{
58+
input := []*pb.List{
5959
newList([]uint64{}),
6060
newList([]uint64{}),
6161
}
6262
require.Empty(t, MergeSorted(input).Uids)
6363
}
6464

6565
func TestMergeSorted6(t *testing.T) {
66-
input := []*intern.List{
66+
input := []*pb.List{
6767
newList([]uint64{11, 13, 16, 18, 20}),
6868
newList([]uint64{12, 14, 15, 15, 16, 16, 17, 25}),
6969
newList([]uint64{1, 2}),
@@ -73,7 +73,7 @@ func TestMergeSorted6(t *testing.T) {
7373
}
7474

7575
func TestMergeSorted7(t *testing.T) {
76-
input := []*intern.List{
76+
input := []*pb.List{
7777
newList([]uint64{5, 6, 7}),
7878
newList([]uint64{3, 4}),
7979
newList([]uint64{1, 2}),
@@ -83,54 +83,54 @@ func TestMergeSorted7(t *testing.T) {
8383
}
8484

8585
func TestMergeSorted8(t *testing.T) {
86-
input := []*intern.List{}
86+
input := []*pb.List{}
8787
require.Empty(t, MergeSorted(input).Uids)
8888
}
8989

9090
func TestMergeSorted9(t *testing.T) {
91-
input := []*intern.List{
91+
input := []*pb.List{
9292
newList([]uint64{1, 1, 1}),
9393
}
9494
require.Equal(t, MergeSorted(input).Uids, []uint64{1})
9595
}
9696

9797
func TestMergeSorted10(t *testing.T) {
98-
input := []*intern.List{
98+
input := []*pb.List{
9999
newList([]uint64{1, 2, 3, 3, 6}),
100100
newList([]uint64{4, 8, 9}),
101101
}
102102
require.Equal(t, MergeSorted(input).Uids, []uint64{1, 2, 3, 4, 6, 8, 9})
103103
}
104104

105105
func TestIntersectSorted1(t *testing.T) {
106-
input := []*intern.List{
106+
input := []*pb.List{
107107
newList([]uint64{1, 2, 3}),
108108
newList([]uint64{2, 3, 4, 5}),
109109
}
110110
require.Equal(t, []uint64{2, 3}, IntersectSorted(input).Uids)
111111
}
112112

113113
func TestIntersectSorted2(t *testing.T) {
114-
input := []*intern.List{
114+
input := []*pb.List{
115115
newList([]uint64{1, 2, 3}),
116116
}
117117
require.Equal(t, IntersectSorted(input).Uids, []uint64{1, 2, 3})
118118
}
119119

120120
func TestIntersectSorted3(t *testing.T) {
121-
input := []*intern.List{}
121+
input := []*pb.List{}
122122
require.Empty(t, IntersectSorted(input).Uids)
123123
}
124124

125125
func TestIntersectSorted4(t *testing.T) {
126-
input := []*intern.List{
126+
input := []*pb.List{
127127
newList([]uint64{100, 101}),
128128
}
129129
require.Equal(t, IntersectSorted(input).Uids, []uint64{100, 101})
130130
}
131131

132132
func TestIntersectSorted5(t *testing.T) {
133-
input := []*intern.List{
133+
input := []*pb.List{
134134
newList([]uint64{1, 2, 3}),
135135
newList([]uint64{2, 3, 4, 5}),
136136
newList([]uint64{4, 5, 6}),
@@ -139,7 +139,7 @@ func TestIntersectSorted5(t *testing.T) {
139139
}
140140

141141
func TestIntersectSorted6(t *testing.T) {
142-
input := []*intern.List{
142+
input := []*pb.List{
143143
newList([]uint64{10, 12, 13}),
144144
newList([]uint64{2, 3, 4, 13}),
145145
newList([]uint64{4, 5, 6}),
@@ -148,7 +148,7 @@ func TestIntersectSorted6(t *testing.T) {
148148
}
149149

150150
func TestDiffSorted1(t *testing.T) {
151-
input := []*intern.List{
151+
input := []*pb.List{
152152
newList([]uint64{1, 2, 3}),
153153
newList([]uint64{1}),
154154
}
@@ -157,7 +157,7 @@ func TestDiffSorted1(t *testing.T) {
157157
}
158158

159159
func TestDiffSorted2(t *testing.T) {
160-
input := []*intern.List{
160+
input := []*pb.List{
161161
newList([]uint64{1, 2, 3}),
162162
newList([]uint64{2}),
163163
}
@@ -166,7 +166,7 @@ func TestDiffSorted2(t *testing.T) {
166166
}
167167

168168
func TestDiffSorted3(t *testing.T) {
169-
input := []*intern.List{
169+
input := []*pb.List{
170170
newList([]uint64{1, 2, 3}),
171171
newList([]uint64{3}),
172172
}
@@ -175,7 +175,7 @@ func TestDiffSorted3(t *testing.T) {
175175
}
176176

177177
func TestDiffSorted4(t *testing.T) {
178-
input := []*intern.List{
178+
input := []*pb.List{
179179
newList([]uint64{1, 2, 3}),
180180
newList([]uint64{}),
181181
}
@@ -184,7 +184,7 @@ func TestDiffSorted4(t *testing.T) {
184184
}
185185

186186
func TestDiffSorted5(t *testing.T) {
187-
input := []*intern.List{
187+
input := []*pb.List{
188188
newList([]uint64{}),
189189
newList([]uint64{1, 2}),
190190
}
@@ -193,7 +193,7 @@ func TestDiffSorted5(t *testing.T) {
193193
}
194194

195195
func TestSubSorted1(t *testing.T) {
196-
input := []*intern.List{
196+
input := []*pb.List{
197197
newList([]uint64{1, 2, 3}),
198198
newList([]uint64{2, 3, 4, 5}),
199199
}
@@ -202,7 +202,7 @@ func TestSubSorted1(t *testing.T) {
202202
}
203203

204204
func TestSubSorted6(t *testing.T) {
205-
input := []*intern.List{
205+
input := []*pb.List{
206206
newList([]uint64{10, 12, 13}),
207207
newList([]uint64{2, 3, 4, 13}),
208208
}
@@ -290,8 +290,8 @@ func BenchmarkListIntersectRandom(b *testing.B) {
290290

291291
u := newList(u1)
292292
v := newList(v1)
293-
dst1 := &intern.List{}
294-
dst2 := &intern.List{}
293+
dst1 := &pb.List{}
294+
dst2 := &pb.List{}
295295
compressedUids := bp128.DeltaPack(u1)
296296

297297
b.Run(fmt.Sprintf(":size=%d:overlap=%.2f:", arrSz, overlap),
@@ -353,10 +353,10 @@ func BenchmarkListIntersectRatio(b *testing.B) {
353353
sort.Slice(u1, func(i, j int) bool { return u1[i] < u1[j] })
354354
sort.Slice(v1, func(i, j int) bool { return v1[i] < v1[j] })
355355

356-
u := &intern.List{u1}
357-
v := &intern.List{v1}
358-
dst1 := &intern.List{}
359-
dst2 := &intern.List{}
356+
u := &pb.List{u1}
357+
v := &pb.List{v1}
358+
dst1 := &pb.List{}
359+
dst2 := &pb.List{}
360360
compressedUids := bp128.DeltaPack(v1)
361361

362362
fmt.Printf("len: %d, compressed: %d, bytes/int: %f\n",

Diff for: conn/node.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/coreos/etcd/raft/raftpb"
2121
"github.com/dgraph-io/badger/y"
2222
"github.com/dgraph-io/dgo/protos/api"
23-
"github.com/dgraph-io/dgraph/protos/intern"
23+
"github.com/dgraph-io/dgraph/protos/pb"
2424
"github.com/dgraph-io/dgraph/raftwal"
2525
"github.com/dgraph-io/dgraph/x"
2626
"github.com/golang/glog"
@@ -51,7 +51,7 @@ type Node struct {
5151
peers map[uint64]string
5252
confChanges map[uint64]chan error
5353
messages chan sendmsg
54-
RaftContext *intern.RaftContext
54+
RaftContext *pb.RaftContext
5555
Store *raftwal.DiskStorage
5656
Rand *rand.Rand
5757

@@ -62,7 +62,7 @@ type Node struct {
6262
Applied x.WaterMark
6363
}
6464

65-
func NewNode(rc *intern.RaftContext, store *raftwal.DiskStorage) *Node {
65+
func NewNode(rc *pb.RaftContext, store *raftwal.DiskStorage) *Node {
6666
snap, err := store.Snapshot()
6767
x.Check(err)
6868

@@ -332,9 +332,9 @@ func (n *Node) doSendMessage(pool *Pool, data []byte) {
332332

333333
client := pool.Get()
334334

335-
c := intern.NewRaftClient(client)
335+
c := pb.NewRaftClient(client)
336336
p := &api.Payload{Data: data}
337-
batch := &intern.RaftBatch{
337+
batch := &pb.RaftBatch{
338338
Context: n.RaftContext,
339339
Payload: p,
340340
}
@@ -415,7 +415,7 @@ func (n *Node) proposeConfChange(ctx context.Context, pb raftpb.ConfChange) erro
415415
func (n *Node) AddToCluster(ctx context.Context, pid uint64) error {
416416
addr, ok := n.Peer(pid)
417417
x.AssertTruef(ok, "Unable to find conn pool for peer: %d", pid)
418-
rc := &intern.RaftContext{
418+
rc := &pb.RaftContext{
419419
Addr: addr,
420420
Group: n.RaftContext.Group,
421421
Id: pid,

0 commit comments

Comments
 (0)