private static Pair<GroupByDesc,VectorGroupByDesc> buildGroupByDescCountStar( VectorizationContext ctx) { AggregationDesc agg = buildAggregationDescCountStar(ctx); ArrayList<AggregationDesc> aggs = new ArrayList<AggregationDesc>(); aggs.add(agg); ArrayList<String> outputColumnNames = new ArrayList<String>(); outputColumnNames.add("_col0"); GroupByDesc desc = new GroupByDesc(); VectorGroupByDesc vectorDesc = new VectorGroupByDesc(); vectorDesc.setVecAggrDescs( new VectorAggregationDesc[] { new VectorAggregationDesc( agg.getGenericUDAFName(), new GenericUDAFCount.GenericUDAFCountEvaluator(), agg.getMode(), null, ColumnVector.Type.NONE, null, TypeInfoFactory.longTypeInfo, ColumnVector.Type.LONG, VectorUDAFCountStar.class)}); vectorDesc.setProcessingMode(VectorGroupByDesc.ProcessingMode.HASH); desc.setOutputColumnNames(outputColumnNames); desc.setAggregators(aggs); return new Pair<GroupByDesc,VectorGroupByDesc>(desc, vectorDesc); }
private static AggregationDesc buildAggregationDescCountStar( VectorizationContext ctx) { AggregationDesc agg = new AggregationDesc(); agg.setGenericUDAFName("count"); agg.setMode(GenericUDAFEvaluator.Mode.PARTIAL1); agg.setParameters(new ArrayList<ExprNodeDesc>()); agg.setGenericUDAFEvaluator(new GenericUDAFCount.GenericUDAFCountEvaluator()); return agg; }
switch (aggregate) { case "count": evaluator = new GenericUDAFCount.GenericUDAFCountEvaluator(); break; case "min":
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo paramInfo) throws SemanticException { TypeInfo[] parameters = paramInfo.getParameters(); if (parameters.length == 0) { if (!paramInfo.isAllColumns()) { throw new UDFArgumentException("Argument expected"); } assert !paramInfo.isDistinct() : "DISTINCT not supported with *"; } else { if (parameters.length > 1 && !paramInfo.isDistinct()) { throw new UDFArgumentException("DISTINCT keyword must be specified"); } assert !paramInfo.isAllColumns() : "* not supported in expression list"; } return new GenericUDAFCountEvaluator().setCountAllColumns( paramInfo.isAllColumns()); }
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo paramInfo) throws SemanticException { TypeInfo[] parameters = paramInfo.getParameters(); if (parameters.length == 0) { if (!paramInfo.isAllColumns()) { throw new UDFArgumentException("Argument expected"); } assert !paramInfo.isDistinct() : "DISTINCT not supported with *"; } else { if (parameters.length > 1 && !paramInfo.isDistinct()) { throw new UDFArgumentException("DISTINCT keyword must be specified"); } assert !paramInfo.isAllColumns() : "* not supported in expression list"; } return new GenericUDAFCountEvaluator().setCountAllColumns( paramInfo.isAllColumns()); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo paramInfo) throws SemanticException { TypeInfo[] parameters = paramInfo.getParameters(); if (parameters.length == 0) { if (!paramInfo.isAllColumns()) { throw new UDFArgumentException("Argument expected"); } assert !paramInfo.isDistinct() : "DISTINCT not supported with *"; } else { if (parameters.length > 1 && !paramInfo.isDistinct()) { throw new UDFArgumentException("DISTINCT keyword must be specified"); } assert !paramInfo.isAllColumns() : "* not supported in expression list"; } GenericUDAFCountEvaluator countEvaluator = new GenericUDAFCountEvaluator(); countEvaluator.setWindowing(paramInfo.isWindowing()); countEvaluator.setCountAllColumns(paramInfo.isAllColumns()); countEvaluator.setCountDistinct(paramInfo.isDistinct()); return countEvaluator; }
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo paramInfo) throws SemanticException { TypeInfo[] parameters = paramInfo.getParameters(); if (parameters.length == 0) { if (!paramInfo.isAllColumns()) { throw new UDFArgumentException("Argument expected"); } assert !paramInfo.isDistinct() : "DISTINCT not supported with *"; } else { if (parameters.length > 1 && !paramInfo.isDistinct()) { throw new UDFArgumentException("DISTINCT keyword must be specified"); } assert !paramInfo.isAllColumns() : "* not supported in expression list"; } GenericUDAFCountEvaluator countEvaluator = new GenericUDAFCountEvaluator(); countEvaluator.setWindowing(paramInfo.isWindowing()); countEvaluator.setCountAllColumns(paramInfo.isAllColumns()); countEvaluator.setCountDistinct(paramInfo.isDistinct()); return countEvaluator; }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }