Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
courses:mapreduce-tutorial:step-27 [2012/01/28 18:34] straka |
courses:mapreduce-tutorial:step-27 [2012/01/28 18:46] straka |
||
---|---|---|---|
Line 33: | Line 33: | ||
} | } | ||
</ | </ | ||
- | Some accessory | + | Accessory |
<code java> | <code java> | ||
public int get() { return value; } | public int get() { return value; } | ||
public void set(int value) { this.value = value; } | public void set(int value) { this.value = value; } | ||
+ | public String toString() { return String.valueOf(value); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Such implementation can be used as a type of //values//. If we wanted to use it as a type of //keys//, we need to implement [[http:// | ||
+ | <code java> | ||
+ | public class BERIntWritable implements WritableComparable { | ||
+ | ... //Same as before | ||
+ | |||
+ | public int compareTo(Object other) { | ||
+ | int otherValue = ((BERIntWritable)other).get(); | ||
+ | return value < otherValue ? -1 : (value == otherValue ? 0 : 1); | ||
+ | } | ||
+ | } | ||
</ | </ | ||
===== PairWritable< | ===== PairWritable< | ||
+ | As another example, we implement a type storing two user-defined '' |