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

java.lang.Object
  extended by java.io.OutputStream
      extended by org.elasticsearch.common.io.stream.StreamOutput
          extended by org.elasticsearch.common.compress.CompressedStreamOutput<T>
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
LZFCompressedStreamOutput, SnappyCompressedStreamOutput

public abstract class CompressedStreamOutput<T extends CompressorContext>
extends StreamOutput


Field Summary
protected  T context
           
protected  byte[] uncompressed
           
protected  int uncompressedLength
           
 
Constructor Summary
CompressedStreamOutput(StreamOutput out, T context)
           
 
Method Summary
 void close()
          Closes this stream to further operations.
protected abstract  void compress(byte[] data, int offset, int len, StreamOutput out)
          Compresses the data into the output
protected abstract  void doClose()
           
 void flush()
          Forces any buffered output to be written.
 void reset()
           
 void write(int b)
           
 void writeByte(byte b)
          Writes a single byte.
 void writeBytes(byte[] input, int offset, int length)
          Writes an array of bytes.
protected abstract  void writeHeader(StreamOutput out)
           
 
Methods inherited from class org.elasticsearch.common.io.stream.StreamOutput
position, seek, seekPositionSupported, write, writeBoolean, writeBytes, writeBytes, writeBytesReference, writeDouble, writeFloat, writeGenericValue, writeInt, writeLong, writeMap, writeOptionalString, writeOptionalUTF, writeShort, writeString, writeStringArray, writeText, writeUTF, writeVInt, writeVLong
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected final T extends CompressorContext context

uncompressed

protected byte[] uncompressed

uncompressedLength

protected int uncompressedLength
Constructor Detail

CompressedStreamOutput

public CompressedStreamOutput(StreamOutput out,
                              T context)
                       throws IOException
Throws:
IOException
Method Detail

write

public void write(int b)
           throws IOException
Overrides:
write in class StreamOutput
Throws:
IOException

writeByte

public void writeByte(byte b)
               throws IOException
Description copied from class: StreamOutput
Writes a single byte.

Specified by:
writeByte in class StreamOutput
Throws:
IOException

writeBytes

public void writeBytes(byte[] input,
                       int offset,
                       int length)
                throws IOException
Description copied from class: StreamOutput
Writes an array of bytes.

Specified by:
writeBytes in class StreamOutput
Parameters:
input - the bytes to write
offset - the offset in the byte array
length - the number of bytes to write
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from class: StreamOutput
Forces any buffered output to be written.

Specified by:
flush in interface Flushable
Specified by:
flush in class StreamOutput
Throws:
IOException

close

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

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

doClose

protected abstract void doClose()
                         throws IOException
Throws:
IOException

reset

public void reset()
           throws IOException
Specified by:
reset in class StreamOutput
Throws:
IOException

writeHeader

protected abstract void writeHeader(StreamOutput out)
                             throws IOException
Throws:
IOException

compress

protected abstract void compress(byte[] data,
                                 int offset,
                                 int len,
                                 StreamOutput out)
                          throws IOException
Compresses the data into the output

Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.