diff --git a/cache.go b/cache.go index 3504806c6..23bc52c30 100644 --- a/cache.go +++ b/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 } diff --git a/fragment_test.go b/fragment_test.go index 56e2381e2..7f3d35add 100644 --- a/fragment_test.go +++ b/fragment_test.go @@ -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) {