org.apache.cassandra.io.util

## Interface DataOutputPlus

- All Superinterfaces:
    java.io.DataOutput
  All Known Implementing Classes:
    BufferedDataOutputStreamPlus, ChecksummedSequentialWriter, CompressedSequentialWriter, DataOutputBuffer, DataOutputBufferFixed, DataOutputStreamPlus, SafeMemoryWriter, SequentialWriter, UnbufferedDataOutputStreamPlus, WrappedDataOutputStreamPlus

      public interface DataOutputPlus
      extends java.io.DataOutput

  Extension to DataOutput that provides for writing ByteBuffer and Memory, potentially with an efficient implementation that is zero copy or at least has reduced bounds checking overhead.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `<R> R` | `applyToChannel(com.google.common.base.Function<java.nio.channels.WritableByteChannel,R> c)` Safe way to operate against the underlying channel.
    `default boolean` | `hasPosition()` If the implementation supports providing a position, this method returns `true`, otherwise `false`.
    `default long` | `position()` Returns the current position of the underlying target like a file-pointer or the position withing a buffer.
    `void` | `write(java.nio.ByteBuffer buffer)`
    `void` | `write(Memory memory, long offset, long length)`
    `default void` | `writeUnsignedVInt(long i)` This is more efficient for storing unsigned values, both in storage and CPU burden.
    `default void` | `writeVInt(long i)`

    - ### Methods inherited from interface java.io.DataOutput

      `write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF`

- - ### Method Detail

    - #### write

          void write(java.nio.ByteBuffer buffer)
              throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### write

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

      Throws:
        `java.io.IOException`

    - #### applyToChannel

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

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

    - #### writeVInt

          default void writeVInt(long i)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### writeUnsignedVInt

          default void writeUnsignedVInt(long i)
                                  throws java.io.IOException

      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`

    - #### position

          default long position()

      Returns the current position of the underlying target like a file-pointer or the position withing a buffer. Not every implementation may support this functionality. Whether or not this functionality is supported can be checked via the `hasPosition()`.
      Throws:
        `java.lang.UnsupportedOperationException` - if the implementation does not support position

    - #### hasPosition

          default boolean hasPosition()

      If the implementation supports providing a position, this method returns `true`, otherwise `false`.

Copyright © 2018 The Apache Software Foundation