当前位置: 首页>>代码示例>>Java>>正文


Java Param类代码示例

本文整理汇总了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;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:43,代码来源:InterpreterEvaluator.java


注:本文中的org.apache.drill.exec.expr.annotations.Param类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。