Package com.linkedin.venice.compression
Class VeniceCompressor
- java.lang.Object
-
- com.linkedin.venice.compression.VeniceCompressor
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
GzipCompressor
,NoopCompressor
,ZstdWithDictCompressor
public abstract class VeniceCompressor extends java.lang.Object implements java.io.Closeable
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
SCHEMA_HEADER_LENGTH
-
Constructor Summary
Constructors Modifier Constructor Description protected
VeniceCompressor(CompressionStrategy compressionStrategy)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
protected abstract void
closeInternal()
byte[]
compress(byte[] data)
java.nio.ByteBuffer
compress(java.nio.ByteBuffer src, int startPositionOfOutput)
protected abstract byte[]
compressInternal(byte[] data)
protected abstract java.nio.ByteBuffer
compressInternal(java.nio.ByteBuffer src, int startPositionOfOutput)
java.nio.ByteBuffer
decompress(byte[] data, int offset, int length)
java.io.InputStream
decompress(java.io.InputStream inputStream)
java.nio.ByteBuffer
decompress(java.nio.ByteBuffer data)
java.nio.ByteBuffer
decompressAndPrependSchemaHeader(byte[] data, int offset, int length, int schemaHeader)
This method tries to decompress data and maybe prepend the schema header.protected abstract java.nio.ByteBuffer
decompressAndPrependSchemaHeaderInternal(byte[] data, int offset, int length, int schemaHeader)
protected abstract java.nio.ByteBuffer
decompressInternal(byte[] data, int offset, int length)
protected abstract java.io.InputStream
decompressInternal(java.io.InputStream inputStream)
protected abstract java.nio.ByteBuffer
decompressInternal(java.nio.ByteBuffer data)
CompressionStrategy
getCompressionStrategy()
-
-
-
Field Detail
-
SCHEMA_HEADER_LENGTH
protected static final int SCHEMA_HEADER_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VeniceCompressor
protected VeniceCompressor(CompressionStrategy compressionStrategy)
-
-
Method Detail
-
compress
public byte[] compress(byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
compressInternal
protected abstract byte[] compressInternal(byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
compress
public java.nio.ByteBuffer compress(java.nio.ByteBuffer src, int startPositionOfOutput) throws java.io.IOException
- Throws:
java.io.IOException
-
compressInternal
protected abstract java.nio.ByteBuffer compressInternal(java.nio.ByteBuffer src, int startPositionOfOutput) throws java.io.IOException
- Throws:
java.io.IOException
-
decompress
public java.nio.ByteBuffer decompress(java.nio.ByteBuffer data) throws java.io.IOException
- Throws:
java.io.IOException
-
decompressInternal
protected abstract java.nio.ByteBuffer decompressInternal(java.nio.ByteBuffer data) throws java.io.IOException
- Throws:
java.io.IOException
-
decompress
public java.nio.ByteBuffer decompress(byte[] data, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
decompressInternal
protected abstract java.nio.ByteBuffer decompressInternal(byte[] data, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
decompressAndPrependSchemaHeader
public java.nio.ByteBuffer decompressAndPrependSchemaHeader(byte[] data, int offset, int length, int schemaHeader) throws java.io.IOException
This method tries to decompress data and maybe prepend the schema header. The returned ByteBuffer will be backed by byte array that starts with schema header, followed by the decompressed data. The ByteBuffer will be positioned at the beginning of the decompressed data and the remaining of the ByteBuffer will be the length of the decompressed data.- Throws:
java.io.IOException
-
decompressAndPrependSchemaHeaderInternal
protected abstract java.nio.ByteBuffer decompressAndPrependSchemaHeaderInternal(byte[] data, int offset, int length, int schemaHeader) throws java.io.IOException
- Throws:
java.io.IOException
-
getCompressionStrategy
public CompressionStrategy getCompressionStrategy()
-
decompress
public java.io.InputStream decompress(java.io.InputStream inputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
decompressInternal
protected abstract java.io.InputStream decompressInternal(java.io.InputStream inputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
closeInternal
protected abstract void closeInternal() throws java.io.IOException
- Throws:
java.io.IOException
-
-