Example #1
0
  @Override
  public void serviceInit(Configuration conf) throws Exception {

    Constructor<?> cons;
    try {
      if (conf instanceof TajoConf) {
        this.conf = (TajoConf) conf;
      } else {
        throw new TajoInternalError("conf must be a TajoConf instance");
      }

      Class<?> storeClass = this.conf.getClass(CatalogConstants.STORE_CLASS, DerbyStore.class);

      LOG.info("Catalog Store Class: " + storeClass.getCanonicalName());
      cons = storeClass.getConstructor(new Class[] {Configuration.class});

      this.store = (CatalogStore) cons.newInstance(this.conf);

      initBuiltinFunctions(builtingFuncs);
    } catch (Throwable t) {
      LOG.error("CatalogServer initialization failed", t);
      throw new TajoInternalError(t);
    }

    super.serviceInit(conf);
  }
Example #2
0
  private Method getEvaluateMethod(TajoDataTypes.DataType[] tajoParamTypes, Class<?> clazz) {
    Constructor constructor = clazz.getConstructors()[0];

    try {
      instance = constructor.newInstance();
    } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
      throw new TajoInternalError(e);
    }

    for (Method m : clazz.getMethods()) {
      if (m.getName().equals("evaluate")) {
        Class[] methodParamTypes = m.getParameterTypes();
        if (checkParamTypes(methodParamTypes, tajoParamTypes)) {
          return m;
        }
      }
    }

    throw new TajoInternalError(
        new UndefinedFunctionException(String.format("Hive UDF (%s)", clazz.getSimpleName())));
  }