| Modifier and Type | Method and Description |
|---|---|
static TransformablePublisher<CompositeByteBuf> |
buffer(Publisher<? extends ByteBuf> publisher,
long sizeWatermark,
int maxNum)
Buffers and composes byte bufs together into composites before emitting.
|
static TransformablePublisher<CompositeByteBuf> |
buffer(Publisher<? extends ByteBuf> publisher,
long sizeWatermark,
int maxNum,
ByteBufAllocator alloc)
Buffers and composes byte bufs together into composites before emitting.
|
static Promise<CompositeByteBuf> |
compose(Publisher<? extends ByteBuf> publisher)
Reduces the stream to a single composite byte buf.
|
static Promise<CompositeByteBuf> |
compose(Publisher<? extends ByteBuf> publisher,
ByteBufAllocator alloc)
Reduces the stream to a single composite byte buf.
|
static Promise<byte[]> |
toByteArray(Publisher<? extends ByteBuf> publisher)
Reduces the stream to a single
byte[]. |
static Publisher<byte[]> |
toByteArrays(Publisher<? extends ByteBuf> publisher)
Converts the byte buf stream to a stream of
byte[]. |
public static TransformablePublisher<CompositeByteBuf> buffer(Publisher<? extends 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<CompositeByteBuf> buffer(Publisher<? extends ByteBuf> publisher, long sizeWatermark, int maxNum, 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<CompositeByteBuf> compose(Publisher<? extends ByteBuf> publisher)
Calls compose(Publisher, ByteBufAllocator) with PooledByteBufAllocator.DEFAULT.
publisher - the streampublic static Promise<CompositeByteBuf> compose(Publisher<? extends ByteBuf> publisher, ByteBufAllocator alloc)
publisher - the streamalloc - the buffer allocatorpublic static Promise<byte[]> toByteArray(Publisher<? extends 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[]