<commit_before>using System;
using System.Text;

namespace DbMaker
{


    /**
     * util class 
     * 
     * @author chenxin<<EMAIL>>
    */
    public class Util
    {
        /**
         * write specfield bytes to a byte array start from offset
         * 
         * @param    b
         * @param    offset
         * @param    v
         * @param    bytes
        */
        public static void write(byte[] b, int offset, long v, int bytes)
        {
            for (int i = 0; i < bytes; i++)
            {
                //b[offset++] = (byte)((v >>> (8 * i)) & 0xFF);
                b[offset++] = (byte) ((v >> (8 * i)) & 0xFF);
            }
        }

        /**
         * write a int to a byte array
         * 
         * @param    b
         * @param    offet
         * @param    v
        */
        public static void writeIntLong(byte[] b, int offset, long v)
        {
            b[offset++] = (byte) ((v >> 0) & 0xFF);
            b[offset++] = (byte) ((v >> 8) & 0xFF);
            b[offset++] = (byte) ((v >> 16) & 0xFF);
            b[offset] = (byte) ((v >> 24) & 0xFF);
        }

        /**
         * get a int from a byte array start from the specifiled offset
         * 
         * @param    b
         * @param    offset
        */
        public static long getIntLong(byte[] b, int offset)
        {
            return (
                ((b[offset++] & 0x000000FFL)) |
                ((b[offset++] << 8) & 0x0000FF00L) |
                ((b[offset++] << 16) & 0x00FF0000L) |
                ((b[offset] << 24) & 0xFF000000L)
            );
        }

        /**
         * get a int from a byte array start from the specifield offset
         * 
         * @param    b
         * @param    offset
        */
        public static int getInt3(byte[] b, int offset)
        {
            return (
                (b[offset++] & 0x000000FF) |
                (b[offset++] & 0x0000FF00) |
                (b[offset] & 0x00FF0000)
            );
        }

        public static int getInt2(byte[] b, int offset)
        {
            return (
                (b[offset++] & 0x000000FF) |
                (b[offset] & 0x0000FF00)
            );
        }

        public static int getInt1(byte[] b, int offset)
        {
            return (
                (b[offset] & 0x000000FF)
            );
        }

        /**
         * string ip to long ip
         * 
         * @param    ip
         * @return    long
        */
        public static long ip2long(String ip)
        {
            throw new NotImplementedException();
            //String[] p = ip.Split("\\.");
            //if ( p.Length != 4 ) return 0;

            //int p1 = ((Convert.ToInt32(p[0]) << 24) & 0xFF000000);
            //int p2 = ((Integer.valueOf(p[1]) << 16) & 0x00FF0000);
            //int p3 = ((Integer.valueOf(p[2]) <<  8) & 0x0000FF00);
            //int p4 = ((Integer.valueOf(p[3]) <<  0) & 0x000000FF);

            //return ((p1 | p2 | p3 | p4) & 0xFFFFFFFFL);<commit_msg>Util.cs -> ip2long<commit_after>using System;
using System.Text;

namespace DbMaker
{


    /**
     * util class 
     * 
     * @author chenxin<<EMAIL>>
    */
    public class Util
    {
        /**
         * write specfield bytes to a byte array start from offset
         * 
         * @param    b
         * @param    offset
         * @param    v
         * @param    bytes
        */
        public static void write(byte[] b, int offset, long v, int bytes)
        {
            for (int i = 0; i < bytes; i++)
            {
                //b[offset++] = (byte)((v >>> (8 * i)) & 0xFF);
                b[offset++] = (byte) ((v >> (8 * i)) & 0xFF);
            }
        }

        /**
         * write a int to a byte array
         * 
         * @param    b
         * @param    offet
         * @param    v
        */
        public static void writeIntLong(byte[] b, int offset, long v)
        {
            b[offset++] = (byte) ((v >> 0) & 0xFF);
            b[offset++] = (byte) ((v >> 8) & 0xFF);
            b[offset++] = (byte) ((v >> 16) & 0xFF);
            b[offset] = (byte) ((v >> 24) & 0xFF);
        }

        /**
         * get a int from a byte array start from the specifiled offset
         * 
         * @param    b
         * @param    offset
        */
        public static long getIntLong(byte[] b, int offset)
        {
            return (
                ((b[offset++] & 0x000000FFL)) |
                ((b[offset++] << 8) & 0x0000FF00L) |
                ((b[offset++] << 16) & 0x00FF0000L) |
                ((b[offset] << 24) & 0xFF000000L)
            );
        }

        /**
         * get a int from a byte array start from the specifield offset
         * 
         * @param    b
         * @param    offset
        */
        public static int getInt3(byte[] b, int offset)
        {
            return (
                (b[offset++] & 0x000000FF) |
                (b[offset++] & 0x0000FF00) |
                (b[offset] & 0x00FF0000)
            );
        }

        public static int getInt2(byte[] b, int offset)
        {
            return (
                (b[offset++] & 0x000000FF) |
                (b[offset] & 0x0000FF00)
            );
        }

        public static int getInt1(byte[] b, int offset)
        {
            return (
                (b[offset] & 0x000000FF)
            );
        }

        /**
         * string ip to long ip
         * 
         * @param    ip
         * @return    long
        */
        public static long ip2long(String ip)
        {
            ip = ip.Trim();
            String[] ips = ip.Split('.');
            long ip1 = Int64.Parse(ips[0]);
            long ip2 = Int64.Parse(ips[1]);
            long ip3 = Int64.Parse(ips[2]);
            long ip4 = Int64.Parse(ips[3]);
            long ip2long = 1L * ip1 * 256 * 256 * 256 + ip2 * 256 * 256 + ip3 * 256 + ip4;
            return ip2long;
{'fraction_non_alphanumeric': 0.1388231315522489, 'fraction_numerical': 0.04751437267500845, 'mean_word_length': 1.1208318393689494, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '2734029', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1771, 'n_words': 475}