org.apache.hadoop.mapreduce.lib.join
Class TupleWritable

java.lang.Object
  extended by org.apache.hadoop.mapreduce.lib.join.TupleWritable
All Implemented Interfaces:
Iterable<Writable>, Writable
Direct Known Subclasses:
TupleWritable

@InterfaceAudience.Public
@InterfaceStability.Stable
public class TupleWritable
extends Object
implements Writable, Iterable<Writable>

Writable type storing multiple Writables. This is *not* a general-purpose tuple type. In almost all cases, users are encouraged to implement their own serializable types, which can perform better validation and provide more efficient encodings than this class is capable. TupleWritable relies on the join framework for type safety and assumes its instances will rarely be persisted, assumptions not only incompatible with, but contrary to the general case.

See Also:
Writable

Field Summary
protected  BitSet written
           
 
Constructor Summary
TupleWritable()
          Create an empty tuple with no allocated storage for writables.
TupleWritable(Writable[] vals)
          Initialize tuple with storage; unknown whether any of them contain "written" values.
 
Method Summary
 boolean equals(Object other)
          
 Writable get(int i)
          Get ith Writable from Tuple.
 boolean has(int i)
          Return true if tuple has an element at the position provided.
 int hashCode()
           
 Iterator<Writable> iterator()
          Return an iterator over the elements in this tuple.
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 int size()
          The number of children in this Tuple.
 String toString()
          Convert Tuple to String as in the following.
 void write(DataOutput out)
          Writes each Writable to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

written

protected BitSet written
Constructor Detail

TupleWritable

public TupleWritable()
Create an empty tuple with no allocated storage for writables.


TupleWritable

public TupleWritable(Writable[] vals)
Initialize tuple with storage; unknown whether any of them contain "written" values.

Method Detail

has

public boolean has(int i)
Return true if tuple has an element at the position provided.


get

public Writable get(int i)
Get ith Writable from Tuple.


size

public int size()
The number of children in this Tuple.


equals

public boolean equals(Object other)

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

iterator

public Iterator<Writable> iterator()
Return an iterator over the elements in this tuple. Note that this doesn't flatten the tuple; one may receive tuples from this iterator.

Specified by:
iterator in interface Iterable<Writable>

toString

public String toString()
Convert Tuple to String as in the following. [,,...,]

Overrides:
toString in class Object

write

public void write(DataOutput out)
           throws IOException
Writes each Writable to out. TupleWritable format: <count><type1><type2>...<typen><obj1><obj2>...<objn>

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.