<commit_before>//
// Treasure Data Bulk-Import Tool in Java
//
// Copyright (C) 2012 - 2013 <NAME>
//
//    Licensed 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.treasure_data.bulk_import.model;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.treasure_data.bulk_import.prepare_parts.PreparePartsException;
import com.treasure_data.bulk_import.writer.FileWriter;

public enum ColumnType {
    STRING("string", 0) {
        @Override
        public ColumnValue createColumnValue() {
            return new StringColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (StringColumnValue) v);
        }
    },
    INT("int", 1) {
        @Override
        public ColumnValue createColumnValue() {
            return new IntColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (IntColumnValue) v);
        }
    },
    DOUBLE("double", 2) {
        @Override
        public ColumnValue createColumnValue() {
            return new DoubleColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (DoubleColumnValue) v);
        }
    },
    LONG("long", 3) {
        @Override
        public ColumnValue createColumnValue() {
            return new LongColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (LongColumnValue) v);
        }
    },
    ;

    private String name;
    private int index;

    ColumnType(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }

    public abstract ColumnValue createColumnValue();

    public abstract void convertTypeInto(String v, ColumnValue cv)
            throws PreparePartsException;

    public abstract void filterAndWrite(ColumnValue v, TimeColumnValue filter,
            FileWriter with) throws PreparePartsException;

    public static ColumnType fromInt(int index) {
        return IntToColumnType.get(index);
    }

    public static ColumnType fromString(String name) {
        return StringToColumnType.get(name);
    }

    private static class IntToColumnType {
        private static final Map<Integer, ColumnType> REVERSE_DICTIONARY;

        static {
            Map<Integer, ColumnType> map = new HashMap<Integer, ColumnType>();
            for (ColumnType elem : ColumnType.values()) {
                map.put(elem.getIndex(), elem);
            }
            REVERSE_DICTIONARY = Collections.unmodifiableMap(map);
        }

        static ColumnType get(Integer index) {
            return REVERSE_DICTIONARY.get(index);
        }
    }

    private static class StringToColumnType {
        private static final Map<String, ColumnType> REVERSE_DICTIONARY;

        static {
            Map<String, ColumnType> map = new HashMap<String, ColumnType>();
            for (ColumnType elem : ColumnType.values()) {
                map.put(elem.getName(), elem);
            }
            REVERSE_DICTIONARY = Collections.unmodifiableMap(map);
        }

        static ColumnType get(String key) {
            return REVERSE_DICTIONARY.get(key);
        }
    }
}
<commit_msg>changed ColumnType class -- added new method 'convertType' in this class<commit_after>//
// Treasure Data Bulk-Import Tool in Java
//
// Copyright (C) 2012 - 2013 <NAME>
//
//    Licensed 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.treasure_data.bulk_import.model;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.treasure_data.bulk_import.prepare_parts.PreparePartsException;
import com.treasure_data.bulk_import.writer.FileWriter;

public enum ColumnType {
    STRING("string", 0) {
        @Override
        public ColumnValue createColumnValue() {
            return new StringColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void convertTypeInto(Object v, ColumnValue cv)
                throws PreparePartsException {
            cv.set(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (StringColumnValue) v);
        }
    },
    INT("int", 1) {
        @Override
        public ColumnValue createColumnValue() {
            return new IntColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void convertTypeInto(Object v, ColumnValue cv)
                throws PreparePartsException {
            cv.set(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (IntColumnValue) v);
        }
    },
    DOUBLE("double", 2) {
        @Override
        public ColumnValue createColumnValue() {
            return new DoubleColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void convertTypeInto(Object v, ColumnValue cv)
                throws PreparePartsException {
            cv.set(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (DoubleColumnValue) v);
        }
    },
    LONG("long", 3) {
        @Override
        public ColumnValue createColumnValue() {
            return new LongColumnValue(this);
        }

        @Override
        public void convertTypeInto(String v, ColumnValue cv)
                throws PreparePartsException {
            cv.parse(v);
        }

        @Override
        public void convertTypeInto(Object v, ColumnValue cv)
                throws PreparePartsException {
            cv.set(v);
        }

        @Override
        public void filterAndWrite(ColumnValue v, TimeColumnValue filter, FileWriter with)
                throws PreparePartsException {
            with.write(filter, (LongColumnValue) v);
        }
    },
    ;

    private String name;
    private int index;

    ColumnType(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }

    public abstract ColumnValue createColumnValue();

    public abstract void convertTypeInto(String v, ColumnValue cv)
            throws PreparePartsException;

    public abstract void convertTypeInto(Object v, ColumnValue cv)
            throws PreparePartsException;

    public abstract void filterAndWrite(ColumnValue v, TimeColumnValue filter,
            FileWriter with) throws PreparePartsException;

    public static ColumnType fromInt(int index) {
        return IntToColumnType.get(index);
    }

    public static ColumnType fromString(String name) {
        return StringToColumnType.get(name);
    }

    private static class IntToColumnType {
        private static final Map<Integer, ColumnType> REVERSE_DICTIONARY;

        static {
            Map<Integer, ColumnType> map = new HashMap<Integer, ColumnType>();
            for (ColumnType elem : ColumnType.values()) {
                map.put(elem.getIndex(), elem);
            }
            REVERSE_DICTIONARY = Collections.unmodifiableMap(map);
        }

        static ColumnType get(Integer index) {
            return REVERSE_DICTIONARY.get(index);
        }
    }

    private static class StringToColumnType {
        private static final Map<String, ColumnType> REVERSE_DICTIONARY;

        static {
            Map<String, ColumnType> map = new HashMap<String, ColumnType>();
            for (ColumnType elem : ColumnType.values()) {
                map.put(elem.getName(), elem);
            }
            REVERSE_DICTIONARY = Collections.unmodifiableMap(map);
        }

        static ColumnType get(String key) {
            return REVERSE_DICTIONARY.get(key);
        }
    }
}

{'fraction_non_alphanumeric': 0.07860668715656143, 'fraction_numerical': 0.00298034832821086, 'mean_word_length': 2.124236252545825, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5527318', 'n_tokens_mistral': 2804, 'n_tokens_neox': 2704, 'n_words': 780}