<commit_before>package org.mwg.core.task;

import org.mwg.Constants;
import org.mwg.core.CoreConstants;
import org.mwg.plugin.AbstractTaskAction;
import org.mwg.task.TaskAction;
import org.mwg.task.TaskActionFactory;
import org.mwg.task.TaskContext;

class ActionPlugin extends AbstractTaskAction {

    private final String _actionName;
    private final String _flatParams;
    private boolean initilized = false;

    private TaskAction subAction = null;

    ActionPlugin(final String actionName, final String flatParams) {
        super();
        this._actionName = actionName;
        this._flatParams = flatParams;
    }

    @Override
    public void eval(final TaskContext context) {
        final String templatedName = context.template(_actionName);
        final String templatedParams = context.template(_flatParams);
        if (!initilized) {
            final TaskActionFactory actionFactory = context.graph().taskAction(templatedName);
            if (actionFactory == null) {
                throw new RuntimeException("Unknown task action: " + templatedName);
            }
            int paramsCapacity = CoreConstants.MAP_INITIAL_CAPACITY;
            String[] params = new String[paramsCapacity];
            int paramsIndex = 0;
            int cursor = 0;
            int flatSize = templatedParams.length();
            int previous = 0;
            while (cursor < flatSize) {
                char current = templatedParams.charAt(cursor);
                if (current == Constants.QUERY_SEP) {
                    String param = templatedParams.substring(previous, cursor);
                    if (param.length() > 0) {
                        if (paramsIndex >= paramsCapacity) {
                            int newParamsCapacity = paramsCapacity * 2;
                            String[] newParams = new String[newParamsCapacity];
                            System.arraycopy(params, 0, newParams, 0, paramsCapacity);
                            params = newParams;
                            paramsCapacity = newParamsCapacity;
                        }
                        params[paramsIndex] = param;
                        paramsIndex++;
                    }
                    previous = cursor + 1;
                }
                cursor++;
            }
            //add last param
            String param = templatedParams.substring(previous, cursor);
            if (param.length() > 0) {
                if (paramsIndex >= paramsCapacity) {
                    int newParamsCapacity = paramsCapacity * 2;
                    String[] newParams = new String[newParamsCapacity];
                    System.arraycopy(params, 0, newParams, 0, paramsCapacity);
                    params = newParams;
                    paramsCapacity = newParamsCapacity;
                }
                params[paramsIndex] = param;
                paramsIndex++;
            }
            //schrink
            if (paramsIndex < params.length) {
                String[] shrinked = new String[paramsIndex];
                System.arraycopy(params, 0, shrinked, 0, paramsIndex);
                params = shrinked;
            }
            //add the action to the action
            subAction = actionFactory.create(params);
            initilized = true;
        }<commit_msg>try to fix the caching of action<commit_after>package org.mwg.core.task;

import org.mwg.Constants;
import org.mwg.core.CoreConstants;
import org.mwg.plugin.AbstractTaskAction;
import org.mwg.task.TaskAction;
import org.mwg.task.TaskActionFactory;
import org.mwg.task.TaskContext;

class ActionPlugin extends AbstractTaskAction {

    private final String _actionName;
    private final String _flatParams;
    //private boolean initilized = false;

    private TaskAction subAction = null;

    ActionPlugin(final String actionName, final String flatParams) {
        super();
        this._actionName = actionName;
        this._flatParams = flatParams;
    }

    @Override
    public void eval(final TaskContext context) {
        final String templatedName = context.template(_actionName);
        final String templatedParams = context.template(_flatParams);
        //if (!initilized) {
        final TaskActionFactory actionFactory = context.graph().taskAction(templatedName);
        if (actionFactory == null) {
            throw new RuntimeException("Unknown task action: " + templatedName);
        }
        int paramsCapacity = CoreConstants.MAP_INITIAL_CAPACITY;
        String[] params = new String[paramsCapacity];
        int paramsIndex = 0;
        int cursor = 0;
        int flatSize = templatedParams.length();
        int previous = 0;
        while (cursor < flatSize) {
            char current = templatedParams.charAt(cursor);
            if (current == Constants.QUERY_SEP) {
                String param = templatedParams.substring(previous, cursor);
                if (param.length() > 0) {
                    if (paramsIndex >= paramsCapacity) {
                        int newParamsCapacity = paramsCapacity * 2;
                        String[] newParams = new String[newParamsCapacity];
                        System.arraycopy(params, 0, newParams, 0, paramsCapacity);
                        params = newParams;
                        paramsCapacity = newParamsCapacity;
                    }
                    params[paramsIndex] = param;
                    paramsIndex++;
                }
                previous = cursor + 1;
            }
            cursor++;
        }
        //add last param
        String param = templatedParams.substring(previous, cursor);
        if (param.length() > 0) {
            if (paramsIndex >= paramsCapacity) {
                int newParamsCapacity = paramsCapacity * 2;
                String[] newParams = new String[newParamsCapacity];
                System.arraycopy(params, 0, newParams, 0, paramsCapacity);
                params = newParams;
                paramsCapacity = newParamsCapacity;
            }
            params[paramsIndex] = param;
            paramsIndex++;
        }
        //schrink
        if (paramsIndex < params.length) {
            String[] shrinked = new String[paramsIndex];
            System.arraycopy(params, 0, shrinked, 0, paramsIndex);
            params = shrinked;
        }
        //add the action to the action
        subAction = actionFactory.create(params);
        //initilized = true;
        // }
{'fraction_non_alphanumeric': 0.08346261247285137, 'fraction_numerical': 0.004343779087806391, 'mean_word_length': 1.7693298969072164, 'pattern_counts': {'":': 0, '<': 7, '<?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': '132317', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1516, 'n_words': 394}