summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/RoaringBitmap
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-05-10 07:40:54 +0200
committerGitHub <noreply@github.com>2020-05-10 06:40:54 +0100
commitfdf750e4d4273620e774d03db087ab0dd4eef8c5 (patch)
tree3185d56c8cdbdce9fdd5d320062fed16bee65db9 /vendor/github.com/RoaringBitmap
parenta44854c287ac7127a73ea2790716311ba918dd1d (diff)
downloadgitea-fdf750e4d4273620e774d03db087ab0dd4eef8c5.tar.gz
gitea-fdf750e4d4273620e774d03db087ab0dd4eef8c5.zip
[Vendor] blevesearch v0.8.1 -> v1.0.7 (#11360)
* Update blevesearch v0.8.1 -> v1.0.7 * make vendor Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'vendor/github.com/RoaringBitmap')
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/.travis.yml1
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/README.md10
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/arraycontainer.go12
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go12
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/roaring.go85
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/roaringarray.go17
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/runcontainer.go12
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/setutil.go1
-rw-r--r--vendor/github.com/RoaringBitmap/roaring/util.go2
9 files changed, 128 insertions, 24 deletions
diff --git a/vendor/github.com/RoaringBitmap/roaring/.travis.yml b/vendor/github.com/RoaringBitmap/roaring/.travis.yml
index 8839c14fd0..c17804322b 100644
--- a/vendor/github.com/RoaringBitmap/roaring/.travis.yml
+++ b/vendor/github.com/RoaringBitmap/roaring/.travis.yml
@@ -14,6 +14,7 @@ go:
- "1.10.x"
- "1.11.x"
- "1.12.x"
+- "1.13.x"
- tip
# whitelist
diff --git a/vendor/github.com/RoaringBitmap/roaring/README.md b/vendor/github.com/RoaringBitmap/roaring/README.md
index b711d09ec2..94fdf057e5 100644
--- a/vendor/github.com/RoaringBitmap/roaring/README.md
+++ b/vendor/github.com/RoaringBitmap/roaring/README.md
@@ -29,11 +29,17 @@ Roaring bitmaps are found to work well in many important applications:
The ``roaring`` Go library is used by
-* [Cloud Torrent](https://github.com/jpillora/cloud-torrent): a self-hosted remote torrent client
-* [runv](https://github.com/hyperhq/runv): an Hypervisor-based runtime for the Open Containers Initiative
+* [Cloud Torrent](https://github.com/jpillora/cloud-torrent)
+* [runv](https://github.com/hyperhq/runv)
* [InfluxDB](https://www.influxdata.com)
* [Pilosa](https://www.pilosa.com/)
* [Bleve](http://www.blevesearch.com)
+* [lindb](https://github.com/lindb/lindb)
+* [Elasticell](https://github.com/deepfabric/elasticell)
+* [SourceGraph](https://github.com/sourcegraph/sourcegraph)
+* [M3](https://github.com/m3db/m3)
+* [trident](https://github.com/NetApp/trident)
+
This library is used in production in several systems, it is part of the [Awesome Go collection](https://awesome-go.com).
diff --git a/vendor/github.com/RoaringBitmap/roaring/arraycontainer.go b/vendor/github.com/RoaringBitmap/roaring/arraycontainer.go
index 621616f5df..eb124f3b76 100644
--- a/vendor/github.com/RoaringBitmap/roaring/arraycontainer.go
+++ b/vendor/github.com/RoaringBitmap/roaring/arraycontainer.go
@@ -24,6 +24,18 @@ func (ac *arrayContainer) fillLeastSignificant16bits(x []uint32, i int, mask uin
}
}
+func (ac *arrayContainer) iterate(cb func(x uint16) bool) bool {
+ iterator := shortIterator{ac.content, 0}
+
+ for iterator.hasNext() {
+ if !cb(iterator.next()) {
+ return false
+ }
+ }
+
+ return true
+}
+
func (ac *arrayContainer) getShortIterator() shortPeekable {
return &shortIterator{ac.content, 0}
}
diff --git a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go b/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go
index e749721bb2..cd259fd2d9 100644
--- a/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go
+++ b/vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go
@@ -96,6 +96,18 @@ func (bc *bitmapContainer) maximum() uint16 {
return uint16(0)
}
+func (bc *bitmapContainer) iterate(cb func(x uint16) bool) bool {
+ iterator := bitmapContainerShortIterator{bc, bc.NextSetBit(0)}
+
+ for iterator.hasNext() {
+ if !cb(iterator.next()) {
+ return false
+ }
+ }
+
+ return true
+}
+
type bitmapContainerShortIterator struct {
ptr *bitmapContainer
i int
diff --git a/vendor/github.com/RoaringBitmap/roaring/roaring.go b/vendor/github.com/RoaringBitmap/roaring/roaring.go
index df58cc30b5..ed75d58b97 100644
--- a/vendor/github.com/RoaringBitmap/roaring/roaring.go
+++ b/vendor/github.com/RoaringBitmap/roaring/roaring.go
@@ -416,6 +416,38 @@ func (rb *Bitmap) String() string {
return buffer.String()
}
+// Iterate iterates over the bitmap, calling the given callback with each value in the bitmap. If the callback returns
+// false, the iteration is halted.
+// The iteration results are undefined if the bitmap is modified (e.g., with Add or Remove).
+// There is no guarantee as to what order the values will be iterated
+func (rb *Bitmap) Iterate(cb func(x uint32) bool) {
+ for i := 0; i < rb.highlowcontainer.size(); i++ {
+ hs := uint32(rb.highlowcontainer.getKeyAtIndex(i)) << 16
+ c := rb.highlowcontainer.getContainerAtIndex(i)
+
+ var shouldContinue bool
+ // This is hacky but it avoids allocations from invoking an interface method with a closure
+ switch t := c.(type) {
+ case *arrayContainer:
+ shouldContinue = t.iterate(func(x uint16) bool {
+ return cb(uint32(x) | hs)
+ })
+ case *runContainer16:
+ shouldContinue = t.iterate(func(x uint16) bool {
+ return cb(uint32(x) | hs)
+ })
+ case *bitmapContainer:
+ shouldContinue = t.iterate(func(x uint16) bool {
+ return cb(uint32(x) | hs)
+ })
+ }
+
+ if !shouldContinue {
+ break
+ }
+ }
+}
+
// Iterator creates a new IntPeekable to iterate over the integers contained in the bitmap, in sorted order;
// the iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).
func (rb *Bitmap) Iterator() IntPeekable {
@@ -475,41 +507,72 @@ func (rb *Bitmap) Equals(o interface{}) bool {
// AddOffset adds the value 'offset' to each and every value in a bitmap, generating a new bitmap in the process
func AddOffset(x *Bitmap, offset uint32) (answer *Bitmap) {
- containerOffset := highbits(offset)
- inOffset := lowbits(offset)
+ return AddOffset64(x, int64(offset))
+}
+
+// AddOffset64 adds the value 'offset' to each and every value in a bitmap, generating a new bitmap in the process
+// If offset + element is outside of the range [0,2^32), that the element will be dropped
+func AddOffset64(x *Bitmap, offset int64) (answer *Bitmap) {
+ // we need "offset" to be a long because we want to support values
+ // between -0xFFFFFFFF up to +-0xFFFFFFFF
+ var containerOffset64 int64
+
+ if offset < 0 {
+ containerOffset64 = (offset - (1 << 16) + 1) / (1 << 16)
+ } else {
+ containerOffset64 = offset >> 16
+ }
+
+ if containerOffset64 >= (1<<16) || containerOffset64 <= -(1<<16) {
+ return New()
+ }
+
+ containerOffset := int32(containerOffset64)
+ inOffset := (uint16)(offset - containerOffset64*(1<<16))
+
if inOffset == 0 {
answer = x.Clone()
for pos := 0; pos < answer.highlowcontainer.size(); pos++ {
- key := answer.highlowcontainer.getKeyAtIndex(pos)
+ key := int32(answer.highlowcontainer.getKeyAtIndex(pos))
key += containerOffset
- answer.highlowcontainer.keys[pos] = key
+
+ if key >= 0 && key <= MaxUint16 {
+ answer.highlowcontainer.keys[pos] = uint16(key)
+ }
}
} else {
answer = New()
+
for pos := 0; pos < x.highlowcontainer.size(); pos++ {
- key := x.highlowcontainer.getKeyAtIndex(pos)
+ key := int32(x.highlowcontainer.getKeyAtIndex(pos))
key += containerOffset
+
c := x.highlowcontainer.getContainerAtIndex(pos)
offsetted := c.addOffset(inOffset)
- if offsetted[0].getCardinality() > 0 {
+
+ if offsetted[0].getCardinality() > 0 && (key >= 0 && key <= MaxUint16) {
curSize := answer.highlowcontainer.size()
- lastkey := uint16(0)
+ lastkey := int32(0)
+
if curSize > 0 {
- lastkey = answer.highlowcontainer.getKeyAtIndex(curSize - 1)
+ lastkey = int32(answer.highlowcontainer.getKeyAtIndex(curSize - 1))
}
+
if curSize > 0 && lastkey == key {
prev := answer.highlowcontainer.getContainerAtIndex(curSize - 1)
orrseult := prev.ior(offsetted[0])
answer.highlowcontainer.setContainerAtIndex(curSize-1, orrseult)
} else {
- answer.highlowcontainer.appendContainer(key, offsetted[0], false)
+ answer.highlowcontainer.appendContainer(uint16(key), offsetted[0], false)
}
}
- if offsetted[1].getCardinality() > 0 {
- answer.highlowcontainer.appendContainer(key+1, offsetted[1], false)
+
+ if offsetted[1].getCardinality() > 0 && ((key+1) >= 0 && (key+1) <= MaxUint16) {
+ answer.highlowcontainer.appendContainer(uint16(key+1), offsetted[1], false)
}
}
}
+
return answer
}
diff --git a/vendor/github.com/RoaringBitmap/roaring/roaringarray.go b/vendor/github.com/RoaringBitmap/roaring/roaringarray.go
index d9d5edda73..3dddbffdbc 100644
--- a/vendor/github.com/RoaringBitmap/roaring/roaringarray.go
+++ b/vendor/github.com/RoaringBitmap/roaring/roaringarray.go
@@ -4,9 +4,10 @@ import (
"bytes"
"encoding/binary"
"fmt"
+ "io"
+
snappy "github.com/glycerine/go-unsnap-stream"
"github.com/tinylib/msgp/msgp"
- "io"
)
//go:generate msgp -unexported
@@ -38,6 +39,7 @@ type container interface {
inot(firstOfRange, endx int) container // i stands for inplace, range is [firstOfRange,endx)
xor(r container) container
getShortIterator() shortPeekable
+ iterate(cb func(x uint16) bool) bool
getReverseIterator() shortIterable
getManyIterator() manyIterable
contains(i uint16) bool
@@ -488,20 +490,15 @@ func (ra *roaringArray) writeTo(w io.Writer) (n int64, err error) {
nw += 2
binary.LittleEndian.PutUint16(buf[2:], uint16(len(ra.keys)-1))
nw += 2
-
- // compute isRun bitmap
- var ir []byte
-
- isRun := newBitmapContainer()
+ // compute isRun bitmap without temporary allocation
+ var runbitmapslice = buf[nw:nw+isRunSizeInBytes]
for i, c := range ra.containers {
switch c.(type) {
case *runContainer16:
- isRun.iadd(uint16(i))
+ runbitmapslice[i / 8] |= 1<<(uint(i)%8)
}
}
- // convert to little endian
- ir = isRun.asLittleEndianByteSlice()[:isRunSizeInBytes]
- nw += copy(buf[nw:], ir)
+ nw += isRunSizeInBytes
} else {
binary.LittleEndian.PutUint32(buf[0:], uint32(serialCookieNoRunContainer))
nw += 4
diff --git a/vendor/github.com/RoaringBitmap/roaring/runcontainer.go b/vendor/github.com/RoaringBitmap/roaring/runcontainer.go
index cbffdaf24d..5a0f985f1d 100644
--- a/vendor/github.com/RoaringBitmap/roaring/runcontainer.go
+++ b/vendor/github.com/RoaringBitmap/roaring/runcontainer.go
@@ -1162,6 +1162,18 @@ func (rc *runContainer16) newRunIterator16() *runIterator16 {
return &runIterator16{rc: rc, curIndex: 0, curPosInIndex: 0}
}
+func (rc *runContainer16) iterate(cb func(x uint16) bool) bool {
+ iterator := runIterator16{rc, 0, 0}
+
+ for iterator.hasNext() {
+ if !cb(iterator.next()) {
+ return false
+ }
+ }
+
+ return true
+}
+
// hasNext returns false if calling next will panic. It
// returns true when there is at least one more value
// available in the iteration sequence.
diff --git a/vendor/github.com/RoaringBitmap/roaring/setutil.go b/vendor/github.com/RoaringBitmap/roaring/setutil.go
index 3e8c01dd1f..2fe8151411 100644
--- a/vendor/github.com/RoaringBitmap/roaring/setutil.go
+++ b/vendor/github.com/RoaringBitmap/roaring/setutil.go
@@ -14,6 +14,7 @@ func equal(a, b []uint16) bool {
func difference(set1 []uint16, set2 []uint16, buffer []uint16) int {
if 0 == len(set2) {
+ buffer = buffer[:len(set1)]
for k := 0; k < len(set1); k++ {
buffer[k] = set1[k]
}
diff --git a/vendor/github.com/RoaringBitmap/roaring/util.go b/vendor/github.com/RoaringBitmap/roaring/util.go
index 3a9a47236b..6763033916 100644
--- a/vendor/github.com/RoaringBitmap/roaring/util.go
+++ b/vendor/github.com/RoaringBitmap/roaring/util.go
@@ -112,7 +112,7 @@ func highbits(x uint32) uint16 {
return uint16(x >> 16)
}
func lowbits(x uint32) uint16 {
- return uint16(x & 0xFFFF)
+ return uint16(x & maxLowBit)
}
const maxLowBit = 0xFFFF