Package org.apache.cassandra.io.util
Class DataOutputBuffer
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.cassandra.io.util.DataOutputStreamPlus
-
- org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
-
- org.apache.cassandra.io.util.DataOutputBuffer
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataOutput,java.io.Flushable,java.lang.AutoCloseable,DataOutputPlus
- Direct Known Subclasses:
DataOutputBufferFixed,SafeMemoryWriter
public class DataOutputBuffer extends BufferedDataOutputStreamPlus
An implementation of the DataOutputStream interface using a FastByteArrayOutputStream and exposing its buffer so copies can be avoided. This class is completely thread unsafe.
-
-
Field Summary
Fields Modifier and Type Field Description static io.netty.util.concurrent.FastThreadLocal<DataOutputBuffer>scratchBufferScratch buffers used mostly for serializing in memory.-
Fields inherited from class org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
buffer
-
Fields inherited from class org.apache.cassandra.io.util.DataOutputStreamPlus
channel
-
-
Constructor Summary
Constructors Constructor Description DataOutputBuffer()DataOutputBuffer(int size)DataOutputBuffer(java.nio.ByteBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBufferasNewBuffer()java.nio.ByteBufferbuffer()java.nio.ByteBufferbuffer(boolean duplicate)voidclear()voidclose()protected voiddoFlush(int count)protected voidexpandToFit(long count)voidflush()byte[]getData()intgetLength()booleanhasPosition()If the implementation supports providing a position, this method returnstrue, otherwisefalse.protected java.nio.channels.WritableByteChannelnewDefaultChannel()longposition()Returns the current position of the underlying target like a file-pointer or the position withing a buffer.byte[]toByteArray()-
Methods inherited from class org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
order, write, write, write, write, writeBoolean, writeByte, writeBytes, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Methods inherited from class org.apache.cassandra.io.util.DataOutputStreamPlus
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
write, writeUnsignedVInt, writeVInt
-
-
-
-
Field Detail
-
scratchBuffer
public static final io.netty.util.concurrent.FastThreadLocal<DataOutputBuffer> scratchBuffer
Scratch buffers used mostly for serializing in memory. It's important to call #recycle() when finished to keep the memory overhead from being too large in the system.
-
-
Method Detail
-
flush
public void flush()
- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classBufferedDataOutputStreamPlus
-
doFlush
protected void doFlush(int count) throws java.io.IOException- Overrides:
doFlushin classBufferedDataOutputStreamPlus- Throws:
java.io.IOException
-
expandToFit
protected void expandToFit(long count)
-
newDefaultChannel
protected java.nio.channels.WritableByteChannel newDefaultChannel()
- Overrides:
newDefaultChannelin classDataOutputStreamPlus
-
clear
public void clear()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classBufferedDataOutputStreamPlus
-
buffer
public java.nio.ByteBuffer buffer()
-
buffer
public java.nio.ByteBuffer buffer(boolean duplicate)
-
getData
public byte[] getData()
-
getLength
public int getLength()
-
hasPosition
public boolean hasPosition()
Description copied from interface:DataOutputPlusIf the implementation supports providing a position, this method returnstrue, otherwisefalse.
-
position
public long position()
Description copied from interface:DataOutputPlusReturns 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 theDataOutputPlus.hasPosition().
-
asNewBuffer
public java.nio.ByteBuffer asNewBuffer()
-
toByteArray
public byte[] toByteArray()
-
-