<commit_before>package ch.zhaw.dna.ssh.mapreduce.model.framework.impl;

import java.util.List;

import ch.zhaw.dna.ssh.mapreduce.model.framework.MapReduceTask;
import ch.zhaw.dna.ssh.mapreduce.model.framework.MapRunner;
import ch.zhaw.dna.ssh.mapreduce.model.framework.PoolHelper;
import ch.zhaw.dna.ssh.mapreduce.model.framework.ReduceRunner;
import ch.zhaw.dna.ssh.mapreduce.model.framework.ReduceTask;

public class PooledReduceRunner implements ReduceRunner {

	private final String key;

	private final ReduceTask reduceTask;

	private final MapReduceTask master;

	private List<MapRunner> mapRunners;

	private volatile State curState = State.IDLE;

	public PooledReduceRunner(String key, ReduceTask reduceTask, MapReduceTask master) {
		this.key = key;
		this.reduceTask = reduceTask;
		this.master = master;
	}

	@Override
	public void runReduceTask(List<MapRunner> mapRunners) {
		this.curState = State.INPROGRESS;
		this.mapRunners = mapRunners;
		PoolHelper.getPool().enqueueWork(this);
	}

	@Override
	public void emit(String result) {
		if (this.master.globalResultStructureContainsKey(key)) {
			this.master.globalResultStructureAddToKey(key, result);
		} else {
			this.master.globalResultStructureAddKeyValue(key, result);
		}
	}

	@Override
	public void doWork() {
		for (MapRunner mapRunner : mapRunners) {
			this.reduceTask.reduce(this, this.key, mapRunner.getIntermediate(this.key).iterator());
		}
	}

	@Override
	public State getCurrentState() {
		return this.curState;
	}

}<commit_msg>PooledReduceRunner save war vergessen<commit_after>package ch.zhaw.dna.ssh.mapreduce.model.framework.impl;

import java.util.List;

import ch.zhaw.dna.ssh.mapreduce.model.framework.MapReduceTask;
import ch.zhaw.dna.ssh.mapreduce.model.framework.MapRunner;
import ch.zhaw.dna.ssh.mapreduce.model.framework.PoolHelper;
import ch.zhaw.dna.ssh.mapreduce.model.framework.ReduceRunner;
import ch.zhaw.dna.ssh.mapreduce.model.framework.ReduceTask;

public class PooledReduceRunner implements ReduceRunner {

	private final String key;

	private final ReduceTask reduceTask;

	private final MapReduceTask master;

	private List<MapRunner> mapRunners;

	private volatile State curState = State.IDLE;

	public PooledReduceRunner(String key, ReduceTask reduceTask, MapReduceTask master) {
		this.key = key;
		this.reduceTask = reduceTask;
		this.master = master;
	}

	@Override
	public void runReduceTask(List<MapRunner> mapRunners) {
		this.curState = State.INPROGRESS;
		this.mapRunners = mapRunners;
		PoolHelper.getPool().enqueueWork(this);
	}

	@Override
	public void emit(String result) {
		this.master.globalResultStructureAppend(key, result);
	}

	@Override
	public void doWork() {
		for (MapRunner mapRunner : mapRunners) {
			this.reduceTask.reduce(this, this.key, mapRunner.getIntermediate(this.key).iterator());
		}
	}

	@Override
	public State getCurrentState() {
		return this.curState;
	}

}
{'fraction_non_alphanumeric': 0.10464716006884682, 'fraction_numerical': 0.0, 'mean_word_length': 5.117894736842105, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1377546', 'n_tokens_mistral': 1030, 'n_tokens_neox': 966, 'n_words': 180}