Java Code Examples for io.netty.buffer.Unpooled#wrappedUnmodifiableBuffer()
The following examples show how to use
io.netty.buffer.Unpooled#wrappedUnmodifiableBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PravegaRequestProcessor.java From pravega with Apache License 2.0 | 5 votes |
/** * Collect all the data from the given contents into a {@link ByteBuf}. */ private ByteBuf toByteBuf(List<BufferView> contents) { val buffers = contents.stream() .flatMap(bv -> bv.getContents().stream()) .map(Unpooled::wrappedBuffer) .toArray(ByteBuf[]::new); return Unpooled.wrappedUnmodifiableBuffer(buffers); }
Example 2
Source File: PravegaRequestProcessor.java From pravega with Apache License 2.0 | 5 votes |
private ByteBuf toByteBuf(BufferView bufferView) { if (bufferView.getLength() == 0) { return EMPTY_BUFFER; } val buffers = bufferView.getContents().stream().map(Unpooled::wrappedBuffer).toArray(ByteBuf[]::new); return Unpooled.wrappedUnmodifiableBuffer(buffers); }
Example 3
Source File: WireCommands.java From pravega with Apache License 2.0 | 4 votes |
public ByteBuf getAsByteBuf() { ByteBuf header = Unpooled.buffer(TYPE_PLUS_LENGTH_SIZE, TYPE_PLUS_LENGTH_SIZE); header.writeInt(type.getCode()); header.writeInt(data.readableBytes()); return Unpooled.wrappedUnmodifiableBuffer(header, data); }
Example 4
Source File: PravegaRequestProcessorTest.java From pravega with Apache License 2.0 | 4 votes |
private ByteBuf toByteBuf(BufferView bufferView) { val buffers = bufferView.getContents().stream().map(Unpooled::wrappedBuffer).toArray(ByteBuf[]::new); return Unpooled.wrappedUnmodifiableBuffer(buffers); }
Example 5
Source File: Write.java From pravega with Apache License 2.0 | 4 votes |
private ByteBuf convertData(CompositeArrayView data) { ByteBuf[] components = new ByteBuf[data.getComponentCount()]; val index = new AtomicInteger(); data.collect(bb -> components[index.getAndIncrement()] = Unpooled.wrappedBuffer(bb)); return Unpooled.wrappedUnmodifiableBuffer(components); }