mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 04:17:51 +00:00
Refactor roaring repair operations
This commit is contained in:
parent
34b1f2199f
commit
71621e60ba
2 changed files with 16 additions and 6 deletions
|
|
@ -156,11 +156,9 @@ func (sc *sliceContainers) Iterator(key uint64) (citer ContainerIterator, found
|
|||
return &sliceIterator{e: sc, i: i}, found
|
||||
}
|
||||
|
||||
func (sc *sliceContainers) repairBitmaps() {
|
||||
func (sc *sliceContainers) Repair() {
|
||||
for _, c := range sc.containers {
|
||||
if c.isBitmap() {
|
||||
c.bitmapRepair()
|
||||
}
|
||||
c.Repair()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,12 @@ type Containers interface {
|
|||
|
||||
Count() uint64
|
||||
|
||||
//Reset will clear the containers collection to allow for recycling during snapshot
|
||||
// Reset will clear the containers collection to allow for recycling during snapshot
|
||||
Reset()
|
||||
|
||||
// Repair will repair the cardinality of any containers whose cardinality were corrupted
|
||||
// due to optimized operations.
|
||||
Repair()
|
||||
}
|
||||
|
||||
type ContainerIterator interface {
|
||||
|
|
@ -687,7 +691,7 @@ func (b *Bitmap) unionIntoTarget(target *Bitmap, others ...*Bitmap) {
|
|||
// n (container cardinality) to fall out of sync, and then at the very end we perform
|
||||
// a "Repair" to recalculate all the container values. That way we never popcount()
|
||||
// an entire bitmap container more than once per bulk union operation.
|
||||
target.Containers.(*sliceContainers).repairBitmaps()
|
||||
target.Containers.Repair()
|
||||
}
|
||||
|
||||
// Difference returns the difference of b and other.
|
||||
|
|
@ -2091,6 +2095,14 @@ func (c *Container) check() error {
|
|||
return a
|
||||
}
|
||||
|
||||
// Repair repairs the cardinality of c if it has been corrupted by
|
||||
// optimized operations.
|
||||
func (c *Container) Repair() {
|
||||
if c.isBitmap() {
|
||||
c.bitmapRepair()
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Container) bitmapRepair() {
|
||||
n := int32(0)
|
||||
// Manually unroll loop to make it a little faster.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue