1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/pkg/runtime/expressions/clauses/distinct.go
2018-10-07 01:23:35 -04:00

29 lines
602 B
Go

package clauses
import (
"context"
"github.com/MontFerret/ferret/pkg/runtime/collections"
"github.com/MontFerret/ferret/pkg/runtime/core"
)
type DistinctClause struct {
*baseClause
}
func NewDistinctClause(
src core.SourceMap,
dataSource collections.IterableExpression,
) *DistinctClause {
return &DistinctClause{&baseClause{src, dataSource}}
}
func (clause *DistinctClause) 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.NewUniqueIterator(src)
}