本文整理了Java中com.couchbase.client.deps.io.netty.buffer.ByteBuf.clear()
方法的一些代码示例,展示了ByteBuf.clear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.clear()
方法的具体详情如下:
包路径:com.couchbase.client.deps.io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:clear
[英]Sets the readerIndex and writerIndex of this buffer to 0. This method is identical to #setIndex(int,int).
Please note that the behavior of this method is different from that of NIO buffer, which sets the limit to the capacity of the buffer.
[中]将此缓冲区的readerIndex和writerIndex设置为0。此方法与#setIndex(int,int)相同。
请注意,此方法的行为与NIO buffer不同,后者设置了缓冲区容量的限制。
代码示例来源:origin: com.couchbase.client/core-io
@Override
public ByteBuf clear() {
buf.clear();
return this;
}
代码示例来源:origin: com.couchbase.client/core-io
@Override
public final ByteBuf clear() {
buf.clear();
return this;
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public final ByteBuf clear() {
buf.clear();
return this;
}
代码示例来源:origin: couchbase/couchbase-jvm-core
@Override
public ByteBuf clear() {
buf.clear();
return this;
}
代码示例来源:origin: com.couchbase.client/core-io
/**
* Push a config chunk into the streaming observable.
*/
private void maybePushConfigChunk() {
String currentChunk = responseContent.toString(CHARSET);
int separatorIndex = currentChunk.indexOf("\n\n\n\n");
if (separatorIndex > 0) {
String content = currentChunk.substring(0, separatorIndex);
streamingConfigObservable.onNext(content.trim());
responseContent.clear();
responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CHARSET));
}
}
代码示例来源:origin: couchbase/couchbase-jvm-core
/**
* Push a config chunk into the streaming observable.
*/
private void maybePushConfigChunk() {
String currentChunk = responseContent.toString(CHARSET);
int separatorIndex = currentChunk.indexOf("\n\n\n\n");
if (separatorIndex > 0) {
String content = currentChunk.substring(0, separatorIndex);
streamingConfigObservable.onNext(content.trim());
responseContent.clear();
responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CHARSET));
}
}
代码示例来源:origin: couchbase/java-dcp-client
/**
* Helper method to decode and analyze the chunk.
*
* @param chunk the chunk to analyze.
*/
private void decodeChunk(InetSocketAddress address, final ByteBuf chunk) {
responseContent.writeBytes(chunk);
String currentChunk = responseContent.toString(CharsetUtil.UTF_8);
int separatorIndex = currentChunk.indexOf("\n\n\n\n");
if (separatorIndex > 0) {
String rawConfig = currentChunk
.substring(0, separatorIndex)
.trim()
.replace("$HOST", address.getAddress().getHostAddress());
NetworkAddress origin = NetworkAddress.create(address.getAddress().getHostAddress());
CouchbaseBucketConfig config = (CouchbaseBucketConfig) BucketConfigParser.parse(rawConfig, environment, origin);
synchronized (currentBucketConfigRev) {
if (config.rev() > currentBucketConfigRev.get()) {
currentBucketConfigRev.set(config.rev());
configStream.onNext(config);
} else {
LOGGER.trace("Ignoring config, since rev has not changed.");
}
}
responseContent.clear();
responseContent.writeBytes(currentChunk.substring(separatorIndex + 4).getBytes(CharsetUtil.UTF_8));
}
}
代码示例来源:origin: apache/asterixdb
private void generateNextDocument() {
byteBuff.retain();
// reset the string
strBuilder.setLength(0);
strBuilder.append("{\"id\":" + (counter + upsertCounter) + ",\"name\":\""
+ names[(counter + upsertCounter) % names.length] + "\"");
switch (counter % 3) {
case 0:
// Missing
break;
case 1:
strBuilder.append(",\"exp\":null");
break;
case 2:
strBuilder.append(",\"exp\":" + ((counter + upsertCounter) * 3));
break;
default:
break;
}
strBuilder.append("}");
byteBuff.clear();
byteBuff.writeBytes(strBuilder.toString().getBytes(StandardCharsets.UTF_8));
}
代码示例来源:origin: apache/asterixdb
private void process(String input) throws IOException {
value.reset();
nettyBuffer.clear();
nettyBuffer.writeBytes(input.getBytes(StandardCharsets.UTF_8));
DCPMessageToRecordConverter.set(nettyBuffer, decoder, bytes, chars, value);
Assert.assertEquals(input, value.toString());
}
}
代码示例来源:origin: com.couchbase.client/core-io
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
responseContent.clear();
responseContent.discardReadBytes();
} else if (request instanceof PingRequest) {
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), request);
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: com.couchbase.client/core-io
responseHeader = (HttpResponse) msg;
if (responseContent != null) {
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: com.couchbase.client/core-io
responseHeader = (HttpResponse) msg;
if (responseContent != null) {
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: couchbase/couchbase-jvm-core
responseHeader = (HttpResponse) msg;
if (responseContent != null) {
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: couchbase/couchbase-jvm-core
responseHeader = (HttpResponse) msg;
if (responseContent != null) {
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: couchbase/couchbase-jvm-core
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
responseContent.clear();
responseContent.discardReadBytes();
} else if (request instanceof PingRequest) {
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), request);
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: com.couchbase.client/core-io
responseHeader = (HttpResponse) msg;
if (responseContent != null) {
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: couchbase/couchbase-jvm-core
responseHeader = (HttpResponse) msg;
if (responseContent != null) {
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: com.couchbase.client/core-io
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
代码示例来源:origin: com.couchbase.client/java-client
byte[] compressed = compress(encoded.copy().array());
if (compressed.length < encoded.array().length) {
encoded.clear().writeBytes(compressed);
flags |= COMPRESSED;
代码示例来源:origin: couchbase/couchbase-jvm-core
responseContent.clear();
} else {
responseContent = ctx.alloc().buffer();
if (msg instanceof LastHttpContent) {
response = new KeepAliveResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
if (msg instanceof LastHttpContent) {
response = new PingResponse(ResponseStatusConverter.fromHttp(responseHeader.getStatus().code()), currentRequest());
responseContent.clear();
responseContent.discardReadBytes();
finishedDecoding();
内容来源于网络,如有侵权,请联系作者删除!