本文整理汇总了Java中org.apache.drill.exec.expr.annotations.FunctionTemplate类的典型用法代码示例。如果您正苦于以下问题:Java FunctionTemplate类的具体用法?Java FunctionTemplate怎么用?Java FunctionTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionTemplate类属于org.apache.drill.exec.expr.annotations包,在下文中一共展示了FunctionTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
/**
* Return type is used for functions where we need to remove the scale part.
* For example, truncate and round functions.
*
* @param logicalExpressions logical expressions
* @param attributes function attributes
* @return return type
*/
@Override
public TypeProtos.MajorType getType(List<LogicalExpression> logicalExpressions, FunctionAttributes attributes) {
int precision = 0;
TypeProtos.DataMode mode = attributes.getReturnValue().getType().getMode();
if (attributes.getNullHandling() == FunctionTemplate.NullHandling.NULL_IF_NULL) {
// if any one of the input types is nullable, then return nullable return type
for (LogicalExpression e : logicalExpressions) {
if (e.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
mode = TypeProtos.DataMode.OPTIONAL;
}
precision = Math.max(precision, e.getMajorType().getPrecision());
}
}
return TypeProtos.MajorType.newBuilder()
.setMinorType(attributes.getReturnValue().getType().getMinorType())
.setScale(0)
.setPrecision(precision)
.setMode(mode)
.build();
}
示例2: getReturnTypeDataMode
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
/**
* Calculates return type data mode based on give logical expressions.
* If null handling strategy is internal, returns return value data mode.
* If null handling strategy is null if null and at least one of the input types are nullable,
* return nullable data mode.
*
* @param logicalExpressions logical expressions
* @param attributes function attributes
* @return data mode
*/
public static TypeProtos.DataMode getReturnTypeDataMode(final List<LogicalExpression> logicalExpressions, FunctionAttributes attributes) {
if (attributes.getNullHandling() == FunctionTemplate.NullHandling.NULL_IF_NULL) {
for (final LogicalExpression logicalExpression : logicalExpressions) {
if (logicalExpression.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
return TypeProtos.DataMode.OPTIONAL;
}
}
}
return attributes.getReturnValue().getType().getMode();
}
示例3: FunctionAttributes
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public FunctionAttributes (FunctionTemplate template,
ValueReference[] parameters,
ValueReference returnValue,
WorkspaceReference[] workspaceVars) {
this.template = template;
this.registeredNames = ((template.name().isEmpty()) ? template.names() : new String[] {template.name()});
this.parameters = parameters;
this.returnValue = returnValue;
this.workspaceVars = workspaceVars;
}
示例4: verifyAnnotations
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
private void verifyAnnotations(Annotation[] annotations, List<AnnotationDescriptor> scannedAnnotations) throws Exception {
assertEquals(Arrays.toString(annotations) + " expected but got " + scannedAnnotations, annotations.length, scannedAnnotations.size());
for (int i = 0; i < annotations.length; i++) {
Annotation annotation = annotations[i];
AnnotationDescriptor scannedAnnotation = scannedAnnotations.get(i);
Class<? extends Annotation> annotationType = annotation.annotationType();
assertEquals(annotationType.getName(), scannedAnnotation.getAnnotationType());
if (annotation instanceof FunctionTemplate) {
FunctionTemplate ft = (FunctionTemplate)annotation;
if (ft.name() != null && !ft.name().equals("")) {
assertEquals(ft.name(), scannedAnnotation.getSingleValue("name"));
}
}
// generally verify all properties
Annotation proxy = scannedAnnotation.getProxy(annotationType);
Method[] declaredMethods = annotationType.getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.getParameterTypes().length == 0) {
Object reflectValue = method.invoke(annotation);
Object byteCodeValue = method.invoke(proxy);
String message = annotationType.getSimpleName() + "." + method.getName();
if (method.getReturnType().isArray()) {
assertArrayEquals(message, (Object[])reflectValue, (Object[])byteCodeValue);
} else {
assertEquals(message, reflectValue, byteCodeValue);
}
}
}
}
}
示例5: DrillDecimalSetScaleFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalSetScaleFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例6: DrillDecimalAddFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalAddFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例7: DrillDecimalMaxScaleFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalMaxScaleFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars,
methods, imports, costCategory, drillFuncClass);
}
示例8: DrillDecimalCastFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalCastFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例9: DrillDecimalDivScaleFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalDivScaleFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例10: DrillDecimalSumScaleFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalSumScaleFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例11: DrillDecimalAggFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalAggFuncHolder(FunctionTemplate.FunctionScope scope, FunctionTemplate.NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom, String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars, Map<String, String> methods, List<String> imports) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports);
}
示例12: DrillDecimalZeroScaleFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalZeroScaleFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例13: DrillDecimalSumAggFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalSumAggFuncHolder(FunctionTemplate.FunctionScope scope, FunctionTemplate.NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom, String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars, Map<String, String> methods, List<String> imports) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports);
}
示例14: DrillDecimalModScaleFuncHolder
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public DrillDecimalModScaleFuncHolder(FunctionScope scope, NullHandling nullHandling, boolean isBinaryCommutative, boolean isRandom,
String[] registeredNames, ValueReference[] parameters, ValueReference returnValue, WorkspaceReference[] workspaceVars,
Map<String, String> methods, List<String> imports, FunctionTemplate.FunctionCostCategory costCategory, Class<? extends DrillSimpleFunc> drillFuncClass) {
super(scope, nullHandling, isBinaryCommutative, isRandom, registeredNames, parameters, returnValue, workspaceVars, methods, imports, costCategory, drillFuncClass);
}
示例15: getSelfCost
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
@Override
public int getSelfCost() {
return FunctionTemplate.FunctionCostCategory.getDefault().getValue();
}