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
FieldsModifier and TypeFieldDescriptionprivate BlockTypeprivate ByteArrayOutputStreamUnderlying stream to write compressed bytes toprivate org.apache.hadoop.io.compress.CompressionOutputStreamCompression output streamprivate org.apache.hadoop.io.compress.CompressorCompressor, which is also reused between consecutive blocks.private ByteArrayOutputStreamUnderlying stream to write encrypted bytes toprivate byte[]private EncodingStateprivate final DataBlockEncodingprivate HFileContextprivate byte[]Initialization vectorprivate TagCompressionContext -
Constructor Summary
ConstructorsConstructorDescriptionHFileBlockDefaultEncodingContext(org.apache.hadoop.conf.Configuration conf, DataBlockEncoding encoding, byte[] headerBytes, HFileContext fileContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases the compressor this writer uses to compress blocks into the compressor pool.private BytescompressAfterEncoding(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 theDataBlockEncodingencoding usedReturns the encoding stateReturns HFile context informationvoidpostEncoding(BlockType blockType) Do any action that needs to be performed after the encoding.voidprepare to start a new encoding.voidsetEncodingState(EncodingState state) Sets the encoding state.voidsetTagCompressionContext(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:HFileBlockEncodingContextDo any action that needs to be performed after the encoding. Compression is also included if a non-null compression algorithm is used- Specified by:
postEncodingin interfaceHFileBlockEncodingContext- Throws:
IOException
-
compressAndEncrypt
Description copied from interface:HFileBlockEncodingContextCompress and encrypt the supplied encoded block data with header.- Specified by:
compressAndEncryptin 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:HFileBlockEncodingContextReturns the block type after encoding- Specified by:
getBlockTypein interfaceHFileBlockEncodingContext
-
close
Releases the compressor this writer uses to compress blocks into the compressor pool.- Specified by:
closein interfaceHFileBlockEncodingContext
-
getDataBlockEncoding
Description copied from interface:HFileBlockEncodingContextReturns theDataBlockEncodingencoding used- Specified by:
getDataBlockEncodingin interfaceHFileBlockEncodingContext
-
getHFileContext
Description copied from interface:HFileBlockEncodingContextReturns HFile context information- Specified by:
getHFileContextin interfaceHFileBlockEncodingContext
-
getTagCompressionContext
-
setTagCompressionContext
-
getEncodingState
Description copied from interface:HFileBlockEncodingContextReturns the encoding state- Specified by:
getEncodingStatein interfaceHFileBlockEncodingContext
-
setEncodingState
Description copied from interface:HFileBlockEncodingContextSets the encoding state.- Specified by:
setEncodingStatein interfaceHFileBlockEncodingContext
-