Exemple #1
0
    public Object terminate(
        AnalysisEvaluatorBuffer analysisEvaBuffer,
        ExprNodeEvaluator[] analysisParameterFields,
        AnalysisBuffer<Object> analysisBuffer,
        int currrowid,
        boolean absolute,
        BooleanTrans canternimate) {
      canternimate.set(true);
      RankAgg agg = (RankAgg) analysisEvaBuffer;
      if (agg.rowid == currrowid) {
        result.set(agg.rank);
        return result;
      }
      agg.rowid = currrowid;
      Object row = analysisBuffer.getByRowid(currrowid);
      ArrayList<Object> rowfull = ((ArrayList<Object>) row);
      row = rowfull.get(0);

      if (agg.firstrow) {
        agg.firstrow = false;
        agg.lastobj = new Object[analysisParameterFields.length];
        try {
          for (int i = 0; i < agg.lastobj.length; i++) {
            agg.lastobj[i] = analysisParameterFields[i].evaluate(row);
          }
        } catch (HiveException e) {
          e.printStackTrace();
        }
        agg.rank = agg.rowid + 1;
      } else {
        try {
          boolean newobj = false;
          Object[] objs = new Object[analysisParameterFields.length];
          for (int i = 0; i < objs.length; i++) {
            Object obj = analysisParameterFields[i].evaluate(row);
            if (ObjectInspectorUtils.compare(agg.lastobj[i], inputOI[i], obj, inputOI[i]) != 0) {
              newobj = true;
            }
            objs[i] = obj;
          }
          if (newobj) {
            agg.lastobj = objs;
            agg.rank = agg.rowid + 1;
          }
        } catch (HiveException e) {
          e.printStackTrace();
        }
      }
      result.set(agg.rank);
      return result;
    }
Exemple #2
0
  public int processLine(String line) {
    int lastRet = 0, ret = 0;

    String command = "";
    for (String oneCmd : line.split(";")) {

      if (StringUtils.endsWith(oneCmd, "\\")) {
        command += StringUtils.chop(oneCmd) + ";";
        continue;
      } else {
        command += oneCmd;
      }
      if (StringUtils.isBlank(command)) continue;

      try {
        ret = processCmd(command);
      } catch (TException e) {
        e.printStackTrace();
      } catch (HiveException e) {
        e.printStackTrace();
      }
      command = "";
      lastRet = ret;
      boolean ignoreErrors = HiveConf.getBoolVar(conf, HiveConf.ConfVars.CLIIGNOREERRORS);
      if (ret != 0 && !ignoreErrors) {
        return ret;
      }
    }
    return lastRet;
  }