Skip to content


TextBasedFileFormat is an extension of the FileFormat contract for <> that can be <>.

[[implementations]] .TextBasedFileFormats [cols="1,2",options="header",width="100%"] |=== | TextBasedFileFormat | Description

| CSVFileFormat | [[CSVFileFormat]]

| JsonFileFormat | [[JsonFileFormat]]

| LibSVMFileFormat | [[LibSVMFileFormat]] Used in Spark MLlib

| TextFileFormat | [[TextFileFormat]] |===

[[codecFactory]] TextBasedFileFormat uses Hadoop's[CompressionCodecFactory] to <>.

=== [[isSplitable]] isSplitable Method

[source, scala]

isSplitable( sparkSession: SparkSession, options: Map[String, String], path: Path): Boolean

isSplitable is part of the FileFormat abstraction.

isSplitable requests the <> to find the ++[compression codec for the given file] (as the input path) based on its filename suffix.

isSplitable returns true when the compression codec is not used (i.e. null) or is a Hadoop[SplittableCompressionCodec] (e.g.[BZip2Codec]).

If the <> is not defined, isSplitable creates a[CompressionCodecFactory] (with a Hadoop Configuration by requesting the SessionState for a[new Hadoop Configuration with extra options]).

NOTE: isSplitable uses the input sparkSession to access[SessionState].

[NOTE][SplittableCompressionCodec] interface is for compression codecs that are capable to compress and de-compress a stream starting at any arbitrary position.

Such codecs are highly valuable, especially in the context of Hadoop, because an input compressed file can be split and hence can be worked on by multiple machines in parallel.

One such compression codec is[BZip2Codec] that provides output and input streams for bzip2 compression and decompression.