From e3d5ddea05d56192fbabcaef31ceae0145ff008d Mon Sep 17 00:00:00 2001 From: Marty Schoch Date: Wed, 17 Feb 2021 14:57:41 -0500 Subject: [PATCH 1/2] depend on new Bitmap interface this removes dependency on roaring bitmaps --- bitmap.go | 39 +++++++++++++++++++++++++++++++++++++++ go.mod | 7 +------ go.sum | 33 --------------------------------- segment.go | 9 ++++----- 4 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 bitmap.go diff --git a/bitmap.go b/bitmap.go new file mode 100644 index 0000000..b2fb6d2 --- /dev/null +++ b/bitmap.go @@ -0,0 +1,39 @@ +package segment + +import "io" + +type IntIterable interface { + HasNext() bool + Next() uint32 +} + +type IntPeekable interface { + IntIterable + + PeekNext() uint32 + AdvanceIfNeeded(minval uint32) +} + +type Bitmap interface { + + // these methods manipulate the bitmap + Add(uint32) + AddMany([]uint32) + AddRange(uint64, uint64) + And(Bitmap) + AndNot(Bitmap) + Clone() Bitmap + Contains(uint32) bool + GetCardinality() uint64 + GetSizeInBytes() uint64 + IsEmpty() bool + Iterator() IntPeekable + ReadFrom(io.Reader) (int64, error) + WriteTo(io.Writer) (int64, error) + + // these methods return new bitmaps + OrNew(Bitmap) Bitmap + AndNew(Bitmap) Bitmap + AndNotNew(Bitmap) Bitmap + HeapOrNew(bitmaps ...Bitmap) Bitmap +} diff --git a/go.mod b/go.mod index fb60b84..a0abdbd 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,4 @@ module github.com/blevesearch/scorch_segment_api/v2 go 1.13 -require ( - github.com/RoaringBitmap/roaring v0.4.23 - github.com/blevesearch/bleve_index_api v1.0.0 - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/mschoch/smat v0.2.0 // indirect -) +require github.com/blevesearch/bleve_index_api v1.0.0 diff --git a/go.sum b/go.sum index c465e59..2300f27 100644 --- a/go.sum +++ b/go.sum @@ -1,35 +1,2 @@ -github.com/RoaringBitmap/roaring v0.4.23 h1:gpyfd12QohbqhFO4NVDUdoPOCXsyahYRQhINmlHxKeo= -github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= github.com/blevesearch/bleve_index_api v1.0.0 h1:Ds3XeuTxjXCkG6pgIwWDRyooJKNIuOKemnN0N0IkhTU= github.com/blevesearch/bleve_index_api v1.0.0/go.mod h1:fiwKS0xLEm+gBRgv5mumf0dhgFr2mDgZah1pqv1c1M4= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= -github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= -github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= -github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/tinylib/msgp v1.1.0 h1:9fQd+ICuRIu/ue4vxJZu6/LzxN0HwMds2nq/0cFvxHU= -github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= -github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= -github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/segment.go b/segment.go index 702214a..a164a27 100644 --- a/segment.go +++ b/segment.go @@ -17,7 +17,6 @@ package segment import ( "fmt" - "github.com/RoaringBitmap/roaring" index "github.com/blevesearch/bleve_index_api" ) @@ -37,7 +36,7 @@ type Segment interface { Count() uint64 - DocNumbers([]string) (*roaring.Bitmap, error) + DocNumbers([]string) (Bitmap, error) Fields() []string @@ -60,7 +59,7 @@ type PersistedSegment interface { } type TermDictionary interface { - PostingsList(term []byte, except *roaring.Bitmap, prealloc PostingsList) (PostingsList, error) + PostingsList(term []byte, except Bitmap, prealloc PostingsList) (PostingsList, error) AutomatonIterator(a Automaton, startKeyInclusive, endKeyExclusive []byte) DictionaryIterator @@ -102,9 +101,9 @@ type PostingsIterator interface { } type OptimizablePostingsIterator interface { - ActualBitmap() *roaring.Bitmap + ActualBitmap() Bitmap DocNum1Hit() (uint64, bool) - ReplaceActual(*roaring.Bitmap) + ReplaceActual(Bitmap) } type Posting interface { From eee8a064ebbcd98d889940deccb1317ef0317956 Mon Sep 17 00:00:00 2001 From: Marty Schoch Date: Wed, 17 Feb 2021 15:09:06 -0500 Subject: [PATCH 2/2] fix gofmt --- bitmap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitmap.go b/bitmap.go index b2fb6d2..01e0df0 100644 --- a/bitmap.go +++ b/bitmap.go @@ -19,7 +19,7 @@ type Bitmap interface { // these methods manipulate the bitmap Add(uint32) AddMany([]uint32) - AddRange(uint64, uint64) + AddRange(uint64, uint64) And(Bitmap) AndNot(Bitmap) Clone() Bitmap