Exemple #1
0
    /*
     * Iterate over the Symbol Functions in the Chain:
     * - If we are not at the end of the Iterator (i.e. row != null )
     * - match the current componentFn
     * - if it returns false, then return false
     * - otherwise set row to the next row from the Iterator.
     * - if we are at the end of the Iterator
     * - skip any optional Symbol Fns (star patterns) at the end.
     * - but if we come to a non optional Symbol Fn, return false.
     * - if we match all Fns in the chain return true.
     */
    @Override
    protected SymbolFunctionResult match(Object row, PTFPartitionIterator<Object> pItr)
        throws HiveException {
      SymbolFunctionResult componentResult = null;
      for (SymbolFunction sFn : components) {
        if (row != null) {
          componentResult = sFn.match(row, pItr);
          if (!componentResult.matches) {
            result.matches = false;
            result.nextRow = componentResult.nextRow;
            return result;
          }
          row = pItr.resetToIndex(componentResult.nextRow);
        } else {
          if (!sFn.isOptional()) {
            result.matches = false;
            result.nextRow = componentResult.nextRow;
            return result;
          }
        }
      }

      result.matches = true;
      result.nextRow = componentResult.nextRow;
      return result;
    }
Exemple #2
0
    @Override
    protected SymbolFunctionResult match(Object row, PTFPartitionIterator<Object> pItr)
        throws HiveException {
      result.matches = true;
      SymbolFunctionResult rowResult = symbolFn.match(row, pItr);

      while (rowResult.matches && pItr.hasNext()) {
        row = pItr.next();
        rowResult = symbolFn.match(row, pItr);
      }

      result.nextRow = pItr.getIndex();
      if (pItr.hasNext()) {
        result.nextRow -= 1;
      }
      return result;
    }
Exemple #3
0
 public static SymbolFunctionResult match(
     SymbolFunction syFn, Object row, PTFPartitionIterator<Object> pItr) throws HiveException {
   int resetToIdx = pItr.getIndex() - 1;
   try {
     return syFn.match(row, pItr);
   } finally {
     pItr.resetToIndex(resetToIdx);
   }
 }
Exemple #4
0
  @Override
  public void execute(PTFPartitionIterator<Object> pItr, PTFPartition outP) throws HiveException {
    while (pItr.hasNext()) {
      Object iRow = pItr.next();

      SymbolFunctionResult syFnRes = SymbolFunction.match(syFn, iRow, pItr);
      if (syFnRes.matches) {
        int sz = syFnRes.nextRow - (pItr.getIndex() - 1);
        Object selectListInput =
            MatchPath.getSelectListInput(
                iRow, tableDef.getInput().getOutputShape().getOI(), pItr, sz);
        ArrayList<Object> oRow = new ArrayList<Object>();
        for (ExprNodeEvaluator resExprEval : resultExprInfo.resultExprEvals) {
          oRow.add(resExprEval.evaluate(selectListInput));
        }
        outP.append(oRow);
      }
    }
  }