<commit_before>package gflogger.formatter;

import java.nio.CharBuffer;

/**
 * CharBufferFormatter
 * 
 * @author <NAME>, <EMAIL>
 */
public class BufferFormatter {

    public static CharBuffer append(final CharBuffer buffer, boolean b){
        if (b){
            return buffer.put('t').put('r').put('u').put('e');
        }
        return buffer.put('f').put('a').put('l').put('s').put('e');
    }
    
    public static CharBuffer append(final CharBuffer buffer, CharSequence s){
        return append(buffer, s, 0, s != null ? s.length() : 0);
    }
    
    public static CharBuffer append(final CharBuffer buffer, CharSequence s, int start, int end){
        if (s != null){
            for(int i = start; i < end; i++){
                buffer.put(s.charAt(i));
            }
            return buffer;
        }
        return buffer.put('n').put('u').put('l').put('l');
    }
    
    public static CharBuffer append(final CharBuffer buffer, byte b) {
        int i = b;
        if (i < 0) {
            buffer.put('-');
            i = -i;
        }
        int j = i;
        // positive byte values is in 0 .. 128
        if (i >= 100){
            buffer.put(DIGIT_ONES[1]);
            i -= 100;
        }
        
        if (i >= 10 || j >= 100){
            buffer.put(DIGIT_TENS[i]);
        }
        
        buffer.put(DIGIT_ONES[i]);
        
        return buffer;
    }
    
    public static CharBuffer append(final CharBuffer buffer, int i) {
        if (i == Integer.MIN_VALUE) {
         // uses java.lang.Integer string constant of MIN_VALUE
            return append(buffer, Integer.toString(i));
        }
        
        put(buffer, i);
        return buffer;
    }
    
    public static CharBuffer append(final CharBuffer buffer, long i) {
        if (i == Long.MIN_VALUE){
            // uses java.lang.Long string constant of MIN_VALUE
            return append(buffer, Long.toString(i));
        }
        put(buffer, i);
        return buffer;
    }
    
    
    public static CharBuffer append(final CharBuffer buffer, double i, int precision) {
        put(buffer, i, precision < 0 ? 4 : precision);
        return buffer;
    }

    final static int[] INT_SIZE_TABLE = {
        10,
        100,
        1000,
        10000,
        100000,
        1000000,
        10000000,
        100000000,
        1000000000,
        Integer.MAX_VALUE };
    
    final static long[] LONG_SIZE_TABLE = { 
        10L,
        100L,
        1000L,
        10000L,
        100000L,
        1000000L,
        10000000L,
        100000000L,
        1000000000L,
        10000000000L,
        100000000000L,
        1000000000000L,
        10000000000000L,
        100000000000000L,
        1000000000000000L,
        10000000000000000L,
        100000000000000000L,
        1000000000000000000L,
        Long.MAX_VALUE};
    
    final static char [] DIGIT_TENS = {
        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
        '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
        '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
        '3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
        '4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
        '5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
        '6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
        '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
        '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
        '9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
    } ; 

    final static char [] DIGIT_ONES = { 
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    } ;
        
    /**
     * All possible chars for representing a number as a String
     */
    final static char[] DIGITS = {
        '0' , '1' , '2' , '3' , '4' , '5' ,
        '6' , '7' , '8' , '9' , 'a' , 'b' ,
        'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
        'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
        'o' , 'p' , 'q' , 'r' , 's' , 't' ,
        'u' , 'v' , 'w' , 'x' , 'y' , 'z'
    };
    
    // Requires positive x
    public static int stringSize(int x) {
        for (int i = 0; i < INT_SIZE_TABLE.length; i++)
            if (x < INT_SIZE_TABLE[i])
                return i + 1;
        return INT_SIZE_TABLE.length;
    }<commit_msg>make constants public<commit_after>package gflogger.formatter;

import java.nio.CharBuffer;

/**
 * CharBufferFormatter
 * 
 * @author <NAME>, <EMAIL>
 */
public class BufferFormatter {

    public static CharBuffer append(final CharBuffer buffer, boolean b){
        if (b){
            return buffer.put('t').put('r').put('u').put('e');
        }
        return buffer.put('f').put('a').put('l').put('s').put('e');
    }
    
    public static CharBuffer append(final CharBuffer buffer, CharSequence s){
        return append(buffer, s, 0, s != null ? s.length() : 0);
    }
    
    public static CharBuffer append(final CharBuffer buffer, CharSequence s, int start, int end){
        if (s != null){
            for(int i = start; i < end; i++){
                buffer.put(s.charAt(i));
            }
            return buffer;
        }
        return buffer.put('n').put('u').put('l').put('l');
    }
    
    public static CharBuffer append(final CharBuffer buffer, byte b) {
        int i = b;
        if (i < 0) {
            buffer.put('-');
            i = -i;
        }
        int j = i;
        // positive byte values is in 0 .. 128
        if (i >= 100){
            buffer.put(DIGIT_ONES[1]);
            i -= 100;
        }
        
        if (i >= 10 || j >= 100){
            buffer.put(DIGIT_TENS[i]);
        }
        
        buffer.put(DIGIT_ONES[i]);
        
        return buffer;
    }
    
    public static CharBuffer append(final CharBuffer buffer, int i) {
        if (i == Integer.MIN_VALUE) {
         // uses java.lang.Integer string constant of MIN_VALUE
            return append(buffer, Integer.toString(i));
        }
        
        put(buffer, i);
        return buffer;
    }
    
    public static CharBuffer append(final CharBuffer buffer, long i) {
        if (i == Long.MIN_VALUE){
            // uses java.lang.Long string constant of MIN_VALUE
            return append(buffer, Long.toString(i));
        }
        put(buffer, i);
        return buffer;
    }
    
    
    public static CharBuffer append(final CharBuffer buffer, double i, int precision) {
        put(buffer, i, precision < 0 ? 4 : precision);
        return buffer;
    }

    public final static int[] INT_SIZE_TABLE = {
        10,
        100,
        1000,
        10000,
        100000,
        1000000,
        10000000,
        100000000,
        1000000000,
        Integer.MAX_VALUE };
    
    public final static long[] LONG_SIZE_TABLE = { 
        10L,
        100L,
        1000L,
        10000L,
        100000L,
        1000000L,
        10000000L,
        100000000L,
        1000000000L,
        10000000000L,
        100000000000L,
        1000000000000L,
        10000000000000L,
        100000000000000L,
        1000000000000000L,
        10000000000000000L,
        100000000000000000L,
        1000000000000000000L,
        Long.MAX_VALUE};
    
    public final static char [] DIGIT_TENS = {
        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
        '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
        '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
        '3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
        '4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
        '5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
        '6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
        '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
        '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
        '9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
    } ; 

    public final static char [] DIGIT_ONES = { 
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    } ;
        
    /**
     * All possible chars for representing a number as a String
     */
    public final static char[] DIGITS = {
        '0' , '1' , '2' , '3' , '4' , '5' ,
        '6' , '7' , '8' , '9' , 'a' , 'b' ,
        'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
        'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
        'o' , 'p' , 'q' , 'r' , 's' , 't' ,
        'u' , 'v' , 'w' , 'x' , 'y' , 'z'
    };
    
    // Requires positive x
    public static int stringSize(int x) {
        for (int i = 0; i < INT_SIZE_TABLE.length; i++)
            if (x < INT_SIZE_TABLE[i])
                return i + 1;
        return INT_SIZE_TABLE.length;
    }
{'fraction_non_alphanumeric': 0.22619420926100137, 'fraction_numerical': 0.09950872791888785, 'mean_word_length': 1.7166382737081203, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 30, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2391304', 'n_tokens_mistral': 4014, 'n_tokens_neox': 3562, 'n_words': 993}