<commit_before>/**
 * 
 */
package cn.strong.fastdfs.client.protocol.response;

import io.netty.buffer.ByteBuf;

import java.nio.charset.Charset;

/**
 * Rx 响应接收器
 * 
 * @author liulongbiao
 *
 */
public class RxReceiver extends AbstractReceiver<ByteBuf> {

	private long length;
	private long readed = 0;

	@Override
	public void setLength(long length) {
		this.length = length;
	}

	@Override
	public boolean tryRead(ByteBuf in, Charset charset) {
		if (length <= readed) {
			if (!subject.hasThrowable()) {
				subject.onCompleted();
			}
			return true;
		}
		int len = (int) Math.min(length - readed, in.readableBytes());
		ByteBuf buf = in.readBytes(len);
		subject.onNext(buf);
		readed += len;
		if (length <= readed) {
			subject.onCompleted();<commit_msg>ReplayingDecoderByteBuf.readableBytes 修改为 writerIndex - readerIndex<commit_after>/**
 * 
 */
package cn.strong.fastdfs.client.protocol.response;

import java.nio.charset.Charset;

import io.netty.buffer.ByteBuf;

/**
 * Rx 响应接收器
 * 
 * @author liulongbiao
 *
 */
public class RxReceiver extends AbstractReceiver<ByteBuf> {

	private long length;
	private long readed = 0;

	@Override
	public void setLength(long length) {
		this.length = length;
	}

	@Override
	public boolean tryRead(ByteBuf in, Charset charset) {
		if (length <= readed) {
			if (!subject.hasThrowable()) {
				subject.onCompleted();
			}
			return true;
		}
		int len = (int) Math.min(length - readed, in.writerIndex() - in.readerIndex());
		ByteBuf buf = in.readBytes(len);
		subject.onNext(buf);
		readed += len;
		if (length <= readed) {
			subject.onCompleted();
{'fraction_non_alphanumeric': 0.13366645846346034, 'fraction_numerical': 0.0012492192379762648, 'mean_word_length': 3.7537091988130564, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1920306', 'n_tokens_mistral': 610, 'n_tokens_neox': 555, 'n_words': 125}