本文整理了Java中io.netty.buffer.ByteBuf.retainedSlice()
方法的一些代码示例,展示了ByteBuf.retainedSlice()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.retainedSlice()
方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:retainedSlice
[英]Returns a retained 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 to buf.slice(buf.readerIndex(), buf.readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
Note that this method returns a #retain() buffer unlike #slice(). This method behaves similarly to slice().retain() except that this method may return a buffer implementation that produces less garbage.
[中]返回此缓冲区的可读字节的保留片。修改返回的缓冲区或此缓冲区的内容会影响彼此的内容,同时它们会维护单独的索引和标记。此方法与buf相同。切片(buf.readerIndex(),buf。readableBytes()。此方法不修改此缓冲区的readerIndex或writerIndex。
请注意,与#slice()不同,此方法返回一个#retain()缓冲区。此方法的行为类似于slice()。retain(),但此方法可能返回产生较少垃圾的缓冲区实现。
代码示例来源:origin: netty/netty
/**
* Override this method if you want to filter the json objects/arrays that get passed through the pipeline.
*/
@SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
}
代码示例来源:origin: netty/netty
@Override
public ByteBuf retainedSlice(int index, int length) {
return buf.retainedSlice(index, length);
}
代码示例来源:origin: netty/netty
@Override
public ByteBuf retainedSlice() {
return buf.retainedSlice();
}
代码示例来源:origin: netty/netty
/**
* Extract the sub-region of the specified buffer.
* <p>
* If you are sure that the frame and its content are not accessed after
* the current {@link #decode(ChannelHandlerContext, ByteBuf)}
* call returns, you can even avoid memory copy by returning the sliced
* sub-region (i.e. <tt>return buffer.slice(index, length)</tt>).
* It's often useful when you convert the extracted frame into an object.
* Refer to the source code of {@link ObjectDecoder} to see how this method
* is overridden to avoid memory copy.
*/
protected ByteBuf extractFrame(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
}
代码示例来源:origin: redisson/redisson
/**
* Override this method if you want to filter the json objects/arrays that get passed through the pipeline.
*/
@SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf retainedSlice(int index, int length) {
return buf.retainedSlice(index, length);
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf retainedSlice() {
return buf.retainedSlice();
}
代码示例来源:origin: redisson/redisson
/**
* Extract the sub-region of the specified buffer.
* <p>
* If you are sure that the frame and its content are not accessed after
* the current {@link #decode(ChannelHandlerContext, ByteBuf)}
* call returns, you can even avoid memory copy by returning the sliced
* sub-region (i.e. <tt>return buffer.slice(index, length)</tt>).
* It's often useful when you convert the extracted frame into an object.
* Refer to the source code of {@link ObjectDecoder} to see how this method
* is overridden to avoid memory copy.
*/
protected ByteBuf extractFrame(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
}
代码示例来源:origin: wildfly/wildfly
/**
* Override this method if you want to filter the json objects/arrays that get passed through the pipeline.
*/
@SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
}
代码示例来源:origin: wildfly/wildfly
@Override
public ByteBuf retainedSlice() {
return buf.retainedSlice();
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public ByteBuf retainedSlice() {
return byteBuf.retainedSlice();
}
代码示例来源:origin: wildfly/wildfly
@Override
public ByteBuf retainedSlice(int index, int length) {
return buf.retainedSlice(index, length);
}
代码示例来源:origin: netty/netty
@Override
public ByteBuf retainedSlice() {
return buf.retainedSlice().order(order);
}
代码示例来源:origin: netty/netty
@Override
public ByteBuf retainedSlice(int index, int length) {
return buf.retainedSlice(index, length).order(order);
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf retainedSlice(int index, int length) {
return buf.retainedSlice(index, length).order(order);
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf retainedSlice() {
return buf.retainedSlice().order(order);
}
代码示例来源:origin: wildfly/wildfly
@Override
public ByteBuf retainedSlice() {
return buf.retainedSlice().order(order);
}
代码示例来源:origin: line/armeria
private static ByteBuf dataChunk(HttpData data, int offset, int chunkSize) {
if (data instanceof ByteBufHolder) {
final ByteBuf buf = ((ByteBufHolder) data).content();
return buf.retainedSlice(offset, chunkSize);
} else {
return Unpooled.wrappedBuffer(data.array(), offset, chunkSize);
}
}
代码示例来源:origin: apache/pulsar
@Override
public CompletableFuture<LedgerEntries> readAsync(long firstEntry, long lastEntry) {
List<LedgerEntry> readEntries = Lists.newArrayList();
for (long eid = firstEntry; eid <= lastEntry; eid++) {
ByteBuf buf = entries.get((int)eid).retainedSlice();
readEntries.add(LedgerEntryImpl.create(id, eid, buf.readableBytes(), buf));
}
return CompletableFuture.completedFuture(LedgerEntriesImpl.create(readEntries));
}
代码示例来源:origin: apache/pulsar
MockOffloadReadHandle(ReadHandle toCopy) throws Exception {
id = toCopy.getId();
long lac = toCopy.getLastAddConfirmed();
try (LedgerEntries entries = toCopy.read(0, lac)) {
for (LedgerEntry e : entries) {
this.entries.add(e.getEntryBuffer().retainedSlice());
}
}
metadata = new MockMetadata(toCopy.getLedgerMetadata());
}
内容来源于网络,如有侵权,请联系作者删除!