Package org.apache.spark.io
Class HadoopCodecStreams
Object
org.apache.spark.io.HadoopCodecStreams
An utility object to look up Hadoop compression codecs and create input streams.
In addition to standard Hadoop codecs, it also supports Spark's Zstandard codec
if Hadopp is not compiled with Zstandard support. Additionally, it supports
non-standard file extensions like
.zstd and .gzip for Zstandard and Gzip codecs.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamcreateInputStream(org.apache.hadoop.conf.Configuration config, org.apache.hadoop.fs.Path file) static scala.Option<InputStream> createZstdInputStream(org.apache.hadoop.conf.Configuration config, org.apache.hadoop.fs.Path file, InputStream inputStream) static StringHadoopConfigurationkey carrying the read-side compression codec explicitly requested via thedecompressiondata source option.static scala.Option<org.apache.hadoop.io.compress.CompressionCodec> getDecompressionCodec(org.apache.hadoop.conf.Configuration config, org.apache.hadoop.fs.Path file) Returns the codec to decompressfilewith.
-
Constructor Details
-
HadoopCodecStreams
public HadoopCodecStreams()
-
-
Method Details
-
DECOMPRESSION_CODEC_CONF
HadoopConfigurationkey carrying the read-side compression codec explicitly requested via thedecompressiondata source option. The value is a full codec class name, an empty string to force "no compression" (read the file as-is), or absent to infer the codec from the file name extension. Set by the file format / scan read paths and consumed bygetDecompressionCodec(org.apache.hadoop.conf.Configuration,org.apache.hadoop.fs.Path)so it uniformly overrides extension-based detection for line-based, multi-line, whole-text, and schema-inference reads.This is an internal key, deliberately outside the
spark.*namespace so it is not mistaken for a user-facing configuration. The read paths always overwrite or unset it, so a value inherited from the session or Hadoop configuration is never honored.- Returns:
- (undocumented)
-
getDecompressionCodec
public static scala.Option<org.apache.hadoop.io.compress.CompressionCodec> getDecompressionCodec(org.apache.hadoop.conf.Configuration config, org.apache.hadoop.fs.Path file) Returns the codec to decompressfilewith. When a read compression option has been set (seeDECOMPRESSION_CODEC_CONF()) it takes precedence over the file name extension: a codec class name selects that codec, and an empty value means the file is read as-is. Otherwise the codec is inferred from the file name extension.- Parameters:
config- (undocumented)file- (undocumented)- Returns:
- (undocumented)
-
createZstdInputStream
public static scala.Option<InputStream> createZstdInputStream(org.apache.hadoop.conf.Configuration config, org.apache.hadoop.fs.Path file, InputStream inputStream) -
createInputStream
public static InputStream createInputStream(org.apache.hadoop.conf.Configuration config, org.apache.hadoop.fs.Path file)
-