Package org.apache.lucene.document
Class CompressionTools
java.lang.Object
org.apache.lucene.document.CompressionTools
Simple utility class providing static methods to
compress and decompress binary data for stored fields.
This class uses java.util.zip.Deflater and Inflater
classes to compress and decompress.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
compress
(byte[] value) Compresses all bytes in the array, with default BEST_COMPRESSION levelstatic byte[]
compress
(byte[] value, int offset, int length) Compresses the specified byte range, with default BEST_COMPRESSION levelstatic byte[]
compress
(byte[] value, int offset, int length, int compressionLevel) Compresses the specified byte range using the specified compressionLevel (constants are defined in java.util.zip.Deflater).static byte[]
compressString
(String value) Compresses the String value, with default BEST_COMPRESSION levelstatic byte[]
compressString
(String value, int compressionLevel) Compresses the String value using the specified compressionLevel (constants are defined in java.util.zip.Deflater).static byte[]
decompress
(byte[] value) Decompress the byte array previously returned by compressstatic byte[]
decompress
(byte[] value, int offset, int length) Decompress the byte array previously returned by compressstatic byte[]
decompress
(BytesRef bytes) Decompress the byte array previously returned by compress (referenced by the provided BytesRef)static String
decompressString
(byte[] value) Decompress the byte array previously returned by compressString back into a Stringstatic String
decompressString
(byte[] value, int offset, int length) Decompress the byte array previously returned by compressString back into a Stringstatic String
decompressString
(BytesRef bytes) Decompress the byte array (referenced by the provided BytesRef) previously returned by compressString back into a String
-
Method Details
-
compress
public static byte[] compress(byte[] value, int offset, int length, int compressionLevel) Compresses the specified byte range using the specified compressionLevel (constants are defined in java.util.zip.Deflater). -
compress
public static byte[] compress(byte[] value, int offset, int length) Compresses the specified byte range, with default BEST_COMPRESSION level -
compress
public static byte[] compress(byte[] value) Compresses all bytes in the array, with default BEST_COMPRESSION level -
compressString
Compresses the String value, with default BEST_COMPRESSION level -
compressString
Compresses the String value using the specified compressionLevel (constants are defined in java.util.zip.Deflater). -
decompress
Decompress the byte array previously returned by compress (referenced by the provided BytesRef)- Throws:
DataFormatException
-
decompress
Decompress the byte array previously returned by compress- Throws:
DataFormatException
-
decompress
Decompress the byte array previously returned by compress- Throws:
DataFormatException
-
decompressString
Decompress the byte array previously returned by compressString back into a String- Throws:
DataFormatException
-
decompressString
public static String decompressString(byte[] value, int offset, int length) throws DataFormatException Decompress the byte array previously returned by compressString back into a String- Throws:
DataFormatException
-
decompressString
Decompress the byte array (referenced by the provided BytesRef) previously returned by compressString back into a String- Throws:
DataFormatException
-