org.elasticsearch.common.compress
Class CompressedStreamInput<T extends CompressorContext>

java.lang.Object
  extended by java.io.InputStream
      extended by org.elasticsearch.common.io.stream.StreamInput
          extended by org.elasticsearch.common.compress.CompressedStreamInput<T>
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
LZFCompressedStreamInput, SnappyCompressedStreamInput

public abstract class CompressedStreamInput<T extends CompressorContext>
extends StreamInput


Field Summary
protected  CompressorContext context
           
protected  byte[] uncompressed
           
 
Constructor Summary
CompressedStreamInput(StreamInput in, T context)
           
 
Method Summary
 int available()
          Method is overridden to report number of bytes that can now be read from decoded data buffer, without reading bytes from the underlying stream.
 void close()
          Closes the stream to further operations.
protected abstract  void doClose()
           
 int read()
           
 int read(byte[] buffer, int offset, int length)
           
 int read(byte[] buffer, int offset, int length, boolean fullRead)
           
 byte readByte()
          Reads and returns a single byte.
 void readBytes(byte[] b, int offset, int len)
          Reads a specified number of bytes into an array at the specified offset.
protected abstract  void readHeader(StreamInput in)
           
protected  boolean readyBuffer()
          Fill the uncompressed bytes buffer by reading the underlying inputStream.
 void reset()
          Resets the stream.
 void resetToBufferStart()
          Expert!, resets to buffer start, without the need to decompress it again.
protected abstract  int uncompress(StreamInput in, byte[] out)
          Uncompress the data into the out array, returning the size uncompressed
 
Methods inherited from class org.elasticsearch.common.io.stream.StreamInput
readBoolean, readBytesReference, readBytesReference, readDouble, readFloat, readFully, readGenericValue, readInt, readLong, readMap, readOptionalString, readOptionalUTF, readShort, readString, readStringArray, readText, readUTF, readVInt, readVLong
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected final CompressorContext context

uncompressed

protected byte[] uncompressed
Constructor Detail

CompressedStreamInput

public CompressedStreamInput(StreamInput in,
                             T context)
                      throws IOException
Throws:
IOException
Method Detail

resetToBufferStart

public void resetToBufferStart()
Expert!, resets to buffer start, without the need to decompress it again.


available

public int available()
              throws IOException
Method is overridden to report number of bytes that can now be read from decoded data buffer, without reading bytes from the underlying stream. Never throws an exception; returns number of bytes available without further reads from underlying source; -1 if stream has been closed, or 0 if an actual read (and possible blocking) is needed to find out.

Overrides:
available in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

readByte

public byte readByte()
              throws IOException
Description copied from class: StreamInput
Reads and returns a single byte.

Specified by:
readByte in class StreamInput
Throws:
IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] buffer,
                int offset,
                int length,
                boolean fullRead)
         throws IOException
Throws:
IOException

readBytes

public void readBytes(byte[] b,
                      int offset,
                      int len)
               throws IOException
Description copied from class: StreamInput
Reads a specified number of bytes into an array at the specified offset.

Specified by:
readBytes in class StreamInput
Parameters:
b - the array to read bytes into
offset - the offset in the array to start storing bytes
len - the number of bytes to read
Throws:
IOException

reset

public void reset()
           throws IOException
Description copied from class: StreamInput
Resets the stream.

Specified by:
reset in class StreamInput
Throws:
IOException

close

public void close()
           throws IOException
Description copied from class: StreamInput
Closes the stream to further operations.

Specified by:
close in interface Closeable
Specified by:
close in class StreamInput
Throws:
IOException

doClose

protected abstract void doClose()
                         throws IOException
Throws:
IOException

readyBuffer

protected boolean readyBuffer()
                       throws IOException
Fill the uncompressed bytes buffer by reading the underlying inputStream.

Throws:
IOException

readHeader

protected abstract void readHeader(StreamInput in)
                            throws IOException
Throws:
IOException

uncompress

protected abstract int uncompress(StreamInput in,
                                  byte[] out)
                           throws IOException
Uncompress the data into the out array, returning the size uncompressed

Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.