mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 03:47:51 +00:00
off by one take two
This commit is contained in:
parent
5557f529a7
commit
7ec48f2385
2 changed files with 7 additions and 7 deletions
|
|
@ -224,7 +224,7 @@ func dump(r RankList, n int) {
|
|||
func (self *Brand) TopNAll(n int, categories []uint64) []Pair {
|
||||
|
||||
self.checkRank()
|
||||
results := make([]Pair, n+1)
|
||||
results := make([]Pair, 0, 0)
|
||||
|
||||
category := NewIntSet()
|
||||
needCat := false
|
||||
|
|
@ -244,10 +244,10 @@ func (self *Brand) TopNAll(n int, categories []uint64) []Pair {
|
|||
if count >= n {
|
||||
break
|
||||
}
|
||||
results[count] = Pair{pair.Key, pair.Count}
|
||||
results = append(results, Pair{pair.Key, pair.Count})
|
||||
count++
|
||||
}
|
||||
return results[:count]
|
||||
return results
|
||||
}
|
||||
|
||||
func (self *Brand) TopNCat(src_bitmap IBitmap, n int, category *IntSet) []Pair {
|
||||
|
|
|
|||
|
|
@ -141,17 +141,17 @@ func (self *General) Load(requestChan chan Command, f *Fragment) {
|
|||
|
||||
func (self *General) TopNAll(n int, categories []uint64) []Pair {
|
||||
|
||||
results := make([]Pair, n)
|
||||
results := make([]Pair, 0, 0)
|
||||
|
||||
count := 0
|
||||
for k, _ := range self.keys {
|
||||
|
||||
if count > n {
|
||||
if count >= n {
|
||||
break
|
||||
}
|
||||
bm := self.Get(k)
|
||||
results[count] = Pair{k, bm.Count()}
|
||||
results = append(results, Pair{k, bm.Count()})
|
||||
count++
|
||||
}
|
||||
return results[:count]
|
||||
return results
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue