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

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

@InterfaceAudience.Private
public class CopyKeyDataBlockEncoder
extends Object

Just copy data, do not do any kind of compression. Use for comparison and benchmarking.


Nested Class Summary
protected static class BufferedDataBlockEncoder.BufferedEncodedSeeker<STATE extends BufferedDataBlockEncoder.SeekerState>
           
protected static class BufferedDataBlockEncoder.SeekerState
           
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.io.encoding.DataBlockEncoder
DataBlockEncoder.EncodedSeeker
 
Constructor Summary
CopyKeyDataBlockEncoder()
           
 
Method Summary
protected  void afterDecodingKeyValue(DataInputStream source, ByteBuffer dest, HFileBlockDefaultDecodingContext decodingCtx)
           
protected  void afterEncodingKeyValue(ByteBuffer in, DataOutputStream out, HFileBlockDefaultEncodingContext encodingCtx)
           
 DataBlockEncoder.EncodedSeeker createSeeker(KeyValue.KVComparator comparator, HFileBlockDecodingContext decodingCtx)
          Create a HFileBlock seeker which find KeyValues within a block.
 ByteBuffer decodeKeyValues(DataInputStream source, HFileBlockDecodingContext blkDecodingCtx)
          Decode.
 void encodeKeyValues(ByteBuffer in, HFileBlockEncodingContext blkEncodingCtx)
          Encodes KeyValues.
protected static void ensureSpace(ByteBuffer out, int length)
          Asserts that there is at least the given amount of unfilled space remaining in the given buffer.
 ByteBuffer getFirstKeyInBlock(ByteBuffer block)
          Return first key in block.
protected  ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength, int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx)
           
 void internalEncodeKeyValues(DataOutputStream out, ByteBuffer in, HFileBlockDefaultEncodingContext encodingCtx)
          Compress KeyValues and write them to output buffer.
 HFileBlockDecodingContext newDataBlockDecodingContext(HFileContext meta)
          Creates an encoder specific decoding context, which will prepare the data before actual decoding
 HFileBlockEncodingContext newDataBlockEncodingContext(DataBlockEncoding encoding, byte[] header, HFileContext meta)
          Creates a encoder specific encoding context
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CopyKeyDataBlockEncoder

public CopyKeyDataBlockEncoder()
Method Detail

internalEncodeKeyValues

public void internalEncodeKeyValues(DataOutputStream out,
                                    ByteBuffer in,
                                    HFileBlockDefaultEncodingContext encodingCtx)
                             throws IOException
Compress KeyValues and write them to output buffer.

Parameters:
out - Where to write compressed data.
in - Source of KeyValue for compression.
encodingCtx - use the Encoding ctx associated with the current block
Throws:
IOException - If there is an error writing to output stream.

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.

Parameters:
block - encoded block we want index, the position will not change
Returns:
First key in block.

toString

public String toString()
Overrides:
toString in class Object

createSeeker

public DataBlockEncoder.EncodedSeeker createSeeker(KeyValue.KVComparator comparator,
                                                   HFileBlockDecodingContext decodingCtx)
Description copied from interface: DataBlockEncoder
Create a HFileBlock seeker which find KeyValues within a block.

Parameters:
comparator - what kind of comparison should be used
Returns:
A newly created seeker.

internalDecodeKeyValues

protected ByteBuffer internalDecodeKeyValues(DataInputStream source,
                                             int allocateHeaderLength,
                                             int skipLastBytes,
                                             HFileBlockDefaultDecodingContext decodingCtx)
                                      throws IOException
Throws:
IOException

decodeKeyValues

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

Specified by:
decodeKeyValues in interface DataBlockEncoder
Parameters:
source - Compressed stream of KeyValues.
Returns:
Uncompressed block of KeyValues.
Throws:
IOException - If there is an error in source.

afterEncodingKeyValue

protected final void afterEncodingKeyValue(ByteBuffer in,
                                           DataOutputStream out,
                                           HFileBlockDefaultEncodingContext encodingCtx)
                                    throws IOException
Throws:
IOException

afterDecodingKeyValue

protected final void afterDecodingKeyValue(DataInputStream source,
                                           ByteBuffer dest,
                                           HFileBlockDefaultDecodingContext decodingCtx)
                                    throws IOException
Throws:
IOException

newDataBlockEncodingContext

public HFileBlockEncodingContext newDataBlockEncodingContext(DataBlockEncoding encoding,
                                                             byte[] header,
                                                             HFileContext meta)
Description copied from interface: DataBlockEncoder
Creates a encoder specific encoding context

Specified by:
newDataBlockEncodingContext in interface DataBlockEncoder
Parameters:
encoding - encoding strategy used
header - header bytes to be written, put a dummy header here if the header is unknown
meta - HFile meta data
Returns:
a newly created encoding context

newDataBlockDecodingContext

public HFileBlockDecodingContext newDataBlockDecodingContext(HFileContext meta)
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:
meta - HFile meta data
Returns:
a newly created decoding context

encodeKeyValues

public void encodeKeyValues(ByteBuffer in,
                            HFileBlockEncodingContext blkEncodingCtx)
                     throws IOException
Description copied from interface: DataBlockEncoder
Encodes KeyValues. It will first encode key value pairs, and then optionally do the compression for the encoded data.

Specified by:
encodeKeyValues in interface DataBlockEncoder
Parameters:
in - Source of KeyValue for compression.
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.

ensureSpace

protected static void ensureSpace(ByteBuffer out,
                                  int length)
                           throws EncoderBufferTooSmallException
Asserts that there is at least the given amount of unfilled space remaining in the given buffer.

Parameters:
out - typically, the buffer we are writing to
length - the required space in the buffer
Throws:
EncoderBufferTooSmallException - If there are no enough bytes.


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.