Package 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:
AsyncChannelOutputPlus
,DataOutputBuffer
,FileOutputStreamPlus
,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 Description protected java.nio.ByteBuffer
buffer
-
Fields inherited from class org.apache.cassandra.io.util.DataOutputStreamPlus
channel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BufferedDataOutputStreamPlus(int size)
protected
BufferedDataOutputStreamPlus(java.nio.ByteBuffer buffer)
BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc)
BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc, int bufferSize)
BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel channel, java.nio.ByteBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.nio.ByteBuffer
allocate(int size)
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(int b)
void
write(java.nio.ByteBuffer src)
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
writeMostSignificantBytes(long register, int bytes)
An efficient way to write the typebytes
of a longvoid
writeShort(int v)
void
writeUTF(java.lang.String s)
-
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
bytesLeftInPage, hasPosition, maxBytesInPage, paddedPosition, padToPageBoundary, position, write, writeUnsignedVInt, writeUnsignedVInt, writeUnsignedVInt32, writeVInt, writeVInt, writeVInt32
-
-
-
-
Constructor Detail
-
BufferedDataOutputStreamPlus
public BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc)
-
BufferedDataOutputStreamPlus
public BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel wbc, int bufferSize)
-
BufferedDataOutputStreamPlus
public BufferedDataOutputStreamPlus(java.nio.channels.WritableByteChannel channel, java.nio.ByteBuffer buffer)
-
BufferedDataOutputStreamPlus
protected BufferedDataOutputStreamPlus(java.nio.ByteBuffer buffer)
-
BufferedDataOutputStreamPlus
protected BufferedDataOutputStreamPlus(int size)
-
-
Method Detail
-
allocate
protected java.nio.ByteBuffer allocate(int size)
-
write
public void write(byte[] b) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer src) throws java.io.IOException
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in classjava.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
-
writeMostSignificantBytes
public void writeMostSignificantBytes(long register, int bytes) throws java.io.IOException
Description copied from interface:DataOutputPlus
An efficient way to write the typebytes
of a long- Parameters:
register
- - the long value to be writtenbytes
- - the number of bytes the register occupies. Valid values are between 1 and 8 inclusive.- 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
-
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
-
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 interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
order
public BufferedDataOutputStreamPlus order(java.nio.ByteOrder order)
-
-