@Internal public class HiveGenericUDAF extends AggregateFunction<Object,org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer> implements HiveFunction
Constructor and Description |
---|
HiveGenericUDAF(HiveFunctionWrapper funcWrapper,
boolean isUDAFBridgeRequired,
String hiveVersion) |
HiveGenericUDAF(HiveFunctionWrapper funcWrapper,
String hiveVersion) |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer acc,
Object... inputs) |
org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer |
createAccumulator()
This is invoked without calling open() in Blink, so we need to call init() for getNewAggregationBuffer().
|
TypeInformation<org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer> |
getAccumulatorType()
Returns the
TypeInformation of the UserDefinedAggregateFunction 's accumulator. |
DataType |
getHiveResultType(Object[] constantArguments,
DataType[] argTypes)
Get result type by arguments and argTypes.
|
TypeInformation |
getResultType()
Returns the
TypeInformation of the UserDefinedAggregateFunction 's result. |
Object |
getValue(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer accumulator)
Called every time when an aggregation result should be materialized.
|
void |
merge(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer accumulator,
Iterable<org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer> its) |
void |
open(FunctionContext context)
Setup method for user-defined function.
|
void |
setArgumentTypesAndConstants(Object[] constantArguments,
DataType[] argTypes)
Set arguments and argTypes for Function instance.
|
getKind, getRequirements, requiresOver
close, functionIdentifier, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isDeterministic
public HiveGenericUDAF(HiveFunctionWrapper funcWrapper, String hiveVersion)
public HiveGenericUDAF(HiveFunctionWrapper funcWrapper, boolean isUDAFBridgeRequired, String hiveVersion)
public void open(FunctionContext context) throws Exception
UserDefinedFunction
open
in class UserDefinedFunction
Exception
public org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer createAccumulator()
createAccumulator
in class UserDefinedAggregateFunction<Object,org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer>
public void accumulate(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer acc, Object... inputs) throws org.apache.hadoop.hive.ql.metadata.HiveException
org.apache.hadoop.hive.ql.metadata.HiveException
public void merge(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer accumulator, Iterable<org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer> its) throws org.apache.hadoop.hive.ql.metadata.HiveException
org.apache.hadoop.hive.ql.metadata.HiveException
public Object getValue(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer accumulator)
AggregateFunction
getValue
in class AggregateFunction<Object,org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer>
accumulator
- the accumulator which contains the current
aggregated resultspublic void setArgumentTypesAndConstants(Object[] constantArguments, DataType[] argTypes)
HiveFunction
setArgumentTypesAndConstants
in interface HiveFunction
constantArguments
- arguments of a function call (only literal arguments
are passed, nulls for non-literal ones)argTypes
- types of argumentspublic DataType getHiveResultType(Object[] constantArguments, DataType[] argTypes)
HiveFunction
We can't use getResultType(Object[], Class[]). The Class[] is the classes of what is defined in eval(), for example, if eval() is "public Integer eval(Double)", the argTypes would be Class[Double]. However, in our wrapper, the signature of eval() is "public Object eval(Object... args)", which means we cannot get any info from the interface.
getHiveResultType
in interface HiveFunction
constantArguments
- arguments of a function call (only literal arguments
are passed, nulls for non-literal ones)argTypes
- types of argumentspublic TypeInformation getResultType()
UserDefinedAggregateFunction
TypeInformation
of the UserDefinedAggregateFunction
's result.getResultType
in class UserDefinedAggregateFunction<Object,org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer>
TypeInformation
of the UserDefinedAggregateFunction
's result or
null
if the result type should be automatically inferred.public TypeInformation<org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer> getAccumulatorType()
UserDefinedAggregateFunction
TypeInformation
of the UserDefinedAggregateFunction
's accumulator.getAccumulatorType
in class UserDefinedAggregateFunction<Object,org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.AggregationBuffer>
TypeInformation
of the UserDefinedAggregateFunction
's accumulator
or null
if the accumulator type should be automatically inferred.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.