[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
courses:mapreduce-tutorial:step-27 [2012/01/28 18:46]
straka
courses:mapreduce-tutorial:step-27 [2012/01/28 18:55]
straka
Line 55: Line 55:
 ===== PairWritable<A, B> ===== ===== PairWritable<A, B> =====
  
-As another example, we implement a type storing two user-defined ''Writable'' implementations:+As another example, we implement a type consisting of two user-defined ''Writable'' implementations: 
 +<code java> 
 +public static class PairWritable<A extends Writable, B extends Writable > implements Writable { 
 +  private A first; 
 +  private B second; 
 + 
 +  public void readFields(DataInput in) throws IOException { 
 +    first.readFields(in); 
 +    second.readFields(in); 
 +  } 
 + 
 +  public void write(DataOutput out) throws IOException { 
 +    first.write(out); 
 +    second.write(out); 
 +  } 
 + 
 +  public A getFirst() { return first; } 
 +  public B getSecond() { return second; } 
 +  public void setFirst(A first) { this.first = first; } 
 +  public void setSecond(B first) { this.second = second; } 
 +  public PairWritable(A first, B second) { this.first = first; this.second = second; } 
 +
 +</code> 

[ Back to the navigation ] [ Back to the content ]