org.apache.pig.impl.io
Class PigNullableWritable

java.lang.Object
  extended by org.apache.pig.impl.io.PigNullableWritable
All Implemented Interfaces:
Comparable, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable
Direct Known Subclasses:
NullableBag, NullableBigDecimalWritable, NullableBigIntegerWritable, NullableBooleanWritable, NullableBytesWritable, NullableDateTimeWritable, NullableDoubleWritable, NullableFloatWritable, NullableIntWritable, NullableLongWritable, NullablePartitionWritable, NullableText, NullableTuple, NullableUnknownWritable

public abstract class PigNullableWritable
extends Object
implements org.apache.hadoop.io.WritableComparable

A base class for all types that pig uses to move data between map and reduce. It implements WritableComparable so that compareTo etc. can be called. It also wraps a WritableComparable 'value'. This is set by each different type to be an object of its specific type. It also provides a getIndex() and setIndex() calls that are used to get and set the index. These can be used by LocalRearrange, the partitioner, and Package to determine the index. Index and the null indicator are packed into one byte to save space.


Field Summary
static byte idxSpace
          regular indices used in group and cogroup can only go from 0x00 to 0x7F
static byte mqFlag
          indices in multiquery optimized maps will have the Most Significant Bit set This is a bitmask used in those cases.
protected  org.apache.hadoop.io.WritableComparable mValue
           
 
Constructor Summary
PigNullableWritable()
           
 
Method Summary
 int compareTo(Object o)
          Compare two nullable objects.
 boolean equals(Object arg0)
           
 byte getIndex()
           
abstract  Object getValueAsPigType()
           
 int hashCode()
           
 boolean isNull()
           
 void readFields(DataInput in)
           
 void setIndex(byte index)
           
 void setNull(boolean isNull)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mqFlag

public static final byte mqFlag
indices in multiquery optimized maps will have the Most Significant Bit set This is a bitmask used in those cases.

See Also:
Constant Field Values

idxSpace

public static final byte idxSpace
regular indices used in group and cogroup can only go from 0x00 to 0x7F

See Also:
Constant Field Values

mValue

protected org.apache.hadoop.io.WritableComparable mValue
Constructor Detail

PigNullableWritable

public PigNullableWritable()
Method Detail

compareTo

public int compareTo(Object o)
Compare two nullable objects. Step one is to check if either or both are null. If one is null and the other is not, then the one that is null is declared to be less. If both are null the indices are compared. If neither are null the indices are again compared. If these are equal, finally the values are compared. These comparators are used by hadoop as part of the post-map sort, when the data is still in object format.

Specified by:
compareTo in interface Comparable

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

isNull

public boolean isNull()
Returns:
the isNull

setNull

public void setNull(boolean isNull)
Parameters:
isNull - the isNull to set

getIndex

public byte getIndex()
Returns:
the index for this value

setIndex

public void setIndex(byte index)
Parameters:
index - for this value.

getValueAsPigType

public abstract Object getValueAsPigType()
Returns:
The wrapped value as a pig type, not as a WritableComparable.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object arg0)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2012 The Apache Software Foundation