TypedByteArrayComparator extends ByteArrayComparable { @Override public int compareTo(byte[] value, int offset, int length) { return this.comparator.compare(this.getValue(), 0, this.getValue().length, value, offset, length); } @SuppressWarnings("unused")  TypedByteArrayComparator();  TypedByteArrayComparator(byte[] value, Class type); void readFields(DataInput in); void write(DataOutput out); @Override byte[] toByteArray(); static TypedByteArrayComparator parseFrom(final byte[] bytes); @Override int compareTo(byte[] value, int offset, int length); static RawComparator get(Class type); static void define(Class type, RawComparator comparator);  }
@Test public void testCompare() { EntitySerDeser serDeser = new DoubleSerDeser(); TypedByteArrayComparator comparator = new TypedByteArrayComparator(serDeser.serialize(0.9), serDeser.type()); Assert.assertTrue(comparator.compareTo(serDeser.serialize(0.8)) > 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(1.1)) < 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(0.9)) == 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(-0.9)) > 0); serDeser = new IntSerDeser(); comparator = new TypedByteArrayComparator(serDeser.serialize(9), serDeser.type()); Assert.assertTrue(comparator.compareTo(serDeser.serialize(8)) > 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(11)) < 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(9)) == 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(-9)) > 0); serDeser = new LongSerDeser(); comparator = new TypedByteArrayComparator(serDeser.serialize(9l), serDeser.type()); Assert.assertTrue(comparator.compareTo(serDeser.serialize(8l)) > 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(11l)) < 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(9l)) == 0); Assert.assertTrue(comparator.compareTo(serDeser.serialize(-9l)) > 0); }