Class UnbufferedDataOutputStreamPlus

java.lang.Object
java.io.OutputStream
org.apache.cassandra.io.util.DataOutputStreamPlus
org.apache.cassandra.io.util.UnbufferedDataOutputStreamPlus
All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable, DataOutputPlus
Direct Known Subclasses:
WrappedDataOutputStreamPlus

public abstract class UnbufferedDataOutputStreamPlus extends DataOutputStreamPlus
Base class for DataOutput implementations that does not have an optimized implementations of Plus methods and does no buffering.

Unlike BufferedDataOutputStreamPlus this is capable of operating as an unbuffered output stream. Currently necessary because SequentialWriter implements its own buffering along with mark/reset/truncate.

  • Constructor Details

    • UnbufferedDataOutputStreamPlus

      protected UnbufferedDataOutputStreamPlus()
    • UnbufferedDataOutputStreamPlus

      protected UnbufferedDataOutputStreamPlus(WritableByteChannel channel)
  • Method Details

    • write

      public void write(byte[] buffer) throws IOException
      Writes the entire contents of the byte array buffer to this RandomAccessFile starting at the current file pointer.
      Specified by:
      write in interface DataOutput
      Overrides:
      write in class OutputStream
      Parameters:
      buffer - the buffer to be written.
      Throws:
      IOException - If an error occurs trying to write to this RandomAccessFile.
    • write

      public abstract void write(byte[] buffer, int offset, int count) throws IOException
      Writes count bytes from the byte array buffer starting at offset to this RandomAccessFile starting at the current file pointer..
      Specified by:
      write in interface DataOutput
      Overrides:
      write in class OutputStream
      Parameters:
      buffer - the bytes to be written
      offset - offset in buffer to get bytes
      count - number of bytes in buffer to write
      Throws:
      IOException - If an error occurs attempting to write to this RandomAccessFile.
      IndexOutOfBoundsException - If offset or count are outside of bounds.
    • write

      public abstract void write(int oneByte) throws IOException
      Writes the specified byte oneByte to this RandomAccessFile starting at the current file pointer. Only the low order byte of oneByte is written.
      Specified by:
      write in interface DataOutput
      Specified by:
      write in class OutputStream
      Parameters:
      oneByte - the byte to be written
      Throws:
      IOException - If an error occurs attempting to write to this RandomAccessFile.
    • writeBoolean

      public final void writeBoolean(boolean val) throws IOException
      Writes a boolean to this output stream.
      Parameters:
      val - the boolean value to write to the OutputStream
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeByte

      public final void writeByte(int val) throws IOException
      Writes a 8-bit byte to this output stream.
      Parameters:
      val - the byte value to write to the OutputStream
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeBytes

      public final void writeBytes(String str) throws IOException
      Writes the low order 8-bit bytes from a String to this output stream.
      Parameters:
      str - the String containing the bytes to write to the OutputStream
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeChar

      public final void writeChar(int val) throws IOException
      Writes the specified 16-bit character to the OutputStream. Only the lower 2 bytes are written with the higher of the 2 bytes written first. This represents the Unicode value of val.
      Parameters:
      val - the character to be written
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeChars

      public final void writeChars(String str) throws IOException
      Writes the specified 16-bit characters contained in str to the OutputStream. Only the lower 2 bytes of each character are written with the higher of the 2 bytes written first. This represents the Unicode value of each character in str.
      Parameters:
      str - the String whose characters are to be written.
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeDouble

      public final void writeDouble(double val) throws IOException
      Writes a 64-bit double to this output stream. The resulting output is the 8 bytes resulting from calling Double.doubleToLongBits().
      Parameters:
      val - the double to be written.
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeFloat

      public final void writeFloat(float val) throws IOException
      Writes a 32-bit float to this output stream. The resulting output is the 4 bytes resulting from calling Float.floatToIntBits().
      Parameters:
      val - the float to be written.
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeInt

      public void writeInt(int val) throws IOException
      Writes a 32-bit int to this output stream. The resulting output is the 4 bytes, highest order first, of val.
      Parameters:
      val - the int to be written.
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeLong

      public void writeLong(long val) throws IOException
      Writes a 64-bit long to this output stream. The resulting output is the 8 bytes, highest order first, of val.
      Parameters:
      val - the long to be written.
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeShort

      public void writeShort(int val) throws IOException
      Writes the specified 16-bit short to the OutputStream. Only the lower 2 bytes are written with the higher of the 2 bytes written first.
      Parameters:
      val - the short to be written
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeUTF

      public static void writeUTF(String str, DataOutput out) throws IOException
      Writes the specified String out in UTF format to the provided DataOutput
      Parameters:
      str - the String to be written in UTF format.
      out - the DataOutput to write the UTF encoded string to
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • writeUTF

      public final void writeUTF(String str) throws IOException
      Writes the specified String out in UTF format.
      Parameters:
      str - the String to be written in UTF format.
      Throws:
      IOException - If an error occurs attempting to write to this DataOutputStream.
    • write

      public void write(ByteBuffer buf) throws IOException
      Throws:
      IOException