Class CompositeRecordReader<K extends WritableComparable<?>,V extends Writable,X extends Writable>
java.lang.Object
org.apache.hadoop.mapreduce.RecordReader<K,V>
org.apache.hadoop.mapreduce.lib.join.ComposableRecordReader<K,X>
org.apache.hadoop.mapreduce.lib.join.CompositeRecordReader<K,V,X>
- All Implemented Interfaces:
Closeable,AutoCloseable,Comparable<ComposableRecordReader<K,,?>> Configurable
- Direct Known Subclasses:
JoinRecordReader,MultiFilterRecordReader
@Public
@Stable
public abstract class CompositeRecordReader<K extends WritableComparable<?>,V extends Writable,X extends Writable>
extends ComposableRecordReader<K,X>
implements Configurable
A RecordReader that can effect joins of RecordReaders sharing a common key
type and partitioning.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassorg.apache.hadoop.mapreduce.lib.join.CompositeRecordReader.JoinCollectorCollector for join values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Configurationprotected final CompositeRecordReader<K,V, X>.org.apache.hadoop.mapreduce.lib.join.CompositeRecordReader.JoinCollector protected Kprotected Class<? extends WritableComparable>protected final ComposableRecordReader<K,? extends V>[] protected X -
Constructor Summary
ConstructorsConstructorDescriptionCompositeRecordReader(int id, int capacity, Class<? extends WritableComparator> cmpcl) Create a RecordReader withcapacitychildren to positionidin the parent reader. -
Method Summary
Modifier and TypeMethodDescriptionvoidIf key provided matches that of this Composite, give JoinCollector iterator over values it may emit.voidadd(ComposableRecordReader<K, ? extends V> rr) Add a RecordReader to this collection.voidclose()Close all child RRs.protected abstract booleancombine(Object[] srcs, TupleWritable value) intcompareTo(ComposableRecordReader<K, ?> other) Implement Comparable contract (compare key of join or head of heap with that of another).protected KCreate a new key common to all child RRs.protected TupleWritableCreate a value to be used internally for joins.protected voidfillJoinCollector(K iterkey) For all child RRs offering the key provided, obtain an iterator at that position in the JoinCollector.protected WritableComparatorReturn comparator defining the ordering for RecordReaders in this composite.getConf()Return the configuration used by this object.Get the current keyGet the current value.protected abstract ResetableIterator<X>Obtain an iterator over the child RRs apropos of the value type ultimately emitted from this join.floatReport progress as the minimum of all child RR progress.protected PriorityQueue<ComposableRecordReader<K,?>> Return sorted list of RecordReaders for this composite.booleanhasNext()Return true if it is possible that this could emit more values.intid()Return the position in the collector this class occupies.voidinitialize(InputSplit split, TaskAttemptContext context) Called once at initialization.key()Return the key for the current join or the value at the top of the RecordReader heap.voidClone the key at the top of this RR into the given object.voidsetConf(Configuration conf) Set the configuration to be used by this object.voidPass skip key to child RRs.Methods inherited from class org.apache.hadoop.mapreduce.RecordReader
nextKeyValue
-
Field Details
-
conf
-
keyclass
-
jc
protected final CompositeRecordReader<K extends WritableComparable<?>,V extends Writable, jcX extends Writable>.org.apache.hadoop.mapreduce.lib.join.CompositeRecordReader.JoinCollector -
kids
protected final ComposableRecordReader<K extends WritableComparable<?>,? extends V extends Writable>[] kids -
key
-
value
-
-
Constructor Details
-
CompositeRecordReader
public CompositeRecordReader(int id, int capacity, Class<? extends WritableComparator> cmpcl) throws IOException Create a RecordReader withcapacitychildren to positionidin 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
-
initialize
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException Description copied from class:RecordReaderCalled once at initialization.- Specified by:
initializein classRecordReader<K extends WritableComparable<?>,X extends Writable> - Parameters:
split- the split that defines the range of records to readcontext- the information about the task- Throws:
IOExceptionInterruptedException
-
id
public int id()Return the position in the collector this class occupies. -
setConf
Set the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Parameters:
conf- configuration to be used
-
getConf
Return the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Returns:
- Configuration
-
getRecordReaderQueue
Return sorted list of RecordReaders for this composite. -
getComparator
Return comparator defining the ordering for RecordReaders in this composite. -
add
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:
IOExceptionInterruptedException
-
key
Return the key for the current join or the value at the top of the RecordReader heap. -
key
Clone the key at the top of this RR into the given object.- Throws:
IOException
-
getCurrentKey
Description copied from class:RecordReaderGet the current key- Specified by:
getCurrentKeyin classRecordReader<K extends WritableComparable<?>,X extends Writable> - Returns:
- the current key or null if there is no current key
-
hasNext
public boolean hasNext()Return true if it is possible that this could emit more values. -
skip
Pass skip key to child RRs.- Throws:
IOExceptionInterruptedException
-
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.mapreduce.lib.join.CompositeRecordReader.JoinCollector jc, K key) throws IOException, InterruptedException If key provided matches that of this Composite, give JoinCollector iterator over values it may emit.- Throws:
IOExceptionInterruptedException
-
fillJoinCollector
For all child RRs offering the key provided, obtain an iterator at that position in the JoinCollector.- Throws:
IOExceptionInterruptedException
-
compareTo
Implement Comparable contract (compare key of join or head of heap with that of another).- Specified by:
compareToin interfaceComparable<K extends WritableComparable<?>>
-
createKey
Create a new key common to all child RRs.- Throws:
ClassCastException- if key classes differ.
-
createTupleWritable
Create a value to be used internally for joins. -
getCurrentValue
Get the current value.- Specified by:
getCurrentValuein classRecordReader<K extends WritableComparable<?>,X extends Writable> - Returns:
- the object that was read
- Throws:
IOExceptionInterruptedException
-
close
Close all child RRs.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classRecordReader<K extends WritableComparable<?>,X extends Writable> - Throws:
IOException
-
getProgress
Report progress as the minimum of all child RR progress.- Specified by:
getProgressin classRecordReader<K extends WritableComparable<?>,X extends Writable> - Returns:
- a number between 0.0 and 1.0 that is the fraction of the data read
- Throws:
IOExceptionInterruptedException
-