Skip to content

Commit

Permalink
More genericization in ConfigurableCombineFileRecordReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshRosen committed Dec 16, 2014
1 parent 95d13eb commit dc3d21a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ private[spark] class WholeTextFileInputFormat
split: InputSplit,
context: TaskAttemptContext): RecordReader[String, String] = {

val reader = new ConfigurableCombineFileRecordReader(split, context)
val reader =
new ConfigurableCombineFileRecordReader(split, context, classOf[WholeTextFileRecordReader])
reader.setConf(getConf)
reader
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,23 @@ private[spark] class WholeTextFileRecordReader(

/**
* A [[org.apache.hadoop.mapreduce.lib.input.CombineFileRecordReader CombineFileRecordReader]]
* that could pass Hadoop configuration to WholeTextFileRecordReader.
* that can pass Hadoop Configuration to [[org.apache.hadoop.conf.Configurable Configurable]]
* RecordReaders.
*/
private[spark] class ConfigurableCombineFileRecordReader(
private[spark] class ConfigurableCombineFileRecordReader[K, V](
split: InputSplit,
context: TaskAttemptContext)
extends CombineFileRecordReader[String, String](
context: TaskAttemptContext,
recordReaderClass: Class[_ <: RecordReader[K, V] with HConfigurable])
extends CombineFileRecordReader[K, V](
split.asInstanceOf[CombineFileSplit],
context,
classOf[WholeTextFileRecordReader]
recordReaderClass
) with Configurable {

override def initNextRecordReader(): Boolean = {
val r = super.initNextRecordReader()
if (r) {
this.curReader.asInstanceOf[WholeTextFileRecordReader].setConf(getConf)
this.curReader.asInstanceOf[HConfigurable].setConf(getConf)
}
r
}
Expand Down

0 comments on commit dc3d21a

Please sign in to comment.