ColumnBasedRecordComparator extends NaturalRecordComparator { @Override public int compare(Object[] l, Object[] r) { int result = 0; for (int i : selIdxs) { if (r.length < i) { return -1; } if (l.length < i) { return 1; } if (sortOrder != null && sortOrder[i] == JobConf.SortOrder.DESC) { result = compare(r[i], l[i], comparators[i]); } else { result = compare(l[i], r[i], comparators[i]); } if (result != 0) { return result; } } return 0; } ColumnBasedRecordComparator(int[] selIdxs, Column[] schema);  ColumnBasedRecordComparator(String[] selCols, Column[] schema);  ColumnBasedRecordComparator(String[] selCols, Column[] schema, SortOrder[] sortOrder); @Override int compare(Object[] l, Object[] r);  }
@Test public void testEmptyColumnlist() { Column[] schema = new Column[]{new Column("col1", OdpsType.BIGINT), new Column("col2", OdpsType.BOOLEAN), new Column("col3", OdpsType.DOUBLE), new Column("col4", OdpsType.STRING), new Column("col5", OdpsType.DATETIME)}; ColumnBasedRecordComparator comp = new ColumnBasedRecordComparator(new String[0], schema); assertTrue(comp.compare(new Object[]{null, null, null, null, null}, new Object[]{ new LongWritable(0), new BooleanWritable(true), new DoubleWritable(0.0), new Text(""), new DatetimeWritable(0)}) == 0); assertTrue(comp.compare(new Object[]{new LongWritable(0), new BooleanWritable(true), new DoubleWritable(0.0), new Text(""), new DatetimeWritable(0)}, new Object[]{null, null, null, null, null}) == 0); assertTrue(comp.compare(new Object[]{null, null, null, null, null}, new Object[]{null, null, null, null, null}) == 0); }