mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 20:07:51 +00:00
roaring allowed import to merge with existing data
This commit is contained in:
parent
8254d0fadd
commit
156260e68e
1 changed files with 29 additions and 0 deletions
29
fragment.go
29
fragment.go
|
|
@ -1430,6 +1430,35 @@ func (f *fragment) importRoaringBytes(roaringBytes []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// get a list of keys in order to update the cache
|
||||
i, _ := bm.Containers.Iterator(0)
|
||||
set := make([]uint64, 0)
|
||||
var lastRow uint64 = math.MaxUint64
|
||||
|
||||
for i.Next() {
|
||||
key, _ := i.Value()
|
||||
|
||||
// virtual row for the current container
|
||||
vRow := key >> containersPerRowSegment
|
||||
|
||||
// skip dups
|
||||
if vRow == lastRow {
|
||||
continue
|
||||
}
|
||||
set = append(set, vRow)
|
||||
lastRow = vRow
|
||||
}
|
||||
|
||||
if f.storage.Count() > 0 {
|
||||
bm = f.storage.Union(bm)
|
||||
}
|
||||
|
||||
for _,rowID := range set {
|
||||
n := bm.CountRange(rowID*ShardWidth, (rowID+1)*ShardWidth)
|
||||
f.cache.BulkAdd(rowID, n)
|
||||
}
|
||||
|
||||
err = snapshot(f, bm)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue