<commit_before>/*******************************************************************************
 * c7a/engine/controller.hpp
 *
 ******************************************************************************/

#ifndef C7A_ENGINE_CONTROLLER_HEADER
#define C7A_ENGINE_CONTROLLER_HEADER

#include <vector>

namespace c7a {
namespace engine {

//todo make it virtual!
template <typename T>
class Controller
{
public:
    Controller(int id, const std::vector<int> &otherWorkers) : 
        _id(id), _otherWorkers(otherWorkers);

    // First reduce with reduce() function
    //
    // Shuffle
    //
    // Second reduce with reduce() function

    void shuffle() {
        // 
    }

//    template <typename K, V>
    // This is the final reduce
    T reduce(std::function<T(T, T)> ReduceFn) {
        T res;
        // Iterate over 
        for (auto it = _data.getIt(); it.hasNext(); it = it.next())
            res = ReduceFn(*it, res);
        // Alternativ<F3>
        for (auto x : _data)
            res = ReduceFn(x, res);
        
    }

    void populateData(std::vector<std::pair<K, V>>) {
        
    }
private:
    int _id;
    // The worker needs to know the ids of all other workers
    std::vector<int> _otherWorkers;
    std::vector<std::pair<K, V>> _data;
};

class MasterController : public Controller
{
public:
    void foo();
};

class WorkerController : public Controller
{
public:
    void foo();
};

}
}

#endif // !C7A_ENGINE_CONTROLLER_HEADER

/******************************************************************************/
<commit_msg>make shuffle a private function<commit_after>/*******************************************************************************
 * c7a/engine/controller.hpp
 *
 ******************************************************************************/

#ifndef C7A_ENGINE_CONTROLLER_HEADER
#define C7A_ENGINE_CONTROLLER_HEADER

#include <vector>

namespace c7a {
namespace engine {

//todo make it virtual!
template <typename T>
class Controller
{
public:
    Controller(int id, const std::vector<int> &otherWorkers) : 
        _id(id), _otherWorkers(otherWorkers);

//    template <typename K, V>
    // This is the final reduce
    T reduce(std::function<T(T, T)> ReduceFn) {
        T res;
        // Iterate over 
        for (auto it = _data.getIt(); it.hasNext(); it = it.next())
            res = ReduceFn(*it, res);
        // Alternativ<F3>
        for (auto x : _data)
            res = ReduceFn(x, res);
        
    }

    void populateData(std::vector<std::pair<K, V>>) {
        
    }
private:
    int _id;
    // The worker needs to know the ids of all other workers
    std::vector<int> _otherWorkers;
    std::vector<std::pair<K, V>> _data;
    // First reduce with reduce() function
    //
    // Shuffle
    //
    // Second reduce with reduce() function

    void shuffle() {
        // 
    }
};

class MasterController : public Controller
{
public:
    void foo();
};

class WorkerController : public Controller
{
public:
    void foo();
};

}
}

#endif // !C7A_ENGINE_CONTROLLER_HEADER

/******************************************************************************/

{'fraction_non_alphanumeric': 0.25851639605221266, 'fraction_numerical': 0.0038204393505253103, 'mean_word_length': 3.038560411311054, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '1649471', 'n_tokens_mistral': 953, 'n_tokens_neox': 910, 'n_words': 234}