本文整理汇总了Java中org.apache.drill.exec.expr.annotations.Param类的典型用法代码示例。如果您正苦于以下问题:Java Param类的具体用法?Java Param怎么用?Java Param使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Param类属于org.apache.drill.exec.expr.annotations包,在下文中一共展示了Param类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateFunction
import org.apache.drill.exec.expr.annotations.Param; //导入依赖的package包/类
public static ValueHolder evaluateFunction(DrillSimpleFunc interpreter, ValueHolder[] args, String funcName) throws Exception {
Preconditions.checkArgument(interpreter != null, "interpreter could not be null when use interpreted model to evaluate function " + funcName);
// the current input index to assign into the next available parameter, found using the @Param notation
// the order parameters are declared in the java class for the DrillFunc is meaningful
int currParameterIndex = 0;
Field outField = null;
try {
Field[] fields = interpreter.getClass().getDeclaredFields();
for (Field f : fields) {
// if this is annotated as a parameter to the function
if ( f.getAnnotation(Param.class) != null ) {
f.setAccessible(true);
if (currParameterIndex < args.length) {
f.set(interpreter, args[currParameterIndex]);
}
currParameterIndex++;
} else if ( f.getAnnotation(Output.class) != null ) {
f.setAccessible(true);
outField = f;
// create an instance of the holder for the output to be stored in
f.set(interpreter, f.getType().newInstance());
}
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
if (args.length != currParameterIndex ) {
throw new DrillRuntimeException(
String.format("Wrong number of parameters provided to interpreted expression evaluation " +
"for function %s, expected %d parameters, but received %d.",
funcName, currParameterIndex, args.length));
}
if (outField == null) {
throw new DrillRuntimeException("Malformed DrillFunction without a return type: " + funcName);
}
interpreter.setup();
interpreter.eval();
ValueHolder out = (ValueHolder) outField.get(interpreter);
return out;
}