class Constraint implements Writable {

  protected static boolean progressUntil(byte[] key,
      SeekingCurrentIterator resultIterator) {
    if (!resultIterator.isMarkedDoneWith()) {
      // load up the current result from the iterator
      Result current = resultIterator.current();
      byte[] currentKey = current == null ? EMPTY_START_ROW : current
          .getRecordId();

      int comparison = Bytes.compareTo(currentKey, key);
      // first check if we're already there.
      if (comparison == 0) {
        return true;
      } else if (comparison < 0)
      // if not and we're less, then seek and check again
      {
        resultIterator.seek(key);
        Result seeked = resultIterator.current();
        // if we went to the end, we now get a null
        if (seeked == null) {
          return false;
        }
        // if the current key is greater, we overshot
        else if ((comparison = Bytes.compareTo(seeked.getRecordId(), key)) > 0) {
          return false;
        }
        // if its equal we're good (we assume seek works)
        else {
          assert (comparison == 0);
          return true;
        }
      } else
      // otherwise we've overshot it and its not here.
      {
        return false;
      }
    }

    return false;
  }

}