Class UnsafeByteBufferInput

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

    public class UnsafeByteBufferInput
    extends ByteBufferInput
    A ByteBufferInput that reads data from direct ByteBuffer (off-heap memory) using sun.misc.Unsafe. Multi-byte primitive types use native byte order, so the native byte order on different computers which read and write the data must be the same.

    Not available on all JVMs. Util.unsafe can be checked before using this class.

    This class may be much faster when Input.setVariableLengthEncoding(boolean) is false.

    Author:
    Roman Levenstein , Nathan Sweet
    • Constructor Detail

      • UnsafeByteBufferInput

        public UnsafeByteBufferInput()
        Creates an uninitialized Input, setBuffer(ByteBuffer) must be called before the Input is used.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(int bufferSize)
        Creates a new Input for reading from a direct ByteBuffer.
        Parameters:
        bufferSize - The size of the buffer. An exception is thrown if more bytes than this are read and ByteBufferInput.fill(ByteBuffer, int, int) does not supply more bytes.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(byte[] bytes)
        Creates a new Input for reading from a ByteBuffer which is filled with the specified bytes.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(byte[] bytes,
                                     int offset,
                                     int count)
        Creates a new Input for reading from a ByteBuffer which is filled with the specified bytes.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(java.nio.ByteBuffer buffer)
        Creates a new Input for reading from a ByteBuffer.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(long address,
                                     int size)
        Creates a new Input for reading from a ByteBuffer representing the memory region at the specified address and size. @throws UnsupportedOperationException if creating a ByteBuffer this way is not available.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(java.io.InputStream inputStream)
        Creates a new Input for reading from an InputStream with a buffer size of 4096.
      • UnsafeByteBufferInput

        public UnsafeByteBufferInput​(java.io.InputStream inputStream,
                                     int bufferSize)
        Creates a new Input for reading from an InputStream with the specified buffer size.