NaturalRecordComparator implements Comparator<Object[]> { @Override public int compare(Object[] l, Object[] r) { int result = 0; for (int i = 0; i < l.length; i++) { if (r.length < i) { return -1; } result = compare(l[i], r[i], comparators[i]); if (result != 0) { return result; } } if (r.length > l.length) { return 1; } return 0; } NaturalRecordComparator(Column[] schema); @Override int compare(Object[] l, Object[] r);  }
@Test public void testNull() { Column[] schema = new Column[]{ new Column("col1", OdpsType.BIGINT), new Column("col2", OdpsType.BOOLEAN), new Column("col3", OdpsType.DOUBLE), new Column("col4", OdpsType.STRING)}; NaturalRecordComparator comp = new NaturalRecordComparator(schema); assertTrue(comp.compare(new Object[]{null, null, null, null}, new Object[]{ new LongWritable(0), new BooleanWritable(true), new DoubleWritable(0.0), new Text("")}) < 0); assertTrue(comp.compare(new Object[]{new LongWritable(0), new BooleanWritable(true), new DoubleWritable(0.0), new Text("")}, new Object[]{null, null, null, null}) > 0); assertTrue(comp.compare(new Object[]{null, null, null, null}, new Object[]{null, null, null, null}) == 0); }