Interface DataBlockEncoder
- All Known Implementing Classes:
AbstractDataBlockEncoder
,BufferedDataBlockEncoder
,CopyKeyDataBlockEncoder
,DiffKeyDeltaEncoder
,FastDiffDeltaEncoder
,PrefixKeyDeltaEncoder
,RowIndexCodecV1
Encoding of KeyValue. It aims to be fast and efficient using assumptions:
- the KeyValues are stored sorted by key
- we know the structure of KeyValue
- the values are always iterated forward from beginning of block
- knowledge of Key Value format
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An interface which enable to seek while underlying data is encoded. -
Method Summary
Modifier and TypeMethodDescriptioncreateSeeker
(HFileBlockDecodingContext decodingCtx) Create a HFileBlock seeker which find KeyValues within a block.decodeKeyValues
(DataInputStream source, HFileBlockDecodingContext decodingCtx) Decode.void
encode
(ExtendedCell cell, HFileBlockEncodingContext encodingCtx, DataOutputStream out) Encodes a KeyValue.void
endBlockEncoding
(HFileBlockEncodingContext encodingCtx, DataOutputStream out, byte[] uncompressedBytesWithHeader) Ends encoding for a block of KeyValues.getFirstKeyCellInBlock
(ByteBuff block) Return first key in block as a cell.newDataBlockDecodingContext
(org.apache.hadoop.conf.Configuration conf, HFileContext meta) Creates an encoder specific decoding context, which will prepare the data before actual decoding store configuration HFile meta datanewDataBlockEncodingContext
(org.apache.hadoop.conf.Configuration conf, DataBlockEncoding encoding, byte[] headerBytes, HFileContext meta) Creates a encoder specific encoding context store configuration encoding strategy used header bytes to be written, put a dummy header here if the header is unknown HFile meta datavoid
startBlockEncoding
(HFileBlockEncodingContext encodingCtx, DataOutputStream out) Starts encoding for a block of KeyValues.
-
Method Details
-
startBlockEncoding
void startBlockEncoding(HFileBlockEncodingContext encodingCtx, DataOutputStream out) throws IOException Starts encoding for a block of KeyValues. CallendBlockEncoding(HFileBlockEncodingContext, DataOutputStream, byte[])
to finish encoding of a block.- Throws:
IOException
-
encode
void encode(ExtendedCell cell, HFileBlockEncodingContext encodingCtx, DataOutputStream out) throws IOException Encodes a KeyValue. After the encode,EncodingState.postCellEncode(int, int)
needs to be called to keep track of the encoded and unencoded data size- Throws:
IOException
-
endBlockEncoding
void endBlockEncoding(HFileBlockEncodingContext encodingCtx, DataOutputStream out, byte[] uncompressedBytesWithHeader) throws IOException Ends encoding for a block of KeyValues. Gives a chance for the encoder to do the finishing stuff for the encoded block. It must be called at the end of block encoding.- Throws:
IOException
-
decodeKeyValues
ByteBuffer decodeKeyValues(DataInputStream source, HFileBlockDecodingContext decodingCtx) throws IOException Decode.- Parameters:
source
- Compressed stream of KeyValues.- Returns:
- Uncompressed block of KeyValues.
- Throws:
IOException
- If there is an error in source.
-
getFirstKeyCellInBlock
Return first key in block as a cell. Useful for indexing. Typically does not make a deep copy but returns a buffer wrapping a segment of the actual block's byte array. This is because the first key in block is usually stored unencoded.- Parameters:
block
- encoded block we want index, the position will not change- Returns:
- First key in block as a cell.
-
createSeeker
Create a HFileBlock seeker which find KeyValues within a block.- Returns:
- A newly created seeker.
-
newDataBlockEncodingContext
HFileBlockEncodingContext newDataBlockEncodingContext(org.apache.hadoop.conf.Configuration conf, DataBlockEncoding encoding, byte[] headerBytes, HFileContext meta) Creates a encoder specific encoding context store configuration encoding strategy used header bytes to be written, put a dummy header here if the header is unknown HFile meta data- Returns:
- a newly created encoding context
-
newDataBlockDecodingContext
HFileBlockDecodingContext newDataBlockDecodingContext(org.apache.hadoop.conf.Configuration conf, HFileContext meta) Creates an encoder specific decoding context, which will prepare the data before actual decoding store configuration HFile meta data- Returns:
- a newly created decoding context
-