Package io.airlift.slice
Class DynamicSliceOutput
java.lang.Object
java.io.OutputStream
io.airlift.slice.SliceOutput
io.airlift.slice.DynamicSliceOutput
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendByte(int value) appendBytes(byte[] source) appendBytes(byte[] source, int sourceIndex, int length) appendBytes(Slice slice) appendDouble(double value) appendInt(int value) appendLong(long value) appendShort(int value) longApproximate number of bytes retained by this.Returns the raw underlying slice of this output stream.booleanReturnstrueif and only if(this.capacity - this.writerIndex)is greater than0.voidreset()Resets this stream to the initial position.voidreset(int position) Resets this stream to the specified position.intsize()Returns thewriterIndexof this buffer.slice()Returns a slice of this buffer's readable bytes.toString()Decodes this buffer's readable bytes into a string with the specified character set name.intReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).voidwriteByte(int value) Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.voidwriteBytes(byte[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=source.length).voidwriteBytes(byte[] source, int sourceIndex, int length) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteBytes(Slice source) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes.voidwriteBytes(Slice source, int sourceIndex, int length) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteBytes(InputStream in, int length) Transfers the content of the specified stream to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.voidwriteDouble(double value) Sets the specified 64-bit double at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidwriteFloat(float value) Sets the specified 32-bit float at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteInt(int value) Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteLong(long value) Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidwriteShort(int value) Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.voidwriteZero(int length) Fills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength.Methods inherited from class io.airlift.slice.SliceOutput
write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeUTFMethods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Constructor Details
-
DynamicSliceOutput
public DynamicSliceOutput(int estimatedSize)
-
-
Method Details
-
reset
public void reset()Description copied from class:SliceOutputResets this stream to the initial position.- Specified by:
resetin classSliceOutput
-
reset
public void reset(int position) Description copied from class:SliceOutputResets this stream to the specified position.- Specified by:
resetin classSliceOutput
-
size
public int size()Description copied from class:SliceOutputReturns thewriterIndexof this buffer.- Specified by:
sizein classSliceOutput
-
getRetainedSize
public long getRetainedSize()Description copied from class:SliceOutputApproximate number of bytes retained by this.- Specified by:
getRetainedSizein classSliceOutput
-
isWritable
public boolean isWritable()Description copied from class:SliceOutputReturnstrueif and only if(this.capacity - this.writerIndex)is greater than0.- Specified by:
isWritablein classSliceOutput
-
writableBytes
public int writableBytes()Description copied from class:SliceOutputReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).- Specified by:
writableBytesin classSliceOutput
-
writeByte
public void writeByte(int value) Description copied from class:SliceOutputSets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer. The 24 high-order bits of the specified value are ignored.- Specified by:
writeBytein interfaceDataOutput- Specified by:
writeBytein classSliceOutput
-
writeShort
public void writeShort(int value) Description copied from class:SliceOutputSets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer. The 16 high-order bits of the specified value are ignored.- Specified by:
writeShortin interfaceDataOutput- Specified by:
writeShortin classSliceOutput
-
writeInt
public void writeInt(int value) Description copied from class:SliceOutputSets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Specified by:
writeIntin interfaceDataOutput- Specified by:
writeIntin classSliceOutput
-
writeLong
public void writeLong(long value) Description copied from class:SliceOutputSets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Specified by:
writeLongin interfaceDataOutput- Specified by:
writeLongin classSliceOutput
-
writeFloat
public void writeFloat(float value) Description copied from class:SliceOutputSets the specified 32-bit float at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Specified by:
writeFloatin interfaceDataOutput- Specified by:
writeFloatin classSliceOutput
-
writeDouble
public void writeDouble(double value) Description copied from class:SliceOutputSets the specified 64-bit double at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Specified by:
writeDoublein interfaceDataOutput- Specified by:
writeDoublein classSliceOutput
-
writeBytes
public void writeBytes(byte[] source) Description copied from class:SliceOutputTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=source.length).- Specified by:
writeBytesin classSliceOutput
-
writeBytes
public void writeBytes(byte[] source, int sourceIndex, int length) Description copied from class:SliceOutputTransfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).- Specified by:
writeBytesin classSliceOutputsourceIndex- the first index of the sourcelength- the number of bytes to transfer
-
writeBytes
Description copied from class:SliceOutputTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer becomes unreadable, and increases thewriterIndexby the number of the transferred bytes. This method is basically same withSliceOutput.writeBytes(Slice, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whileSliceOutput.writeBytes(Slice, int, int)does not.- Specified by:
writeBytesin classSliceOutput
-
writeBytes
Description copied from class:SliceOutputTransfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).- Specified by:
writeBytesin classSliceOutputsourceIndex- the first index of the sourcelength- the number of bytes to transfer
-
writeBytes
Description copied from class:SliceOutputTransfers the content of the specified stream to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.- Specified by:
writeBytesin classSliceOutputlength- the number of bytes to transfer- Throws:
IOException- if the specified stream threw an exception during I/O
-
writeZero
public void writeZero(int length) Description copied from class:SliceOutputFills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength.- Overrides:
writeZeroin classSliceOutput- Parameters:
length- the number of NULs to write to the buffer
-
appendLong
- Specified by:
appendLongin classSliceOutput
-
appendDouble
- Specified by:
appendDoublein classSliceOutput
-
appendInt
- Specified by:
appendIntin classSliceOutput
-
appendShort
- Specified by:
appendShortin classSliceOutput
-
appendByte
- Specified by:
appendBytein classSliceOutput
-
appendBytes
- Specified by:
appendBytesin classSliceOutput
-
appendBytes
- Specified by:
appendBytesin classSliceOutput
-
appendBytes
- Specified by:
appendBytesin classSliceOutput
-
slice
Description copied from class:SliceOutputReturns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical tobuf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
slicein classSliceOutput
-
copySlice
-
getUnderlyingSlice
Description copied from class:SliceOutputReturns the raw underlying slice of this output stream. The slice may be larger than the size of this stream.- Specified by:
getUnderlyingSlicein classSliceOutput
-
toString
-
toString
Description copied from class:SliceOutputDecodes this buffer's readable bytes into a string with the specified character set name. This method is identical tobuf.toString(buf.readerIndex(), buf.readableBytes(), charsetName). This method does not modifyreaderIndexorwriterIndexof this buffer.- Specified by:
toStringin classSliceOutput
-