Skip to content
Snippets Groups Projects
Commit a5e2b6a6 authored by Matei Zaharia's avatar Matei Zaharia
Browse files

Merge pull request #112 from cengle/master

Changed HadoopRDD to get key and value containers from the RecordReader instead of through reflection
parents 97eee508 dd68cb60
No related branches found
No related tags found
No related merge requests found
...@@ -60,18 +60,6 @@ class HadoopRDD[K, V]( ...@@ -60,18 +60,6 @@ class HadoopRDD[K, V](
.asInstanceOf[InputFormat[K, V]] .asInstanceOf[InputFormat[K, V]]
} }
/**
* Helper method for creating a Hadoop Writable, because the commonly used NullWritable class has
* no constructor.
*/
def createWritable[T](clazz: Class[T]): T = {
if (clazz == classOf[NullWritable]) {
NullWritable.get().asInstanceOf[T]
} else {
clazz.newInstance()
}
}
override def splits = splits_ override def splits = splits_
override def compute(theSplit: Split) = new Iterator[(K, V)] { override def compute(theSplit: Split) = new Iterator[(K, V)] {
...@@ -82,8 +70,8 @@ class HadoopRDD[K, V]( ...@@ -82,8 +70,8 @@ class HadoopRDD[K, V](
val fmt = createInputFormat(conf) val fmt = createInputFormat(conf)
reader = fmt.getRecordReader(split.inputSplit.value, conf, Reporter.NULL) reader = fmt.getRecordReader(split.inputSplit.value, conf, Reporter.NULL)
val key: K = createWritable(keyClass) val key: K = reader.createKey()
val value: V = createWritable(valueClass) val value: V = reader.createValue()
var gotNext = false var gotNext = false
var finished = false var finished = false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment