mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
implemented count optimization for btree
This commit is contained in:
parent
1488ac0e3a
commit
aa71c08f12
2 changed files with 15 additions and 0 deletions
|
|
@ -121,6 +121,16 @@ func (btc *BTreeContainers) GetOrCreate(key uint64) *roaring.Container {
|
|||
return btc.lastContainer
|
||||
}
|
||||
|
||||
func (btc *BTreeContainers) Count() (n uint64) {
|
||||
e, _ := btc.tree.Seek(0)
|
||||
_, c, err := e.Next()
|
||||
for err != io.EOF {
|
||||
n += uint64(c.N())
|
||||
_, c, err = e.Next()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (btc *BTreeContainers) Clone() roaring.Containers {
|
||||
nbtc := NewBTreeContainers()
|
||||
|
||||
|
|
|
|||
|
|
@ -1026,6 +1026,11 @@ func (c *Container) Mapped() bool {
|
|||
return c.mapped
|
||||
}
|
||||
|
||||
// N returns the cached bit count of the container
|
||||
func (c *Container) N() int {
|
||||
return c.n
|
||||
}
|
||||
|
||||
// Update updates the container
|
||||
func (c *Container) Update(containerType byte, n int, mapped bool) {
|
||||
c.containerType = containerType
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue