Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt(IsEmpty): Upgrade sroar to optimize IsEmpty API #8010

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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