<commit_before>package org.lightmare.remote.rpc.decoders;

import java.io.IOException;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
import org.lightmare.remote.rpc.wrappers.RpcWrapper;
import org.lightmare.utils.RpcUtils;
import org.lightmare.utils.serialization.NativeSerializer;

/**
 * Decoder class for netty remote procedure call
 * 
 * @author levan
 * @since 0.0.21-SNAPSHOT
 */
public class RpcDecoder extends FrameDecoder {

    @Override
    protected Object decode(ChannelHandlerContext context, Channel channel,
	    ChannelBuffer buffer) throws IOException {

	if (buffer.readableBytes() < RpcUtils.PROTOCOL_SIZE) {
	    buffer.resetReaderIndex();
	    return null;
	}

	int beanNameSize = buffer.readInt();
	int methodSize = buffer.readInt();
	int paramTypesSize = buffer.readInt();
	int classSize = buffer.readInt();
	int paramArraySize = buffer.readInt();

	int paramsSize = beanNameSize + methodSize + classSize + paramArraySize;

	if (buffer.readableBytes() < paramsSize) {
	    buffer.resetReaderIndex();
	    return null;
	}

	byte[] beanNameBt = new byte[beanNameSize];
	buffer.readBytes(beanNameBt);

	byte[] methodBt = new byte[methodSize];
	buffer.readBytes(methodBt);

	byte[] paramTypesBt = new byte[paramTypesSize];
	buffer.readBytes(paramTypesBt);

	byte[] classBt = new byte[classSize];
	buffer.readBytes(classBt);

	byte[] paramBt = new byte[paramArraySize];
	buffer.readBytes(paramBt);

	RpcWrapper wrapper = new RpcWrapper();

	String beanName = new String(beanNameBt);
	String methodName = (String) NativeSerializer.deserialize(methodBt);
	Class<?>[] paramTypes = (Class<?>[]) NativeSerializer
		.deserialize(paramTypesBt);
	Class<?> interfaceClass = (Class<?>) NativeSerializer
		.deserialize(classBt);
	Object[] params = (Object[]) NativeSerializer.deserialize(paramBt);

	wrapper.setBeanName(beanName);
	wrapper.setMethodName(methodName);
	wrapper.setParamTypes(paramTypes);
	wrapper.setInterfaceClass(interfaceClass);
	wrapper.setParams(params);

	return wrapper;
    }
}<commit_msg>improved RPC classes for "netty" dependency<commit_after>package org.lightmare.remote.rpc.decoders;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.io.IOException;
import java.util.List;

import org.lightmare.remote.rpc.wrappers.RpcWrapper;
import org.lightmare.utils.RpcUtils;
import org.lightmare.utils.serialization.NativeSerializer;

/**
 * Decoder class for netty remote procedure call
 * 
 * @author levan
 * @since 0.0.21-SNAPSHOT
 */
public class RpcDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext context, ByteBuf buffer,
	    List<Object> out) throws IOException {

	if (buffer.readableBytes() < RpcUtils.PROTOCOL_SIZE) {
	    buffer.resetReaderIndex();
	    return;
	}

	int beanNameSize = buffer.readInt();
	int methodSize = buffer.readInt();
	int paramTypesSize = buffer.readInt();
	int classSize = buffer.readInt();
	int paramArraySize = buffer.readInt();

	int paramsSize = beanNameSize + methodSize + classSize + paramArraySize;

	if (buffer.readableBytes() < paramsSize) {
	    buffer.resetReaderIndex();
	    return;
	}

	byte[] beanNameBt = new byte[beanNameSize];
	buffer.readBytes(beanNameBt);

	byte[] methodBt = new byte[methodSize];
	buffer.readBytes(methodBt);

	byte[] paramTypesBt = new byte[paramTypesSize];
	buffer.readBytes(paramTypesBt);

	byte[] classBt = new byte[classSize];
	buffer.readBytes(classBt);

	byte[] paramBt = new byte[paramArraySize];
	buffer.readBytes(paramBt);

	RpcWrapper wrapper = new RpcWrapper();

	String beanName = new String(beanNameBt);
	String methodName = (String) NativeSerializer.deserialize(methodBt);
	Class<?>[] paramTypes = (Class<?>[]) NativeSerializer
		.deserialize(paramTypesBt);
	Class<?> interfaceClass = (Class<?>) NativeSerializer
		.deserialize(classBt);
	Object[] params = (Object[]) NativeSerializer.deserialize(paramBt);

	wrapper.setBeanName(beanName);
	wrapper.setMethodName(methodName);
	wrapper.setParamTypes(paramTypes);
	wrapper.setInterfaceClass(interfaceClass);
	wrapper.setParams(params);

	out.add(wrapper);
    }
}
{'fraction_non_alphanumeric': 0.11812297734627832, 'fraction_numerical': 0.0018492834026814608, 'mean_word_length': 5.526395173453997, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 12, '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': '4554688', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1349, 'n_words': 274}