Skip to content

Instantly share code, notes, and snippets.

@wikibook
Created February 25, 2014 05:15
Show Gist options
  • Save wikibook/9203150 to your computer and use it in GitHub Desktop.
Save wikibook/9203150 to your computer and use it in GitHub Desktop.
시작하세요! 하둡 프로그래밍 예제 4.3
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.WritableComparable;
public class MyWritableComparable implements WritableComparable<MyWritableComparable> {
private Integer counter;
private Long timestamp;
public void write(DataOutput out) throws IOException {
out.writeInt(counter);
out.writeLong(timestamp);
}
public void readFields(DataInput in) throws IOException {
counter = in.readInt();
timestamp = in.readLong();
}
public int compareTo(MyWritableComparable o) {
int result = counter.compareTo(o.counter);
if (0 == result) {
result = timestamp.compareTo(o.timestamp);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment