Class SliceInput

java.lang.Object
java.io.InputStream
io.airlift.slice.SliceInput
All Implemented Interfaces:
Closeable, DataInput, AutoCloseable
Direct Known Subclasses:
FixedLengthSliceInput, InputStreamSliceInput

public abstract class SliceInput extends InputStream implements DataInput
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract int
    Returns the number of bytes that can be read without blocking.
    void
     
    abstract long
    Approximate number of bytes retained by this instance.
    abstract boolean
    Returns true if and only if available() is greater than 0.
    final void
    mark(int readLimit)
     
    final boolean
     
    abstract long
    Returns the position of this buffer.
    abstract int
     
    final int
    read(byte[] destination)
     
    abstract int
    read(byte[] destination, int destinationIndex, int length)
     
    abstract boolean
    Returns true if the byte at the current position is not 0 and increases the position by 1 in this buffer.
    abstract byte
    Gets a byte at the current position and increases the position by 1 in this buffer.
    final void
    readBytes(byte[] destination)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= dst.length).
    abstract void
    readBytes(byte[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
    final void
    readBytes(Slice destination)
    Transfers this buffer's data to the specified destination starting at the current position until the destination becomes non-writable, and increases the position by the number of the transferred bytes.
    final void
    readBytes(Slice destination, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
    abstract void
    readBytes(Slice destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
    abstract void
    readBytes(OutputStream out, int length)
    Transfers this buffer's data to the specified stream starting at the current position.
    final char
     
    abstract double
    Gets a 64-bit double at the current position and increases the position by 8 in this buffer.
    final void
    readDoubles(double[] destination)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred doubles (= dst.length).
    abstract void
    readDoubles(double[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred doubles (= length).
    abstract float
    Gets a 32-bit float at the current position and increases the position by 4 in this buffer.
    final void
    readFloats(float[] destination)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred floats (= dst.length).
    abstract void
    readFloats(float[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred floats (= length).
    final void
    readFully(byte[] destination)
     
    final void
    readFully(byte[] destination, int offset, int length)
     
    abstract int
    Gets a 32-bit integer at the current position and increases the position by 4 in this buffer.
    final void
    readInts(int[] destination)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred ints (= dst.length).
    abstract void
    readInts(int[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred ints (= length).
    final String
     
    abstract long
    Gets a 64-bit long at the current position and increases the position by 8 in this buffer.
    final void
    readLongs(long[] destination)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred longs (= dst.length).
    abstract void
    readLongs(long[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred longs (= length).
    abstract short
    Gets a 16-bit short integer at the current position and increases the position by 2 in this buffer.
    final void
    readShorts(short[] destination)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred shorts (= dst.length).
    abstract void
    readShorts(short[] destination, int destinationIndex, int length)
    Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred shorts (= length).
    abstract Slice
    readSlice(int length)
    Returns a new slice of this buffer's sub-region starting at the current position and increases the position by the size of the new slice (= length).
    abstract int
    Gets an unsigned byte at the current position and increases the position by 1 in this buffer.
    final long
    Gets an unsigned 32-bit integer at the current position and increases the position by 4 in this buffer.
    abstract int
    Gets an unsigned 16-bit short integer at the current position and increases the position by 2 in this buffer.
    final String
     
    final void
     
    abstract void
    setPosition(long position)
    Sets the position of this buffer.
    abstract long
    skip(long length)
     
    abstract int
    skipBytes(int length)
     

    Methods inherited from class java.lang.Object

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

    • SliceInput

      public SliceInput()
  • Method Details

    • position

      public abstract long position()
      Returns the position of this buffer.
    • setPosition

      public abstract void setPosition(long position)
      Sets the position of this buffer.
      Throws:
      IndexOutOfBoundsException - if the specified position is less than 0 or greater than this.writerIndex
    • isReadable

      public abstract boolean isReadable()
      Returns true if and only if available() is greater than 0.
    • available

      public abstract int available()
      Returns the number of bytes that can be read without blocking.
      Overrides:
      available in class InputStream
    • read

      public abstract int read()
      Specified by:
      read in class InputStream
    • readBoolean

      public abstract boolean readBoolean()
      Returns true if the byte at the current position is not 0 and increases the position by 1 in this buffer.
      Specified by:
      readBoolean in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 1
    • readByte

      public abstract byte readByte()
      Gets a byte at the current position and increases the position by 1 in this buffer.
      Specified by:
      readByte in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 1
    • readUnsignedByte

      public abstract int readUnsignedByte()
      Gets an unsigned byte at the current position and increases the position by 1 in this buffer.
      Specified by:
      readUnsignedByte in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 1
    • readShort

      public abstract short readShort()
      Gets a 16-bit short integer at the current position and increases the position by 2 in this buffer.
      Specified by:
      readShort in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 2
    • readUnsignedShort

      public abstract int readUnsignedShort()
      Gets an unsigned 16-bit short integer at the current position and increases the position by 2 in this buffer.
      Specified by:
      readUnsignedShort in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 2
    • readInt

      public abstract int readInt()
      Gets a 32-bit integer at the current position and increases the position by 4 in this buffer.
      Specified by:
      readInt in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 4
    • readUnsignedInt

      public final long readUnsignedInt()
      Gets an unsigned 32-bit integer at the current position and increases the position by 4 in this buffer.
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 4
    • readLong

      public abstract long readLong()
      Gets a 64-bit long at the current position and increases the position by 8 in this buffer.
      Specified by:
      readLong in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 8
    • readFloat

      public abstract float readFloat()
      Gets a 32-bit float at the current position and increases the position by 4 in this buffer.
      Specified by:
      readFloat in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 4
    • readDouble

      public abstract double readDouble()
      Gets a 64-bit double at the current position and increases the position by 8 in this buffer.
      Specified by:
      readDouble in interface DataInput
      Throws:
      IndexOutOfBoundsException - if this.available() is less than 8
    • readSlice

      public abstract Slice readSlice(int length)
      Returns a new slice of this buffer's sub-region starting at the current position and increases the position by the size of the new slice (= length). The new slice could be either COMPACT or NOT_COMPACT.
      Parameters:
      length - the size of the new slice
      Returns:
      the newly created slice
      Throws:
      IndexOutOfBoundsException - if length is greater than this.available()
    • readFully

      public final void readFully(byte[] destination)
      Specified by:
      readFully in interface DataInput
    • read

      public final int read(byte[] destination)
      Overrides:
      read in class InputStream
    • read

      public abstract int read(byte[] destination, int destinationIndex, int length)
      Overrides:
      read in class InputStream
    • readBytes

      public final void readBytes(byte[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= dst.length).
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.available()
    • readFully

      public final void readFully(byte[] destination, int offset, int length)
      Specified by:
      readFully in interface DataInput
    • readBytes

      public abstract void readBytes(byte[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of bytes to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
    • readShorts

      public final void readShorts(short[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred shorts (= dst.length).
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.available()
    • readShorts

      public abstract void readShorts(short[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred shorts (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of shorts to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
    • readInts

      public final void readInts(int[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred ints (= dst.length).
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.available()
    • readInts

      public abstract void readInts(int[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred ints (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of ints to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
    • readLongs

      public final void readLongs(long[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred longs (= dst.length).
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.available()
    • readLongs

      public abstract void readLongs(long[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred longs (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of longs to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
    • readFloats

      public final void readFloats(float[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred floats (= dst.length).
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.available()
    • readFloats

      public abstract void readFloats(float[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred floats (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of floats to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
    • readDoubles

      public final void readDoubles(double[] destination)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred doubles (= dst.length).
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.available()
    • readDoubles

      public abstract void readDoubles(double[] destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred doubles (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of doubles to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.length
    • readBytes

      public final void readBytes(Slice destination)
      Transfers this buffer's data to the specified destination starting at the current position until the destination becomes non-writable, and increases the position by the number of the transferred bytes. This method is basically same with readBytes(Slice, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes while readBytes(Slice, int, int) does not.
      Throws:
      IndexOutOfBoundsException - if destination.writableBytes is greater than this.available()
    • readBytes

      public final void readBytes(Slice destination, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length). This method is basically same with readBytes(Slice, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes (= length) while readBytes(Slice, int, int) does not.
      Throws:
      IndexOutOfBoundsException - if length is greater than this.available() or if length is greater than destination.writableBytes
    • readBytes

      public abstract void readBytes(Slice destination, int destinationIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current position and increases the position by the number of the transferred bytes (= length).
      Parameters:
      destinationIndex - the first index of the destination
      length - the number of bytes to transfer
      Throws:
      IndexOutOfBoundsException - if the specified destinationIndex is less than 0, if length is greater than this.available(), or if destinationIndex + length is greater than destination.capacity
    • readBytes

      public abstract void readBytes(OutputStream out, int length) throws IOException
      Transfers this buffer's data to the specified stream starting at the current position.
      Parameters:
      length - the number of bytes to transfer
      Throws:
      IndexOutOfBoundsException - if length is greater than this.available()
      IOException - if the specified stream threw an exception during I/O
    • skip

      public abstract long skip(long length)
      Overrides:
      skip in class InputStream
    • skipBytes

      public abstract int skipBytes(int length)
      Specified by:
      skipBytes in interface DataInput
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
    • getRetainedSize

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

      public final void mark(int readLimit)
      Overrides:
      mark in class InputStream
    • reset

      public final void reset()
      Overrides:
      reset in class InputStream
    • markSupported

      public final boolean markSupported()
      Overrides:
      markSupported in class InputStream
    • readChar

      public final char readChar()
      Specified by:
      readChar in interface DataInput
    • readLine

      public final String readLine()
      Specified by:
      readLine in interface DataInput
    • readUTF

      public final String readUTF()
      Specified by:
      readUTF in interface DataInput