Created
February 25, 2014 05:15
-
-
Save wikibook/9203150 to your computer and use it in GitHub Desktop.
시작하세요! 하둡 프로그래밍 예제 4.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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