org.apache.hadoop.hbase.io.encoding
Class HFileBlockDefaultEncodingContext

java.lang.Object
  extended by org.apache.hadoop.hbase.io.encoding.HFileBlockDefaultEncodingContext
All Implemented Interfaces:
HFileBlockEncodingContext

public class HFileBlockDefaultEncodingContext
extends Object
implements HFileBlockEncodingContext

A default implementation of HFileBlockEncodingContext. It will compress the data section as one continuous buffer.

See Also:
for the decompression part

Constructor Summary
HFileBlockDefaultEncodingContext(Compression.Algorithm compressionAlgorithm, DataBlockEncoding encoding, byte[] headerBytes)
           
 
Method Summary
 void close()
          Releases the compressor this writer uses to compress blocks into the compressor pool.
protected  void compressAfterEncoding(byte[] uncompressedBytesWithHeader, BlockType blockType, byte[] headerBytes)
           
 void compressAfterEncodingWithBlockType(byte[] uncompressedBytesWithHeader, BlockType blockType)
           
 BlockType getBlockType()
           
 Compression.Algorithm getCompression()
           
 DataBlockEncoding getDataBlockEncoding()
           
 byte[] getOnDiskBytesWithHeader()
           
 DataOutputStream getOutputStreamForEncoder()
           
 byte[] getUncompressedBytesWithHeader()
           
 void postEncoding(BlockType blockType)
          Do any action that needs to be performed after the encoding.
 void prepareEncoding()
          prepare to start a new encoding.
 void setDummyHeader(byte[] headerBytes)
          sets the dummy header bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HFileBlockDefaultEncodingContext

public HFileBlockDefaultEncodingContext(Compression.Algorithm compressionAlgorithm,
                                        DataBlockEncoding encoding,
                                        byte[] headerBytes)
Parameters:
compressionAlgorithm - compression algorithm used
encoding - encoding used
headerBytes - dummy header bytes
Method Detail

setDummyHeader

public void setDummyHeader(byte[] headerBytes)
Description copied from interface: HFileBlockEncodingContext
sets the dummy header bytes

Specified by:
setDummyHeader in interface HFileBlockEncodingContext

prepareEncoding

public void prepareEncoding()
                     throws IOException
prepare to start a new encoding.

Throws:
IOException

postEncoding

public void postEncoding(BlockType blockType)
                  throws IOException
Description copied from interface: HFileBlockEncodingContext
Do any action that needs to be performed after the encoding. Compression is also included if HFileBlockEncodingContext.getCompression() returns non-null compression algorithm

Specified by:
postEncoding in interface HFileBlockEncodingContext
Throws:
IOException

compressAfterEncodingWithBlockType

public void compressAfterEncodingWithBlockType(byte[] uncompressedBytesWithHeader,
                                               BlockType blockType)
                                        throws IOException
Parameters:
uncompressedBytesWithHeader -
blockType -
Throws:
IOException

compressAfterEncoding

protected void compressAfterEncoding(byte[] uncompressedBytesWithHeader,
                                     BlockType blockType,
                                     byte[] headerBytes)
                              throws IOException
Parameters:
uncompressedBytesWithHeader -
blockType -
headerBytes -
Throws:
IOException

getOnDiskBytesWithHeader

public byte[] getOnDiskBytesWithHeader()
Specified by:
getOnDiskBytesWithHeader in interface HFileBlockEncodingContext
Returns:
encoded and compressed bytes with header which are ready to write out to disk

getUncompressedBytesWithHeader

public byte[] getUncompressedBytesWithHeader()
Specified by:
getUncompressedBytesWithHeader in interface HFileBlockEncodingContext
Returns:
encoded but not heavily compressed bytes with header which can be cached in block cache

getBlockType

public BlockType getBlockType()
Specified by:
getBlockType in interface HFileBlockEncodingContext
Returns:
the block type after encoding

close

public void close()
Releases the compressor this writer uses to compress blocks into the compressor pool.

Specified by:
close in interface HFileBlockEncodingContext

getCompression

public Compression.Algorithm getCompression()
Specified by:
getCompression in interface HFileBlockEncodingContext
Returns:
the compression algorithm used by this encoding context

getOutputStreamForEncoder

public DataOutputStream getOutputStreamForEncoder()
Specified by:
getOutputStreamForEncoder in interface HFileBlockEncodingContext
Returns:
OutputStream to which encoded data is written

getDataBlockEncoding

public DataBlockEncoding getDataBlockEncoding()
Specified by:
getDataBlockEncoding in interface HFileBlockEncodingContext
Returns:
the DataBlockEncoding encoding used


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