mirror of
https://github.com/MontFerret/ferret.git
synced 2025-12-21 23:27:30 +02:00
29 lines
602 B
Go
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)
|
||
|
|
}
|