Пример #1
0
  public static boolean startsWith(Bytes bytes, Range target, byte[] match, boolean caseSensitive) {

    if (target.length < match.length || target.start < 0 || target.last() >= bytes.limit()) {
      return false;
    }

    boolean result = match(bytes, target.start, match, caseSensitive);

    return result;
  }
 private long longHashCode(Bytes bytes) {
   long h = 0;
   int i = 0;
   long limit = bytes.limit(); // clustering.
   for (; i < limit - 7; i += 8) h = 10191 * h + bytes.readLong(i);
   //        for (; i < bytes.limit() - 3; i += 2)
   //            h = 10191 * h + bytes.readInt(i);
   for (; i < limit; i++) h = 57 * h + bytes.readByte(i);
   h ^= (h >>> 31) + (h << 31);
   h += (h >>> 21) + (h >>> 11);
   return h;
 }
Пример #3
0
  public static boolean containsAt(
      Bytes bytes, Range target, long offset, byte[] match, boolean caseSensitive) {

    if (offset < 0
        || target.length < offset + match.length
        || target.start < 0
        || target.last() >= bytes.limit()) {
      return false;
    }

    boolean result = match(bytes, target.start + offset, match, caseSensitive);

    return result;
  }