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

All Known Implementing Classes:
HFileDataBlockEncoderImpl, NoOpDataBlockEncoder

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
 Pair<ByteBuffer,BlockType> beforeWriteToDisk(ByteBuffer in, boolean includesMemstoreTS, byte[] dummyHeader)
          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()
           
 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

Pair<ByteBuffer,BlockType> beforeWriteToDisk(ByteBuffer in,
                                             boolean includesMemstoreTS,
                                             byte[] dummyHeader)
Should be called before an encoded or unencoded data block is written to disk.

Parameters:
in - KeyValues next to each other
dummyHeader - A dummy header to be written as a placeholder
Returns:
a non-null on-heap buffer containing the contents of the HFileBlock with unfilled header and block type

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.


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