updated dependencies
This commit is contained in:
parent
1410847c03
commit
cff4b58f6d
446 changed files with 57869 additions and 27621 deletions
78
vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go
generated
vendored
78
vendor/github.com/RoaringBitmap/roaring/bitmapcontainer.go
generated
vendored
|
|
@ -5,8 +5,6 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
//go:generate msgp -unexported
|
||||
|
||||
type bitmapContainer struct {
|
||||
cardinality int
|
||||
bitmap []uint64
|
||||
|
|
@ -115,7 +113,7 @@ type bitmapContainerShortIterator struct {
|
|||
|
||||
func (bcsi *bitmapContainerShortIterator) next() uint16 {
|
||||
j := bcsi.i
|
||||
bcsi.i = bcsi.ptr.NextSetBit(bcsi.i + 1)
|
||||
bcsi.i = bcsi.ptr.NextSetBit(uint(bcsi.i) + 1)
|
||||
return uint16(j)
|
||||
}
|
||||
func (bcsi *bitmapContainerShortIterator) hasNext() bool {
|
||||
|
|
@ -128,7 +126,7 @@ func (bcsi *bitmapContainerShortIterator) peekNext() uint16 {
|
|||
|
||||
func (bcsi *bitmapContainerShortIterator) advanceIfNeeded(minval uint16) {
|
||||
if bcsi.hasNext() && bcsi.peekNext() < minval {
|
||||
bcsi.i = bcsi.ptr.NextSetBit(int(minval))
|
||||
bcsi.i = bcsi.ptr.NextSetBit(uint(minval))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +264,7 @@ func bitmapEquals(a, b []uint64) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (bc *bitmapContainer) fillLeastSignificant16bits(x []uint32, i int, mask uint32) {
|
||||
func (bc *bitmapContainer) fillLeastSignificant16bits(x []uint32, i int, mask uint32) int {
|
||||
// TODO: should be written as optimized assembly
|
||||
pos := i
|
||||
base := mask
|
||||
|
|
@ -280,6 +278,7 @@ func (bc *bitmapContainer) fillLeastSignificant16bits(x []uint32, i int, mask ui
|
|||
}
|
||||
base += 64
|
||||
}
|
||||
return pos
|
||||
}
|
||||
|
||||
func (bc *bitmapContainer) equals(o container) bool {
|
||||
|
|
@ -351,6 +350,10 @@ func (bc *bitmapContainer) getCardinality() int {
|
|||
return bc.cardinality
|
||||
}
|
||||
|
||||
func (bc *bitmapContainer) isEmpty() bool {
|
||||
return bc.cardinality == 0
|
||||
}
|
||||
|
||||
func (bc *bitmapContainer) clone() container {
|
||||
ptr := bitmapContainer{bc.cardinality, make([]uint64, len(bc.bitmap))}
|
||||
copy(ptr.bitmap, bc.bitmap[:])
|
||||
|
|
@ -1009,20 +1012,23 @@ func (bc *bitmapContainer) fillArray(container []uint16) {
|
|||
}
|
||||
}
|
||||
|
||||
func (bc *bitmapContainer) NextSetBit(i int) int {
|
||||
x := i / 64
|
||||
if x >= len(bc.bitmap) {
|
||||
func (bc *bitmapContainer) NextSetBit(i uint) int {
|
||||
var (
|
||||
x = i / 64
|
||||
length = uint(len(bc.bitmap))
|
||||
)
|
||||
if x >= length {
|
||||
return -1
|
||||
}
|
||||
w := bc.bitmap[x]
|
||||
w = w >> uint(i%64)
|
||||
if w != 0 {
|
||||
return i + countTrailingZeros(w)
|
||||
return int(i) + countTrailingZeros(w)
|
||||
}
|
||||
x++
|
||||
for ; x < len(bc.bitmap); x++ {
|
||||
for ; x < length; x++ {
|
||||
if bc.bitmap[x] != 0 {
|
||||
return (x * 64) + countTrailingZeros(bc.bitmap[x])
|
||||
return int(x*64) + countTrailingZeros(bc.bitmap[x])
|
||||
}
|
||||
}
|
||||
return -1
|
||||
|
|
@ -1118,34 +1124,60 @@ func (bc *bitmapContainer) containerType() contype {
|
|||
return bitmapContype
|
||||
}
|
||||
|
||||
func (bc *bitmapContainer) addOffset(x uint16) []container {
|
||||
low := newBitmapContainer()
|
||||
high := newBitmapContainer()
|
||||
func (bc *bitmapContainer) addOffset(x uint16) (container, container) {
|
||||
var low, high *bitmapContainer
|
||||
|
||||
if bc.cardinality == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
b := uint32(x) >> 6
|
||||
i := uint32(x) % 64
|
||||
end := uint32(1024) - b
|
||||
|
||||
low = newBitmapContainer()
|
||||
if i == 0 {
|
||||
copy(low.bitmap[b:], bc.bitmap[:end])
|
||||
copy(high.bitmap[:b], bc.bitmap[end:])
|
||||
} else {
|
||||
low.bitmap[b] = bc.bitmap[0] << i
|
||||
for k := uint32(1); k < end; k++ {
|
||||
newval := bc.bitmap[k] << i
|
||||
if newval == 0 {
|
||||
newval = bc.bitmap[k-1] >> (64 - i)
|
||||
}
|
||||
newval |= bc.bitmap[k-1] >> (64 - i)
|
||||
low.bitmap[b+k] = newval
|
||||
}
|
||||
}
|
||||
low.computeCardinality()
|
||||
|
||||
if low.cardinality == bc.cardinality {
|
||||
// All elements from bc ended up in low, meaning high will be empty.
|
||||
return low, nil
|
||||
}
|
||||
|
||||
if low.cardinality == 0 {
|
||||
// low is empty, let's reuse the container for high.
|
||||
high = low
|
||||
low = nil
|
||||
} else {
|
||||
// None of the containers will be empty, so allocate both.
|
||||
high = newBitmapContainer()
|
||||
}
|
||||
|
||||
if i == 0 {
|
||||
copy(high.bitmap[:b], bc.bitmap[end:])
|
||||
} else {
|
||||
for k := end; k < 1024; k++ {
|
||||
newval := bc.bitmap[k] << i
|
||||
if newval == 0 {
|
||||
newval = bc.bitmap[k-1] >> (64 - i)
|
||||
}
|
||||
newval |= bc.bitmap[k-1] >> (64 - i)
|
||||
high.bitmap[k-end] = newval
|
||||
}
|
||||
high.bitmap[b] = bc.bitmap[1023] >> (64 - i)
|
||||
}
|
||||
low.computeCardinality()
|
||||
high.computeCardinality()
|
||||
return []container{low, high}
|
||||
|
||||
// Ensure proper nil interface.
|
||||
if low == nil {
|
||||
return nil, high
|
||||
}
|
||||
|
||||
return low, high
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue