コード例 #1
0
ファイル: agg_array.go プロジェクト: amarantha-k/query
/*
Compute the Final result after sorting(post processing).
*/
func (this *ArrayAgg) ComputeFinal(cumulative value.Value, context Context) (value.Value, error) {
	if cumulative == value.NULL_VALUE {
		return cumulative, nil
	}

	sort.Sort(value.NewSorter(cumulative))
	return cumulative, nil
}
コード例 #2
0
ファイル: func_array.go プロジェクト: amarantha-k/query
/*
This method sorts the input array value, in N1QL collation
order. It uses the Sort method in the sort package. If the
input value is of type missing return a missing value, and
for all non array values return null.
*/
func (this *ArraySort) 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
	}

	cv := arg.Copy()
	sorter := value.NewSorter(cv)
	sort.Sort(sorter)
	return cv, nil
}
コード例 #3
0
/*
Compute the Final result. If input cumulative value is null return
it. Get the attachment, create a new value and add it to the set
in a sorted manner. (The values in the set are distinct).
*/
func (this *ArrayAggDistinct) ComputeFinal(cumulative value.Value, context Context) (c value.Value, e error) {
	if cumulative == value.NULL_VALUE {
		return cumulative, nil
	}

	av := cumulative.(value.AnnotatedValue)
	set := av.GetAttachment("set").(*value.Set)
	if set.Len() == 0 {
		return value.NULL_VALUE, nil
	}

	actuals := set.Actuals()
	c = value.NewValue(actuals)
	sorter := value.NewSorter(c)
	sort.Sort(sorter)
	return c, nil
}