Package io.airlift.slice
Class SliceOutput
java.lang.Object
java.io.OutputStream
io.airlift.slice.SliceOutput
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable
- Direct Known Subclasses:
BasicSliceOutput,DynamicSliceOutput,OutputStreamSliceOutput
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract SliceOutputappendByte(int value) abstract SliceOutputappendBytes(byte[] source) abstract SliceOutputappendBytes(byte[] source, int sourceIndex, int length) abstract SliceOutputappendBytes(Slice slice) abstract SliceOutputappendDouble(double value) appendDoubles(double[] source) appendDoubles(double[] source, int sourceIndex, int length) appendFloats(float[] source) appendFloats(float[] source, int sourceIndex, int length) abstract SliceOutputappendInt(int value) appendInts(int[] source) appendInts(int[] source, int sourceIndex, int length) abstract SliceOutputappendLong(long value) appendLongs(long[] source) appendLongs(long[] source, int sourceIndex, int length) abstract SliceOutputappendShort(int value) appendShorts(short[] source) appendShorts(short[] source, int sourceIndex, int length) abstract longApproximate number of bytes retained by this.abstract SliceReturns the raw underlying slice of this output stream.abstract booleanReturnstrueif and only if(this.capacity - this.writerIndex)is greater than0.abstract voidreset()Resets this stream to the initial position.abstract voidreset(int position) Resets this stream to the specified position.abstract intsize()Returns thewriterIndexof this buffer.abstract Sliceslice()Returns a slice of this buffer's readable bytes.abstract StringDecodes this buffer's readable bytes into a string with the specified character set name.abstract intReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).final voidwrite(byte[] source) final voidwrite(byte[] source, int sourceIndex, int length) final voidwrite(int value) final voidwriteBoolean(boolean value) abstract voidwriteByte(int value) Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.abstract 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).abstract 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).abstract 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.abstract 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).abstract 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.voidwriteBytes(String s) Unsupported operationvoidwriteChar(int value) Unsupported operationvoidwriteChars(String s) Unsupported operationabstract voidwriteDouble(double value) Sets the specified 64-bit double at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidwriteDoubles(double[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred doubles.abstract voidwriteDoubles(double[] 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 doubles.abstract voidwriteFloat(float v) Sets the specified 32-bit float at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteFloats(float[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred floats.abstract voidwriteFloats(float[] 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 floats.abstract voidwriteInt(int value) Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteInts(int[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred ints.abstract voidwriteInts(int[] 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 ints.abstract voidwriteLong(long value) Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidwriteLongs(long[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred longs.abstract voidwriteLongs(long[] 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 longs.abstract voidwriteShort(int value) Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.voidwriteShorts(short[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred shorts.abstract voidwriteShorts(short[] 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 shorts.voidUnsupported operationvoidwriteZero(int length) Fills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength.Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Constructor Details
-
SliceOutput
public SliceOutput()
-
-
Method Details
-
reset
public abstract void reset()Resets this stream to the initial position. -
reset
public abstract void reset(int position) Resets this stream to the specified position. -
size
public abstract int size()Returns thewriterIndexof this buffer. -
getRetainedSize
public abstract long getRetainedSize()Approximate number of bytes retained by this. -
writableBytes
public abstract int writableBytes()Returns the number of writable bytes which is equal to(this.capacity - this.writerIndex). -
isWritable
public abstract boolean isWritable()Returnstrueif and only if(this.capacity - this.writerIndex)is greater than0. -
writeBoolean
public final void writeBoolean(boolean value) - Specified by:
writeBooleanin interfaceDataOutput
-
write
public final void write(int value) - Specified by:
writein interfaceDataOutput- Specified by:
writein classOutputStream
-
writeByte
public abstract void writeByte(int value) Sets 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- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than1
-
writeShort
public abstract void writeShort(int value) Sets 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- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than2
-
writeInt
public abstract void writeInt(int value) Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Specified by:
writeIntin interfaceDataOutput- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than4
-
writeLong
public abstract void writeLong(long value) Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Specified by:
writeLongin interfaceDataOutput- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than8
-
writeFloat
public abstract void writeFloat(float v) Sets the specified 32-bit float at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Specified by:
writeFloatin interfaceDataOutput- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than4
-
writeDouble
public abstract void writeDouble(double value) Sets the specified 64-bit double at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Specified by:
writeDoublein interfaceDataOutput- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than8
-
writeBytes
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. This method is basically same withwriteBytes(Slice, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whilewriteBytes(Slice, int, int)does not.- Throws:
IndexOutOfBoundsException- ifsource.readableBytesis greater thanthis.writableBytes
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).- Parameters:
sourceIndex- the first index of the sourcelength- the number of bytes to transfer- Throws:
IndexOutOfBoundsException- if the specifiedsourceIndexis less than0, ifsourceIndex + lengthis greater thansource.capacity, or iflengthis greater thanthis.writableBytes
-
write
public final void write(byte[] source) - Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream
-
writeBytes
public abstract void writeBytes(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).- Throws:
IndexOutOfBoundsException- ifsource.lengthis greater thanthis.writableBytes
-
write
public final void write(byte[] source, int sourceIndex, int length) - Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream
-
writeBytes
public abstract void writeBytes(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).- Parameters:
sourceIndex- the first index of the sourcelength- the number of bytes to transfer- Throws:
IndexOutOfBoundsException- if the specifiedsourceIndexis less than0, ifsourceIndex + lengthis greater thansource.length, or iflengthis greater thanthis.writableBytes
-
writeShorts
public void writeShorts(short[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred shorts. -
writeShorts
public abstract void writeShorts(short[] 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 shorts.- Parameters:
sourceIndex- the first index of the sourcelength- the number of shorts to transfer
-
writeInts
public void writeInts(int[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred ints. -
writeInts
public abstract void writeInts(int[] 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 ints.- Parameters:
sourceIndex- the first index of the sourcelength- the number of ints to transfer
-
writeLongs
public void writeLongs(long[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred longs. -
writeLongs
public abstract void writeLongs(long[] 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 longs.- Parameters:
sourceIndex- the first index of the sourcelength- the number of longs to transfer
-
writeFloats
public void writeFloats(float[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred floats. -
writeFloats
public abstract void writeFloats(float[] 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 floats.- Parameters:
sourceIndex- the first index of the sourcelength- the number of floats to transfer
-
writeDoubles
public void writeDoubles(double[] source) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred doubles. -
writeDoubles
public abstract void writeDoubles(double[] 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 doubles.- Parameters:
sourceIndex- the first index of the sourcelength- the number of doubles to transfer
-
writeBytes
Transfers the content of the specified stream to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes.- Parameters:
length- the number of bytes to transfer- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.writableBytesIOException- if the specified stream threw an exception during I/O
-
writeZero
public void writeZero(int length) Fills this buffer with NUL (0x00) starting at the currentwriterIndexand increases thewriterIndexby the specifiedlength.- Parameters:
length- the number of NULs to write to the buffer- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.writableBytes
-
slice
Returns 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. -
getUnderlyingSlice
Returns the raw underlying slice of this output stream. The slice may be larger than the size of this stream. -
toString
Decodes 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. -
appendLong
-
appendDouble
-
appendInt
-
appendShort
-
appendByte
-
appendBytes
-
appendBytes
-
appendShorts
-
appendShorts
-
appendInts
-
appendInts
-
appendLongs
-
appendLongs
-
appendFloats
-
appendFloats
-
appendDoubles
-
appendDoubles
-
appendBytes
-
writeChar
public void writeChar(int value) Unsupported operation- Specified by:
writeCharin interfaceDataOutput- Throws:
UnsupportedOperationException- always
-
writeChars
Unsupported operation- Specified by:
writeCharsin interfaceDataOutput- Throws:
UnsupportedOperationException- always
-
writeUTF
Unsupported operation- Specified by:
writeUTFin interfaceDataOutput- Throws:
UnsupportedOperationException- always
-
writeBytes
Unsupported operation- Specified by:
writeBytesin interfaceDataOutput- Throws:
UnsupportedOperationException- always
-