Skip to content

Commit

Permalink
fix(sroar): Fix TestAuthWithCustomDQL failure because of roaring bitm…
Browse files Browse the repository at this point in the history
…aps (#7902)

We should consider the state of UIdMatrix (whether it was in the form of SortedUids
or bitmap) in order to set the result after pagination. Pagination with cascade is
handled separately, where it is possible to have no order.
  • Loading branch information
ahsanbarkati authored Jun 17, 2021
1 parent 3407eb1 commit d628f2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 10 additions & 0 deletions codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ func GetUids(l *pb.List) []uint64 {
return FromList(l).ToArray()
}

func SetUids(l *pb.List, uids []uint64) {
if len(l.SortedUids) > 0 {
l.SortedUids = uids
} else {
r := sroar.NewBitmap()
r.SetMany(uids)
l.Bitmap = ToBytes(r)
}
}

func BitmapToSorted(l *pb.List) {
if l == nil {
return
Expand Down
7 changes: 3 additions & 4 deletions query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1415,14 +1415,13 @@ func (sg *SubGraph) populateVarMap(doneVars map[string]varValue, sgPath []*SubGr
child.updateUidMatrix()

// Apply pagination after the @cascade.
if len(child.Params.Cascade.Fields) > 0 && (child.Params.Cascade.First != 0 || child.Params.Cascade.Offset != 0) {
if len(child.Params.Cascade.Fields) > 0 && (child.Params.Cascade.First != 0 ||
child.Params.Cascade.Offset != 0) {
for i := 0; i < len(child.uidMatrix); i++ {
uids := codec.GetUids(child.uidMatrix[i])
start, end := x.PageRange(child.Params.Cascade.First, child.Params.Cascade.Offset,
len(uids))
r := sroar.NewBitmap()
r.SetMany(uids[start:end])
child.uidMatrix[i].Bitmap = codec.ToBytes(r)
codec.SetUids(child.uidMatrix[i], uids[start:end])
}
}
}
Expand Down

0 comments on commit d628f2e

Please sign in to comment.