### Question:
BulkIngestKey implements WritableComparable<BulkIngestKey> { @Override public void write(DataOutput out) throws IOException { writeText(out, tableName); Text t = new Text(); writeText(out, key.getRow(t)); writeText(out, key.getColumnFamily(t)); writeText(out, key.getColumnQualifier(t)); writeText(out, key.getColumnVisibility(t)); WritableUtils.writeVLong(out, key.getTimestamp()); out.writeBoolean(key.isDeleted()); } BulkIngestKey();  BulkIngestKey(Text tableName, Key key); Text getTableName(); Key getKey(); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override String toString(); void setTableName(final Text tableName); @Override int compareTo(BulkIngestKey other); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testBinaryKeyComparison() throws IOException { Text tableName = new Text("testTable"); Key key = new Key(new Text("row\0key"), new Text("e"), new Text("col\0qual\0data"), new Text("sample\0col\0vis")); key.setDeleted(true); BulkIngestKey key1 = new BulkIngestKey(tableName, key); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); key1.write(dos); byte[] key1bytes = bos.toByteArray(); key = new Key(new Text("row\0key"), new Text("h"), new Text("col"), new Text("sample\0col\0vis")); key.setDeleted(false); BulkIngestKey key2 = new BulkIngestKey(tableName, key); bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); key2.write(dos); byte[] key2bytes = bos.toByteArray(); BulkIngestKey.Comparator comparator = new BulkIngestKey.Comparator(); int result = comparator.compare(key1bytes, 0, key1bytes.length, key2bytes, 0, key2bytes.length); assertTrue(result < 0); result = comparator.compare(key2bytes, 0, key2bytes.length, key1bytes, 0, key1bytes.length); assertFalse(result < 0); result = comparator.compare(key2bytes, 0, key2bytes.length, key2bytes, 0, key2bytes.length); assertEquals(0, result); key = new Key(new Text("row\0key"), new Text("e"), new Text("col\0qual\0data"), new Text("sample\0col\0vis")); key.setDeleted(true); key1 = new BulkIngestKey(tableName, key); bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); key1.write(dos); key1bytes = bos.toByteArray(); key.setDeleted(false); key2 = new BulkIngestKey(tableName, key); bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); key2.write(dos); key2bytes = bos.toByteArray(); result = comparator.compare(key1bytes, 0, key1bytes.length, key2bytes, 0, key2bytes.length); assertTrue(0 > result); key = new Key(new Text("row\0key"), new Text("e"), new Text("col\0qual\0data"), new Text("sample\0col\0vis")); key.setDeleted(false); key1 = new BulkIngestKey(tableName, key); bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); key1.write(dos); key1bytes = bos.toByteArray(); key.setDeleted(true); key2 = new BulkIngestKey(tableName, key); bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); key2.write(dos); key2bytes = bos.toByteArray(); result = comparator.compare(key1bytes, 0, key1bytes.length, key2bytes, 0, key2bytes.length); assertTrue(0 < result); }