Class SliceOutput

java.lang.Object
java.io.OutputStream
io.airlift.slice.SliceOutput
All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable
Direct Known Subclasses:
BasicSliceOutput, DynamicSliceOutput, OutputStreamSliceOutput

public abstract class SliceOutput extends OutputStream implements DataOutput
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract SliceOutput
    appendByte(int value)
     
    abstract SliceOutput
    appendBytes(byte[] source)
     
    abstract SliceOutput
    appendBytes(byte[] source, int sourceIndex, int length)
     
    abstract SliceOutput
     
    abstract SliceOutput
    appendDouble(double value)
     
    appendDoubles(double[] source)
     
    appendDoubles(double[] source, int sourceIndex, int length)
     
    appendFloats(float[] source)
     
    appendFloats(float[] source, int sourceIndex, int length)
     
    abstract SliceOutput
    appendInt(int value)
     
    appendInts(int[] source)
     
    appendInts(int[] source, int sourceIndex, int length)
     
    abstract SliceOutput
    appendLong(long value)
     
    appendLongs(long[] source)
     
    appendLongs(long[] source, int sourceIndex, int length)
     
    abstract SliceOutput
    appendShort(int value)
     
    appendShorts(short[] source)
     
    appendShorts(short[] source, int sourceIndex, int length)
     
    abstract long
    Approximate number of bytes retained by this.
    abstract Slice
    Returns the raw underlying slice of this output stream.
    abstract boolean
    Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
    abstract void
    Resets this stream to the initial position.
    abstract void
    reset(int position)
    Resets this stream to the specified position.
    abstract int
    Returns the writerIndex of this buffer.
    abstract Slice
    Returns a slice of this buffer's readable bytes.
    abstract String
    toString(Charset charset)
    Decodes this buffer's readable bytes into a string with the specified character set name.
    abstract int
    Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
    final void
    write(byte[] source)
     
    final void
    write(byte[] source, int sourceIndex, int length)
     
    final void
    write(int value)
     
    final void
    writeBoolean(boolean value)
     
    abstract void
    writeByte(int value)
    Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
    abstract 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).
    abstract 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).
    abstract 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.
    abstract 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).
    abstract 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
    Unsupported operation
    void
    writeChar(int value)
    Unsupported operation
    void
    Unsupported operation
    abstract void
    writeDouble(double value)
    Sets the specified 64-bit double at the current writerIndex and increases the writerIndex by 8 in this buffer.
    void
    writeDoubles(double[] 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 doubles.
    abstract void
    writeDoubles(double[] 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 doubles.
    abstract void
    writeFloat(float v)
    Sets the specified 32-bit float at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeFloats(float[] 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 floats.
    abstract void
    writeFloats(float[] 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 floats.
    abstract void
    writeInt(int value)
    Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
    void
    writeInts(int[] 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 ints.
    abstract void
    writeInts(int[] 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 ints.
    abstract 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
    writeLongs(long[] 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 longs.
    abstract void
    writeLongs(long[] 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 longs.
    abstract 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
    writeShorts(short[] 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 shorts.
    abstract void
    writeShorts(short[] 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 shorts.
    void
    Unsupported operation
    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 java.io.OutputStream

    close, flush, nullOutputStream

    Methods inherited from class java.lang.Object

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

    • SliceOutput

      public SliceOutput()
  • Method Details

    • reset

      public abstract void reset()
      Resets this stream to the initial position.
    • reset

      public abstract void reset(int position)
      Resets this stream to the specified position.
    • size

      public abstract int size()
      Returns the writerIndex of this buffer.
    • getRetainedSize

      public abstract long getRetainedSize()
      Approximate number of bytes retained by this.
    • writableBytes

      public abstract int writableBytes()
      Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).
    • isWritable

      public abstract boolean isWritable()
      Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.
    • writeBoolean

      public final void writeBoolean(boolean value)
      Specified by:
      writeBoolean in interface DataOutput
    • write

      public final void write(int value)
      Specified by:
      write in interface DataOutput
      Specified by:
      write in class OutputStream
    • writeByte

      public abstract void writeByte(int value)
      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
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 1
    • writeShort

      public abstract void writeShort(int value)
      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
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 2
    • writeInt

      public abstract void writeInt(int value)
      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
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 4
    • writeLong

      public abstract void writeLong(long value)
      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
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 8
    • writeFloat

      public abstract void writeFloat(float v)
      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
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 4
    • writeDouble

      public abstract void writeDouble(double value)
      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
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 8
    • writeBytes

      public abstract 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. This method is basically same with writeBytes(Slice, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while writeBytes(Slice, int, int) does not.
      Throws:
      IndexOutOfBoundsException - if source.readableBytes is greater than this.writableBytes
    • writeBytes

      public abstract 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).
      Parameters:
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
      Throws:
      IndexOutOfBoundsException - if the specified sourceIndex is less than 0, if sourceIndex + length is greater than source.capacity, or if length is greater than this.writableBytes
    • write

      public final void write(byte[] source)
      Specified by:
      write in interface DataOutput
      Overrides:
      write in class OutputStream
    • writeBytes

      public abstract 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).
      Throws:
      IndexOutOfBoundsException - if source.length is greater than this.writableBytes
    • write

      public final void write(byte[] source, int sourceIndex, int length)
      Specified by:
      write in interface DataOutput
      Overrides:
      write in class OutputStream
    • writeBytes

      public abstract 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).
      Parameters:
      sourceIndex - the first index of the source
      length - the number of bytes to transfer
      Throws:
      IndexOutOfBoundsException - if the specified sourceIndex is less than 0, if sourceIndex + length is greater than source.length, or if length is greater than this.writableBytes
    • writeShorts

      public void writeShorts(short[] 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 shorts.
    • writeShorts

      public abstract void writeShorts(short[] 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 shorts.
      Parameters:
      sourceIndex - the first index of the source
      length - the number of shorts to transfer
    • writeInts

      public void writeInts(int[] 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 ints.
    • writeInts

      public abstract void writeInts(int[] 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 ints.
      Parameters:
      sourceIndex - the first index of the source
      length - the number of ints to transfer
    • writeLongs

      public void writeLongs(long[] 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 longs.
    • writeLongs

      public abstract void writeLongs(long[] 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 longs.
      Parameters:
      sourceIndex - the first index of the source
      length - the number of longs to transfer
    • writeFloats

      public void writeFloats(float[] 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 floats.
    • writeFloats

      public abstract void writeFloats(float[] 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 floats.
      Parameters:
      sourceIndex - the first index of the source
      length - the number of floats to transfer
    • writeDoubles

      public void writeDoubles(double[] 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 doubles.
    • writeDoubles

      public abstract void writeDoubles(double[] 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 doubles.
      Parameters:
      sourceIndex - the first index of the source
      length - the number of doubles to transfer
    • writeBytes

      public abstract void writeBytes(InputStream in, int length) throws IOException
      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.
      Parameters:
      length - the number of bytes to transfer
      Throws:
      IndexOutOfBoundsException - if length is greater than this.writableBytes
      IOException - if the specified stream threw an exception during I/O
    • writeZero

      public void writeZero(int length)
      Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.
      Parameters:
      length - the number of NULs to write to the buffer
      Throws:
      IndexOutOfBoundsException - if length is greater than this.writableBytes
    • slice

      public abstract Slice slice()
      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.
    • getUnderlyingSlice

      public abstract Slice getUnderlyingSlice()
      Returns the raw underlying slice of this output stream. The slice may be larger than the size of this stream.
    • toString

      public abstract String toString(Charset charset)
      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.
    • appendLong

      public abstract SliceOutput appendLong(long value)
    • appendDouble

      public abstract SliceOutput appendDouble(double value)
    • appendInt

      public abstract SliceOutput appendInt(int value)
    • appendShort

      public abstract SliceOutput appendShort(int value)
    • appendByte

      public abstract SliceOutput appendByte(int value)
    • appendBytes

      public abstract SliceOutput appendBytes(byte[] source, int sourceIndex, int length)
    • appendBytes

      public abstract SliceOutput appendBytes(byte[] source)
    • appendShorts

      public SliceOutput appendShorts(short[] source)
    • appendShorts

      public SliceOutput appendShorts(short[] source, int sourceIndex, int length)
    • appendInts

      public SliceOutput appendInts(int[] source)
    • appendInts

      public SliceOutput appendInts(int[] source, int sourceIndex, int length)
    • appendLongs

      public SliceOutput appendLongs(long[] source)
    • appendLongs

      public SliceOutput appendLongs(long[] source, int sourceIndex, int length)
    • appendFloats

      public SliceOutput appendFloats(float[] source)
    • appendFloats

      public SliceOutput appendFloats(float[] source, int sourceIndex, int length)
    • appendDoubles

      public SliceOutput appendDoubles(double[] source)
    • appendDoubles

      public SliceOutput appendDoubles(double[] source, int sourceIndex, int length)
    • appendBytes

      public abstract SliceOutput appendBytes(Slice slice)
    • writeChar

      public void writeChar(int value)
      Unsupported operation
      Specified by:
      writeChar in interface DataOutput
      Throws:
      UnsupportedOperationException - always
    • writeChars

      public void writeChars(String s)
      Unsupported operation
      Specified by:
      writeChars in interface DataOutput
      Throws:
      UnsupportedOperationException - always
    • writeUTF

      public void writeUTF(String s)
      Unsupported operation
      Specified by:
      writeUTF in interface DataOutput
      Throws:
      UnsupportedOperationException - always
    • writeBytes

      public void writeBytes(String s)
      Unsupported operation
      Specified by:
      writeBytes in interface DataOutput
      Throws:
      UnsupportedOperationException - always