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

org.apache.cassandra.io.util

## Class BufferedDataOutputStreamPlus

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.cassandra.io.util.DataOutputStreamPlus
    - - org.apache.cassandra.io.util.BufferedDataOutputStreamPlus

- All Implemented Interfaces:
    java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable, DataOutputPlus
  Direct Known Subclasses:
    DataOutputBuffer, SequentialWriter

      public class BufferedDataOutputStreamPlus
      extends DataOutputStreamPlus

  An implementation of the DataOutputStreamPlus interface using a ByteBuffer to stage writes before flushing them to an underlying channel. This class is completely thread unsafe.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.nio.ByteBuffer` | `buffer`
    `protected boolean` | `strictFlushing`

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

      `channel`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BufferedDataOutputStreamPlus(java.nio.ByteBuffer buffer)`
    `` | `BufferedDataOutputStreamPlus(java.io.FileOutputStream fos)`
    `` | `BufferedDataOutputStreamPlus(java.io.FileOutputStream fos, int bufferSize)`
    `` | `BufferedDataOutputStreamPlus(java.io.RandomAccessFile ras)`
    `` | `BufferedDataOutputStreamPlus(java.io.RandomAccessFile ras, int bufferSize)`
    `` | `BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc)`
    `protected` | `BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel channel, java.nio.ByteBuffer buffer)`
    `` | `BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc, int bufferSize)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<R> R` | `applyToChannel(com.google.common.base.Function<java.nio.channels.WritableByteChannel,R> f)` Safe way to operate against the underlying channel.
    `void` | `close()`
    `protected void` | `doFlush(int count)`
    `void` | `flush()`
    `BufferedDataOutputStreamPlus` | `order(java.nio.ByteOrder order)`
    `void` | `write(byte[] b)`
    `void` | `write(byte[] b, int off, int len)`
    `void` | `write(java.nio.ByteBuffer toWrite)`
    `void` | `write(int b)`
    `void` | `write(Memory memory, long offset, long length)`
    `void` | `writeBoolean(boolean v)`
    `void` | `writeByte(int v)`
    `void` | `writeBytes(java.lang.String s)`
    `void` | `writeChar(int v)`
    `void` | `writeChars(java.lang.String s)`
    `void` | `writeDouble(double v)`
    `void` | `writeFloat(float v)`
    `void` | `writeInt(int v)`
    `void` | `writeLong(long v)`
    `void` | `writeShort(int v)`
    `void` | `writeUnsignedVInt(long value)` This is more efficient for storing unsigned values, both in storage and CPU burden.
    `void` | `writeUTF(java.lang.String s)`
    `void` | `writeVInt(long value)`

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

      `newDefaultChannel, retrieveTemporaryBuffer`

    - ### 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.DataOutputPlus

      `hasPosition, position`

- - ### Field Detail

    - #### buffer

          protected java.nio.ByteBuffer buffer

    - #### strictFlushing

          protected boolean strictFlushing

  - ### Constructor Detail

    - #### BufferedDataOutputStreamPlus

          public BufferedDataOutputStreamPlus(java.io.RandomAccessFile ras)

    - #### BufferedDataOutputStreamPlus

          public BufferedDataOutputStreamPlus(java.io.RandomAccessFile ras,
                                              int bufferSize)

    - #### BufferedDataOutputStreamPlus

          public BufferedDataOutputStreamPlus(java.io.FileOutputStream fos)

    - #### BufferedDataOutputStreamPlus

          public BufferedDataOutputStreamPlus(java.io.FileOutputStream fos,
                                              int bufferSize)

    - #### BufferedDataOutputStreamPlus

          public BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc)

    - #### BufferedDataOutputStreamPlus

          public BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc,
                                              int bufferSize)

    - #### BufferedDataOutputStreamPlus

          protected BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel channel,
                                                 java.nio.ByteBuffer buffer)

    - #### BufferedDataOutputStreamPlus

          protected BufferedDataOutputStreamPlus(java.nio.ByteBuffer buffer)

  - ### Method Detail

    - #### write

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

      Specified by:
        `write` in interface `java.io.DataOutput`
      Overrides:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### write

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

      Specified by:
        `write` in interface `java.io.DataOutput`
      Overrides:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### write

          public void write(java.nio.ByteBuffer toWrite)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public void write(int b)
                     throws java.io.IOException

      Specified by:
        `write` in interface `java.io.DataOutput`
      Specified by:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### writeBoolean

          public void writeBoolean(boolean v)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeByte

          public void writeByte(int v)
                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeShort

          public void writeShort(int v)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeChar

          public void writeChar(int v)
                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeInt

          public void writeInt(int v)
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeLong

          public void writeLong(long v)
                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeVInt

          public void writeVInt(long value)
                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeUnsignedVInt

          public void writeUnsignedVInt(long value)
                                 throws java.io.IOException

      Description copied from interface: `DataOutputPlus`
      This is more efficient for storing unsigned values, both in storage and CPU burden. Note that it is still possible to store negative values, they just take up more space. So this method doesn't forbid e.g. negative sentinel values in future, if they need to be snuck in. A protocol version bump can then be introduced to improve efficiency.
      Throws:
        `java.io.IOException`

    - #### writeFloat

          public void writeFloat(float v)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeDouble

          public void writeDouble(double v)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeBytes

          public void writeBytes(java.lang.String s)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeChars

          public void writeChars(java.lang.String s)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeUTF

          public void writeUTF(java.lang.String s)
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

          public void write(Memory memory,
                            long offset,
                            long length)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### doFlush

          @DontInline
          protected void doFlush(int count)
                                      throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### flush

          public void flush()
                     throws java.io.IOException

      Specified by:
        `flush` in interface `java.io.Flushable`
      Overrides:
        `flush` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### applyToChannel

          public <R> R applyToChannel(com.google.common.base.Function<java.nio.channels.WritableByteChannel,R> f)
                               throws java.io.IOException

      Description copied from interface: `DataOutputPlus`
      Safe way to operate against the underlying channel. Impossible to stash a reference to the channel and forget to flush
      Throws:
        `java.io.IOException`

    - #### order

          public BufferedDataOutputStreamPlus order(java.nio.ByteOrder order)

Copyright © 2018 The Apache Software Foundation