Examples of DrillFuncHolder


Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

  private class EvalVisitor extends AbstractExprVisitor<HoldingContainer, CodeGenerator<?>, RuntimeException> {

   
    @Override
    public HoldingContainer visitFunctionCall(FunctionCall call, CodeGenerator<?> generator) throws RuntimeException {
      DrillFuncHolder holder = registry.getFunction(call);
      JVar[] workspaceVars = holder.renderStart(generator, null);

     
      if(holder.isNested()) generator.getMappingSet().enterChild();
      HoldingContainer[] args = new HoldingContainer[call.args.size()];
      for (int i = 0; i < call.args.size(); i++) {
        args[i] = call.args.get(i).accept(this, generator);
      }
      holder.renderMiddle(generator, args, workspaceVars);
      if(holder.isNested()) generator.getMappingSet().exitChild();
      return holder.renderEnd(generator, args, workspaceVars);
    }
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

        castArgs.add(new ValueExpressions.LongExpression(fromExpr.getMajorType().getScale(), null));
      }

      FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
      FunctionResolver resolver = FunctionResolverFactory.getResolver(castCall);
      DrillFuncHolder matchedCastFuncHolder = registry.findDrillFunction(resolver, castCall);

      if (matchedCastFuncHolder == null) {
        logFunctionResolutionError(errorCollector, castCall);
        return NullExpression.INSTANCE;
      }

      return matchedCastFuncHolder.getExpr(castFuncName, castArgs, ExpressionPosition.UNKNOWN);

    }
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

      //replace with a new function call, since its argument could be changed.
      call = new FunctionCall(call.getName(), args, call.getPosition());

      FunctionResolver resolver = FunctionResolverFactory.getResolver(call);
      DrillFuncHolder matchedFuncHolder = registry.findDrillFunction(resolver, call);

      if (matchedFuncHolder instanceof DrillComplexWriterFuncHolder && ! allowComplexWriter) {
        errorCollector.addGeneralError(call.getPosition(), "Only ProjectRecordBatch could have complex writer function. You are using complex writer function " + call.getName() + " in a non-project operation!");
      }
     
      //new arg lists, possible with implicit cast inserted.
      List<LogicalExpression> argsWithCast = Lists.newArrayList();

      if (matchedFuncHolder!=null) {
        //Compare parm type against arg type. Insert cast on top of arg, whenever necessary.
        for (int i = 0; i < call.args.size(); ++i) {

          LogicalExpression currentArg = call.args.get(i);

          TypeProtos.MajorType parmType = matchedFuncHolder.getParmMajorType(i);

          //Case 1: If  1) the argument is NullExpression
          //            2) the parameter of matchedFuncHolder allows null input, or func's null_handling is NULL_IF_NULL (means null and non-null are exchangable).
          //        then replace NullExpression with a TypedNullConstant
          if (currentArg.equals(NullExpression.INSTANCE) &&
            ( parmType.getMode().equals(TypeProtos.DataMode.OPTIONAL) ||
              matchedFuncHolder.getNullHandling() == FunctionTemplate.NullHandling.NULL_IF_NULL)) {
            argsWithCast.add(new TypedNullConstant(parmType));
          } else if (Types.softEquals(parmType, currentArg.getMajorType(), matchedFuncHolder.getNullHandling() == FunctionTemplate.NullHandling.NULL_IF_NULL) ||
                     matchedFuncHolder.isFieldReader(i)) {
            //Case 2: argument and parameter matches, or parameter is FieldReader.  Do nothing.
            argsWithCast.add(currentArg);
          } else {
            //Case 3: insert cast if param type is different from arg type.
            argsWithCast.add(addCastExpression(call.args.get(i), parmType, registry));
          }
        }

        return matchedFuncHolder.getExpr(call.getName(), argsWithCast, call.getPosition());
      }

      // as no drill func is found, search for a non-Drill function.
      AbstractFuncHolder matchedNonDrillFuncHolder = registry.findNonDrillFunction(call);
      if (matchedNonDrillFuncHolder != null) {
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

        FunctionImplementationRegistry registry) {
      String funcName = "convertToNullable" + minorType.toString();
      FunctionCall funcCall = new FunctionCall(funcName, args, ExpressionPosition.UNKNOWN);
      FunctionResolver resolver = FunctionResolverFactory.getResolver(funcCall);

      DrillFuncHolder matchedConvertToNullableFuncHolder = registry.findDrillFunction(resolver, funcCall);

      if (matchedConvertToNullableFuncHolder == null) {
        logFunctionResolutionError(errorCollector, funcCall);
        return NullExpression.INSTANCE;
      }

      return matchedConvertToNullableFuncHolder.getExpr(funcName, args, ExpressionPosition.UNKNOWN);
    }
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

  @Override
  public DrillFuncHolder getBestMatch(List<DrillFuncHolder> methods,FunctionCall call) {
   
    int bestcost = Integer.MAX_VALUE;
    int currcost = Integer.MAX_VALUE;
    DrillFuncHolder bestmatch = null;

    for (DrillFuncHolder h : methods) {

      currcost = TypeCastRules.getCost(call, h);
     
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

        "hash",
        args,
        ExpressionPosition.UNKNOWN
    );
    FunctionResolver resolver = FunctionResolverFactory.getResolver(call);
    DrillFuncHolder matchedFuncHolder = registry.findDrillFunction(resolver, call);
    assertEquals( expectedBestInputMode, matchedFuncHolder.getParmMajorType(0).getMode());
  }
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

        "hash",
        args,
        ExpressionPosition.UNKNOWN
    );
    FunctionResolver resolver = FunctionResolverFactory.getResolver(call);
    DrillFuncHolder matchedFuncHolder = registry.findDrillFunction(resolver, call);
    assertEquals( expectedBestInputMode, matchedFuncHolder.getParmMajorType(0).getMode());
  }
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

    Set<Class<? extends DrillFunc>> providerClasses = PathScanner.scanForImplementations(DrillFunc.class, config.getStringList(ExecConstants.FUNCTION_PACKAGES));

    int count = 0;
    for (Class<? extends DrillFunc> clazz : providerClasses) {
      try {
        DrillFuncHolder holder = converter.getHolder(clazz);

        if (holder != null && holder instanceof DrillSimpleFuncHolder) {
          InterpreterGenerator generator = new InterpreterGenerator((DrillSimpleFuncHolder)holder, clazz.getSimpleName() + InterpreterGenerator.INTERPRETER_CLASSNAME_POSTFIX, targetSrcDir);
          generator.build();
          count ++;
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

  @Override
  public DrillFuncHolder getBestMatch(List<DrillFuncHolder> methods,FunctionCall call) {

    int bestcost = Integer.MAX_VALUE;
    int currcost = Integer.MAX_VALUE;
    DrillFuncHolder bestmatch = null;

    for (DrillFuncHolder h : methods) {

      currcost = TypeCastRules.getCost(call, h);
View Full Code Here

Examples of org.apache.drill.exec.expr.fn.DrillFuncHolder

        castArgs.add(new ValueExpressions.LongExpression(fromExpr.getMajorType().getScale(), null));
      }

      FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
      FunctionResolver resolver = FunctionResolverFactory.getResolver(castCall);
      DrillFuncHolder matchedCastFuncHolder = registry.findDrillFunction(resolver, castCall);

      if (matchedCastFuncHolder == null) {
        logFunctionResolutionError(errorCollector, castCall);
        return NullExpression.INSTANCE;
      }

      return matchedCastFuncHolder.getExpr(castFuncName, castArgs, ExpressionPosition.UNKNOWN);

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.