@Override public int compareTo(RecordIdentifier other) { if (other.getClass() != RecordIdentifier.class) { //WTF? assumes that other instanceof OrcRawRecordMerger.ReaderKey??? return -other.compareTo(this); } return compareToInternal(other); }
@Override public int compareTo(Row row) { RowWithPartNRecID other = (RowWithPartNRecID) row; if (recId == null && other.recId == null) { return comparePartVal(other); } else if (recId == null) { return -1; } else { int rc = recId.compareTo(other.recId); if (rc == 0) return comparePartVal(other); else return rc; } }
@Override public int compareTo(RecordIdentifier other) { if (other.getClass() != RecordIdentifier.class) { return -other.compareTo(this); } return compareToInternal(other); }
@Override public int compareTo(Row row) { RowWithRecID other = (RowWithRecID) row; if (recId == null && other.recId == null) { return comparePartVal(other); } else if (recId == null) { return -1; } else { int rc = recId.compareTo(other.recId); if (rc == 0) return comparePartVal(other); else return rc; } } private int comparePartVal(RowWithRecID other) {
@Override public int compareTo(RecordIdentifier other) { if (other.getClass() != RecordIdentifier.class) { return -other.compareTo(this); } return compareToInternal(other); }
@Test public void TestOrdering() throws Exception { RecordIdentifier left = new RecordIdentifier(100, 200, 1200); RecordIdentifier right = new RecordIdentifier(); right.setValues(100L, 200, 1000L); assertTrue(right.compareTo(left) < 0); assertTrue(left.compareTo(right) > 0); left.set(right); assertTrue(right.compareTo(left) == 0); right.setRowId(2000); assertTrue(right.compareTo(left) > 0); left.setValues(1, 2, 3); right.setValues(100, 2, 3); assertTrue(left.compareTo(right) < 0); assertTrue(right.compareTo(left) > 0); left.setValues(1, 2, 3); right.setValues(1, 100, 3); assertTrue(left.compareTo(right) < 0); assertTrue(right.compareTo(left) > 0); }
assertEquals(1, ri.compareTo(left)); assertEquals(-1, left.compareTo(ri)); assertEquals(false, ri.equals(left));