public class ByteBufStreams
extends java.lang.Object
ByteBuf.| Modifier and Type | Method and Description |
|---|---|
static TransformablePublisher<io.netty.buffer.CompositeByteBuf> |
buffer(Publisher<? extends io.netty.buffer.ByteBuf> publisher,
long sizeWatermark,
int maxNum)
Buffers and composes byte bufs together into composites before emitting.
|
static TransformablePublisher<io.netty.buffer.CompositeByteBuf> |
buffer(Publisher<? extends io.netty.buffer.ByteBuf> publisher,
long sizeWatermark,
int maxNum,
io.netty.buffer.ByteBufAllocator alloc)
Buffers and composes byte bufs together into composites before emitting.
|
static Promise<io.netty.buffer.CompositeByteBuf> |
compose(Publisher<? extends io.netty.buffer.ByteBuf> publisher)
Reduces the stream to a single composite byte buf.
|
static Promise<io.netty.buffer.CompositeByteBuf> |
compose(Publisher<? extends io.netty.buffer.ByteBuf> publisher,
io.netty.buffer.ByteBufAllocator alloc)
Reduces the stream to a single composite byte buf.
|
static Promise<byte[]> |
toByteArray(Publisher<? extends io.netty.buffer.ByteBuf> publisher)
Reduces the stream to a single
byte[]. |
static Publisher<byte[]> |
toByteArrays(Publisher<? extends io.netty.buffer.ByteBuf> publisher)
Converts the byte buf stream to a stream of
byte[]. |
public static TransformablePublisher<io.netty.buffer.CompositeByteBuf> buffer(Publisher<? extends io.netty.buffer.ByteBuf> publisher, long sizeWatermark, int maxNum)
Calls buffer(Publisher, long, int, ByteBufAllocator) with PooledByteBufAllocator.DEFAULT
publisher - the publisher of byte bufs to buffersizeWatermark - the watermark size for a compositemaxNum - the maximum number of composite componentspublic static TransformablePublisher<io.netty.buffer.CompositeByteBuf> buffer(Publisher<? extends io.netty.buffer.ByteBuf> publisher, long sizeWatermark, int maxNum, io.netty.buffer.ByteBufAllocator alloc)
This is roughly analogous to BufferedInputStream.
The returned published accumulates upstream buffers until maxNum have been received,
or the cumulative size of buffered byte bufs is greater than or equal to sizeWatermark.
Note that unlike BufferedInputStream, the downstream writes are not guaranteed to be less than the buffer size.
Byte bufs are requested of the given publisher one at a time.
If this is inefficient, consider wrapping it with Streams.batch(int, Publisher, Action) before giving to this method.
publisher - the publisher of byte bufs to buffersizeWatermark - the watermark size for a compositemaxNum - the maximum number of composite componentsalloc - the allocator of compositespublic static Promise<io.netty.buffer.CompositeByteBuf> compose(Publisher<? extends io.netty.buffer.ByteBuf> publisher)
Calls compose(Publisher, ByteBufAllocator) with PooledByteBufAllocator.DEFAULT.
publisher - the streampublic static Promise<io.netty.buffer.CompositeByteBuf> compose(Publisher<? extends io.netty.buffer.ByteBuf> publisher, io.netty.buffer.ByteBufAllocator alloc)
publisher - the streamalloc - the buffer allocatorpublic static Promise<byte[]> toByteArray(Publisher<? extends io.netty.buffer.ByteBuf> publisher)
byte[].
This should only be used when it is known that the stream is small, as this will effectively force the entire stream to be held in memory.
publisher - the byte streambyte[]