mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
549b4abd3b
Implemented COLLECT key word
37 lines
540 B
Go
37 lines
540 B
Go
package collections
|
|
|
|
import (
|
|
"context"
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
)
|
|
|
|
type (
|
|
Variables []string
|
|
|
|
Iterator interface {
|
|
HasNext() bool
|
|
Next() (DataSet, error)
|
|
}
|
|
|
|
Iterable interface {
|
|
Variables() Variables
|
|
Iterate(ctx context.Context, scope *core.Scope) (Iterator, error)
|
|
}
|
|
)
|
|
|
|
func ToSlice(iterator Iterator) ([]DataSet, error) {
|
|
res := make([]DataSet, 0, 10)
|
|
|
|
for iterator.HasNext() {
|
|
ds, err := iterator.Next()
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
res = append(res, ds)
|
|
}
|
|
|
|
return res, nil
|
|
}
|