mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
33 lines
679 B
Go
33 lines
679 B
Go
package clauses
|
|
|
|
import (
|
|
"context"
|
|
"github.com/MontFerret/ferret/pkg/runtime/collections"
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
)
|
|
|
|
type LimitClause struct {
|
|
*baseClause
|
|
count int
|
|
offset int
|
|
}
|
|
|
|
func NewLimitClause(
|
|
src core.SourceMap,
|
|
dataSource collections.IterableExpression,
|
|
count int,
|
|
offset int,
|
|
) *LimitClause {
|
|
return &LimitClause{&baseClause{src, dataSource}, count, offset}
|
|
}
|
|
|
|
func (clause *LimitClause) Iterate(ctx context.Context, scope *core.Scope) (collections.Iterator, error) {
|
|
src, err := clause.dataSource.Iterate(ctx, scope)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return collections.NewLimitIterator(src, clause.count, clause.offset)
|
|
}
|