/** * Define the sort order of the BytesWritable. * @param that The other bytes writable * @return Positive if left is bigger than right, 0 if they are equal, and * negative if left is smaller than right. */ @Override public int compareTo(ImmutableBytesWritable that) { return WritableComparator.compareBytes( this.bytes, this.offset, this.length, that.bytes, that.offset, that.length); }
/** * Compares the bytes in this object to the specified byte array * @param that * @return Positive if left is bigger than right, 0 if they are equal, and * negative if left is smaller than right. */ public int compareTo(final byte [] that) { return WritableComparator.compareBytes( this.bytes, this.offset, this.length, that, 0, that.length); }
public int compare(Integer o1, Integer o2) { byte[] key1 = keys[o1]; byte[] key2 = keys[o2]; int length1 = distKeyLengths[o1]; int length2 = distKeyLengths[o2]; return WritableComparator.compareBytes(key1, 0, length1, key2, 0, length2); } };
/** * Define the sort order of the BytesWritable. * @param that The other bytes writable * @return Positive if left is bigger than right, 0 if they are equal, and * negative if left is smaller than right. */ public int compareTo(ByteArrayWritable that) { return WritableComparator.compareBytes(this.data, this.offset, this.length, that.data, that.offset, that.length); }
/** * Compares the bytes in this object to the specified byte array * @param that * @return Positive if left is bigger than right, 0 if they are equal, and * negative if left is smaller than right. */ public int compareTo(final byte[] that) { return WritableComparator.compareBytes(this.data, this.offset, this.length, that, 0, that.length); }
public final int compare(byte[] o1, byte[] o2) { return WritableComparator.compareBytes(o1, 0, o1.length, o2, 0, o2.length); } };
/** Compare two UTF8s. */ @Override public int compareTo(UTF8 o) { return WritableComparator.compareBytes(bytes, 0, length, o.bytes, 0, o.length); }
/** Returns true iff <code>o</code> is a UTF8 with the same contents. */ @Override public boolean equals(Object o) { if (!(o instanceof UTF8)) return false; UTF8 that = (UTF8)o; if (this.length != that.length) return false; else return WritableComparator.compareBytes(bytes, 0, length, that.bytes, 0, that.length) == 0; }
/** Compares this object with the specified object for order.*/ @Override public int compareTo(MD5Hash that) { return WritableComparator.compareBytes(this.digest, 0, MD5_LEN, that.digest, 0, MD5_LEN); }
public int compare(Integer o1, Integer o2) { byte[] key1 = keys[o1]; byte[] key2 = keys[o2]; int length1 = distKeyLengths[o1]; int length2 = distKeyLengths[o2]; return WritableComparator.compareBytes(key1, 0, length1, key2, 0, length2); } };
public final int compare(byte[] o1, byte[] o2) { return WritableComparator.compareBytes(o1, 0, o1.length, o2, 0, o2.length); } };
@Override public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) { return WritableComparator.compareBytes(b1, s1, l1, b2, s2, l2); }
/** * Compare bytes from {#getBytes()} to those provided. */ public int compareTo(byte[] other, int off, int len) { return WritableComparator.compareBytes(getBytes(), 0, getLength(), other, off, len); }
/** {@inheritDoc} */ @Override public int compareTo(BytesRefWritable other) { if (other == null) { throw new IllegalArgumentException("Argument can not be null."); } if (this == other) { return 0; } try { return WritableComparator.compareBytes(getData(), start, getLength(), other.getData(), other.start, other.getLength()); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Compare bytes from {#getBytes()}. * @see org.apache.hadoop.io.WritableComparator#compareBytes(byte[],int,int,byte[],int,int) */ @Override public int compareTo(BinaryComparable other) { if (this == other) return 0; return WritableComparator.compareBytes(getBytes(), 0, getLength(), other.getBytes(), 0, other.getLength()); }
/** * Compares the bytes in this object to the specified byte array * * @return Positive if left is bigger than right, 0 if they are equal, and negative if left is * smaller than right. */ public int compareTo(final byte[] that) { int diff = this.value.length - that.length; return (diff != 0) ? diff : WritableComparator.compareBytes(this.value, 0, this.value.length, that, 0, that.length); }
private void fillKey(BytesWritable o) { int len = keyLenRNG.nextInt(); if (len < MIN_KEY_LEN) len = MIN_KEY_LEN; o.setSize(len); int n = MIN_KEY_LEN; while (n < len) { byte[] word = dict[random.nextInt(dict.length)]; int l = Math.min(word.length, len - n); System.arraycopy(word, 0, o.get(), n, l); n += l; } if (sorted && WritableComparator.compareBytes(lastKey.get(), MIN_KEY_LEN, lastKey .getSize() - MIN_KEY_LEN, o.get(), MIN_KEY_LEN, o.getSize() - MIN_KEY_LEN) > 0) { incrementPrefix(); } System.arraycopy(prefix, 0, o.get(), 0, MIN_KEY_LEN); lastKey.set(o); }
/** * Compares this key's column family with another. * * @param cf * column family to compare * @return same as {@link #getColumnFamily()}.compareTo(cf) */ public int compareColumnFamily(Text cf) { return WritableComparator.compareBytes(colFamily, 0, colFamily.length, cf.getBytes(), 0, cf.getLength()); }
/** * Compares this key's column qualifier with another. * * @param cq * column qualifier to compare * @return same as {@link #getColumnQualifier()}.compareTo(cq) */ public int compareColumnQualifier(Text cq) { return WritableComparator.compareBytes(colQualifier, 0, colQualifier.length, cq.getBytes(), 0, cq.getLength()); }
/** * Compares this key's row ID with another. * * @param r * row ID to compare * @return same as {@link #getRow()}.compareTo(r) */ public int compareRow(Text r) { return WritableComparator.compareBytes(row, 0, row.length, r.getBytes(), 0, r.getLength()); }