Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package slim3.mapreduce.wordcount.writables;
  2.  
  3. import java.io.DataInput;
  4. import java.io.DataOutput;
  5. import java.io.IOException;
  6.  
  7. import org.apache.hadoop.io.WritableComparable;
  8.  
  9. import com.google.appengine.tools.mapreduce.OutputKey;
  10.  
  11. public class WordCountIntermediateValue extends OutputKey implements
  12. WritableComparable<WordCountIntermediateValue> {
  13.  
  14. private long count = 0;
  15.  
  16. public WordCountIntermediateValue() {
  17. }
  18.  
  19. public WordCountIntermediateValue(long count) {
  20. set(count);
  21. }
  22.  
  23. public void set(long count) {
  24. this.count = count;
  25. }
  26.  
  27. public long getCount() {
  28. return count;
  29. }
  30.  
  31. @Override
  32. public String getKeyString() {
  33. return String.valueOf(count);
  34. }
  35.  
  36. @Override
  37. public void readFromKeyString(String keyString) {
  38. count = Long.parseLong(keyString);
  39. }
  40.  
  41. public void write(DataOutput out) throws IOException {
  42. out.writeLong(count);
  43. }
  44.  
  45. public void readFields(DataInput in) throws IOException {
  46. count = in.readLong();
  47. }
  48.  
  49. public int compareTo(WordCountIntermediateValue other) {
  50. return Long.valueOf(this.count).compareTo(Long.valueOf(other.count));
  51. }
  52. }
Add Comment
Please, Sign In to add comment