<commit_before>/**
 * Copyright 2010 The Apache Software Foundation
 *
 * 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 nl.gridline.leveldb.bindings.utils;

/**
 * Simple Byte array conversions.<br />
 * Subset of the HBase bytes util: {@link org.apache.hadoop.hbase.util.Bytes}
 * @author <a href="mailto:<EMAIL>">Job</a>
 */
public class Bytes
{

	public static final int SIZE_OF_INT = Integer.SIZE / 8;
	public static final int SIZE_OF_LONG = Long.SIZE / 8;

	public static int toInt(byte[] bytes)
	{
		int n = 0;
		for (int i = 0; i < SIZE_OF_INT; i++)
		{
			n <<= 8;
			n ^= bytes[i] & 0xFF;
		}
		return n;
	}

	public static long toLong(byte[] bytes)
	{
		long l = 0;
		for (int i = 0; i < SIZE_OF_LONG; i++)
		{
			l <<= 8;
			l ^= bytes[i] & 0xFF;
		}
		return l;
	}

	public static double toDouble(final byte[] bytes)<commit_msg>Don't use magic numbers.<commit_after>/**
 * Copyright 2010 The Apache Software Foundation
 *
 * 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 nl.gridline.leveldb.bindings.utils;

/**
 * Simple Byte array conversions.<br />
 * Subset of the HBase bytes util: {@link org.apache.hadoop.hbase.util.Bytes}
 * @author <a href="mailto:<EMAIL>">Job</a>
 */
public class Bytes
{

	public static final int SIZE_OF_INT = Integer.SIZE / Byte.SIZE;
	public static final int SIZE_OF_LONG = Long.SIZE / Byte.SIZE;

	public static int toInt(byte[] bytes)
	{
		int n = 0;
		for (int i = 0; i < SIZE_OF_INT; i++)
		{
			n <<= 8;
			n ^= bytes[i] & 0xFF;
		}
		return n;
	}

	public static long toLong(byte[] bytes)
	{
		long l = 0;
		for (int i = 0; i < SIZE_OF_LONG; i++)
		{
			l <<= 8;
			l ^= bytes[i] & 0xFF;
		}
		return l;
	}

	public static double toDouble(final byte[] bytes)
{'fraction_non_alphanumeric': 0.10151655834107087, 'fraction_numerical': 0.010523057876818322, 'mean_word_length': 3.4456671251719393, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 11, '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': '6343927', 'n_tokens_mistral': 1056, 'n_tokens_neox': 973, 'n_words': 408}