<commit_before>#include "storage.h"
#include "meas.h"
#include "flags.h"

using namespace memseries;
using namespace memseries::storage;

class InnerCallback:public memseries::storage::ReaderClb{
public:
    InnerCallback(Meas::MeasList * output){
        _output=output;
    }
    ~InnerCallback(){}
    void call(const Meas&m){
        _output->push_back(m);
    }

    Meas::MeasList *_output;
};

class ByStepClbk :public memseries::storage::ReaderClb {
public:
	ByStepClbk(memseries::storage::ReaderClb*clb, memseries::Time step) {
		_out_clbk = clb;
		_isFirst = true;
		_step = step;
	}
	~ByStepClbk() {}
	void call(const Meas&m) {
		if (_isFirst) {
			_isFirst = false;
			_out_clbk->call(m);
			_last_data = m;
			_last = m;
			_new_time_point = (_last.time + _step);
			return;
		}
		if (m.time < _new_time_point) {
			_last = m;
			return;
		}
		if (m.time == _new_time_point) {
			_last = m;
			memseries::Meas cp{ m };
			cp.time = _new_time_point;
			_new_time_point = (_last.time + _step);
			_last_data = cp;
			_out_clbk->call(cp);
			return;
		}
		if (m.time > _new_time_point) {
			auto delta_time = m.time - _new_time_point;
			memseries::Meas cp{ _last };
			for (size_t i = 0; i < (delta_time / _step)+1; i++) {
				cp.time = _last_data.time + _step;
				_out_clbk->call(cp);
				_last_data = cp;
				_new_time_point += _step;
			}
			if (m.time == _new_time_point) {
				_out_clbk->call(m);
				_new_time_point = (m.time + _step);
			}
			_last = m;
			return;
		}
	}

	memseries::storage::ReaderClb *_out_clbk;
	bool _isFirst;
	memseries::Meas _last;
	memseries::Meas _last_data;
	memseries::Time _step;
	memseries::Time _new_time_point;
};

void Reader::readAll(Meas::MeasList * output)
{<commit_msg>comment. issue #9<commit_after>#include "storage.h"
#include "meas.h"
#include "flags.h"

using namespace memseries;
using namespace memseries::storage;

class InnerCallback:public memseries::storage::ReaderClb{
public:
    InnerCallback(Meas::MeasList * output){
        _output=output;
    }
    ~InnerCallback(){}
    void call(const Meas&m){
        _output->push_back(m);
    }

    Meas::MeasList *_output;
};

class ByStepClbk :public memseries::storage::ReaderClb {
public:
	ByStepClbk(memseries::storage::ReaderClb*clb, memseries::Time step) {
		_out_clbk = clb;
		_isFirst = true;
		_step = step;
	}
	~ByStepClbk() {}
	void call(const Meas&m) {
		if (_isFirst) {
			_isFirst = false;
			_out_clbk->call(m);
			_last_data = m;
			_last = m;
			_new_time_point = (_last.time + _step);
			return;
		}
		if (m.time < _new_time_point) {
			_last = m;
			return;
		}
		if (m.time == _new_time_point) {
			_last = m;
			memseries::Meas cp{ m };
			cp.time = _new_time_point;
			_new_time_point = (_last.time + _step);
			_last_data = cp;
			_out_clbk->call(cp);
			return;
		}
		if (m.time > _new_time_point) {
			auto delta_time = m.time - _new_time_point;
			memseries::Meas cp{ _last };
			// get all from _new_time_point to m.time  with step
			for (size_t i = 0; i < (delta_time / _step)+1; i++) {
				cp.time = _last_data.time + _step;
				_out_clbk->call(cp);
				_last_data = cp;
				_new_time_point += _step;
			}
			if (m.time == _new_time_point) {
				_out_clbk->call(m);
				_new_time_point = (m.time + _step);
			}
			_last = m;
			return;
		}
	}

	memseries::storage::ReaderClb *_out_clbk;
	bool _isFirst;
	memseries::Meas _last;
	memseries::Meas _last_data;
	memseries::Time _step;
	memseries::Time _new_time_point;
};

void Reader::readAll(Meas::MeasList * output)
{
{'fraction_non_alphanumeric': 0.14216524216524218, 'fraction_numerical': 0.0014245014245014246, 'mean_word_length': 3.5012820512820513, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '4086952', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1419, 'n_words': 272}