<commit_before>/*******************************************************************************
 * c7a/engine/stage_builder.hpp
 *
 * Functions to build stages
 ******************************************************************************/

#pragma once

#include "../api/dia_base.hpp"
#include "../common/logger.hpp"
#include <stack>
 #include <utility>

namespace c7a { 
namespace engine {

bool test = true;

class Stage
{
public:
    Stage(DIABase* node) : node_(node)
    {
        SpacingLogger(test) << "I'm creating stage" << node_->ToString();   
    }
    void Run() {
        SpacingLogger(test) << "I'm running stage" << node_->ToString();
        //GOAL: Make sure the stage is executed efficiently. 
        node_->execute();
    };
private:
    DIABase* node_;
};

// Returns a list of stages of graph scope
typedef std::pair<std::vector<Stage>::reverse_iterator, std::vector<Stage>::reverse_iterator> vec_it;
vec_it  FindStages(DIABase* action)
{
    SpacingLogger(test) << "I'm looking for stages:";

    std::vector<Stage> result_stages;

    // GOAL: Returns a vector with stages
    // TEMP SOLUTION: Every node is a stage
    std::stack<DIABase*> dia_stack;
    dia_stack.push(action);
    while (!dia_stack.empty()) {
        DIABase* curr = dia_stack.top();
        dia_stack.pop();
        result_stages.emplace_back(Stage(curr));
        std::vector<DIABase*> parents = curr->get_parents();
        for (DIABase* p : parents) {
            dia_stack.push(p);
        }
    }

    auto it_begin = result_stages.rbegin();
    auto it_end = result_stages.rend();

    return std::make_pair(it_begin, it_end);
};

}}// !C7A_ENGINE_STAGE_BUILD
<commit_msg>try to understand the seg fault<commit_after>/*******************************************************************************
 * c7a/engine/stage_builder.hpp
 *
 * Functions to build stages
 ******************************************************************************/

#pragma once

#include "../api/dia_base.hpp"
#include "../common/logger.hpp"
#include <stack>
 #include <utility>

namespace c7a { 
namespace engine {

bool test = true;

class Stage
{
public:
    Stage(DIABase* node) : node_(node)
    {
        SpacingLogger(test) << "I'm creating stage" << node_->ToString() << node_;   
    }
    void Run() {
        SpacingLogger(test) << "I'm running stage" << node_->ToString() << node_;
        //GOAL: Make sure the stage is executed efficiently. 
        node_->execute();
    };
private:
    DIABase* node_;
};

// Returns a list of stages of graph scope
typedef std::pair<std::vector<Stage>::reverse_iterator, std::vector<Stage>::reverse_iterator> vec_it;
vec_it  FindStages(DIABase* action)
{
    SpacingLogger(test) << "I'm looking for stages:";

    std::vector<Stage> result_stages;

    // GOAL: Returns a vector with stages
    // TEMP SOLUTION: Every node is a stage
    std::stack<DIABase*> dia_stack;
    dia_stack.push(action);
    while (!dia_stack.empty()) {
        DIABase* curr = dia_stack.top();
        dia_stack.pop();
        result_stages.emplace_back(Stage(curr));
        std::vector<DIABase*> parents = curr->get_parents();
        for (DIABase* p : parents) {
            dia_stack.push(p);
        }
    }

    auto it_begin = result_stages.rbegin();
    auto it_end = result_stages.rend();

    return std::make_pair(it_begin, it_end);
};

}}// !C7A_ENGINE_STAGE_BUILD

{'fraction_non_alphanumeric': 0.22182890855457227, 'fraction_numerical': 0.0017699115044247787, 'mean_word_length': 3.521333333333333, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 27, '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': '1435370', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1027, 'n_words': 239}