Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/3119#discussion_r19908213
--- Diff: core/src/main/scala/org/apache/spark/io/CompressionCodec.scala ---
@@ -42,28 +43,52 @@ trait CompressionCodec {
def compressedOutputStream(s: OutputStream): OutputStream
def compressedInputStream(s: InputStream): InputStream
-}
+ def isAvailable() : Boolean = true
+}
-private[spark] object CompressionCodec {
+private[spark] object CompressionCodec extends Logging {
+ private val configKey = "spark.io.compression.codec"
private val shortCompressionCodecNames = Map(
"lz4" -> classOf[LZ4CompressionCodec].getName,
"lzf" -> classOf[LZFCompressionCodec].getName,
"snappy" -> classOf[SnappyCompressionCodec].getName)
def createCodec(conf: SparkConf): CompressionCodec = {
- createCodec(conf, conf.get("spark.io.compression.codec",
DEFAULT_COMPRESSION_CODEC))
+ conf.getOption(configKey)
+ .map(createCodec(conf, _))
+ .orElse(createCodecFromName(conf, DEFAULT_COMPRESSION_CODEC))
+ .orElse({
+ logWarning("Default codec " + DEFAULT_COMPRESSION_CODEC +
+ " is unavailable. Faling back to " +
FALLBACK_COMPRESSION_CODEC)
+ createCodecFromName(conf, FALLBACK_COMPRESSION_CODEC)
+ })
+ .getOrElse(throw new IllegalArgumentException("The codec [" +
+ FALLBACK_COMPRESSION_CODEC + "] is not available."))
}
def createCodec(conf: SparkConf, codecName: String): CompressionCodec = {
+ createCodecFromName(conf, codecName)
+ .getOrElse(throw new IllegalArgumentException("The specified codec
[" +
--- End diff --
Interpolation is probably prettier here:
s"The specified codec [$codecName] is not available."
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]