Class RawInputStream

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

    public class RawInputStream
    extends java.io.InputStream
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] buffer  
      protected long bufferOffset  
      protected long current  
      protected java.io.DataInputStream source  
      protected org.apache.cassandra.analytics.stats.Stats stats  
      protected int validBufferBytes  
    • Constructor Summary

      Constructors 
      Constructor Description
      RawInputStream​(java.io.DataInputStream source, byte[] buffer, org.apache.cassandra.analytics.stats.Stats stats)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected boolean finishedReadingBuffer()  
      boolean isEOF()  
      protected void maybeReBuffer()  
      protected long maybeStandardSkip​(long count)
      Perform standard in-memory skip if n is less than or equal to the number of bytes buffered in memory
      long position()
      `current` tracks the current position in the source, this isn't necessarily total bytes read as skipping at the base InputStream might seek to the new offset without reading the bytes
      int read()  
      int read​(byte[] buff, int offset, int length)  
      protected void reBuffer()  
      protected int remainingBytes()  
      long skip​(long count)  
      protected long skipBuffered()
      Skip any bytes already buffered in the 'buffer' array
      long standardSkip​(long count)  
      • Methods inherited from class java.io.InputStream

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

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

      • source

        protected final java.io.DataInputStream source
      • buffer

        protected final byte[] buffer
      • bufferOffset

        protected long bufferOffset
      • current

        protected long current
      • validBufferBytes

        protected int validBufferBytes
      • stats

        protected final org.apache.cassandra.analytics.stats.Stats stats
    • Constructor Detail

      • RawInputStream

        public RawInputStream​(java.io.DataInputStream source,
                              byte[] buffer,
                              org.apache.cassandra.analytics.stats.Stats stats)
    • Method Detail

      • isEOF

        public boolean isEOF()
      • finishedReadingBuffer

        protected boolean finishedReadingBuffer()
      • maybeReBuffer

        protected void maybeReBuffer()
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • reBuffer

        protected void reBuffer()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • position

        public long position()
        `current` tracks the current position in the source, this isn't necessarily total bytes read as skipping at the base InputStream might seek to the new offset without reading the bytes
        Returns:
        the current position in the source
      • maybeStandardSkip

        protected long maybeStandardSkip​(long count)
                                  throws java.io.IOException
        Perform standard in-memory skip if n is less than or equal to the number of bytes buffered in memory
        Parameters:
        count - the number of bytes to be skipped
        Returns:
        number of bytes skipped or -1 if not skipped
        Throws:
        java.io.IOException - IOException
      • skipBuffered

        protected long skipBuffered()
                             throws java.io.IOException
        Skip any bytes already buffered in the 'buffer' array
        Returns:
        bytes actually skipped
        Throws:
        java.io.IOException - IOException
      • standardSkip

        public long standardSkip​(long count)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • skip

        public long skip​(long count)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

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

        public int read​(@NotNull
                        byte[] buff,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • remainingBytes

        protected int remainingBytes()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException