<commit_before>package com.facebook.presto.tuple;

import com.facebook.presto.slice.SizeOf;
import com.facebook.presto.block.BlockBuilder;
import com.facebook.presto.slice.DynamicSliceOutput;
import com.facebook.presto.slice.Slice;
import com.facebook.presto.slice.SliceInput;
import com.facebook.presto.slice.SliceOutput;
import com.facebook.presto.slice.Slices;
import com.google.common.base.Charsets;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.facebook.presto.slice.SizeOf.SIZE_OF_DOUBLE;
import static com.facebook.presto.slice.SizeOf.SIZE_OF_LONG;
import static com.facebook.presto.slice.SizeOf.SIZE_OF_SHORT;
import static com.facebook.presto.tuple.TupleInfo.Type.DOUBLE;
import static com.facebook.presto.tuple.TupleInfo.Type.FIXED_INT_64;
import static com.facebook.presto.tuple.TupleInfo.Type.VARIABLE_BINARY;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Arrays.asList;

/**
 * Tuple layout is:
 * <pre>
 *     fixed_0
 *     fixed_1
 *     ...
 *     fixed_N
 *     var_off_1
 *     var_off_2
 *     ...
 *     var_off_N
 *     size
 *     var_0
 *     var_1
 *     ...
 *     var_N
 * </pre>
 */
public class TupleInfo
{
    public static final TupleInfo EMPTY = new TupleInfo();
    public static final TupleInfo SINGLE_LONG = new TupleInfo(FIXED_INT_64);
    public static final TupleInfo SINGLE_VARBINARY = new TupleInfo(VARIABLE_BINARY);
    public static final TupleInfo SINGLE_DOUBLE = new TupleInfo(DOUBLE);

    public enum Type
    {
        FIXED_INT_64(SIZE_OF_LONG, "long")
                {
                    @Override
                    public void convert(String value, BlockBuilder blockBuilder)
                    {
                        blockBuilder.append(Long.valueOf(value));
                    }

                    @Override
                    public void convert(String value, TupleInfo.Builder tupleBuilder)
                    {
                        tupleBuilder.append(Long.valueOf(value));
                    }
                },
        VARIABLE_BINARY(-1, "string")
                {
                    @Override
                    public void convert(String value, BlockBuilder blockBuilder)
                    {
                        blockBuilder.append(value.getBytes(Charsets.UTF_8));
                    }

                    @Override
                    public void convert(String value, TupleInfo.Builder tupleBuilder)
                    {
                        tupleBuilder.append(Slices.wrappedBuffer(value.getBytes(Charsets.UTF_8)));
                    }
                },
        DOUBLE(SIZE_OF_DOUBLE, "double")
                {
                    @Override
                    public void convert(String value, BlockBuilder blockBuilder)
                    {
                        blockBuilder.append(Double.valueOf(value));
                    }

                    @Override
                    public void convert(String value, TupleInfo.Builder tupleBuilder)
                    {
                        tupleBuilder.append(Double.valueOf(value));
                    }
                };

        private static final Map<String, Type> NAME_MAP;
        static {
            ImmutableMap.Builder<String, Type> builder = ImmutableMap.builder();
            for (Type encoding : Type.values()) {
                builder.put(encoding.getName(), encoding);
            }
            NAME_MAP = builder.build();
        }<commit_msg>Use parseValue instead of valueOf which creates an object<commit_after>package com.facebook.presto.tuple;

import com.facebook.presto.slice.SizeOf;
import com.facebook.presto.block.BlockBuilder;
import com.facebook.presto.slice.DynamicSliceOutput;
import com.facebook.presto.slice.Slice;
import com.facebook.presto.slice.SliceInput;
import com.facebook.presto.slice.SliceOutput;
import com.facebook.presto.slice.Slices;
import com.google.common.base.Charsets;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.facebook.presto.slice.SizeOf.SIZE_OF_DOUBLE;
import static com.facebook.presto.slice.SizeOf.SIZE_OF_LONG;
import static com.facebook.presto.slice.SizeOf.SIZE_OF_SHORT;
import static com.facebook.presto.tuple.TupleInfo.Type.DOUBLE;
import static com.facebook.presto.tuple.TupleInfo.Type.FIXED_INT_64;
import static com.facebook.presto.tuple.TupleInfo.Type.VARIABLE_BINARY;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Arrays.asList;

/**
 * Tuple layout is:
 * <pre>
 *     fixed_0
 *     fixed_1
 *     ...
 *     fixed_N
 *     var_off_1
 *     var_off_2
 *     ...
 *     var_off_N
 *     size
 *     var_0
 *     var_1
 *     ...
 *     var_N
 * </pre>
 */
public class TupleInfo
{
    public static final TupleInfo EMPTY = new TupleInfo();
    public static final TupleInfo SINGLE_LONG = new TupleInfo(FIXED_INT_64);
    public static final TupleInfo SINGLE_VARBINARY = new TupleInfo(VARIABLE_BINARY);
    public static final TupleInfo SINGLE_DOUBLE = new TupleInfo(DOUBLE);

    public enum Type
    {
        FIXED_INT_64(SIZE_OF_LONG, "long")
                {
                    @Override
                    public void convert(String value, BlockBuilder blockBuilder)
                    {
                        blockBuilder.append(Long.parseLong(value));
                    }

                    @Override
                    public void convert(String value, TupleInfo.Builder tupleBuilder)
                    {
                        tupleBuilder.append(Long.parseLong(value));
                    }
                },
        VARIABLE_BINARY(-1, "string")
                {
                    @Override
                    public void convert(String value, BlockBuilder blockBuilder)
                    {
                        blockBuilder.append(value.getBytes(Charsets.UTF_8));
                    }

                    @Override
                    public void convert(String value, TupleInfo.Builder tupleBuilder)
                    {
                        tupleBuilder.append(Slices.wrappedBuffer(value.getBytes(Charsets.UTF_8)));
                    }
                },
        DOUBLE(SIZE_OF_DOUBLE, "double")
                {
                    @Override
                    public void convert(String value, BlockBuilder blockBuilder)
                    {
                        blockBuilder.append(Double.parseDouble(value));
                    }

                    @Override
                    public void convert(String value, TupleInfo.Builder tupleBuilder)
                    {
                        tupleBuilder.append(Double.parseDouble(value));
                    }
                };

        private static final Map<String, Type> NAME_MAP;
        static {
            ImmutableMap.Builder<String, Type> builder = ImmutableMap.builder();
            for (Type encoding : Type.values()) {
                builder.put(encoding.getName(), encoding);
            }
            NAME_MAP = builder.build();
        }
{'fraction_non_alphanumeric': 0.08815214597789771, 'fraction_numerical': 0.0038550501156515036, 'mean_word_length': 1.9380898452246131, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5629008', 'n_tokens_mistral': 2147, 'n_tokens_neox': 2087, 'n_words': 380}