@Override public int compareTo(DateTemperaturePair pair) { int compareValue = this.yearMonth.compareTo(pair.getYearMonth()); if (compareValue == 0) { compareValue = temperature.compareTo(pair.getTemperature()); } //return compareValue; // to sort ascending return -1*compareValue; // to sort descending }
@Override public int compare(String s1, String s2) { return locationToNumSplits.get(s1).compareTo(locationToNumSplits.get(s2)); }
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, Text> out, Reporter reporter) throws IOException { // check key order int currentKey = key.get(); if (currentKey < lastKey) { fail("Keys not in sorted ascending order"); } lastKey = currentKey; // check order of values IntWritable previous = new IntWritable(Integer.MIN_VALUE); int valueCount = 0; while (values.hasNext()) { IntWritable current = values.next(); // Check that the values are sorted if (current.compareTo(previous) < 0) fail("Values generated by Mapper not in order"); previous = current; ++valueCount; } if (valueCount != 5) { fail("Values not grouped by primary key"); } out.collect(key, new Text("success")); }
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, Text> out, Reporter reporter) throws IOException { // check key order int currentKey = key.get(); if (currentKey > lastKey) { fail("Keys not in sorted descending order"); } lastKey = currentKey; // check order of values IntWritable previous = new IntWritable(Integer.MAX_VALUE); int valueCount = 0; while (values.hasNext()) { IntWritable current = values.next(); // Check that the values are sorted if (current.compareTo(previous) > 0) fail("Values generated by Mapper not in order"); previous = current; ++valueCount; } if (valueCount != 5) { fail("Values not grouped by primary key"); } out.collect(key, new Text("success")); }
public int compareTo(IntMatrixItemPair o) { int cmp = reducerNum.compareTo(o.reducerNum); if (cmp != 0) { return cmp; } return matItem.compareTo(o.getMatItem()); }
@Override public int compareTo(TextInt other) { int cmp = first.compareTo(other.getFirst()); if (0 == cmp) { cmp = second.compareTo(other.getSecond()); } return cmp; }
return assignmentDifference; return locationToNumSplits.get(s1).compareTo(locationToNumSplits.get(s2)); });
@Override public int compareTo(TextInt other) { int cmp = first.compareTo(other.getFirst()); if (0 == cmp) { cmp = second.compareTo(other.getSecond()); } return cmp; }
@Override public int compareTo(CompositeType o) { int compare = getOldKey().compareTo(o.getOldKey()); if (compare != 0) { return compare; } return getPriority().compareTo(o.getPriority()); }
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, Text> out, Reporter reporter) throws IOException { // check key order int currentKey = key.get(); if (currentKey < lastKey) { fail("Keys not in sorted ascending order"); } lastKey = currentKey; // check order of values IntWritable previous = new IntWritable(Integer.MIN_VALUE); int valueCount = 0; while (values.hasNext()) { IntWritable current = values.next(); // Check that the values are sorted if (current.compareTo(previous) < 0) fail("Values generated by Mapper not in order"); previous = current; ++valueCount; } if (valueCount != 5) { fail("Values not grouped by primary key"); } out.collect(key, new Text("success")); }
public class MyDataType implements WritableComparable<MyDataType> { private Text name; private IntWritable age; @Override public void readFields(DataInput in) throws IOException { name.readFields(in); age.readFields(in); } @Override public void write(DataOutput out) throws IOException { name.write(out); age.write(out); } @Override public int compareTo(MyDataType o) { int nameCompare = name.compareTo(o.name); if(nameCompare != 0) { return nameCompare; } else { return age.compareTo(o.age); } } }
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, Text> out, Reporter reporter) throws IOException { // check key order int currentKey = key.get(); if (currentKey > lastKey) { fail("Keys not in sorted descending order"); } lastKey = currentKey; // check order of values IntWritable previous = new IntWritable(Integer.MAX_VALUE); int valueCount = 0; while (values.hasNext()) { IntWritable current = values.next(); // Check that the values are sorted if (current.compareTo(previous) > 0) fail("Values generated by Mapper not in order"); previous = current; ++valueCount; } if (valueCount != 5) { fail("Values not grouped by primary key"); } out.collect(key, new Text("success")); }