ChecksummedDataInput (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.hints

## Class ChecksummedDataInput

- java.lang.Object
- - java.io.InputStream
  - - org.apache.cassandra.io.util.RebufferingInputStream
    - - org.apache.cassandra.hints.ChecksummedDataInput

- All Implemented Interfaces:
    java.io.Closeable, java.io.DataInput, java.lang.AutoCloseable, DataInputPlus
  Direct Known Subclasses:
    CompressedChecksummedDataInput, EncryptedChecksummedDataInput

      public class ChecksummedDataInput
      extends RebufferingInputStream

  A `RandomAccessReader` wrapper that calculates the CRC in place. Useful for `HintsReader`, for example, where we must verify the CRC, yet don't want to allocate an extra byte array just that purpose. The CRC can be embedded in the input stream and checked via checkCrc(). In addition to calculating the CRC, it allows to enforce a maximum known size. This is needed so that `Mutation.MutationSerializer` doesn't blow up the heap when deserializing a corrupted sequence by reading a huge corrupted length of bytes via `ByteBufferUtil.readWithLength(java.io.DataInput)`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.cassandra.io.util.DataInputPlus

      `DataInputPlus.DataInputStreamPlus`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `bufferOffset`
    `protected ChannelProxy` | `channel`

    - ### Fields inherited from class org.apache.cassandra.io.util.RebufferingInputStream

      `buffer`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `bytesPastLimit()`
    `boolean` | `checkCrc()`
    `void` | `checkLimit(int length)`
    `void` | `close()`
    `ChannelProxy` | `getChannel()`
    `protected java.lang.String` | `getPath()`
    `protected long` | `getPosition()` Returns the exact position in the uncompressed view of the file.
    `InputPosition` | `getSeekPosition()` Return a seekable representation of the current position.
    `protected long` | `getSourcePosition()` Returns the position in the source file, which is different for getPosition() for compressed/encrypted files and may be imprecise.
    `boolean` | `isEOF()`
    `void` | `limit(long newLimit)`
    `static ChecksummedDataInput` | `open(java.io.File file)`
    `int` | `read(byte[] b, int off, int len)`
    `protected void` | `readBuffer()`
    `void` | `readFully(byte[] b)`
    `protected void` | `reBuffer()` Implementations must implement this method to refill the buffer.
    `void` | `resetCrc()`
    `void` | `resetLimit()`
    `void` | `seek(InputPosition pos)`
    `void` | `tryUncacheRead()`

    - ### Methods inherited from class org.apache.cassandra.io.util.RebufferingInputStream

      `read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readInt, readLine, readLong, readPrimitiveSlowly, readShort, readUnsignedByte, readUnsignedShort, readUnsignedVInt, readUTF, readVInt, skipBytes`

    - ### Methods inherited from class java.io.InputStream

      `available, mark, markSupported, read, reset, skip`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.cassandra.io.util.DataInputPlus

      `skipBytesFully`

- - ### Field Detail

    - #### bufferOffset

          protected long bufferOffset

    - #### channel

          protected final ChannelProxy channel

  - ### Method Detail

    - #### open

          public static ChecksummedDataInput open(java.io.File file)

    - #### isEOF

          public boolean isEOF()

    - #### getSeekPosition

          public InputPosition getSeekPosition()

      Return a seekable representation of the current position. For compressed files this is chunk position in file and offset within chunk.

    - #### seek

          public void seek(InputPosition pos)

    - #### resetCrc

          public void resetCrc()

    - #### limit

          public void limit(long newLimit)

    - #### getPosition

          protected long getPosition()

      Returns the exact position in the uncompressed view of the file.

    - #### getSourcePosition

          protected long getSourcePosition()

      Returns the position in the source file, which is different for getPosition() for compressed/encrypted files and may be imprecise.

    - #### resetLimit

          public void resetLimit()

    - #### checkLimit

          public void checkLimit(int length)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### bytesPastLimit

          public long bytesPastLimit()

    - #### checkCrc

          public boolean checkCrc()
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readFully

          public void readFully(byte[] b)
                         throws java.io.IOException

      Specified by:
        `readFully` in interface `java.io.DataInput`
      Overrides:
        `readFully` in class `RebufferingInputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException

      Overrides:
        `read` in class `RebufferingInputStream`
      Throws:
        `java.io.IOException`

    - #### reBuffer

          protected void reBuffer()

      Description copied from class: `RebufferingInputStream`
      Implementations must implement this method to refill the buffer. They can expect the buffer to be empty when this method is invoked.
      Specified by:
        `reBuffer` in class `RebufferingInputStream`

    - #### readBuffer

          protected void readBuffer()

    - #### tryUncacheRead

          public void tryUncacheRead()

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.InputStream`

    - #### getPath

          protected java.lang.String getPath()

    - #### getChannel

          public ChannelProxy getChannel()

Copyright © 2018 The Apache Software Foundation