Class OutputStreamSliceOutput

java.lang.Object
java.io.OutputStream
io.airlift.slice.SliceOutput
io.airlift.slice.OutputStreamSliceOutput
All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable

public class OutputStreamSliceOutput extends SliceOutput
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    OutputStreamSliceOutput(OutputStream outputStream, int bufferSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    appendByte(int value)
     
    appendBytes(byte[] source)
     
    appendBytes(byte[] source, int sourceIndex, int length)
     
     
    appendDouble(double value)
     
    appendInt(int value)
     
    appendLong(long value)
     
    appendShort(int value)
     
    void
     
    void
     
    long
    Approximate number of bytes retained by this.
    Returns the raw underlying slice of this output stream.
    boolean
    Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
    long
     
    void
    Resets this stream to the initial position.
    void
    reset(int position)
    Resets this stream to the specified position.
    int
    Returns the writerIndex of this buffer.
    Returns a slice of this buffer's readable bytes.
     
    toString(Charset charset)
    Decodes this buffer's readable bytes into a string with the specified character set name.
    int
    Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
    void
    writeByte(int value)
    Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
    void
    writeBytes(byte[] source)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= source.length).
    void
    writeBytes(byte[] source, int sourceIndex, int length)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    void
    writeBytes(Slice source)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes.
    void
    writeBytes(Slice source, int sourceIndex, int length)
    Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    void
    writeBytes(InputStream in, int length)
    Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
    void
    writeDouble(double value)
    Sets the specified 64-bit double at the current writerIndex and increases the writerIndex by 8 in this buffer.
    void
    writeFloat(float value)
    Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeInt(int value)
    Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeLong(long value)
    Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
    void
    writeShort(int value)
    Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.
    void
    writeZero(int length)
    Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.

    Methods inherited from class io.airlift.slice.SliceOutput

    write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeUTF

    Methods inherited from class java.io.OutputStream

    nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • OutputStreamSliceOutput

      public OutputStreamSliceOutput(OutputStream inputStream)
    • OutputStreamSliceOutput

      public OutputStreamSliceOutput(OutputStream outputStream, int bufferSize)
  • Method Details

    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • reset

      public void reset()
      Description copied from class: SliceOutput
      Resets this stream to the initial position.
      Specified by:
      reset in class SliceOutput
    • reset

      public void reset(int position)
      Description copied from class: SliceOutput
      Resets this stream to the specified position.
      Specified by:
      reset in class SliceOutput
    • size

      public int size()
      Description copied from class: SliceOutput
      Returns the writerIndex of this buffer.
      Specified by:
      size in class SliceOutput
    • longSize

      public long longSize()
    • getRetainedSize

      public long getRetainedSize()
      Description copied from class: SliceOutput
      Approximate number of bytes retained by this.
      Specified by:
      getRetainedSize in class SliceOutput
    • writableBytes

      public int writableBytes()
      Description copied from class: SliceOutput
      Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
      Specified by:
      writableBytes in class SliceOutput
    • isWritable

      public boolean isWritable()
      Description copied from class: SliceOutput
      Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
      Specified by:
      isWritable in class SliceOutput
    • writeByte

      public void writeByte(int value)
      Description copied from class: SliceOutput
      Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer. The 24 high-order bits of the specified value are ignored.
      Specified by:
      writeByte in interface DataOutput
      Specified by:
      writeByte in class SliceOutput
    • writeShort

      public void writeShort(int value)
      Description copied from class: SliceOutput
      Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer. The 16 high-order bits of the specified value are ignored.
      Specified by:
      writeShort in interface DataOutput
      Specified by:
      writeShort in class SliceOutput
    • writeInt

      public void writeInt(int value)
      Description copied from class: SliceOutput
      Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Specified by:
      writeInt in interface DataOutput
      Specified by:
      writeInt in class SliceOutput
    • writeLong

      public void writeLong(long value)
      Description copied from class: SliceOutput
      Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Specified by:
      writeLong in interface DataOutput
      Specified by:
      writeLong in class SliceOutput
    • writeFloat

      public void writeFloat(float value)
      Description copied from class: SliceOutput
      Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Specified by:
      writeFloat in interface DataOutput
      Specified by:
      writeFloat in class SliceOutput
    • writeDouble

      public void writeDouble(double value)
      Description copied from class: SliceOutput
      Sets the specified 64-bit double at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Specified by:
      writeDouble in interface DataOutput
      Specified by:
      writeDouble in class SliceOutput
    • writeBytes

      public void writeBytes(Slice source)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes. This method is basically same with SliceOutput.writeBytes(Slice, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while SliceOutput.writeBytes(Slice, int, int) does not.
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public void writeBytes(Slice source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Specified by:
      writeBytes in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
    • writeBytes

      public void writeBytes(byte[] source)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= source.length).
      Specified by:
      writeBytes in class SliceOutput
    • writeBytes

      public void writeBytes(byte[] source, int sourceIndex, int length)
      Description copied from class: SliceOutput
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Specified by:
      writeBytes in class SliceOutput
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
    • writeBytes

      public void writeBytes(InputStream in, int length) throws IOException
      Description copied from class: SliceOutput
      Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.
      Specified by:
      writeBytes in class SliceOutput
      length - the number of bytes to transfer
      Throws:
      IOException - if the specified stream threw an exception during I/O
    • writeZero

      public void writeZero(int length)
      Description copied from class: SliceOutput
      Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
      Overrides:
      writeZero in class SliceOutput
      Parameters:
      length - the number of NULs to write to the buffer
    • appendByte

      public SliceOutput appendByte(int value)
      Specified by:
      appendByte in class SliceOutput
    • appendShort

      public SliceOutput appendShort(int value)
      Specified by:
      appendShort in class SliceOutput
    • appendInt

      public SliceOutput appendInt(int value)
      Specified by:
      appendInt in class SliceOutput
    • appendLong

      public SliceOutput appendLong(long value)
      Specified by:
      appendLong in class SliceOutput
    • appendDouble

      public SliceOutput appendDouble(double value)
      Specified by:
      appendDouble in class SliceOutput
    • appendBytes

      public SliceOutput appendBytes(byte[] source, int sourceIndex, int length)
      Specified by:
      appendBytes in class SliceOutput
    • appendBytes

      public SliceOutput appendBytes(byte[] source)
      Specified by:
      appendBytes in class SliceOutput
    • appendBytes

      public SliceOutput appendBytes(Slice slice)
      Specified by:
      appendBytes in class SliceOutput
    • slice

      public Slice slice()
      Description copied from class: SliceOutput
      Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to buf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      slice in class SliceOutput
    • getUnderlyingSlice

      public Slice getUnderlyingSlice()
      Description copied from class: SliceOutput
      Returns the raw underlying slice of this output stream. The slice may be larger than the size of this stream.
      Specified by:
      getUnderlyingSlice in class SliceOutput
    • toString

      public String toString(Charset charset)
      Description copied from class: SliceOutput
      Decodes this buffer's readable bytes into a string with the specified character set name. This method is identical to buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName). This method does not modify readerIndex or writerIndex of this buffer.
      Specified by:
      toString in class SliceOutput
    • toString

      public String toString()
      Overrides:
      toString in class Object