本文整理汇总了Java中org.apache.drill.exec.expr.annotations.FunctionTemplate类的典型用法代码示例。如果您正苦于以下问题:Java FunctionTemplate类的具体用法?Java FunctionTemplate怎么用?Java FunctionTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionTemplate类属于org.apache.drill.exec.expr.annotations包,在下文中一共展示了FunctionTemplate类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:axbaretto,项目名称:drill,代码行数:32,代码来源:DecimalReturnTypeInference.java
示例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();
}
开发者ID:axbaretto,项目名称:drill,代码行数:21,代码来源:FunctionUtils.java
示例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;
}
开发者ID:axbaretto,项目名称:drill,代码行数:11,代码来源:FunctionAttributes.java
示例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);
}
}
}
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:31,代码来源:TestClassPathScanner.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalSetScaleFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalAddFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:7,代码来源:DrillDecimalMaxScaleFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalCastFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalDivScaleFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalSumScaleFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:DrillDecimalAggFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalZeroScaleFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:DrillDecimalSumAggFuncHolder.java
示例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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:DrillDecimalModScaleFuncHolder.java
示例15: getSelfCost
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
@Override
public int getSelfCost() {
return FunctionTemplate.FunctionCostCategory.getDefault().getValue();
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:HiveFuncHolderExpr.java
示例16: getReturnType
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
public FunctionTemplate.ReturnType getReturnType() {
return template.returnType();
}
开发者ID:axbaretto,项目名称:drill,代码行数:4,代码来源:FunctionAttributes.java
示例17: visitFunctionHolderExpression
import org.apache.drill.exec.expr.annotations.FunctionTemplate; //导入依赖的package包/类
@Override
public ValueHolder visitFunctionHolderExpression(FunctionHolderExpression holderExpr, Integer inIndex) {
if (! (holderExpr.getHolder() instanceof DrillSimpleFuncHolder)) {
throw new UnsupportedOperationException("Only Drill simple UDF can be used in interpreter mode!");
}
DrillSimpleFuncHolder holder = (DrillSimpleFuncHolder) holderExpr.getHolder();
ValueHolder [] args = new ValueHolder [holderExpr.args.size()];
for (int i = 0; i < holderExpr.args.size(); i++) {
args[i] = holderExpr.args.get(i).accept(this, inIndex);
// In case function use "NULL_IF_NULL" policy.
if (holder.getNullHandling() == FunctionTemplate.NullHandling.NULL_IF_NULL) {
// Case 1: parameter is non-nullable, argument is nullable.
if (holder.getParameters()[i].getType().getMode() == TypeProtos.DataMode.REQUIRED && TypeHelper.getValueHolderType(args[i]).getMode() == TypeProtos.DataMode.OPTIONAL) {
// Case 1.1 : argument is null, return null value holder directly.
if (TypeHelper.isNull(args[i])) {
return TypeHelper.createValueHolder(holderExpr.getMajorType());
} else {
// Case 1.2: argument is nullable but not null value, deNullify it.
args[i] = TypeHelper.deNullify(args[i]);
}
} else if (holder.getParameters()[i].getType().getMode() == TypeProtos.DataMode.OPTIONAL && TypeHelper.getValueHolderType(args[i]).getMode() == TypeProtos.DataMode.REQUIRED) {
// Case 2: parameter is nullable, argument is non-nullable. Nullify it.
args[i] = TypeHelper.nullify(args[i]);
}
}
}
try {
DrillSimpleFunc interpreter = ((DrillFuncHolderExpr) holderExpr).getInterpreter();
ValueHolder out = evaluateFunction(interpreter, args, holderExpr.getName());
if (TypeHelper.getValueHolderType(out).getMode() == TypeProtos.DataMode.OPTIONAL &&
holderExpr.getMajorType().getMode() == TypeProtos.DataMode.REQUIRED) {
return TypeHelper.deNullify(out);
} else if (TypeHelper.getValueHolderType(out).getMode() == TypeProtos.DataMode.REQUIRED &&
holderExpr.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
return TypeHelper.nullify(out);
} else {
return out;
}
} catch (Exception ex) {
throw new RuntimeException("Error in evaluating function of " + holderExpr.getName(), ex);
}
}
开发者ID:axbaretto,项目名称:drill,代码行数:50,代码来源:InterpreterEvaluator.java
注:本文中的org.apache.drill.exec.expr.annotations.FunctionTemplate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论