<commit_before>package com.treelogic.proteus.flink.incops;

import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.windowing.windows.GlobalWindow;
import org.apache.flink.util.Collector;

import java.lang.reflect.Field;
import java.util.*;

/**
 * Operator that incrementally computes the mode of a variable. State is
 * saved using Flink's key/value store and a java.util.HashMap object. The
 * key of the map represents variable's value and the value represents the
 * repetitions of that value.
 *
 * Collects the mode element and it's value
 *
 * @param <IN> POJO that contains fields to be analyzed
 */
public class IncrementalMode<IN> extends
    IncrementalOperation<IN, List<Tuple2<Double, Integer>>> {

    private static final long serialVersionUID = 1;

    private ValueStateDescriptor<Map<Double, Integer>>
        stateDescriptor;

    private String field = "";
    private int numValues, numDecimals;

    /**
     * numValues = 1 and numDecimals = 0
     * @param field
     */
    public IncrementalMode(String field) {
        this(field, 1, 0);
    }

    /**
     * Main constructor
     * @param field Name of the field to compute the mode
     * @param numValues To return the numValues top modes
     * @param numDecimals Round decimals to numDecimals
     */
    public IncrementalMode(String field, int numValues, int numDecimals) {
        if (field == null || field.equals("")) {
            throw new IllegalArgumentException("Field cannot be empty");
        }

        this.field = field;
        this.numValues = numValues > 0 ? numValues : 1;
        this.numDecimals = numDecimals >= 0 ? numDecimals : 0;
<commit_msg>Removed duplicate code from IncrementalMode<commit_after>package com.treelogic.proteus.flink.incops;

import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.windowing.windows.GlobalWindow;
import org.apache.flink.util.Collector;

import java.lang.reflect.Field;
import java.util.*;

/**
 * Operator that incrementally computes the mode of a variable. State is
 * saved using Flink's key/value store and a java.util.HashMap object. The
 * key of the map represents variable's value and the value represents the
 * repetitions of that value.
 *
 * Collects the mode element and it's value
 *
 * @param <IN> POJO that contains fields to be analyzed
 */
public class IncrementalMode<IN> extends
    IncrementalOperation<IN, List<Tuple2<Double, Integer>>> {

    private static final long serialVersionUID = 1;

    private ValueStateDescriptor<Map<Double, Integer>>
        stateDescriptor;

    private String field = "";
    private int numValues, numDecimals;

    /**
     * numValues = 1 and numDecimals = 0
     * @param field
     */
    public IncrementalMode(String field) {
        this(field, 1, 0);
    }

    /**
     * Main constructor
     * @param field Name of the field to compute the mode
     * @param numValues To return the numValues top modes
     * @param numDecimals Round decimals to numDecimals
     */
    public IncrementalMode(String field, int numValues, int numDecimals) {
        checkField(field);

        this.field = field;
        this.numValues = numValues > 0 ? numValues : 1;
        this.numDecimals = numDecimals >= 0 ? numDecimals : 0;

{'fraction_non_alphanumeric': 0.09554803436605051, 'fraction_numerical': 0.005727675084613382, 'mean_word_length': 3.4416184971098267, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '4941129', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1099, 'n_words': 330}