diff --git a/codec/codec.go b/codec/codec.go index 8c7e8eda1fe..1620887c09a 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -172,8 +172,8 @@ func FromBytes(buf []byte) *sroar.Bitmap { } func FromBackup(buf []byte) *sroar.Bitmap { - r := sroar.NewBitmap() var prev uint64 + var uids []uint64 for len(buf) > 0 { uid, n := binary.Uvarint(buf) if uid == 0 { @@ -182,14 +182,14 @@ func FromBackup(buf []byte) *sroar.Bitmap { buf = buf[n:] next := prev + uid - r.Set(next) + uids = append(uids, next) prev = next } - return r + return sroar.FromSortedList(uids) } func ToUids(plist *pb.PostingList, start uint64) []uint64 { - r := sroar.FromBuffer(plist.Bitmap) + r := sroar.FromBufferWithCopy(plist.Bitmap) r.RemoveRange(0, start) return r.ToArray() } diff --git a/go.mod b/go.mod index 1c0d20e93f7..05b6226fe13 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/dgraph-io/graphql-transport-ws v0.0.0-20210511143556-2cef522f1f15 github.com/dgraph-io/ristretto v0.1.0 github.com/dgraph-io/simdjson-go v0.3.0 - github.com/dgraph-io/sroar v0.0.0-20210604145002-865050cb7465 + github.com/dgraph-io/sroar v0.0.0-20210810060359-2dcd866b0b1f 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 diff --git a/go.sum b/go.sum index c97f0f5e300..5a11da16462 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/Lu github.com/dgraph-io/ristretto v0.1.0/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-20210604145002-865050cb7465 h1:wj9EEeLJyJnopcmtJlw5TzOcEgudIYLWGDE3cBpYUBQ= -github.com/dgraph-io/sroar v0.0.0-20210604145002-865050cb7465/go.mod h1:bdNPtQmcxoIQVkZEWZvX0n0/IDlHFab397xdBlP4OoE= +github.com/dgraph-io/sroar v0.0.0-20210810060359-2dcd866b0b1f h1:t0+mRMDoMgWykf89mPKW9RaeFb3ujM7HoISogMXsaDo= +github.com/dgraph-io/sroar v0.0.0-20210810060359-2dcd866b0b1f/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= diff --git a/posting/list.go b/posting/list.go index e085f52d6be..10843d07463 100644 --- a/posting/list.go +++ b/posting/list.go @@ -520,7 +520,7 @@ func (l *List) bitmap(opt ListOptions) (*sroar.Bitmap, error) { } r := sroar.NewBitmap() if deleteBelow == 0 { - r = sroar.FromBuffer(l.plist.Bitmap) + r = sroar.FromBufferWithCopy(l.plist.Bitmap) if iw != nil { r.And(iw) } @@ -533,7 +533,7 @@ func (l *List) bitmap(opt ListOptions) (*sroar.Bitmap, error) { if err != nil { return nil, errors.Wrapf(err, "while reading a split with startUid: %d", startUid) } - s := sroar.FromBuffer(split.Bitmap) + s := sroar.FromBufferWithCopy(split.Bitmap) // Intersect with opt.Intersect. if iw != nil {