<commit_before>#include <rai/utility.hpp>

#include <cryptopp/aes.h>
#include <cryptopp/modes.h>

#include <ed25519-donna/ed25519.h>

#include <liblmdb/lmdb.h>

CryptoPP::AutoSeededRandomPool rai::random_pool;

boost::filesystem::path rai::unique_path ()
{
	auto result (working_path () / boost::filesystem::unique_path ());
	return result;
}

std::string rai::to_string_hex (uint64_t value_a)
{
    std::stringstream stream;
    stream << std::hex << std::noshowbase << std::setw (16) << std::setfill ('0');
    stream << value_a;
    return stream.str ();
}

bool rai::from_string_hex (std::string const & value_a, uint64_t & target_a)
{
    auto result (value_a.size () == 8);
    if (!result)
    {
        std::stringstream stream (value_a);
        stream << std::hex << std::noshowbase;
        uint64_t number_l;
        try
        {
            stream >> number_l;
            target_a = number_l;
        }
        catch (std::runtime_error &)
        {
            result = true;
        }
    }
    return result;
}

// Divide the raw 128bit number to one that fits in 64bits
uint64_t rai::scale_down (rai::uint128_t const & amount_a)
{
    return (amount_a / rai::scale_64bit_base10).convert_to <uint64_t> ();
}

// Return the full 128bit amount number from a reduced 64bit one
rai::uint128_t rai::scale_up (uint64_t amount_a)
{
    return rai::scale_64bit_base10 * amount_a;
}

rai::mdb_env::mdb_env (bool & error_a, boost::filesystem::path const & path_a)
{
	boost::system::error_code error;
	boost::filesystem::create_directories (path_a, error);
	if (!error)
	{
		auto status1 (mdb_env_create (&environment));
		assert (status1 == 0);
		auto status2 (mdb_env_set_maxdbs (environment, 128));
		assert (status2 == 0);
		auto status3 (mdb_env_set_mapsize (environment, 16 * 1024 * 1024));
		assert (status3 == 0);
		auto status4 (mdb_env_open (environment, path_a.string ().c_str (), 0, 00600));
		assert (status4 == 0);
	}
	else
	{
		error_a = true;
		environment = nullptr;
	}
}

rai::mdb_env::~mdb_env ()
{
	if (environment != nullptr)
	{
		mdb_env_close (environment);
	}
}

rai::mdb_env::operator MDB_env * () const
{
	return environment;
}<commit_msg>Setting environment size back to 1g.<commit_after>#include <rai/utility.hpp>

#include <cryptopp/aes.h>
#include <cryptopp/modes.h>

#include <ed25519-donna/ed25519.h>

#include <liblmdb/lmdb.h>

CryptoPP::AutoSeededRandomPool rai::random_pool;

boost::filesystem::path rai::unique_path ()
{
	auto result (working_path () / boost::filesystem::unique_path ());
	return result;
}

std::string rai::to_string_hex (uint64_t value_a)
{
    std::stringstream stream;
    stream << std::hex << std::noshowbase << std::setw (16) << std::setfill ('0');
    stream << value_a;
    return stream.str ();
}

bool rai::from_string_hex (std::string const & value_a, uint64_t & target_a)
{
    auto result (value_a.size () == 8);
    if (!result)
    {
        std::stringstream stream (value_a);
        stream << std::hex << std::noshowbase;
        uint64_t number_l;
        try
        {
            stream >> number_l;
            target_a = number_l;
        }
        catch (std::runtime_error &)
        {
            result = true;
        }
    }
    return result;
}

// Divide the raw 128bit number to one that fits in 64bits
uint64_t rai::scale_down (rai::uint128_t const & amount_a)
{
    return (amount_a / rai::scale_64bit_base10).convert_to <uint64_t> ();
}

// Return the full 128bit amount number from a reduced 64bit one
rai::uint128_t rai::scale_up (uint64_t amount_a)
{
    return rai::scale_64bit_base10 * amount_a;
}

rai::mdb_env::mdb_env (bool & error_a, boost::filesystem::path const & path_a)
{
	boost::system::error_code error;
	boost::filesystem::create_directories (path_a, error);
	if (!error)
	{
		auto status1 (mdb_env_create (&environment));
		assert (status1 == 0);
		auto status2 (mdb_env_set_maxdbs (environment, 128));
		assert (status2 == 0);
		auto status3 (mdb_env_set_mapsize (environment, 1024 * 1024 * 1024));
		assert (status3 == 0);
		auto status4 (mdb_env_open (environment, path_a.string ().c_str (), 0, 00600));
		assert (status4 == 0);
	}
	else
	{
		error_a = true;
		environment = nullptr;
	}
}

rai::mdb_env::~mdb_env ()
{
	if (environment != nullptr)
	{
		mdb_env_close (environment);
	}
}

rai::mdb_env::operator MDB_env * () const
{
	return environment;
}
{'fraction_non_alphanumeric': 0.14259555962462805, 'fraction_numerical': 0.03776607919432364, 'mean_word_length': 3.693877551020408, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 19, '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': '3342521', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1607, 'n_words': 349}