コード例 #1
0
 @Override
 public List<Object[]> internalYield() throws LocalRunException {
   try {
     SecurityClient.open();
     udf.close();
   } catch (UDFException e) {
     throw new LocalRunException(e);
   } finally {
     SecurityClient.close();
   }
   // avoid user to call function again
   udf = null;
   return buffer;
 }
コード例 #2
0
  public UDFRunner(Odps odps, UDF udf) throws UDFException {
    super(odps);
    if (udf == null) {
      throw new IllegalArgumentException("Missing arguments:udf");
    }
    this.udf = udf;

    try {
      SecurityClient.open();
      udf.setup(context);
    } catch (Exception ex) {
      throw new UDFException(ex);
    } finally {
      SecurityClient.close();
    }
  }
コード例 #3
0
 @Override
 public BaseRunner internalFeed(Object[] input) throws LocalRunException {
   try {
     SecurityClient.open();
     if (evalMethod == null) {
       evalMethod = findMethod(udf.getClass(), input);
     }
     Object result = evalMethod.invoke(udf, input);
     buffer.add(new Object[] {result});
   } catch (InvocationTargetException e) {
     throw new LocalRunException(e);
   } catch (IllegalArgumentException e) {
     throw new LocalRunException(e);
   } catch (IllegalAccessException e) {
     throw new LocalRunException(e);
   } finally {
     SecurityClient.close();
   }
   return this;
 }
コード例 #4
0
  public UDFRunner(Odps odps, String className) throws LocalRunException {
    super(odps);
    if (StringUtils.isBlank(className)) {
      throw new IllegalArgumentException("Missing arguments:className");
    }

    try {
      udf = (UDF) ClassUtils.newInstance(UDFRunner.class.getClassLoader(), className);

      SecurityClient.open();
      udf.setup(context);

    } catch (LocalRunException e) {
      throw e;
    } catch (UDFException e) {
      throw new LocalRunException(e);
    } finally {
      SecurityClient.close();
    }
  }