<commit_before>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.facebook.infrastructure.utils;

import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.zip.Deflater;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.io.*;
import java.net.*;
import java.nio.channels.SocketChannel;
import java.nio.ByteBuffer;
import java.math.BigInteger;
/**
 * Author : <NAME> ( <EMAIL>) & <NAME> ( <EMAIL> ) & <NAME> ( <EMAIL> )
 */

public class CassandraUtilities
{

    private static InetAddress localInetAddress_;
    private static String host_;

    public static String getTimestamp()
    {
        Date date = new Date();
        DateFormat df  = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        return df.format(date);
    }
    
    public static String getTimestamp(long value)
    {
        Date date = new Date(value);
        DateFormat df  = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        return df.format(date);
    }

    public static int getBits(int x, int p, int n)
    {
         return ( x >>> (p + 1 - n)) & ~(~0 << n);
    }

    public static String getCurrentThreadStackTrace()
    {
        Throwable throwable = new Throwable();
        StackTraceElement[] ste = throwable.getStackTrace();
        StringBuffer sbuf = new StringBuffer();

        for ( int i = ste.length - 1; i > 0; --i )
        {
            sbuf.append(ste[i].getClassName() + "." + ste[i].getMethodName());
            sbuf.append("/");
        }
        sbuf.deleteCharAt(sbuf.length() - 1);
        return sbuf.toString();
    }

    public static String[] strip(String string, String token)
    {
        StringTokenizer st = new StringTokenizer(string, token);
        List<String> result = new ArrayList<String>();
        while ( st.hasMoreTokens() )
        {
            result.add( (String)st.nextElement() );
        }
        return result.toArray( new String[0] );
    }

    public static byte[] serializeToStream(Object o)
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] bytes = new byte[0];
        try
        {
    		ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(o);
            oos.flush();
    		bytes = bos.toByteArray();
    		oos.close();
    		bos.close();
        }
        catch ( IOException e )
        {
            LogUtil.getLogger(CassandraUtilities.class.getName()).info( LogUtil.throwableToString(e) );
        }
		return bytes;
    }

    public static Object deserializeFromStream(byte[] bytes)
    {
        Object o = null;
		ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
        try
        {
    		ObjectInputStream ois = new ObjectInputStream(bis);
            try
            {
    		    o = ois.readObject();
            }
            catch ( ClassNotFoundException e )
            {
            }
    		ois.close();
    		bis.close();
        }
        catch ( IOException e )
        {
            LogUtil.getLogger(CassandraUtilities.class.getName()).info( LogUtil.throwableToString(e) );
        }
		return o;
    }

    public static InetAddress getLocalAddress() throws UnknownHostException
    {
	if ( localInetAddress_ == null )
		localInetAddress_ = InetAddress.getLocalHost();
        return localInetAddress_;
    }

    public static String getLocalHostName() throws UnknownHostException
    {
	if ( host_ == null )
	{
		host_ = getLocalAddress().getHostName();
	}
	return host_;
    }

    public static String getHostName() throws UnknownHostException
    {
        return getLocalAddress().getCanonicalHostName();
    }

    public static boolean isHostLocalHost(InetAddress host)
    {
        try {
            return getLocalAddress().equals(host);
        }
        catch ( UnknownHostException e )
        {
            return false;<commit_msg>Fix CassandraUtilities.getLocalHostName to return a canonical hostname instead of a non-qualified one.<commit_after>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.facebook.infrastructure.utils;

import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.zip.Deflater;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.io.*;
import java.net.*;
import java.nio.channels.SocketChannel;
import java.nio.ByteBuffer;
import java.math.BigInteger;
/**
 * Author : <NAME> ( <EMAIL>) & <NAME> ( <EMAIL> ) & <NAME> ( <EMAIL> )
 */

public class CassandraUtilities
{

    private static InetAddress localInetAddress_;
    private static String host_;

    public static String getTimestamp()
    {
        Date date = new Date();
        DateFormat df  = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        return df.format(date);
    }
    
    public static String getTimestamp(long value)
    {
        Date date = new Date(value);
        DateFormat df  = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        return df.format(date);
    }

    public static int getBits(int x, int p, int n)
    {
         return ( x >>> (p + 1 - n)) & ~(~0 << n);
    }

    public static String getCurrentThreadStackTrace()
    {
        Throwable throwable = new Throwable();
        StackTraceElement[] ste = throwable.getStackTrace();
        StringBuffer sbuf = new StringBuffer();

        for ( int i = ste.length - 1; i > 0; --i )
        {
            sbuf.append(ste[i].getClassName() + "." + ste[i].getMethodName());
            sbuf.append("/");
        }
        sbuf.deleteCharAt(sbuf.length() - 1);
        return sbuf.toString();
    }

    public static String[] strip(String string, String token)
    {
        StringTokenizer st = new StringTokenizer(string, token);
        List<String> result = new ArrayList<String>();
        while ( st.hasMoreTokens() )
        {
            result.add( (String)st.nextElement() );
        }
        return result.toArray( new String[0] );
    }

    public static byte[] serializeToStream(Object o)
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        byte[] bytes = new byte[0];
        try
        {
    		ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(o);
            oos.flush();
    		bytes = bos.toByteArray();
    		oos.close();
    		bos.close();
        }
        catch ( IOException e )
        {
            LogUtil.getLogger(CassandraUtilities.class.getName()).info( LogUtil.throwableToString(e) );
        }
		return bytes;
    }

    public static Object deserializeFromStream(byte[] bytes)
    {
        Object o = null;
		ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
        try
        {
    		ObjectInputStream ois = new ObjectInputStream(bis);
            try
            {
    		    o = ois.readObject();
            }
            catch ( ClassNotFoundException e )
            {
            }
    		ois.close();
    		bis.close();
        }
        catch ( IOException e )
        {
            LogUtil.getLogger(CassandraUtilities.class.getName()).info( LogUtil.throwableToString(e) );
        }
		return o;
    }

    public static InetAddress getLocalAddress() throws UnknownHostException
    {
	if ( localInetAddress_ == null )
		localInetAddress_ = InetAddress.getLocalHost();
        return localInetAddress_;
    }

    public static String getLocalHostName() throws UnknownHostException
    {
	if ( host_ == null )
	{
		host_ = getLocalAddress().getCanonicalHostName();
	}
    
	return host_;
    }

    public static String getHostName() throws UnknownHostException
    {
        return getLocalAddress().getCanonicalHostName();
    }

    public static boolean isHostLocalHost(InetAddress host)
    {
        try {
            return getLocalAddress().equals(host);
        }
        catch ( UnknownHostException e )
        {
            return false;
{'fraction_non_alphanumeric': 0.10183150183150183, 'fraction_numerical': 0.002302459445316588, 'mean_word_length': 2.487591240875912, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6201136', 'n_tokens_mistral': 2697, 'n_tokens_neox': 2623, 'n_words': 750}