Class WriteOutBytes
java.lang.Object
java.io.OutputStream
org.apache.druid.segment.writeout.WriteOutBytes
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Channel,WritableByteChannel
- Direct Known Subclasses:
ByteBufferWriteOutBytes,FileWriteOutBytes,LazilyAllocatingHeapWriteOutBytes
Appendable byte sequence for temporary storage. Methods inherited from
OutputStream, WritableByteChannel and writeInt(int) append to the sequence. Methods writeTo(WritableByteChannel) and asInputStream() allow to write the sequence somewhere else. readFully(long, java.nio.ByteBuffer) allows to access the sequence randomly.
WriteOutBytes is a resource that is managed by SegmentWriteOutMedium, so it's own close() method
does nothing. However WriteOutBytes should appear closed, i. e. Channel.isOpen() returns false, after the parental
SegmentWriteOutMedium is closed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InputStreamCreates a finiteInputStreamwith the bytes that are written to this WriteOutBytes so far.final voidclose()Deprecated.does nothing.abstract voidreadFully(long pos, ByteBuffer buffer) Reads bytes from the byte sequences, represented by this WriteOutBytes, at the random position, into the given buffer.abstract longsize()Returns the number of bytes written to this WriteOutBytes so far.voidwrite(byte[] b, int off, int len) abstract voidwriteInt(int v) Writes 4 bytes of the given value in big-endian order, i.abstract voidwriteTo(WritableByteChannel channel) Takes all bytes that are written to this WriteOutBytes so far and writes them into the given channel.Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.nio.channels.WritableByteChannel
write
-
Constructor Details
-
WriteOutBytes
public WriteOutBytes()
-
-
Method Details
-
writeInt
Writes 4 bytes of the given value in big-endian order, i. e. similar toDataOutput.writeInt(int).- Throws:
IOException
-
size
public abstract long size()Returns the number of bytes written to this WriteOutBytes so far. -
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
writeTo
Takes all bytes that are written to this WriteOutBytes so far and writes them into the given channel.- Throws:
IOException
-
asInputStream
Creates a finiteInputStreamwith the bytes that are written to this WriteOutBytes so far. The returned InputStream must be closed properly after it's used up.- Throws:
IOException
-
readFully
Reads bytes from the byte sequences, represented by this WriteOutBytes, at the random position, into the given buffer.- Throws:
BufferUnderflowException- if the byte sequence from the given pos ends before the given buffer is filledIllegalArgumentException- if the given pos is negativeIOException
-
close
Deprecated.does nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-