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
public abstract class WriteOutBytes extends OutputStream implements WritableByteChannel
Appendable byte sequence for temporary storage. Methods inherited fromOutputStream,WritableByteChannelandwriteInt(int)append to the sequence. MethodswriteTo(WritableByteChannel)andasInputStream()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 ownclose()method does nothing. However WriteOutBytes should appear closed, i. e.Channel.isOpen()returns false, after the parental SegmentWriteOutMedium is closed.
-
-
Constructor Summary
Constructors Constructor Description WriteOutBytes()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract InputStreamasInputStream()Creates a finiteInputStreamwith the bytes that are written to this WriteOutBytes so far.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, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.nio.channels.WritableByteChannel
write
-
-
-
-
Method Detail
-
writeInt
public abstract void writeInt(int v) throws IOExceptionWrites 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
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
writeTo
public abstract void writeTo(WritableByteChannel channel) throws IOException
Takes all bytes that are written to this WriteOutBytes so far and writes them into the given channel.- Throws:
IOException
-
asInputStream
public abstract InputStream asInputStream() throws IOException
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
public abstract void readFully(long pos, ByteBuffer buffer) throws IOExceptionReads 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 public final void close()
Deprecated.does nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-
-