handle TopFill correctly for TopNAll queries (i.e. no filter)

This commit is contained in:
travisturner 2014-09-29 12:28:19 -05:00
parent 181215b493
commit 26bdd96552
3 changed files with 15 additions and 7 deletions

View file

@ -102,7 +102,7 @@ func (self *Service) TopFillHandler(msg *db.Message) { //in order for this to ge
topfill := msg.Data.(TopFill)
topn, err := self.Index.TopFillBatch(topfill.Args)
if err != nil {
log.Println("TopFileHandler:", err)
log.Println("TopFillHandler:", err)
}
result_message := db.Message{Data: query.FillResult{&query.BaseQueryResult{Id: &topfill.QueryId, Data: topn}}}

View file

@ -306,11 +306,19 @@ func (self *CmdTopFill) Execute(f *Fragment) Calculation {
for _, v := range self.args.Bitmaps {
if f.exists(v) {
a := f.NewHandle(v)
res := f.intersect([]BitmapHandle{self.args.Handle, a})
bm, _ := f.getBitmap(res)
bc := BitCount(bm)
if bc > 0 {
result = append(result, Pair{v, bc})
if self.args.Handle == 0 {
// return just the count
bm, _ := f.getBitmap(a)
if bm.Count() > 0 {
result = append(result, Pair{v, bm.Count()})
}
} else {
res := f.intersect([]BitmapHandle{self.args.Handle, a})
bm, _ := f.getBitmap(res)
bc := BitCount(bm)
if bc > 0 {
result = append(result, Pair{v, bc})
}
}
}
}

View file

@ -186,7 +186,7 @@ func (self *FragmentContainer) TopNAll(frag_id util.SUUID, n int, categories []u
}
func (self *FragmentContainer) TopFillBatch(args []FillArgs) ([]Pair, error) {
//should probaly make this concurrent but then all hell breaks lose
//should probaly make this concurrent but then all hell breaks loose
results := make(map[uint64]uint64)
for _, v := range args {
items, _ := self.TopFillFragment(v)