mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
fix count() cache retrieval
This commit is contained in:
parent
96680a262c
commit
6ad7d0bfab
2 changed files with 12 additions and 1 deletions
3
cache.go
3
cache.go
|
|
@ -51,7 +51,8 @@ func (c *LRUCache) Add(bitmapID, n uint64) {
|
|||
// Get returns a bitmap with a given id.
|
||||
func (c *LRUCache) Get(bitmapID uint64) uint64 {
|
||||
n, _ := c.cache.Get(bitmapID)
|
||||
return n.(uint64)
|
||||
nn, _ := n.(uint64)
|
||||
return nn
|
||||
}
|
||||
|
||||
// Len returns the number of items in the cache.
|
||||
|
|
|
|||
10
fragment.go
10
fragment.go
|
|
@ -527,6 +527,16 @@ func (f *Fragment) topBitmapPairs(bitmapIDs []uint64) []BitmapPair {
|
|||
// Otherwise retrieve specific bitmaps.
|
||||
pairs := make([]BitmapPair, len(bitmapIDs))
|
||||
for i, bitmapID := range bitmapIDs {
|
||||
// Look up cache first, if available.
|
||||
if n := f.cache.Get(bitmapID); n > 0 {
|
||||
pairs[i] = BitmapPair{
|
||||
ID: bitmapID,
|
||||
Count: n,
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Otherwise load from storage.
|
||||
pairs[i] = BitmapPair{
|
||||
ID: bitmapID,
|
||||
Count: f.Bitmap(bitmapID).Count(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue