public long hash(Key key, int depth) { key.indexTo(depth); int startPosition = key.getIndex(); key.indexTo(depth + 1); int endPosition = key.getIndex(); return hashFunction .hashBytes(key.getEncodedBytes(), startPosition, endPosition - startPosition) .asLong(); }