Skip to content

Commit

Permalink
remove unneeded assert, cache the converter
Browse files Browse the repository at this point in the history
  • Loading branch information
rubanm committed May 14, 2015
1 parent a83b9ff commit 925291c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -64,12 +64,20 @@ private[source] object ConfigBinaryConverterProvider {
*/
private[source] class ConfigBinaryConverterProvider[M] extends BinaryConverterProvider[M] {
import ConfigBinaryConverterProvider._

private[this] var cached: Option[(String, BinaryConverter[M])] = None

override def getConverter(conf: Configuration): BinaryConverter[M] = {
val data = conf.get(ProviderConfKey)
require(data != null, s"$ProviderConfKey is not set in configuration")

val extern = ExternalizerSerializer.inj.invert(data).get
extern.get.asInstanceOf[BinaryConverter[M]]
cached match {
case Some((data, conv)) => conv
case _ =>
val extern = ExternalizerSerializer.inj.invert(data).get
val conv = extern.get.asInstanceOf[BinaryConverter[M]]
cached = Some((data, conv))
conv
}
}
}

Expand Down
Expand Up @@ -37,6 +37,6 @@ object LzoGenericSource {
new LzoGenericSource[T] {
override val conv: BinaryConverter[T] = passedConv
override val hdfsPaths = paths
override val localPaths = { assert(paths.size == 1, "Cannot use multiple input files on local mode"); paths }
override val localPaths = paths
}
}

0 comments on commit 925291c

Please sign in to comment.