@Test public void testSingleIntFieldCompare() { SortField[] sortFields = new SortField[] { new SortField("intField", SortField.INT) }; WritableType[] sortFieldTypes = new WritableType[] { WritableType.INT }; FieldSortComparator fieldSortComparator = new FieldSortComparator(sortFields, sortFieldTypes); Hit hit1 = new Hit("shard", "node", 0.0f, 1, sortFieldTypes); Hit hit2 = new Hit("shard", "node", 0.0f, 2, sortFieldTypes); hit1.setSortFields(new WritableComparable[] { new IntWritable(1) }); hit2.setSortFields(new WritableComparable[] { new IntWritable(2) }); assertEquals(0, fieldSortComparator.compare(hit1, hit1)); assertEquals(1, fieldSortComparator.compare(hit2, hit1)); assertEquals(-1, fieldSortComparator.compare(hit1, hit2)); }
@Override public int compare(Hit hit1, Hit hit2) { int c = compare(hit1.getSortFields(), hit2.getSortFields()); if (c == 0) { c = hit1.compareTo(hit2); } return c; }
FieldSortComparator implements Comparator<Hit> { @Override public int compare(Hit hit1, Hit hit2) { int c = compare(hit1.getSortFields(), hit2.getSortFields()); if (c == 0) { c = hit1.compareTo(hit2); } return c; } }
FieldSortComparator implements Comparator<Hit> { @Override public int compare(Hit hit1, Hit hit2) { int c = compare(hit1.getSortFields(), hit2.getSortFields()); if (c == 0) { c = hit1.compareTo(hit2); } return c; } FieldSortComparator(SortField[] sortFields, WritableType[] fieldTypes); }
FieldSortComparator implements Comparator<Hit> { @Override public int compare(Hit hit1, Hit hit2) { int c = compare(hit1.getSortFields(), hit2.getSortFields()); if (c == 0) { c = hit1.compareTo(hit2); } return c; } FieldSortComparator(SortField[] sortFields, WritableType[] fieldTypes); SortField[] getSortFields(); WritableType[] getFieldTypes(); @Override int compare(Hit hit1, Hit hit2); int compare(Object[] fields1, Object[] fields2); }
FieldSortComparator implements Comparator<Hit> { @Override public int compare(Hit hit1, Hit hit2) { int c = compare(hit1.getSortFields(), hit2.getSortFields()); if (c == 0) { c = hit1.compareTo(hit2); } return c; } FieldSortComparator(SortField[] sortFields, WritableType[] fieldTypes); SortField[] getSortFields(); WritableType[] getFieldTypes(); @Override int compare(Hit hit1, Hit hit2); int compare(Object[] fields1, Object[] fields2);  }