Search in sources :

Example 1 with CountDistinctPRQueryNode

use of org.apache.geode.cache.query.internal.aggregate.CountDistinctPRQueryNode in project geode by apache.

the class CompiledAggregateFunction method evaluate.

@Override
public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
    boolean isPRQueryNode = context.getIsPRQueryNode();
    boolean isBucketNode = context.getBucketList() != null;
    switch(this.aggFuncType) {
        case OQLLexerTokenTypes.SUM:
            if (isPRQueryNode) {
                return this.distinctOnly ? new SumDistinctPRQueryNode() : new Sum();
            } else {
                return this.distinctOnly ? (isBucketNode ? new DistinctAggregator() : new SumDistinct()) : new Sum();
            }
        case OQLLexerTokenTypes.MAX:
            return new MaxMin(true);
        case OQLLexerTokenTypes.MIN:
            return new MaxMin(false);
        case OQLLexerTokenTypes.AVG:
            if (isPRQueryNode) {
                return this.distinctOnly ? new AvgDistinctPRQueryNode() : new AvgPRQueryNode();
            } else {
                return this.distinctOnly ? (isBucketNode ? new DistinctAggregator() : new AvgDistinct()) : (isBucketNode ? new AvgBucketNode() : new Avg());
            }
        case OQLLexerTokenTypes.COUNT:
            if (isPRQueryNode) {
                return this.distinctOnly ? new CountDistinctPRQueryNode() : new CountPRQueryNode();
            } else {
                return this.distinctOnly ? (isBucketNode ? new DistinctAggregator() : new CountDistinct()) : new Count();
            }
        default:
            throw new UnsupportedOperationException("Aggregate function not implemented");
    }
}
Also used : Sum(org.apache.geode.cache.query.internal.aggregate.Sum) CountPRQueryNode(org.apache.geode.cache.query.internal.aggregate.CountPRQueryNode) Count(org.apache.geode.cache.query.internal.aggregate.Count) AvgDistinct(org.apache.geode.cache.query.internal.aggregate.AvgDistinct) SumDistinct(org.apache.geode.cache.query.internal.aggregate.SumDistinct) AvgBucketNode(org.apache.geode.cache.query.internal.aggregate.AvgBucketNode) DistinctAggregator(org.apache.geode.cache.query.internal.aggregate.DistinctAggregator) Avg(org.apache.geode.cache.query.internal.aggregate.Avg) AvgDistinctPRQueryNode(org.apache.geode.cache.query.internal.aggregate.AvgDistinctPRQueryNode) SumDistinctPRQueryNode(org.apache.geode.cache.query.internal.aggregate.SumDistinctPRQueryNode) CountDistinctPRQueryNode(org.apache.geode.cache.query.internal.aggregate.CountDistinctPRQueryNode) CountDistinct(org.apache.geode.cache.query.internal.aggregate.CountDistinct) MaxMin(org.apache.geode.cache.query.internal.aggregate.MaxMin) AvgPRQueryNode(org.apache.geode.cache.query.internal.aggregate.AvgPRQueryNode)

Aggregations

Avg (org.apache.geode.cache.query.internal.aggregate.Avg)1 AvgBucketNode (org.apache.geode.cache.query.internal.aggregate.AvgBucketNode)1 AvgDistinct (org.apache.geode.cache.query.internal.aggregate.AvgDistinct)1 AvgDistinctPRQueryNode (org.apache.geode.cache.query.internal.aggregate.AvgDistinctPRQueryNode)1 AvgPRQueryNode (org.apache.geode.cache.query.internal.aggregate.AvgPRQueryNode)1 Count (org.apache.geode.cache.query.internal.aggregate.Count)1 CountDistinct (org.apache.geode.cache.query.internal.aggregate.CountDistinct)1 CountDistinctPRQueryNode (org.apache.geode.cache.query.internal.aggregate.CountDistinctPRQueryNode)1 CountPRQueryNode (org.apache.geode.cache.query.internal.aggregate.CountPRQueryNode)1 DistinctAggregator (org.apache.geode.cache.query.internal.aggregate.DistinctAggregator)1 MaxMin (org.apache.geode.cache.query.internal.aggregate.MaxMin)1 Sum (org.apache.geode.cache.query.internal.aggregate.Sum)1 SumDistinct (org.apache.geode.cache.query.internal.aggregate.SumDistinct)1 SumDistinctPRQueryNode (org.apache.geode.cache.query.internal.aggregate.SumDistinctPRQueryNode)1