mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
fix count() cache retrieval
This commit is contained in:
parent
07a815eb55
commit
76af8b53a3
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