Class ByteBufferWriteOutBytes
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.druid.segment.writeout.WriteOutBytes
-
- org.apache.druid.segment.writeout.ByteBufferWriteOutBytes
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,Channel
,WritableByteChannel
- Direct Known Subclasses:
HeapByteBufferWriteOutBytes
public abstract class ByteBufferWriteOutBytes extends WriteOutBytes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ByteBuffer
allocateBuffer()
InputStream
asInputStream()
Creates a finiteInputStream
with the bytes that are written to this WriteOutBytes so far.void
free()
boolean
isOpen()
void
readFully(long pos, ByteBuffer buffer)
Reads bytes from the byte sequences, represented by this WriteOutBytes, at the random position, into the given buffer.long
size()
Returns the number of bytes written to this WriteOutBytes so far.void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
int
write(ByteBuffer src)
void
writeInt(int v)
Writes 4 bytes of the given value in big-endian order, i.void
writeTo(ByteBuffer out)
Takes all bytes that are written to this WriteOutBytes so far and writes them into the given ByteBuffer.void
writeTo(WritableByteChannel channel)
Takes all bytes that are written to this WriteOutBytes so far and writes them into the given channel.-
Methods inherited from class org.apache.druid.segment.writeout.WriteOutBytes
close
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
-
-
-
Method Detail
-
size
public long size()
Description copied from class:WriteOutBytes
Returns the number of bytes written to this WriteOutBytes so far.- Specified by:
size
in classWriteOutBytes
-
allocateBuffer
protected abstract ByteBuffer allocateBuffer()
-
write
public void write(int b)
- Specified by:
write
in classOutputStream
-
writeInt
public void writeInt(int v)
Description copied from class:WriteOutBytes
Writes 4 bytes of the given value in big-endian order, i. e. similar toDataOutput.writeInt(int)
.- Specified by:
writeInt
in classWriteOutBytes
-
write
public void write(byte[] b)
- Overrides:
write
in classOutputStream
-
write
public void write(byte[] b, int off, int len)
- Overrides:
write
in classOutputStream
-
write
public int write(ByteBuffer src)
-
writeTo
public void writeTo(WritableByteChannel channel) throws IOException
Description copied from class:WriteOutBytes
Takes all bytes that are written to this WriteOutBytes so far and writes them into the given channel.- Specified by:
writeTo
in classWriteOutBytes
- Throws:
IOException
-
writeTo
public void writeTo(ByteBuffer out)
Takes all bytes that are written to this WriteOutBytes so far and writes them into the given ByteBuffer. This method changes the position of the out buffer by thesize()
of this WriteOutBytes.- Throws:
BufferOverflowException
- if theBuffer.remaining()
capacity of the given buffer is smaller than the size of this WriteOutBytes
-
readFully
public void readFully(long pos, ByteBuffer buffer)
Description copied from class:WriteOutBytes
Reads bytes from the byte sequences, represented by this WriteOutBytes, at the random position, into the given buffer.- Specified by:
readFully
in classWriteOutBytes
-
asInputStream
public InputStream asInputStream() throws IOException
Description copied from class:WriteOutBytes
Creates a finiteInputStream
with the bytes that are written to this WriteOutBytes so far. The returned InputStream must be closed properly after it's used up.- Specified by:
asInputStream
in classWriteOutBytes
- Throws:
IOException
-
isOpen
public boolean isOpen()
-
free
public void free()
-
-