switch (aggregate) { case "count": evaluator = new GenericUDAFCount.GenericUDAFCountEvaluator(); break; case "min":
if (countThisRow && isWindowingDistinct()) { HashSet<ObjectInspectorObject> uniqueObjs = ((CountAgg) agg).uniqueObjects; ObjectInspectorObject obj = new ObjectInspectorObject(
Assert.assertTrue(partial1Evaluator instanceof GenericUDAFCountEvaluator); GenericUDAFCountEvaluator countEvaluator = (GenericUDAFCountEvaluator) partial1Evaluator; countEvaluator.setCountAllColumns(true);
@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 Object terminatePartial(AggregationBuffer agg) throws HiveException { return terminate(agg); } }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }
@Override public Object terminatePartial(AggregationBuffer agg) throws HiveException { return terminate(agg); } }
@Override public AggregationBuffer getNewAggregationBuffer() throws HiveException { CountAgg buffer = new CountAgg(); reset(buffer); return buffer; }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }
@Override public AggregationBuffer getNewAggregationBuffer() throws HiveException { CountAgg buffer = new CountAgg(); reset(buffer); return buffer; }
if (countThisRow && isWindowingDistinct()) { if (((CountAgg) agg).uniqueObjects == null) { ((CountAgg) agg).uniqueObjects = new HashSet<ObjectInspectorObject>();
@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; }
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); }
@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 void merge(AggregationBuffer agg, Object partial) throws HiveException { if (partial != null) { CountAgg countAgg = (CountAgg) agg; if (isWindowingDistinct()) { throw new HiveException("Distinct windowing UDAF doesn't support merge and terminatePartial"); } else { long p = partialCountAggOI.get(partial); countAgg.value += p; } } }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { // This method implementation is preserved for backward compatibility. return new GenericUDAFCountEvaluator(); }
@Override public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException { if (parameters[0] == null || parameters[1] == null) return; super.iterate(agg, new Object[] { parameters[0] }); } }
@Override public Object terminatePartial(AggregationBuffer agg) throws HiveException { if (isWindowingDistinct()) { throw new HiveException("Distinct windowing UDAF doesn't support merge and terminatePartial"); } else { return terminate(agg); } } }
@Override public AggregationBuffer getNewAggregationBuffer() throws HiveException { CountAgg buffer = new CountAgg(); reset(buffer); return buffer; }