Exemplo n.º 1
0
  private boolean checkConstraints(String procName, ClientResponse response) {
    boolean isSatisfied = true;
    int orig_position = -1;

    // Check if all the tables in the result set satisfy the constraints.
    for (int i = 0; isSatisfied && i < response.getResults().length; i++) {
      Pair<String, Integer> key = Pair.of(procName, i);
      if (!m_constraints.containsKey(key)) continue;

      VoltTable table = response.getResults()[i];
      orig_position = table.getActiveRowIndex();
      table.resetRowPosition();

      // Iterate through all rows and check if they satisfy the
      // constraints.
      while (isSatisfied && table.advanceRow()) {
        isSatisfied = Verification.checkRow(m_constraints.get(key), table);
      }

      // Have to reset the position to its original position.
      if (orig_position < 0) table.resetRowPosition();
      else table.advanceToRow(orig_position);
    }

    if (!isSatisfied) System.err.println("Transaction " + procName + " failed check");

    return isSatisfied;
  }