public abstract class DrillFuncHolder extends AbstractFuncHolder
| Constructor and Description |
|---|
DrillFuncHolder(FunctionAttributes attributes,
FunctionInitializer initializer) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addProtectedBlock(ClassGenerator<?> g,
com.sun.codemodel.JBlock sub,
String body,
ClassGenerator.HoldingContainer[] inputVariables,
com.sun.codemodel.JVar[] workspaceJVars,
boolean workspaceOnly)
Generate the function block itself, without surrounding comments, and
whether or not the method is empty.
|
protected void |
assignInjectableValue(ClassGenerator<?> g,
com.sun.codemodel.JVar variable,
WorkspaceReference ref) |
protected void |
checkNullHandling(FunctionTemplate.NullHandling nullHandling)
Check if function type supports provided null handling strategy.
|
boolean |
checkPrecisionRange() |
protected com.sun.codemodel.JAssignmentTarget |
declare(com.sun.codemodel.JBlock jBlock,
ValueReference parameter,
com.sun.codemodel.JType paramClass,
com.sun.codemodel.JExpression paramExpression,
int currentIndex)
Declares specified
paramExpression in specified jBlock
and assigns it to the array component if required and / or returns declared expression. |
protected void |
declareInputVariable(com.sun.codemodel.JCodeModel model,
com.sun.codemodel.JBlock jBlock,
ClassGenerator.HoldingContainer inputVariable,
int currentIndex)
Generate the top part of a function call which simulates passing parameters
into the function.
|
protected void |
declareVarArgArray(com.sun.codemodel.JCodeModel model,
com.sun.codemodel.JBlock jBlock,
ClassGenerator.HoldingContainer[] inputVariables)
Declares array for storing vararg function arguments.
|
protected com.sun.codemodel.JVar[] |
declareWorkspaceVariables(ClassGenerator<?> g) |
protected void |
generateBody(ClassGenerator<?> g,
ClassGenerator.BlockType bt,
String body,
ClassGenerator.HoldingContainer[] inputVariables,
com.sun.codemodel.JVar[] workspaceJVars,
boolean workspaceOnly)
Generate the body of a Drill function by copying the source code of the
corresponding function method into the generated output.
|
ValueReference |
getAttributeParameter(int i)
Returns i-th function attribute parameter.
|
ClassLoader |
getClassLoader() |
int |
getCostCategory() |
FunctionHolderExpression |
getExpr(String name,
List<LogicalExpression> args,
ExpressionPosition pos)
Return a reference to this function given a function alias and a
list of actual arguments.
|
String |
getInputParameters()
Generates string representation of function input parameters:
PARAMETER_TYPE_1-PARAMETER_MODE_1,PARAMETER_TYPE_2-PARAMETER_MODE_2
Example: VARCHAR-REQUIRED,VARCHAR-OPTIONAL
Returns empty string if function has no input parameters.
|
FunctionTemplate.NullHandling |
getNullHandling() |
OutputWidthCalculator |
getOutputWidthCalculator() |
int |
getParamCount()
Number of defined input parameters.
|
ValueReference[] |
getParameters() |
TypeProtos.MajorType |
getParamMajorType(int i)
Drill SQL type of an input parameter.
|
String[] |
getRegisteredNames() |
TypeProtos.MajorType |
getReturnType() |
TypeProtos.MajorType |
getReturnType(List<LogicalExpression> logicalExpressions) |
ValueReference |
getReturnValue() |
WorkspaceReference[] |
getWorkspaceVars() |
boolean |
isAggregating() |
boolean |
isConstant(int i) |
boolean |
isDeterministic() |
boolean |
isFieldReader(int i) |
boolean |
isInternal() |
boolean |
isNiladic() |
boolean |
isVarArg() |
boolean |
matches(TypeProtos.MajorType returnType,
List<TypeProtos.MajorType> argTypes) |
protected String |
meth(String methodName) |
protected String |
meth(String methodName,
boolean required) |
com.sun.codemodel.JVar[] |
renderStart(ClassGenerator<?> g,
ClassGenerator.HoldingContainer[] inputVariables,
FieldReference fieldReference) |
String |
toString() |
int |
variableOutputSizeEstimate() |
isComplexWriterFuncHolder, isNested, renderEnd, renderMiddlepublic DrillFuncHolder(FunctionAttributes attributes, FunctionInitializer initializer)
protected void checkNullHandling(FunctionTemplate.NullHandling nullHandling)
Keep in mind that this method is invoked in
DrillFuncHolder(FunctionAttributes, FunctionInitializer)
constructor so make sure not to use any state fields when overriding the
method to avoid uninitialized state.
nullHandling - null handling strategy defined for a functionIllegalArgumentException - if provided nullHandling is not supportedpublic com.sun.codemodel.JVar[] renderStart(ClassGenerator<?> g, ClassGenerator.HoldingContainer[] inputVariables, FieldReference fieldReference)
renderStart in class AbstractFuncHolderpublic FunctionHolderExpression getExpr(String name, List<LogicalExpression> args, ExpressionPosition pos)
FuncHoldername - alias used in this specific callargs - expressions of the actual function argumentspublic boolean isAggregating()
public boolean isDeterministic()
public boolean isNiladic()
public boolean isInternal()
public boolean isVarArg()
public String getInputParameters()
public ClassLoader getClassLoader()
protected com.sun.codemodel.JVar[] declareWorkspaceVariables(ClassGenerator<?> g)
protected void assignInjectableValue(ClassGenerator<?> g, com.sun.codemodel.JVar variable, WorkspaceReference ref)
protected void generateBody(ClassGenerator<?> g, ClassGenerator.BlockType bt, String body, ClassGenerator.HoldingContainer[] inputVariables, com.sun.codemodel.JVar[] workspaceJVars, boolean workspaceOnly)
To make this work, the function body is wrapped in a code block that simulates the class fields by declaring local variables of the same name, and assigning those variables based on the input and workspace variables provided.
This version is used for blocks other than the main eval block.
g - code generatorbt - type of the block to be addedbody - source code of the block. Optional. Block will be omitted
if the method body is null or emptyinputVariables - list of input variable bindings which match up to declared
@Param member variables in order. The input variables have the
same name as the parameters that they representworkspaceJVars - list of workspace variables, structures the same as
input variablesworkspaceOnly - true if this is a setup block and
we should declare only constant workspace variables, false to
declare all variablesprotected void addProtectedBlock(ClassGenerator<?> g, com.sun.codemodel.JBlock sub, String body, ClassGenerator.HoldingContainer[] inputVariables, com.sun.codemodel.JVar[] workspaceJVars, boolean workspaceOnly)
protected void declareVarArgArray(com.sun.codemodel.JCodeModel model,
com.sun.codemodel.JBlock jBlock,
ClassGenerator.HoldingContainer[] inputVariables)
model - code model to generate the codejBlock - block of code to be populatedinputVariables - array of input variables for current functionprotected void declareInputVariable(com.sun.codemodel.JCodeModel model,
com.sun.codemodel.JBlock jBlock,
ClassGenerator.HoldingContainer inputVariable,
int currentIndex)
public static class UnionIsBigInt implements DrillSimpleFunc {model - code model to generate the codejBlock - block of code to be populatedinputVariable - input variable for current functioncurrentIndex - index of current parameterprotected com.sun.codemodel.JAssignmentTarget declare(com.sun.codemodel.JBlock jBlock,
ValueReference parameter,
com.sun.codemodel.JType paramClass,
com.sun.codemodel.JExpression paramExpression,
int currentIndex)
paramExpression in specified jBlock
and assigns it to the array component if required and / or returns declared expression.jBlock - target block where declaration is addedparameter - function parameter which should be declaredparamClass - type of the declared variableparamExpression - expression to be declaredcurrentIndex - index of current parameterpublic boolean matches(TypeProtos.MajorType returnType, List<TypeProtos.MajorType> argTypes)
public TypeProtos.MajorType getParamMajorType(int i)
FuncHolderpublic int getParamCount()
FuncHolderpublic boolean isConstant(int i)
public ValueReference getAttributeParameter(int i)
i - index of function attribute parameter to be returnedpublic boolean isFieldReader(int i)
public TypeProtos.MajorType getReturnType(List<LogicalExpression> logicalExpressions)
public OutputWidthCalculator getOutputWidthCalculator()
public int variableOutputSizeEstimate()
public FunctionTemplate.NullHandling getNullHandling()
public String[] getRegisteredNames()
public int getCostCategory()
public ValueReference[] getParameters()
public boolean checkPrecisionRange()
public TypeProtos.MajorType getReturnType()
public ValueReference getReturnValue()
public WorkspaceReference[] getWorkspaceVars()
Copyright © 2021 The Apache Software Foundation. All rights reserved.