コード例 #1
0
ファイル: distinct.go プロジェクト: pkdevboxy/query
func NewDistinct(collect bool) *Distinct {
	rv := &Distinct{
		base:    newBase(),
		set:     value.NewSet(_DISTINCT_CAP),
		collect: collect,
	}

	rv.output = rv
	return rv
}
コード例 #2
0
ファイル: func_array.go プロジェクト: jmptrader/query
/*
This method returns the input array with distinct elements.
If the input value is of type missing return a missing
value, and for all non array values return null. Create
a new set and add all distinct values to the set. Return it.
*/
func (this *ArrayDistinct) Apply(context Context, arg value.Value) (value.Value, error) {
	if arg.Type() == value.MISSING {
		return value.MISSING_VALUE, nil
	} else if arg.Type() != value.ARRAY {
		return value.NULL_VALUE, nil
	}

	aa := arg.Actual().([]interface{})
	set := value.NewSet(len(aa))
	for _, a := range aa {
		set.Add(value.NewValue(a))
	}

	return value.NewValue(set.Actuals()), nil
}
コード例 #3
0
ファイル: agg_util.go プロジェクト: pkdevboxy/query
/*
Add input item to the cumulative set. Get the set. If
no errors enountered add the item to the set and return
it. If set has not been initialized yet, create a new set
with capacity _OBJECT_CAP and add the item. Return the
set value.
*/
func setAdd(item, cumulative value.Value) (value.AnnotatedValue, error) {
	av, ok := cumulative.(value.AnnotatedValue)
	if !ok {
		av = value.NewAnnotatedValue(cumulative)
	}

	set, e := getSet(av)
	if e == nil {
		set.Add(item)
		return av, nil
	}

	set = value.NewSet(_OBJECT_CAP)
	set.Add(item)
	av.SetAttachment("set", set)
	return av, nil
}
コード例 #4
0
ファイル: distinct.go プロジェクト: pkdevboxy/query
func (this *Distinct) Copy() Operator {
	return &Distinct{
		base: this.base.copy(),
		set:  value.NewSet(_DISTINCT_CAP),
	}
}