protected int terminatorPosition(PositionedByteRange src) {
    byte[] a = src.getBytes();
    final int offset = src.getOffset();
    int i;
    SKIP: for (i = src.getPosition(); i < src.getLength(); i++) {
      if (a[offset + i] != term[0]) {
        continue;
      }
      int j;
      for (j = 1; j < term.length && offset + j < src.getLength(); j++) {
        if (a[offset + i + j] != term[j]) {
          continue SKIP;
        }
      }
      if (j == term.length) {
        return i; // success
      }
    }
    return -1;
  }
Return the position at which {@code term} begins within {@code src}, or {@code -1} if
{@code term} is not found.
hbase-common/src/main/java/org/apache/hadoop/hbase/types/TerminatedWrapper.java