Class ChunkedValueInputStream

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

    public class ChunkedValueInputStream
    extends java.io.InputStream
    This InputStream implementation allows us to pass a value made up of many chunks into the Avro decoder without stitching it up into a single big byte array. This is in the hope of avoiding humongous allocations and being more GC-efficient. NOT intended for multi-threaded usage.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int read()
      Required part of the InputStream contract, although we hope that it will generally not be called, as the alternative read(byte[], int, int) function is more efficient.
      int read​(byte[] b, int off, int len)
      This function is an optional, but recommended, part of the InputStream contract.
      void setChunk​(int chunkIndex, byte[] chunkContent)  
      • 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
    • Constructor Detail

      • ChunkedValueInputStream

        public ChunkedValueInputStream​(int numberOfChunks)
    • Method Detail

      • setChunk

        public void setChunk​(int chunkIndex,
                             byte[] chunkContent)
      • read

        public int read()
                 throws java.io.IOException
        Required part of the InputStream contract, although we hope that it will generally not be called, as the alternative read(byte[], int, int) function is more efficient. Still, we provide this mandatory function in case any code needs to do byte-by-byte consumption.
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        This function is an optional, but recommended, part of the InputStream contract. It is more optimal than InputStream.read(byte[], int, int) which internally iterates over our own read() implementation, one byte at a time.
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException