Ejemplo n.º 1
0
  /**
   * The tc could be inside something else, so find it recursively.
   *
   * @param wtrNode
   * @param wanted
   * @param current
   * @return
   */
  private Node getTc(Node wtrNode, int wanted, IntRef current) {

    for (int i = 0; i < wtrNode.getChildNodes().getLength(); i++) {

      Node thisChild = wtrNode.getChildNodes().item(i);

      log.debug("Looking at " + thisChild.getLocalName() + "; have encountered " + current.i);

      if (thisChild.getLocalName().equals("tc")) {
        if (current.i == wanted) return thisChild;
        current.increment();
      } else {
        // could be inside
        Node n = getTc(thisChild, wanted, current);
        if (n != null) return n;
      }
    }
    return null;
  }
Ejemplo n.º 2
0
  // TODO: 1) How to handle collisions? 2) Should we be cloning ColumnInfo or not?
  private static boolean add(
      RowResolver rrToAddTo, RowResolver rrToAddFrom, IntRef outputColPosRef, int numColumns)
      throws SemanticException {
    boolean hasDuplicates = false;
    String tabAlias;
    String colAlias;
    String[] qualifiedColName;
    int i = 0;

    int outputColPos = outputColPosRef == null ? 0 : outputColPosRef.val;
    for (ColumnInfo cInfoFrmInput : rrToAddFrom.getRowSchema().getSignature()) {
      if (numColumns >= 0 && i == numColumns) {
        break;
      }
      ColumnInfo newCI = null;
      String internalName = cInfoFrmInput.getInternalName();
      qualifiedColName = rrToAddFrom.reverseLookup(internalName);
      tabAlias = qualifiedColName[0];
      colAlias = qualifiedColName[1];

      newCI = new ColumnInfo(cInfoFrmInput);
      newCI.setInternalName(SemanticAnalyzer.getColumnInternalName(outputColPos));

      outputColPos++;

      boolean isUnique = rrToAddTo.putWithCheck(tabAlias, colAlias, internalName, newCI);
      hasDuplicates |= (!isUnique);

      qualifiedColName = rrToAddFrom.getAlternateMappings(internalName);
      if (qualifiedColName != null) {
        tabAlias = qualifiedColName[0];
        colAlias = qualifiedColName[1];
        rrToAddTo.put(tabAlias, colAlias, newCI);
      }
      i++;
    }

    if (outputColPosRef != null) {
      outputColPosRef.val = outputColPos;
    }
    return !hasDuplicates;
  }