Skip to content

Commit

Permalink
fix edge case related to startUid = 1
Browse files Browse the repository at this point in the history
  • Loading branch information
NamanJain8 committed Nov 11, 2021
1 parent 0756963 commit a56d6c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ github.com/dgraph-io/ristretto v0.1.1-0.20210824115121-89e99415887a h1:2+hTlwc5y
github.com/dgraph-io/ristretto v0.1.1-0.20210824115121-89e99415887a/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=
github.com/dgraph-io/simdjson-go v0.3.0 h1:h71LO7vR4LHMPUhuoGN8bqGm1VNfGOlAG8BI6iDUKw0=
github.com/dgraph-io/simdjson-go v0.3.0/go.mod h1:Otpysdjaxj9OGaJusn4pgQV7OFh2bELuHANq0I78uvY=
github.com/dgraph-io/sroar v0.0.0-20210930201544-8a9a0351f20f h1:/7NA7mug98b6QkBU+3BEfun5EpegFVx7cRZU86vTouQ=
github.com/dgraph-io/sroar v0.0.0-20210930201544-8a9a0351f20f/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE=
github.com/dgraph-io/sroar v0.0.0-20211109162404-04042b4dc6bf h1:8MALpTCcxt9Th2Zg1SoIKd8JiVQxNmRMu82eoRm6ilY=
github.com/dgraph-io/sroar v0.0.0-20211109162404-04042b4dc6bf/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE=
github.com/dgraph-io/sroar v0.0.0-20211109183029-fd981ce5e705 h1:kTbqbQw7mo5AUf8V0u04BjUndA9eFiApin0+vjPO3Qk=
github.com/dgraph-io/sroar v0.0.0-20211109183029-fd981ce5e705/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE=
github.com/dgraph-io/sroar v0.0.0-20211110072951-f8373db427cd h1:qfO1q+M7gc9zLb0N69QbO8OkfrSAszhqo0zCbGKD0o8=
github.com/dgraph-io/sroar v0.0.0-20211110072951-f8373db427cd/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
Expand Down
19 changes: 14 additions & 5 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@ func (l *List) Rollup(alloc *z.Allocator) ([]*bpb.KV, error) {
}
// defer out.free()

if len(out.parts) > 0 {
out.plist.Postings = nil
out.plist.Bitmap = nil
}

var kvs []*bpb.KV
kv := MarshalPostingList(out.plist, alloc)
// We set kv.Version to newMinTs + 1 because if we write the rolled up keys at the same ts as
Expand Down Expand Up @@ -1120,20 +1125,24 @@ func (ro *rollupOutput) split(startUid uint64) error {
// Provide a 30% cushion, because NSplit doesn't do equal splitting based on maxListSize.
bms := r.NSplit(f, uint64(0.7*float64(maxListSize)))

for _, bm := range bms {
for i, bm := range bms {
if bm.GetCardinality() == 0 {
continue
}
startUid, err := bm.Select(0)
start, err := bm.Select(0)
x.Check(err)
endUid, err := bm.Select(uint64(bm.GetCardinality()) - 1)
end, err := bm.Select(uint64(bm.GetCardinality()) - 1)
x.Check(err)

newpl := &pb.PostingList{}
newpl.Bitmap = bm.ToBuffer()
newpl.Postings = getPostings(startUid, endUid)
newpl.Postings = getPostings(start, end)
// startUid = 1 is a special case. ro.parts should always have UID 1
if i == 0 && startUid == 1 {
start = 1
}

ro.parts[startUid] = newpl
ro.parts[start] = newpl
}

return nil
Expand Down

0 comments on commit a56d6c4

Please sign in to comment.