@PublicEvolving @Retention(value=RUNTIME) @Target(value={TYPE,METHOD}) @Repeatable(value=FunctionHints.class) public @interface FunctionHint
TypeInference
logic of a UserDefinedFunction
.
One or more annotations can be declared on top of a UserDefinedFunction
class or
individually for each eval()/accumulate()
method for overloading function signatures. All
hint parameters are optional. If a parameter is not defined, the default reflection-based
extraction is used. Hint parameters defined on top of a UserDefinedFunction
class are
inherited by all eval()/accumulate()
methods.
The following examples show how to explicitly specify function signatures as a whole or in part and let the default extraction do the rest:
{@code // accepts (INT, STRING) and returns BOOLEAN
DataTypeHint
Modifier and Type | Optional Element and Description |
---|---|
DataTypeHint |
accumulator
Explicitly defines the intermediate result type that a function uses as accumulator.
|
String[] |
argumentNames
Explicitly lists the argument names that a function takes as input.
|
DataTypeHint[] |
input
Explicitly lists the argument types that a function takes as input.
|
boolean |
isVarArgs
Defines that the last argument type defined in
input() should be treated as a
variable-length argument. |
DataTypeHint |
output
Explicitly defines the result type that a function uses as output.
|
public abstract DataTypeHint[] input
By default, explicit input types are undefined and the reflection-based extraction is used.
Note: Specifying the input arguments manually disables the entire reflection-based
extraction around arguments. This means that also isVarArgs()
and argumentNames()
need to be specified manually if required.
public abstract boolean isVarArgs
input()
should be treated as a
variable-length argument.
By default, if input()
is defined, the last argument type is not a var-arg. If
input()
is not defined, the reflection-based extraction is used to decide about the
var-arg flag, thus, this parameter is ignored.
public abstract String[] argumentNames
By default, if input()
is defined, explicit argument names are undefined and this
parameter can be used to provide argument names. If input()
is not defined, the
reflection-based extraction is used, thus, this parameter is ignored.
public abstract DataTypeHint accumulator
By default, an explicit accumulator type is undefined and the reflection-based extraction is used.
public abstract DataTypeHint output
By default, an explicit output type is undefined and the reflection-based extraction is used.
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.