### Question:
BytesWritable extends BinaryComparable implements WritableComparable<BinaryComparable> { public byte[] getBytes() { return bytes; } BytesWritable();  BytesWritable(byte[] bytes);  BytesWritable(byte[] bytes, int length); byte[] copyBytes(); byte[] getBytes(); @Deprecated byte[] get(); int getLength(); @Deprecated int getSize(); void setSize(int size); int getCapacity(); void setCapacity(int new_cap); void set(BytesWritable newData); void set(byte[] newData, int offset, int length); void readFields(DataInput in); void write(DataOutput out); @Override int hashCode(); @Override boolean equals(Object right_obj); @Override String toString();  }### Answer:
@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); }