Skip to content

Commit

Permalink
add assert for sorted bitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
NamanJain8 committed Nov 17, 2021
1 parent 0c900f8 commit 6ab63b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dgraph/cmd/bulk/reduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@ func (r *reducer) writeTmpSplits(ci *countIndexer, wg *sync.WaitGroup) {
if kvs == nil || len(kvs.Kv) == 0 {
continue
}
// kvs contain the split generated after rollup. Hence, the keys to be inserted to skiplist
// are already sorted.
sort.Slice(kvs.Kv, func(i, j int) bool {
return bytes.Compare(kvs.Kv[i].Key, kvs.Kv[j].Key) < 0
})
b := skl.NewBuilder(int64(kvs.Size()) + 1<<20)
for _, kv := range kvs.Kv {
if err := badger.ValidEntry(ci.tmpDb, kv.Key, kv.Value); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ func (ro *rollupOutput) split(startUid uint64) error {
// Provide a 30% cushion, because NSplit doesn't do equal splitting based on maxListSize.
bms := r.Split(f, uint64(0.7*float64(maxListSize)))

var prev uint64 = 0
for i, bm := range bms {
c := bm.GetCardinality()
if c == 0 {
Expand Down Expand Up @@ -1180,6 +1181,8 @@ func (ro *rollupOutput) split(startUid uint64) error {
if i == 0 && startUid == 1 {
start = 1
}
x.AssertTruef(prev < start, "Bitmaps not sorted | prev: %d, curr: %d", prev, start)
prev = start
ro.parts[start] = newpl
}

Expand Down

0 comments on commit 6ab63b6

Please sign in to comment.