diff options
Diffstat (limited to 'internal/mapr')
| -rw-r--r-- | internal/mapr/globalgroupset.go | 4 | ||||
| -rw-r--r-- | internal/mapr/groupset.go | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/internal/mapr/globalgroupset.go b/internal/mapr/globalgroupset.go index 21bf990..50bac37 100644 --- a/internal/mapr/globalgroupset.go +++ b/internal/mapr/globalgroupset.go @@ -93,9 +93,9 @@ func (g *GlobalGroupSet) WriteResult(query *Query) error { } // Result returns the result of the mapreduce aggregation as a string. -func (g *GlobalGroupSet) Result(query *Query) (string, int, error) { +func (g *GlobalGroupSet) Result(query *Query, rowsLimit int) (string, int, error) { g.semaphore <- struct{}{} defer func() { <-g.semaphore }() - return g.GroupSet.Result(query) + return g.GroupSet.Result(query, rowsLimit) } diff --git a/internal/mapr/groupset.go b/internal/mapr/groupset.go index d29559a..9bff790 100644 --- a/internal/mapr/groupset.go +++ b/internal/mapr/groupset.go @@ -68,12 +68,16 @@ func (g *GroupSet) Serialize(ctx context.Context, ch chan<- string) { } // Result returns a nicely formated result of the query from the group set. -func (g *GroupSet) Result(query *Query) (string, int, error) { +func (g *GroupSet) Result(query *Query, rowsLimit int) (string, int, error) { rows, widths, err := g.result(query, true) if err != nil { return "", 0, err } + if query.Limit != -1 { + rowsLimit = query.Limit + } + sb := pool.BuilderBuffer.Get().(*strings.Builder) defer pool.RecycleBuilderBuffer(sb) @@ -141,7 +145,7 @@ func (g *GroupSet) Result(query *Query) (string, int, error) { // And now write the data for i, r := range rows { - if i == query.Limit { + if i == rowsLimit { break } for j, value := range r.values { |
