<commit_before>package nanomsg;

import java.nio.charset.Charset;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import nanomsg.jna.NanoMsg;


public abstract class RWSocket extends Socket {
    public RWSocket(int domain, int protocol) {
        super(domain, protocol);
    }

    /**
     * Send string to socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public void sendString(String data, boolean blocking) {
        final Charset encoding = Charset.forName("UTF-8");
        this.sendBytes(data.getBytes(encoding), blocking);
    }

    /**
     * Send string to socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public void sendString(String data) {
        this.sendString(data, true);
    }

    /**
     * Send byte array to socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public void sendBytes(byte[] data, boolean blocking) {
        final int socket = getSocket();
        final int rc = NanoMsg.nn_send(socket, data, data.length, blocking ? 0 : Constants.NN_DONTWAIT);
        if (rc < 0) {
            System.out.println("Error");
        }
    }

    /**
     * Send byte array to socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public void sendBytes(byte[] data) {
        this.sendBytes(data, true);
    }

    /**
     * Receive string from socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public String recvString(boolean blocking) throws RuntimeException {
        final byte[] received = this.recvBytes(blocking);
        final Charset encoding = Charset.forName("UTF-8");

        return new String(received, encoding);
    }

    /**
     * Receive string from socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public String recvString() throws RuntimeException {
        return this.recvString(true);
    }

    /**
     * Receive byte array from socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public byte[] recvBytes(boolean blocking) throws RuntimeException {
        final Pointer buff = Pointer.NULL;
        final PointerByReference ptrBuff = new PointerByReference(buff);

        final int socket = getSocket();
        final int received = NanoMsg.nn_recv(socket, ptrBuff, Constants.NN_MSG, blocking ? 0: Constants.NN_DONTWAIT);

        if (received < 0) {
            throw new RuntimeException(Constants.getError());
        }

        final Pointer result = ptrBuff.getValue();
        return result.getByteArray(0, received);
    }

    /**
     * Receive byte array from socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public byte[] recvBytes() throws RuntimeException {
        return this.recvBytes(true);
    }
}
<commit_msg>Remove unused Pointer instance creation.<commit_after>package nanomsg;

import java.nio.charset.Charset;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import nanomsg.jna.NanoMsg;


public abstract class RWSocket extends Socket {
    public RWSocket(int domain, int protocol) {
        super(domain, protocol);
    }

    /**
     * Send string to socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public void sendString(String data, boolean blocking) {
        final Charset encoding = Charset.forName("UTF-8");
        this.sendBytes(data.getBytes(encoding), blocking);
    }

    /**
     * Send string to socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public void sendString(String data) {
        this.sendString(data, true);
    }

    /**
     * Send byte array to socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public void sendBytes(byte[] data, boolean blocking) {
        final int socket = getSocket();
        final int rc = NanoMsg.nn_send(socket, data, data.length, blocking ? 0 : Constants.NN_DONTWAIT);
        if (rc < 0) {
            System.out.println("Error");
        }
    }

    /**
     * Send byte array to socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public void sendBytes(byte[] data) {
        this.sendBytes(data, true);
    }

    /**
     * Receive string from socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public String recvString(boolean blocking) throws RuntimeException {
        final byte[] received = this.recvBytes(blocking);
        final Charset encoding = Charset.forName("UTF-8");

        return new String(received, encoding);
    }

    /**
     * Receive string from socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public String recvString() throws RuntimeException {
        return this.recvString(true);
    }

    /**
     * Receive byte array from socket with option to set blocking flag.
     *
     * @param blocking set blocking or non blocking flag.
     * @return receved data as unicode string.
     */
    public byte[] recvBytes(boolean blocking) {
        final PointerByReference ptrBuff = new PointerByReference();

        final int socket = getSocket();
        final int received = NanoMsg.nn_recv(socket, ptrBuff, Constants.NN_MSG, blocking ? 0: Constants.NN_DONTWAIT);

        if (received < 0) {
            throw new RuntimeException(Constants.getError());
        }

        final Pointer result = ptrBuff.getValue();
        return result.getByteArray(0, received);
    }

    /**
     * Receive byte array from socket.
     *
     * This operation is blocking by default.
     *
     * @return receved data as unicode string.
     */
    public byte[] recvBytes() throws RuntimeException {
        return this.recvBytes(true);
    }
}

{'fraction_non_alphanumeric': 0.09229390681003584, 'fraction_numerical': 0.002090800477897252, 'mean_word_length': 2.3252234359483617, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '100712', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1809, 'n_words': 612}