org.apache.hadoop.mapreduce.lib.join
Class WrappedRecordReader<K extends WritableComparable<?>,U extends Writable>

java.lang.Object
  extended by org.apache.hadoop.mapreduce.RecordReader<K,V>
      extended by org.apache.hadoop.mapreduce.lib.join.ComposableRecordReader<K,U>
          extended by org.apache.hadoop.mapreduce.lib.join.WrappedRecordReader<K,U>
All Implemented Interfaces:
Closeable, Comparable<ComposableRecordReader<K,?>>

@InterfaceAudience.Public
@InterfaceStability.Stable
public class WrappedRecordReader<K extends WritableComparable<?>,U extends Writable>
extends ComposableRecordReader<K,U>

Proxy class for a RecordReader participating in the join framework. This class keeps track of the "head" key-value pair for the provided RecordReader and keeps a store of values matching a key when this source is participating in a join.


Field Summary
protected  WritableComparator cmp
           
protected  boolean empty
           
 
Constructor Summary
protected WrappedRecordReader(int id)
           
 
Method Summary
 void accept(org.apache.hadoop.mapreduce.lib.join.CompositeRecordReader.JoinCollector i, K key)
          Add an iterator to the collector at the position occupied by this RecordReader over the values in this stream paired with the key provided (ie register a stream of values from this source matching K with a collector).
 void close()
          Forward close request to proxied RR.
 int compareTo(ComposableRecordReader<K,?> other)
          Implement Comparable contract (compare key at head of proxied RR with that of another).
 K createKey()
          Request new key from proxied RR.
 U createValue()
          Create instance of value.
 boolean equals(Object other)
          Return true iff compareTo(other) retn true.
 K getCurrentKey()
          Get current key
 U getCurrentValue()
          Get current value
 float getProgress()
          Request progress from proxied RR.
 int hashCode()
           
 boolean hasNext()
          Return true if the RR- including the k,v pair stored in this object- is exhausted.
 int id()
          Return the position in the collector this class occupies.
 void initialize(InputSplit split, TaskAttemptContext context)
          Called once at initialization.
 K key()
          Return the key at the head of this RR.
 void key(K qkey)
          Clone the key at the head of this RR into the object supplied.
 boolean nextKeyValue()
          Read the next k,v pair into the head of this object; return true iff the RR and this are exhausted.
 void skip(K key)
          Skip key-value pairs with keys less than or equal to the key provided.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

empty

protected boolean empty

cmp

protected WritableComparator cmp
Constructor Detail

WrappedRecordReader

protected WrappedRecordReader(int id)
Method Detail

initialize

public void initialize(InputSplit split,
                       TaskAttemptContext context)
                throws IOException,
                       InterruptedException
Description copied from class: RecordReader
Called once at initialization.

Specified by:
initialize in class RecordReader<K extends WritableComparable<?>,U extends Writable>
Parameters:
split - the split that defines the range of records to read
context - the information about the task
Throws:
IOException
InterruptedException

createKey

public K createKey()
Request new key from proxied RR.


createValue

public U createValue()
Description copied from class: ComposableRecordReader
Create instance of value.


id

public int id()
Return the position in the collector this class occupies.


key

public K key()
Return the key at the head of this RR.


key

public void key(K qkey)
         throws IOException
Clone the key at the head of this RR into the object supplied.

Throws:
IOException

hasNext

public boolean hasNext()
Return true if the RR- including the k,v pair stored in this object- is exhausted.


skip

public void skip(K key)
          throws IOException,
                 InterruptedException
Skip key-value pairs with keys less than or equal to the key provided.

Throws:
IOException
InterruptedException

accept

public void accept(org.apache.hadoop.mapreduce.lib.join.CompositeRecordReader.JoinCollector i,
                   K key)
            throws IOException,
                   InterruptedException
Add an iterator to the collector at the position occupied by this RecordReader over the values in this stream paired with the key provided (ie register a stream of values from this source matching K with a collector).

Throws:
IOException
InterruptedException

nextKeyValue

public boolean nextKeyValue()
                     throws IOException,
                            InterruptedException
Read the next k,v pair into the head of this object; return true iff the RR and this are exhausted.

Specified by:
nextKeyValue in class RecordReader<K extends WritableComparable<?>,U extends Writable>
Returns:
true if a key/value pair was read
Throws:
IOException
InterruptedException

getCurrentKey

public K getCurrentKey()
                                              throws IOException,
                                                     InterruptedException
Get current key

Specified by:
getCurrentKey in class RecordReader<K extends WritableComparable<?>,U extends Writable>
Returns:
the current key or null if there is no current key
Throws:
IOException
InterruptedException

getCurrentValue

public U getCurrentValue()
                                   throws IOException,
                                          InterruptedException
Get current value

Specified by:
getCurrentValue in class RecordReader<K extends WritableComparable<?>,U extends Writable>
Returns:
the object that was read
Throws:
IOException
InterruptedException

getProgress

public float getProgress()
                  throws IOException,
                         InterruptedException
Request progress from proxied RR.

Specified by:
getProgress in class RecordReader<K extends WritableComparable<?>,U extends Writable>
Returns:
a number between 0.0 and 1.0 that is the fraction of the data read
Throws:
IOException
InterruptedException

close

public void close()
           throws IOException
Forward close request to proxied RR.

Specified by:
close in interface Closeable
Specified by:
close in class RecordReader<K extends WritableComparable<?>,U extends Writable>
Throws:
IOException

compareTo

public int compareTo(ComposableRecordReader<K,?> other)
Implement Comparable contract (compare key at head of proxied RR with that of another).


equals

public boolean equals(Object other)
Return true iff compareTo(other) retn true.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2014 Apache Software Foundation. All Rights Reserved.