Class IterableByteBufferInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    class IterableByteBufferInputStream
    extends java.io.InputStream
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long currentAddress
      If the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this ByteBuffer; otherwise should be zero.
      private byte[] currentArray
      If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the array inside ByteBuffer.
      private int currentArrayOffset
      Current ByteBuffer's array offset
      private java.nio.ByteBuffer currentByteBuffer
      The current ByteBuffer;
      private int currentByteBufferPos
      The current position for current ByteBuffer
      private int currentIndex
      Current ByteBuffer's index
      private int dataSize
      The number of ByteBuffers in the input data.
      private boolean hasArray
      Whether current ByteBuffer has an array
      private java.util.Iterator<java.nio.ByteBuffer> iterator
      The Iterator with type ByteBuffer of input
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean getNextByteBuffer()  
      int read()  
      int read​(byte[] output, int offset, int length)  
      private void updateCurrentByteBufferPos​(int numberOfBytesRead)  
      • Methods inherited from class java.io.InputStream

        available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • iterator

        private java.util.Iterator<java.nio.ByteBuffer> iterator
        The Iterator with type ByteBuffer of input
      • currentByteBuffer

        private java.nio.ByteBuffer currentByteBuffer
        The current ByteBuffer;
      • dataSize

        private int dataSize
        The number of ByteBuffers in the input data.
      • currentIndex

        private int currentIndex
        Current ByteBuffer's index

        If index equals dataSize, then all the data in the InputStream has been consumed

      • currentByteBufferPos

        private int currentByteBufferPos
        The current position for current ByteBuffer
      • hasArray

        private boolean hasArray
        Whether current ByteBuffer has an array
      • currentArray

        private byte[] currentArray
        If the current ByteBuffer is unsafe-direct based, currentArray is null; otherwise should be the array inside ByteBuffer.
      • currentArrayOffset

        private int currentArrayOffset
        Current ByteBuffer's array offset
      • currentAddress

        private long currentAddress
        If the current ByteBuffer is unsafe-direct based, currentAddress is the start address of this ByteBuffer; otherwise should be zero.
    • Constructor Detail

      • IterableByteBufferInputStream

        IterableByteBufferInputStream​(java.lang.Iterable<java.nio.ByteBuffer> data)
    • Method Detail

      • getNextByteBuffer

        private boolean getNextByteBuffer()
      • updateCurrentByteBufferPos

        private void updateCurrentByteBufferPos​(int numberOfBytesRead)
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] output,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException