Enum Compression
- java.lang.Object
-
- java.lang.Enum<Compression>
-
- org.apache.beam.sdk.io.Compression
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Compression>
public enum Compression extends java.lang.Enum<Compression>
Various compression types for reading/writing files.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTO
When reading a file, automatically determine the compression type based on filename extension.BZIP2
BZip compression.DEFLATE
Deflate compression.GZIP
GZip compression.LZO
LZO compression using LZO codec.LZOP
LZOP compression using LZOP codec.SNAPPY
Google Snappy compression.UNCOMPRESSED
No compression.ZIP
Zip compression.ZSTD
ZStandard compression.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Compression
detect(java.lang.String filename)
java.lang.String
getSuggestedSuffix()
boolean
isCompressed(java.lang.String filename)
boolean
matches(java.lang.String filename)
abstract java.nio.channels.ReadableByteChannel
readDecompressed(java.nio.channels.ReadableByteChannel channel)
static Compression
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Compression[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.abstract java.nio.channels.WritableByteChannel
writeCompressed(java.nio.channels.WritableByteChannel channel)
-
-
-
Enum Constant Detail
-
AUTO
public static final Compression AUTO
When reading a file, automatically determine the compression type based on filename extension. Not applicable when writing files.
-
UNCOMPRESSED
public static final Compression UNCOMPRESSED
No compression.
-
GZIP
public static final Compression GZIP
GZip compression.
-
BZIP2
public static final Compression BZIP2
BZip compression.
-
ZIP
public static final Compression ZIP
Zip compression.
-
ZSTD
public static final Compression ZSTD
ZStandard compression.The
.zst
extension is specified in RFC 8478.The Beam Java SDK does not pull in the Zstd library by default, so it is the user's responsibility to declare an explicit dependency on
zstd-jni
. Attempts to read or write .zst files withoutzstd-jni
loaded will result inNoClassDefFoundError
at runtime.
-
LZO
public static final Compression LZO
LZO compression using LZO codec..lzo_deflate
extension is specified for files which use the LZO algorithm without headers.The Beam Java SDK does not pull in the required libraries for LZO compression by default, so it is the user's responsibility to declare an explicit dependency on
io.airlift:aircompressor
andcom.facebook.presto.hadoop:hadoop-apache2
. Attempts to read or write.lzo_deflate
files withoutio.airlift:aircompressor
andcom.facebook.presto.hadoop:hadoop-apache2
loaded will result in aNoClassDefFoundError
at runtime.
-
LZOP
public static final Compression LZOP
LZOP compression using LZOP codec..lzo
extension is specified for files with magic bytes and headers.Warning: The LZOP codec being used does not support concatenated LZOP streams and will silently ignore data after the end of the first LZOP stream.
The Beam Java SDK does not pull in the required libraries for LZOP compression by default, so it is the user's responsibility to declare an explicit dependency on
io.airlift:aircompressor
andcom.facebook.presto.hadoop:hadoop-apache2
. Attempts to read or write.lzo
files withoutio.airlift:aircompressor
andcom.facebook.presto.hadoop:hadoop-apache2
loaded will result in aNoClassDefFoundError
at runtime.
-
DEFLATE
public static final Compression DEFLATE
Deflate compression.
-
SNAPPY
public static final Compression SNAPPY
Google Snappy compression.
-
-
Method Detail
-
values
public static Compression[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Compression c : Compression.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Compression valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getSuggestedSuffix
public java.lang.String getSuggestedSuffix()
-
matches
public boolean matches(java.lang.String filename)
-
isCompressed
public boolean isCompressed(java.lang.String filename)
-
detect
public static Compression detect(java.lang.String filename)
-
readDecompressed
public abstract java.nio.channels.ReadableByteChannel readDecompressed(java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCompressed
public abstract java.nio.channels.WritableByteChannel writeCompressed(java.nio.channels.WritableByteChannel channel) throws java.io.IOException
- Throws:
java.io.IOException
-
-