BytesWritable extends BinaryComparable implements WritableComparable<BinaryComparable> { public byte[] getBytes() { return bytes; } BytesWritable();  BytesWritable(byte[] bytes); byte[] getBytes(); int getLength(); void setSize(int size); int getCapacity(); void setCapacity(int new_cap); void set(BytesWritable newData); void replace(byte [] newArray, int size); void set(byte[] newData, int offset, int length); void readFields(DataInput in); void write(DataOutput out); int hashCode(); boolean equals(Object right_obj); String toString();  }
@Test public void testCompare() throws Exception { byte[][] values = new byte[][]{"abc".getBytes(), "ad".getBytes(), "abcd".getBytes(), "".getBytes(), "b".getBytes()}; BytesWritable[] buf = new BytesWritable[values.length]; for(int i=0; i < values.length; ++i) { buf[i] = new BytesWritable(values[i]); } for(int i=0; i < values.length; ++i) { for(int j=0; j < values.length; ++j) { assertTrue(buf[i].compareTo(buf[j]) == -buf[j].compareTo(buf[i])); assertTrue((i == j) == (buf[i].compareTo(buf[j]) == 0)); } } assertTrue(buf[0].compareTo(buf[1]) < 0); assertTrue(buf[1].compareTo(buf[2]) > 0); assertTrue(buf[2].compareTo(buf[3]) > 0); assertTrue(buf[3].compareTo(buf[4]) < 0); }