org.apache.hadoop.hbase.codec.prefixtree
Class PrefixTreeCodec

java.lang.Object
  extended by org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeCodec
All Implemented Interfaces:
DataBlockEncoder

@InterfaceAudience.Private
public class PrefixTreeCodec
extends Object
implements DataBlockEncoder

This class is created via reflection in DataBlockEncoding enum. Update the enum if class name or package changes.

PrefixTreeDataBlockEncoder implementation of DataBlockEncoder. This is the primary entry point for PrefixTree encoding and decoding. Encoding is delegated to instances of PrefixTreeEncoder, and decoding is delegated to instances of CellSearcher. Encoder and decoder instances are created and recycled by static PtEncoderFactory and PtDecoderFactory.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.io.encoding.DataBlockEncoder
DataBlockEncoder.EncodedSeeker
 
Constructor Summary
PrefixTreeCodec()
          no-arg constructor for reflection
 
Method Summary
 DataBlockEncoder.EncodedSeeker createSeeker(org.apache.hadoop.io.RawComparator<byte[]> comparator, boolean includesMvccVersion)
          Is this the correct handling of an illegal comparator? How to prevent that from getting all the way to this point.
 ByteBuffer decodeKeyValues(DataInputStream source, boolean includesMvccVersion)
          Decode.
 ByteBuffer decodeKeyValues(DataInputStream source, int allocateHeaderLength, int skipLastBytes, boolean includesMvccVersion)
          I don't think this method is called during normal HBase operation, so efficiency is not important.
 void encodeKeyValues(ByteBuffer in, boolean includesMvccVersion, HFileBlockEncodingContext blkEncodingCtx)
          Copied from BufferedDataBlockEncoder.
 ByteBuffer getFirstKeyInBlock(ByteBuffer block)
          Return first key in block.
 HFileBlockDecodingContext newDataBlockDecodingContext(Compression.Algorithm compressionAlgorithm)
          Creates an encoder specific decoding context, which will prepare the data before actual decoding
 HFileBlockEncodingContext newDataBlockEncodingContext(Compression.Algorithm compressionAlgorithm, DataBlockEncoding encoding, byte[] header)
          Creates a encoder specific encoding context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrefixTreeCodec

public PrefixTreeCodec()
no-arg constructor for reflection

Method Detail

encodeKeyValues

public void encodeKeyValues(ByteBuffer in,
                            boolean includesMvccVersion,
                            HFileBlockEncodingContext blkEncodingCtx)
                     throws IOException
Copied from BufferedDataBlockEncoder. Almost definitely can be improved, but i'm not familiar enough with the concept of the HFileBlockEncodingContext.

Specified by:
encodeKeyValues in interface DataBlockEncoder
Parameters:
in - Source of KeyValue for compression.
includesMvccVersion - true if including memstore timestamp after every key-value pair
blkEncodingCtx - the encoding context which will contain encoded uncompressed bytes as well as compressed encoded bytes if compression is enabled, and also it will reuse resources across multiple calls.
Throws:
IOException - If there is an error writing to output stream.

decodeKeyValues

public ByteBuffer decodeKeyValues(DataInputStream source,
                                  boolean includesMvccVersion)
                           throws IOException
Description copied from interface: DataBlockEncoder
Decode.

Specified by:
decodeKeyValues in interface DataBlockEncoder
Parameters:
source - Compressed stream of KeyValues.
includesMvccVersion - true if including memstore timestamp after every key-value pair
Returns:
Uncompressed block of KeyValues.
Throws:
IOException - If there is an error in source.

decodeKeyValues

public ByteBuffer decodeKeyValues(DataInputStream source,
                                  int allocateHeaderLength,
                                  int skipLastBytes,
                                  boolean includesMvccVersion)
                           throws IOException
I don't think this method is called during normal HBase operation, so efficiency is not important.

Specified by:
decodeKeyValues in interface DataBlockEncoder
Parameters:
source - encoded stream of KeyValues.
allocateHeaderLength - allocate this many bytes for the header.
skipLastBytes - Do not copy n last bytes.
includesMvccVersion - true if including memstore timestamp after every key-value pair
Returns:
Uncompressed block of KeyValues.
Throws:
IOException - If there is an error in source.

getFirstKeyInBlock

public ByteBuffer getFirstKeyInBlock(ByteBuffer block)
Description copied from interface: DataBlockEncoder
Return first key in block. 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.

Specified by:
getFirstKeyInBlock in interface DataBlockEncoder
Parameters:
block - encoded block we want index, the position will not change
Returns:
First key in block.

newDataBlockEncodingContext

public HFileBlockEncodingContext newDataBlockEncodingContext(Compression.Algorithm compressionAlgorithm,
                                                             DataBlockEncoding encoding,
                                                             byte[] header)
Description copied from interface: DataBlockEncoder
Creates a encoder specific encoding context

Specified by:
newDataBlockEncodingContext in interface DataBlockEncoder
Parameters:
compressionAlgorithm - compression algorithm used if the final data needs to be compressed
encoding - encoding strategy used
header - header bytes to be written, put a dummy header here if the header is unknown
Returns:
a newly created encoding context

newDataBlockDecodingContext

public HFileBlockDecodingContext newDataBlockDecodingContext(Compression.Algorithm compressionAlgorithm)
Description copied from interface: DataBlockEncoder
Creates an encoder specific decoding context, which will prepare the data before actual decoding

Specified by:
newDataBlockDecodingContext in interface DataBlockEncoder
Parameters:
compressionAlgorithm - compression algorithm used if the data needs to be decompressed
Returns:
a newly created decoding context

createSeeker

public DataBlockEncoder.EncodedSeeker createSeeker(org.apache.hadoop.io.RawComparator<byte[]> comparator,
                                                   boolean includesMvccVersion)
Is this the correct handling of an illegal comparator? How to prevent that from getting all the way to this point.

Specified by:
createSeeker in interface DataBlockEncoder
Parameters:
comparator - what kind of comparison should be used
includesMvccVersion - true if including memstore timestamp after every key-value pair
Returns:
A newly created seeker.


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