Class HFileBlockDefaultEncodingContext
java.lang.Object
org.apache.hadoop.hbase.io.encoding.HFileBlockDefaultEncodingContext
- All Implemented Interfaces:
HFileBlockEncodingContext
@Private
public class HFileBlockDefaultEncodingContext
extends Object
implements HFileBlockEncodingContext
A default implementation of
HFileBlockEncodingContext
. It will compress the data section
as one continuous buffer.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate BlockType
private ByteArrayOutputStream
Underlying stream to write compressed bytes toprivate org.apache.hadoop.io.compress.CompressionOutputStream
Compression output streamprivate org.apache.hadoop.io.compress.Compressor
Compressor, which is also reused between consecutive blocks.private ByteArrayOutputStream
Underlying stream to write encrypted bytes toprivate byte[]
private EncodingState
private final DataBlockEncoding
private HFileContext
private byte[]
Initialization vectorprivate TagCompressionContext
-
Constructor Summary
ConstructorDescriptionHFileBlockDefaultEncodingContext
(org.apache.hadoop.conf.Configuration conf, DataBlockEncoding encoding, byte[] headerBytes, HFileContext fileContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases the compressor this writer uses to compress blocks into the compressor pool.private Bytes
compressAfterEncoding
(byte[] uncompressedBytesWithHeaderBuffer, int uncompressedBytesWithHeaderOffset, int uncompressedBytesWithHeaderLength, byte[] headerBytes) compressAndEncrypt
(byte[] data, int offset, int length) Compress and encrypt the supplied encoded block data with header.Returns the block type after encodingReturns theDataBlockEncoding
encoding usedReturns the encoding stateReturns HFile context informationvoid
postEncoding
(BlockType blockType) Do any action that needs to be performed after the encoding.void
prepare to start a new encoding.void
setEncodingState
(EncodingState state) Sets the encoding state.void
setTagCompressionContext
(TagCompressionContext tagCompressionContext)
-
Field Details
-
blockType
-
encodingAlgo
-
dummyHeader
-
compressor
Compressor, which is also reused between consecutive blocks. -
compressionStream
Compression output stream -
compressedByteStream
Underlying stream to write compressed bytes to -
fileContext
-
tagCompressionContext
-
cryptoByteStream
Underlying stream to write encrypted bytes to -
iv
Initialization vector -
encoderState
-
-
Constructor Details
-
HFileBlockDefaultEncodingContext
public HFileBlockDefaultEncodingContext(org.apache.hadoop.conf.Configuration conf, DataBlockEncoding encoding, byte[] headerBytes, HFileContext fileContext) - Parameters:
conf
- configuratonencoding
- encoding usedheaderBytes
- dummy header bytesfileContext
- HFile meta data
-
-
Method Details
-
prepareEncoding
prepare to start a new encoding.- Throws:
IOException
-
postEncoding
Description copied from interface:HFileBlockEncodingContext
Do any action that needs to be performed after the encoding. Compression is also included if a non-null compression algorithm is used- Specified by:
postEncoding
in interfaceHFileBlockEncodingContext
- Throws:
IOException
-
compressAndEncrypt
Description copied from interface:HFileBlockEncodingContext
Compress and encrypt the supplied encoded block data with header.- Specified by:
compressAndEncrypt
in interfaceHFileBlockEncodingContext
- Parameters:
data
- encoded bytes with headeroffset
- the offset in encoded data to start atlength
- the number of encoded bytes- Returns:
- Bytes with header which are ready to write out to disk. This is compressed and encrypted bytes applying the set compression algorithm and encryption. The bytes may be changed. If need a Bytes reference for later use, clone the bytes and use that. Null if the data doesn't need to be compressed and encrypted.
- Throws:
IOException
-
compressAfterEncoding
private Bytes compressAfterEncoding(byte[] uncompressedBytesWithHeaderBuffer, int uncompressedBytesWithHeaderOffset, int uncompressedBytesWithHeaderLength, byte[] headerBytes) throws IOException - Throws:
IOException
-
getBlockType
Description copied from interface:HFileBlockEncodingContext
Returns the block type after encoding- Specified by:
getBlockType
in interfaceHFileBlockEncodingContext
-
close
Releases the compressor this writer uses to compress blocks into the compressor pool.- Specified by:
close
in interfaceHFileBlockEncodingContext
-
getDataBlockEncoding
Description copied from interface:HFileBlockEncodingContext
Returns theDataBlockEncoding
encoding used- Specified by:
getDataBlockEncoding
in interfaceHFileBlockEncodingContext
-
getHFileContext
Description copied from interface:HFileBlockEncodingContext
Returns HFile context information- Specified by:
getHFileContext
in interfaceHFileBlockEncodingContext
-
getTagCompressionContext
-
setTagCompressionContext
-
getEncodingState
Description copied from interface:HFileBlockEncodingContext
Returns the encoding state- Specified by:
getEncodingState
in interfaceHFileBlockEncodingContext
-
setEncodingState
Description copied from interface:HFileBlockEncodingContext
Sets the encoding state.- Specified by:
setEncodingState
in interfaceHFileBlockEncodingContext
-