Class MutableByteArrayInputStream

java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.apache.flink.formats.avro.utils.MutableByteArrayInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public final class MutableByteArrayInputStream extends ByteArrayInputStream
An extension of the ByteArrayInputStream that allows to change a buffer that should be read without creating a new ByteArrayInputStream instance. This allows to re-use the same InputStream instance, copying message to process, and creation of Decoder on every new message.
  • Constructor Details

    • MutableByteArrayInputStream

      public MutableByteArrayInputStream()
  • Method Details

    • setBuffer

      public void setBuffer(byte[] buf)
      Set buffer that can be read via the InputStream interface and reset the input stream. This has the same effect as creating a new ByteArrayInputStream with a new buffer.
      Parameters:
      buf - the new buffer to read.