org.apache.hadoop.hbase.io.hfile
Interface HFileDataBlockEncoder

All Known Implementing Classes:
HFileDataBlockEncoderImpl, NoOpDataBlockEncoder

@InterfaceAudience.Private
public interface HFileDataBlockEncoder

Controls what kind of data block encoding is used. If data block encoding is not set or the given block is not a data block (encoded or not), methods should just return the unmodified block.


Field Summary
static byte[] DATA_BLOCK_ENCODING
          Type of encoding used for data blocks in HFile.
 
Method Summary
 void beforeWriteToDisk(ByteBuffer in, boolean includesMemstoreTS, HFileBlockEncodingContext encodingResult, BlockType blockType)
          Should be called before an encoded or unencoded data block is written to disk.
 HFileBlock diskToCacheFormat(HFileBlock block, boolean isCompaction)
          Converts a block from the on-disk format to the in-cache format.
 DataBlockEncoding getEffectiveEncodingInCache(boolean isCompaction)
           
 DataBlockEncoding getEncodingInCache()
           
 DataBlockEncoding getEncodingOnDisk()
           
 HFileBlockDecodingContext newOnDiskDataBlockDecodingContext(Compression.Algorithm compressionAlgorithm)
          create a encoder specific decoding context for reading.
 HFileBlockEncodingContext newOnDiskDataBlockEncodingContext(Compression.Algorithm compressionAlgorithm, byte[] headerBytes)
          Create an encoder specific encoding context object for writing.
 void saveMetadata(HFile.Writer writer)
          Save metadata in HFile which will be written to disk
 boolean useEncodedScanner(boolean isCompaction)
          Decides whether we should use a scanner over encoded blocks.
 

Field Detail

DATA_BLOCK_ENCODING

static final byte[] DATA_BLOCK_ENCODING
Type of encoding used for data blocks in HFile. Stored in file info.

Method Detail

diskToCacheFormat

HFileBlock diskToCacheFormat(HFileBlock block,
                             boolean isCompaction)
Converts a block from the on-disk format to the in-cache format. Called in the following cases:

Parameters:
block - a block in an on-disk format (read from HFile or freshly generated).
Returns:
non null block which is coded according to the settings.

beforeWriteToDisk

void beforeWriteToDisk(ByteBuffer in,
                       boolean includesMemstoreTS,
                       HFileBlockEncodingContext encodingResult,
                       BlockType blockType)
                       throws IOException
Should be called before an encoded or unencoded data block is written to disk.

Parameters:
in - KeyValues next to each other
encodingResult - the encoded result
blockType - block type
Throws:
IOException

useEncodedScanner

boolean useEncodedScanner(boolean isCompaction)
Decides whether we should use a scanner over encoded blocks.

Parameters:
isCompaction - whether we are in a compaction.
Returns:
Whether to use encoded scanner.

saveMetadata

void saveMetadata(HFile.Writer writer)
                  throws IOException
Save metadata in HFile which will be written to disk

Parameters:
writer - writer for a given HFile
Throws:
IOException - on disk problems

getEncodingOnDisk

DataBlockEncoding getEncodingOnDisk()
Returns:
the on-disk data block encoding

getEncodingInCache

DataBlockEncoding getEncodingInCache()
Returns:
the preferred in-cache data block encoding for normal reads

getEffectiveEncodingInCache

DataBlockEncoding getEffectiveEncodingInCache(boolean isCompaction)
Returns:
the effective in-cache data block encoding, taking into account whether we are doing a compaction.

newOnDiskDataBlockEncodingContext

HFileBlockEncodingContext newOnDiskDataBlockEncodingContext(Compression.Algorithm compressionAlgorithm,
                                                            byte[] headerBytes)
Create an encoder specific encoding context object for writing. And the encoding context should also perform compression if compressionAlgorithm is valid.

Parameters:
compressionAlgorithm - compression algorithm
headerBytes - header bytes
Returns:
a new HFileBlockEncodingContext object

newOnDiskDataBlockDecodingContext

HFileBlockDecodingContext newOnDiskDataBlockDecodingContext(Compression.Algorithm compressionAlgorithm)
create a encoder specific decoding context for reading. And the decoding context should also do decompression if compressionAlgorithm is valid.

Parameters:
compressionAlgorithm -
Returns:
a new HFileBlockDecodingContext object


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.