mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-10 04:47:53 +00:00
trim the ranked cache set on the 1st recalculate call
This commit is contained in:
parent
4e7c2af572
commit
9321637d18
2 changed files with 4 additions and 6 deletions
1
cache.go
1
cache.go
|
|
@ -211,6 +211,7 @@ func (c *RankCache) recalculate() {
|
|||
c.rankings = rankings
|
||||
if len(c.rankings) > c.ThresholdIndex {
|
||||
c.ThresholdValue = rankings[c.ThresholdIndex].Count
|
||||
c.rankings = c.rankings[0:c.ThresholdIndex]
|
||||
} else {
|
||||
c.ThresholdValue = 1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,16 +309,13 @@ func TestFragment_TopN_CacheSize(t *testing.T) {
|
|||
|
||||
p := []pilosa.Pair{
|
||||
{Key: 104, Count: 7},
|
||||
{Key: 103, Count: 6},
|
||||
{Key: 102, Count: 5}}
|
||||
// {Key: 101, Count: 4},
|
||||
// {Key: 100, Count: 3}}
|
||||
{Key: 103, Count: 6}}
|
||||
|
||||
// Retrieve top bitmaps.
|
||||
if pairs, err := f.Top(pilosa.TopOptions{N: 5}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if len(pairs) != cacheLimit {
|
||||
t.Fatalf("TopN count cannot exceed cache size: %d", len(pairs))
|
||||
} else if len(pairs) > cacheLimit {
|
||||
t.Fatalf("TopN count cannot exceed cache size: %d", cacheLimit)
|
||||
} else if pairs[0] != (pilosa.Pair{Key: 104, Count: 7}) {
|
||||
t.Fatalf("unexpected pair(0): %v", pairs)
|
||||
} else if !reflect.DeepEqual(pairs, p) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue