Skip to content

Commit

Permalink
opt(sroar): upgrade sroar to use optimised IsEmpty API (#8010)
Browse files Browse the repository at this point in the history
Upgrade sroar to use an optimized version of IsEmpty API.
  • Loading branch information
ahsanbarkati authored Sep 2, 2021
1 parent 05a3958 commit a092dc0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func Merge(matrix []*pb.List) *sroar.Bitmap {

func FromList(l *pb.List) *sroar.Bitmap {
if l == nil {
return nil
return sroar.NewBitmap()
}
// Keep the check for bitmap before sortedUids because we expect to have bitmap very often
if len(l.Bitmap) > 0 {
Expand All @@ -145,13 +145,12 @@ func FromList(l *pb.List) *sroar.Bitmap {
bm.SetMany(l.SortedUids)
return bm
}
// TODO: Return nil here and handle nil for all the APIs in sroar itself.
return sroar.NewBitmap()
}

func FromListNoCopy(l *pb.List) *sroar.Bitmap {
if l == nil {
return nil
return sroar.NewBitmap()
}
// Keep the check for bitmap before sortedUids because we expect to have bitmap very often
if len(l.Bitmap) > 0 {
Expand All @@ -162,7 +161,7 @@ func FromListNoCopy(l *pb.List) *sroar.Bitmap {
bm.SetMany(l.SortedUids)
return bm
}
return nil
return sroar.NewBitmap()
}

func FromBytes(buf []byte) *sroar.Bitmap {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15
github.com/dgraph-io/ristretto v0.1.1-0.20210824115121-89e99415887a
github.com/dgraph-io/simdjson-go v0.3.0
github.com/dgraph-io/sroar v0.0.0-20210830053543-c5aff93143f7
github.com/dgraph-io/sroar v0.0.0-20210831151133-ad6554cce45c
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ 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-20210830053543-c5aff93143f7 h1:GUNuYUk6Owo1GIxwDxiIDXSn/T3fgpxWbiXmnKFq5Ig=
github.com/dgraph-io/sroar v0.0.0-20210830053543-c5aff93143f7/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE=
github.com/dgraph-io/sroar v0.0.0-20210831151133-ad6554cce45c h1:bHaFPV/3WghTvYa3deF8atHQWk85yfEwFlRgMu89SSo=
github.com/dgraph-io/sroar v0.0.0-20210831151133-ad6554cce45c/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 h1:CaO/zOnF8VvUfEbhRatPcwKVWamvbYd8tQGRWacE9kU=
Expand Down
2 changes: 1 addition & 1 deletion query/recurse.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (start *SubGraph) expandRecurse(ctx context.Context, maxDepth uint64) error
} else {
ul := sg.uidMatrix[mIdx]
ur := codec.FromListNoCopy(ul)
if ur == nil {
if ur.IsEmpty() {
continue
}

Expand Down

0 comments on commit a092dc0

Please sign in to comment.