<commit_before>package backend;

import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Random;
/**
 * 
 * @author Fitria
 * added this function to convert bytes to any types
 * from now long to byte is done
 * if necessary, will add bytes convertion to another types here
 *
 */

public class ByteUtils {
	public byte[] longToBytes(long x) {
	    ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE);
	    buffer.putLong(x);
	    return buffer.array();
	}

	public long bytesToLong(byte[] bytes) {
	    ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE);
	    buffer.put(bytes);
	    buffer.flip();//need flip 
	    return buffer.getLong();
	}
	
	public short bytesToShort(byte[] bytes) {
		ByteBuffer bb = ByteBuffer.allocate(2);
		bb.put(bytes[0]);
		bb.put(bytes[1]);
		short shortVal = bb.getShort(0);
		return shortVal;
	}
	
	
	/** BigInteger to bytes (without leading zero) */
	byte[] getBytes(BigInteger big) {
		byte[] data = big.toByteArray();<commit_msg>add short to bytes and vice versa<commit_after>package backend;

import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Random;
/**
 * 
 * @author Fitria
 * added this function to convert bytes to any types
 * from now long to byte is done
 * if necessary, will add bytes convertion to another types here
 *
 */

public class ByteUtils {
	public byte[] longToBytes(long x) {
	    ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE);
	    buffer.putLong(x);
	    return buffer.array();
	}

	public long bytesToLong(byte[] bytes) {
	    ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE);
	    buffer.put(bytes);
	    buffer.flip();//need flip 
	    return buffer.getLong();
	}
	
	public short bytesToShort(byte[] bytes) {
		ByteBuffer bb = ByteBuffer.allocate(Short.SIZE);
		bb.put(bytes);
		bb.flip();
		return bb.getShort();
	}
	
	public byte[] shortToBytes(short x) {
	    ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE);
	    buffer.putShort(x);
	    return buffer.array();
	}
	
	
	/** BigInteger to bytes (without leading zero) */
	byte[] getBytes(BigInteger big) {
		byte[] data = big.toByteArray();
{'fraction_non_alphanumeric': 0.12192860454334724, 'fraction_numerical': 0.0018544274455261937, 'mean_word_length': 3.670995670995671, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2867287', 'n_tokens_mistral': 722, 'n_tokens_neox': 660, 'n_words': 190}