<commit_before>#include "storage.h"

namespace Epyx
{
namespace DHT
{

    Storage::Storage(){};

    bool Storage::has(const std::string& key){
        lock.lock();
        bool result = data.count(key) != 0;
        lock.unlock();
        return result;
    }

    bool Storage::get(const std::string& key, Value& res){
        bool result = false;
        lock.lock();
        std::map<std::string, Value>::iterator it = data.find(key);
        if (it != data.end()) {
            res = (*it).second;
            result = true;
        }
        lock.unlock();
        return result;
    }

    void Storage::set(const std::string& key, const std::string& datum){
        lock.lock();
        Value v(datum);
        data.insert(std::make_pair(key, datum));
        lock.unlock();
    }

}
}
<commit_msg>DHT: now we can update values in the DHT<commit_after>#include "storage.h"

namespace Epyx
{
namespace DHT
{

    Storage::Storage(){};

    bool Storage::has(const std::string& key){
        lock.lock();
        bool result = data.count(key) != 0;
        lock.unlock();
        return result;
    }

    bool Storage::get(const std::string& key, Value& res){
        bool result = false;
        lock.lock();
        std::map<std::string, Value>::iterator it = data.find(key);
        if (it != data.end()) {
            res = (*it).second;
            result = true;
        }
        lock.unlock();
        return result;
    }

    void Storage::set(const std::string& key, const std::string& datum){
        lock.lock();
        Value v(datum);
        if(data.find(key) == data.end()) {
            data.insert(std::make_pair(key, datum));
        } else {
            (*data.find(key)).second = datum;
        }
        lock.unlock();
    }

}
}

{'fraction_non_alphanumeric': 0.16013628620102216, 'fraction_numerical': 0.001135718341851221, 'mean_word_length': 1.9965986394557824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1027816', 'n_tokens_mistral': 552, 'n_tokens_neox': 543, 'n_words': 125}