Class CompositeRecordReader<K extends WritableComparable,V extends Writable,X extends Writable>

java.lang.Object
org.apache.hadoop.mapred.join.CompositeRecordReader<K,V,X>
All Implemented Interfaces:
Configurable
Direct Known Subclasses:
JoinRecordReader, MultiFilterRecordReader

@Public @Stable public abstract class CompositeRecordReader<K extends WritableComparable,V extends Writable,X extends Writable> extends Object implements Configurable
A RecordReader that can effect joins of RecordReaders sharing a common key type and partitioning.
  • Field Details

  • Constructor Details

    • CompositeRecordReader

      public CompositeRecordReader(int id, int capacity, Class<? extends WritableComparator> cmpcl) throws IOException
      Create a RecordReader with capacity children to position id in the parent reader. The id of a root CompositeRecordReader is -1 by convention, but relying on this is not recommended.
      Throws:
      IOException
  • Method Details

    • combine

      protected abstract boolean combine(Object[] srcs, TupleWritable value)
    • id

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

      public void setConf(Configuration conf)
      Set the configuration to be used by this object.
      Specified by:
      setConf in interface Configurable
      Parameters:
      conf - configuration to be used
    • getConf

      public Configuration getConf()
      Return the configuration used by this object.
      Specified by:
      getConf in interface Configurable
      Returns:
      Configuration
    • getRecordReaderQueue

      protected PriorityQueue<ComposableRecordReader<K,?>> getRecordReaderQueue()
      Return sorted list of RecordReaders for this composite.
    • getComparator

      protected WritableComparator getComparator()
      Return comparator defining the ordering for RecordReaders in this composite.
    • add

      public void add(ComposableRecordReader<K,? extends V> rr) throws IOException
      Add a RecordReader to this collection. The id() of a RecordReader determines where in the Tuple its entry will appear. Adding RecordReaders with the same id has undefined behavior.
      Throws:
      IOException
    • key

      public K key()
      Return the key for the current join or the value at the top of the RecordReader heap.
    • key

      public void key(K key) throws IOException
      Clone the key at the top of this RR into the given object.
      Throws:
      IOException
    • hasNext

      public boolean hasNext()
      Return true if it is possible that this could emit more values.
    • skip

      public void skip(K key) throws IOException
      Pass skip key to child RRs.
      Throws:
      IOException
    • getDelegate

      protected abstract ResetableIterator<X> getDelegate()
      Obtain an iterator over the child RRs apropos of the value type ultimately emitted from this join.
    • accept

      public void accept(org.apache.hadoop.mapred.join.CompositeRecordReader.JoinCollector jc, K key) throws IOException
      If key provided matches that of this Composite, give JoinCollector iterator over values it may emit.
      Throws:
      IOException
    • fillJoinCollector

      protected void fillJoinCollector(K iterkey) throws IOException
      For all child RRs offering the key provided, obtain an iterator at that position in the JoinCollector.
      Throws:
      IOException
    • compareTo

      public int compareTo(ComposableRecordReader<K,?> other)
      Implement Comparable contract (compare key of join or head of heap with that of another).
    • createKey

      public K createKey()
      Create a new key value common to all child RRs.
      Throws:
      ClassCastException - if key classes differ.
    • createInternalValue

      protected TupleWritable createInternalValue()
      Create a value to be used internally for joins.
    • getPos

      public long getPos() throws IOException
      Unsupported (returns zero in all cases).
      Throws:
      IOException
    • close

      public void close() throws IOException
      Close all child RRs.
      Throws:
      IOException
    • getProgress

      public float getProgress() throws IOException
      Report progress as the minimum of all child RR progress.
      Throws:
      IOException