mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-05 08:10:50 +00:00
don't panic if 'n' not supplied to TopN
This commit is contained in:
parent
5048fa1d72
commit
6216c4fb8a
1 changed files with 5 additions and 2 deletions
|
|
@ -168,7 +168,10 @@ func (e *Executor) executeBitmapCallSlice(ctx context.Context, db string, c *pql
|
|||
// requeries to retrieve the full counts for each of the top results.
|
||||
func (e *Executor) executeTopN(ctx context.Context, db string, c *pql.Call, slices []uint64, opt *ExecOptions) ([]Pair, error) {
|
||||
bitmapIDs, _ := c.Args["ids"].([]uint64)
|
||||
n := c.Args["n"].(uint64)
|
||||
var n uint64
|
||||
if nval, ok := c.Args["n"]; ok {
|
||||
n = nval.(uint64)
|
||||
}
|
||||
|
||||
// Execute original query.
|
||||
pairs, err := e.executeTopNSlices(ctx, db, c, slices, opt)
|
||||
|
|
@ -197,7 +200,7 @@ func (e *Executor) executeTopN(ctx context.Context, db string, c *pql.Call, slic
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if int(n) < len(trimmedList) {
|
||||
if n != 0 && int(n) < len(trimmedList) {
|
||||
trimmedList = trimmedList[0:n]
|
||||
}
|
||||
return trimmedList, nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue