org.elasticsearch.common.compress.lzf.impl
Class UnsafeChunkDecoder

java.lang.Object
  extended by org.elasticsearch.common.compress.lzf.ChunkDecoder
      extended by org.elasticsearch.common.compress.lzf.impl.UnsafeChunkDecoder

public class UnsafeChunkDecoder
extends ChunkDecoder

Highly optimized ChunkDecoder implementation that uses Sun JDK's Unsafe class (which may be included by other JDK's as well; IBM's apparently does).

Credits for the idea go to Dain Sundstrom, who kindly suggested this use, and is all-around great source for optimization tips and tricks.


Field Summary
 
Fields inherited from class org.elasticsearch.common.compress.lzf.ChunkDecoder
BYTE_NULL, HEADER_BYTES
 
Constructor Summary
UnsafeChunkDecoder()
           
 
Method Summary
 void decodeChunk(byte[] in, int inPos, byte[] out, int outPos, int outEnd)
          Main decode method for individual chunks.
 int decodeChunk(java.io.InputStream is, byte[] inputBuffer, byte[] outputBuffer)
          Main decode from a stream.
 
Methods inherited from class org.elasticsearch.common.compress.lzf.ChunkDecoder
calculateUncompressedSize, decode, decode, decode, decode, readFully, readHeader, uint16
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnsafeChunkDecoder

public UnsafeChunkDecoder()
Method Detail

decodeChunk

public final int decodeChunk(java.io.InputStream is,
                             byte[] inputBuffer,
                             byte[] outputBuffer)
                      throws java.io.IOException
Description copied from class: ChunkDecoder
Main decode from a stream. Decompressed bytes are placed in the outputBuffer, inputBuffer is a "scratch-area".

Specified by:
decodeChunk in class ChunkDecoder
Parameters:
is - An input stream of LZF compressed bytes
inputBuffer - A byte array used as a scratch area.
outputBuffer - A byte array in which the result is returned
Returns:
The number of bytes placed in the outputBuffer.
Throws:
java.io.IOException

decodeChunk

public final void decodeChunk(byte[] in,
                              int inPos,
                              byte[] out,
                              int outPos,
                              int outEnd)
                       throws java.io.IOException
Description copied from class: ChunkDecoder
Main decode method for individual chunks.

Specified by:
decodeChunk in class ChunkDecoder
Throws:
java.io.IOException