1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-06-03 10:02:01 +03:00

C++20 fixes

This commit is contained in:
Leonid Fedorov 2022-02-01 15:54:05 +00:00
parent 0ee5203262
commit 65252df4f6
36 changed files with 22433 additions and 310 deletions

View File

@ -1,9 +1,10 @@
local events = ['pull_request', 'cron'];
local platforms = {
develop: ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:18.04', 'ubuntu:20.04'],
'develop-6': ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:18.04', 'ubuntu:20.04'],
'develop-5': ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:18.04', 'ubuntu:20.04'],
develop: ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:20.04'],
'develop-6': ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:20.04'],
'develop-5': ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:20.04'],
};
local platforms_arm = {
@ -12,7 +13,7 @@ local platforms_arm = {
};
local any_branch = '**';
local platforms_custom = ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:18.04', 'ubuntu:20.04'];
local platforms_custom = ['opensuse/leap:15', 'centos:7', 'centos:8', 'rockylinux:8', 'debian:10', 'ubuntu:20.04'];
local platforms_arm_custom = ['centos:8'];
local platforms_mtr = ['centos:7', 'centos:8', 'ubuntu:20.04'];
@ -33,7 +34,7 @@ local cmakeflags = '-DCMAKE_BUILD_TYPE=RelWithDebInfo -DPLUGIN_COLUMNSTORE=YES -
local gcc_update_alternatives = 'update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 ';
local clang12_update_alternatives = 'update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-12 ';
local clang12_update_alternatives = 'update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-12 && update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 ';
local rpm_build_deps = 'install -y lz4 systemd-devel git make libaio-devel openssl-devel boost-devel bison snappy-devel flex libcurl-devel libxml2-devel ncurses-devel automake libtool policycoreutils-devel rpm-build lsof iproute pam-devel perl-DBI cracklib-devel expect createrepo ';
@ -54,7 +55,6 @@ local platformMap(platform, arch) =
'centos:8': centos8_build_deps + ' && dnf ' + rpm_build_deps + ' && cmake ' + cmakeflags + ' -DRPM=centos8 && make -j$(nproc) package',
'rockylinux:8': rockylinux8_powertools + ' && ' + centos8_build_deps + ' && dnf ' + rpm_build_deps + ' && cmake ' + cmakeflags + ' -DRPM=rockylinux8 && make -j$(nproc) package',
'debian:10': deb_build_deps + " && CMAKEFLAGS='" + cmakeflags + " -DDEB=buster' debian/autobake-deb.sh",
'ubuntu:18.04': ubuntu18_04_deps + ' && ' + deb_build_deps + " && CMAKEFLAGS='" + cmakeflags + " -DDEB=bionic' debian/autobake-deb.sh",
'ubuntu:20.04': ubuntu20_04_deps + ' && ' + deb_build_deps + " && CMAKEFLAGS='" + cmakeflags + " -DDEB=focal' debian/autobake-deb.sh",
};
platform_map[platform];
@ -67,7 +67,6 @@ local testRun(platform) =
'centos:8': 'ctest3 -R columnstore: -j $(nproc) --output-on-failure',
'rockylinux:8': 'ctest3 -R columnstore: -j $(nproc) --output-on-failure',
'debian:10': 'cd builddir; ctest -R columnstore: -j $(nproc) --output-on-failure',
'ubuntu:18.04': 'cd builddir; ctest -R columnstore: -j $(nproc) --output-on-failure',
'ubuntu:20.04': 'cd builddir; ctest -R columnstore: -j $(nproc) --output-on-failure',
};
platform_map[platform];

View File

@ -28,7 +28,7 @@ endif()
INCLUDE(ExternalProject)
INCLUDE(CheckCXXSourceCompiles)
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
SET(CMAKE_CXX_EXTENSIONS FALSE)
SET(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
@ -214,6 +214,11 @@ IF (MASK_LONGDOUBLE)
MY_CHECK_AND_SET_COMPILER_FLAG("-DMASK_LONGDOUBLE")
ENDIF()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-deprecated-enum-enum-conversion -Wno-register")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-register")
endif()
MY_CHECK_AND_SET_COMPILER_FLAG("-Werror -Wall")
SET (ENGINE_LDFLAGS "-Wl,--no-as-needed -Wl,--add-needed")

View File

@ -22,12 +22,12 @@
#include <unistd.h>
#include <typeinfo>
#include <regex>
#include <string>
#include <vector>
using namespace std;
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include "altertableprocessor.h"
@ -2083,14 +2083,14 @@ void AlterTableProcessor::tableComment(uint32_t sessionID, execplan::CalpontSyst
CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
boost::algorithm::to_upper(ataTableComment.fTableComment);
boost::regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*=[[:space:]]*", boost::regex_constants::extended);
boost::match_results<std::string::const_iterator> what;
std::regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*=[[:space:]]*", std::regex_constants::extended);
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = ataTableComment.fTableComment.begin();
end = ataTableComment.fTableComment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags) && what[0].matched)
if (std::regex_search(start, end, what, compat, flags) && what[0].matched)
{
std::string params(&(*(what[0].second)));
char* ep = NULL;

View File

@ -36,7 +36,6 @@
#endif
#include <cstring>
#include <cmath>
#include <boost/regex.hpp>
#include "expressionparser.h"
#include "returnedcolumn.h"

View File

@ -63,7 +63,7 @@ typedef datatypes::Decimal IDB_Decimal;
#ifdef POSIX_REGEX
typedef regex_t IDB_Regex;
#else
typedef boost::regex IDB_Regex;
typedef std::regex IDB_Regex;
#endif
typedef IDB_Regex CNX_Regex;

View File

@ -479,7 +479,7 @@ class JobStep
bool fDelivery;
bool fOnClauseFilter;
volatile bool fDie;
volatile uint32_t fWaitToRunStepCnt;
uint32_t fWaitToRunStepCnt;
std::string fExtendedInfo;
std::string fMiniInfo;

View File

@ -1398,8 +1398,8 @@ class TupleBPS : public BatchPrimitive, public TupleDeliveryStep
SP_LBIDList lbidList;
uint64_t ridsRequested;
uint64_t totalMsgs;
volatile uint64_t msgsSent;
volatile uint64_t msgsRecvd;
uint64_t msgsSent;
uint64_t msgsRecvd;
volatile bool finishedSending;
bool firstRead;
bool sendWaiting;

View File

@ -29,9 +29,6 @@
#include <sys/time.h>
using namespace std;
#include <boost/regex.hpp>
using namespace boost;
#include "resourcemanager.h"
#include "jl_logger.h"

View File

@ -18,38 +18,42 @@
/*
* $Id$
*/
#include <regex>
#include <string>
#include <boost/algorithm/string.hpp>
#include <utils/loggingcpp/idberrorinfo.h>
bool parseAutoincrementTableComment(std::string comment, uint64_t& startValue, std::string& columnName)
{
algorithm::to_upper(comment);
regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*=[[:space:]]*", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*=[[:space:]]*", std::regex_constants::extended);
bool autoincrement = false;
columnName = "";
boost::match_results<std::string::const_iterator> what;
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = comment.begin();
end = comment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
if (what[0].matched)
{
// string params (what[0].first, what[0].second);
string params(&(*(what[0].second)));
std::string params(&(*(what[0].second)));
unsigned i = params.find_first_of(",");
if (i <= params.length())
{
// check whether there is more autoincrement column
string restComment = params.substr(i + 1, params.length());
std::string restComment = params.substr(i + 1, params.length());
start = restComment.begin();
end = restComment.end();
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
if (what[0].matched)
throw runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_INVALID_NUMBER_AUTOINCREMENT));
throw runtime_error(logging::IDBErrorInfo::instance()->errorMsg(ERR_INVALID_NUMBER_AUTOINCREMENT));
}
columnName = params.substr(0, i);
@ -112,25 +116,25 @@ bool parseAutoincrementTableComment(std::string comment, uint64_t& startValue, s
bool parseAutoincrementColumnComment(std::string comment, uint64_t& startValue)
{
algorithm::to_upper(comment);
regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*", std::regex_constants::extended);
bool autoincrement = false;
boost::match_results<std::string::const_iterator> what;
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = comment.begin();
end = comment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
if (what[0].matched)
{
string params(&(*(what[0].second)));
std::string params(&(*(what[0].second)));
unsigned i = params.find_first_of(",");
if (i <= params.length())
{
string startVal = params.substr(i + 1, params.length());
std::string startVal = params.substr(i + 1, params.length());
// get rid of possible empty space
i = startVal.find_first_not_of(" ");
@ -160,7 +164,7 @@ bool parseAutoincrementColumnComment(std::string comment, uint64_t& startValue)
// (no digits) || (more chars) || (other errors & value = 0)
if ((ep == str) || (*ep != '\0') || (errno != 0))
{
throw runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_INVALID_START_VALUE));
throw runtime_error(logging::IDBErrorInfo::instance()->errorMsg(ERR_INVALID_START_VALUE));
}
}
}

View File

@ -25,27 +25,19 @@
#include <string>
#include <iostream>
#include <stack>
#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
#include <fstream>
#include <sstream>
#include <cerrno>
#include <cstring>
#ifdef _MSC_VER
#include <unordered_set>
#else
#include <regex>
#include <tr1/unordered_set>
#endif
#include <utility>
#include <cassert>
using namespace std;
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
using namespace boost;
@ -142,16 +134,16 @@ CalpontSystemCatalog::ColDataType convertDataType(const ddlpackage::ColumnType&
int parseCompressionComment(std::string comment)
{
algorithm::to_upper(comment);
regex compat("[[:space:]]*COMPRESSION[[:space:]]*=[[:space:]]*", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex compat("[[:space:]]*COMPRESSION[[:space:]]*=[[:space:]]*", std::regex_constants::extended);
int compressiontype = 0;
boost::match_results<std::string::const_iterator> what;
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = comment.begin();
end = comment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
// Find the pattern, now get the compression type
string compType(&(*(what[0].second)));
@ -1389,10 +1381,10 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
if (comment.length() > 0)
{
//@Bug 3782 This is for synchronization after calonlinealter to use
algorithm::to_upper(comment);
regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", std::regex_constants::extended);
if (regex_search(comment, pat))
if (std::regex_search(comment, pat))
{
return 0;
}
@ -2358,14 +2350,14 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
bool schemaSyncOnly = false;
bool isCreate = true;
regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended);
std::regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", std::regex_constants::extended);
if (regex_search(tablecomment, pat))
if (std::regex_search(tablecomment, pat))
{
schemaSyncOnly = true;
pat = createpatstr;
if (!regex_search(stmt, pat))
if (!std::regex_search(stmt, pat))
{
isCreate = false;
}
@ -2395,7 +2387,7 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
pat = alterpatstr;
if (regex_search(stmt, pat))
if (std::regex_search(stmt, pat))
{
ci.isAlter = true;
ci.alterTableState = cal_connection_info::ALTER_FIRST_RENAME;

View File

@ -45,7 +45,6 @@ using namespace std;
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/thread.hpp>
#include "errorids.h"

View File

@ -54,7 +54,6 @@ using namespace std;
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/thread.hpp>
#include "mcs_basic_types.h"

View File

@ -26,28 +26,30 @@
* @file
*/
#include <unistd.h>
#include <iterator>
#include <numeric>
#include <deque>
#include <iostream>
#include <ostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <limits.h>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <vector>
#include <stdio.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/sysinfo.h>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <ctype.h>
#include <deque>
#include <exception>
#include <fstream>
#include <glob.h>
#include <boost/regex.hpp>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <netdb.h>
#include <numeric>
#include <ostream>
#include <regex>
#include <sstream>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <unistd.h>
#include <vector>
#include <sys/sysinfo.h>
#include "liboamcpp.h"
#include "installdir.h"
#include "mcsconfig.h"
@ -178,7 +180,7 @@ int main(int argc, char* argv[])
{
includeArg = line;
boost::regex icludeArgRegEx("^#*\\s*" + includeArg + "\\s*=");
std::regex icludeArgRegEx("^#*\\s*" + includeArg + "\\s*=");
// see if in columnstore.cnf.rpmsave
ifstream mycnfsavefile(mycnfsaveFile.c_str());
char line[200];
@ -188,7 +190,7 @@ int main(int argc, char* argv[])
{
oldbuf = line;
if (boost::regex_search(oldbuf.begin(), oldbuf.end(), icludeArgRegEx))
if (std::regex_search(oldbuf.begin(), oldbuf.end(), icludeArgRegEx))
{
// found in columnstore.cnf.rpmsave, check if this is commented out
if (line[0] != '#')
@ -205,7 +207,7 @@ int main(int argc, char* argv[])
{
newbuf = line1;
if (boost::regex_search(newbuf.begin(), newbuf.end(), icludeArgRegEx))
if (std::regex_search(newbuf.begin(), newbuf.end(), icludeArgRegEx))
{
newbuf = oldbuf;
cout << "Updated argument: " << includeArg << endl;
@ -240,9 +242,9 @@ int main(int argc, char* argv[])
while (mycnffile.getline(line1, 200))
{
newbuf = line1;
boost::regex mysqldSectionRegEx("\\[mysqld\\]");
std::regex mysqldSectionRegEx("\\[mysqld\\]");
if (boost::regex_search(newbuf.begin(), newbuf.end(), mysqldSectionRegEx))
if (std::regex_search(newbuf.begin(), newbuf.end(), mysqldSectionRegEx))
{
lines.push_back(newbuf);
newbuf = oldbuf;

View File

@ -40,7 +40,7 @@
#ifdef POSIX_REGEX
#include <regex.h>
#else
#include <boost/regex.hpp>
#include <regex>
#endif
#include <cstddef>
#include <boost/shared_ptr.hpp>

View File

@ -44,8 +44,6 @@
using namespace std;
#include <boost/thread.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
using namespace boost;
#include "configcpp.h"

View File

@ -23,7 +23,6 @@
#include <boost/thread/mutex.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
#include <stdlib.h>
#include <vector>
@ -31,6 +30,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <iostream>
#include <regex>
#include "SMLogging.h"
@ -165,13 +165,13 @@ bool Config::reload()
return rtn;
}
string use_envvar(const boost::smatch& envvar)
string use_envvar(const std::smatch& envvar)
{
char* env = getenv(envvar[1].str().c_str());
return (env ? env : "");
}
string expand_numbers(const boost::smatch& match)
string expand_numbers(const std::smatch& match)
{
long long num = stol(match[1].str());
char suffix = (char)::tolower(match[2].str()[0]);
@ -187,6 +187,20 @@ string expand_numbers(const boost::smatch& match)
return ::to_string(num);
}
std::string regex_replace_with_format(const std::string& input,
const std::regex& regex,
std::function<std::string(std::smatch const& match)> format)
{
std::ostringstream output;
std::sregex_iterator begin(input.begin(), input.end(), regex), end;
for(; begin != end; begin++){
output << begin->prefix() << format(*begin);
}
output << input.substr(input.size() - begin->position());
return output.str();
}
string Config::getValue(const string& section, const string& key) const
{
// if we care, move this envvar substition stuff to where the file is loaded
@ -202,15 +216,15 @@ string Config::getValue(const string& section, const string& key) const
}
s.unlock();
boost::regex re("\\$\\{(.+)\\}");
std::regex re("\\$\\{(.+)\\}");
ret = boost::regex_replace(ret, re, use_envvar);
ret = regex_replace_with_format(ret, re, use_envvar);
// do the numeric substitutions. ex, the suffixes m, k, g
// ehhhhh. going to end up turning a string to a number, to a string, and then to a number again
// don't like that. OTOH who cares.
boost::regex num_re("^([[:digit:]]+)([mMkKgG])$", boost::regex::extended);
ret = boost::regex_replace(ret, num_re, expand_numbers);
std::regex num_re("^([[:digit:]]+)([mMkKgG])$", std::regex::extended);
ret = regex_replace_with_format(ret, num_re, expand_numbers);
return ret;
}

View File

@ -25,8 +25,6 @@
#include <stdlib.h>
#include <errno.h>
#include <boost/filesystem.hpp>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/json_parser.hpp>
#include <iostream>
#include "checks.h"
#include "vlarray.h"
@ -1266,9 +1264,10 @@ boost::shared_array<uint8_t> IOCoordinator::mergeJournal(const char* object, con
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
stringstream ss;
ss << headertxt.get();
boost::property_tree::ptree header;
boost::property_tree::json_parser::read_json(ss, header);
assert(header.get<int>("version") == 1);
nlohmann::json header = nlohmann::json::parse(ss);
assert(header["version"] == 1);
// start processing the entries
while (1)
@ -1353,9 +1352,9 @@ int IOCoordinator::mergeJournalInMem(boost::shared_array<uint8_t>& objData, size
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
stringstream ss;
ss << headertxt.get();
boost::property_tree::ptree header;
boost::property_tree::json_parser::read_json(ss, header);
assert(header.get<int>("version") == 1);
nlohmann::json header = nlohmann::json::parse(ss);
assert(header["version"] == 1);
// read the journal file into memory
size_t journalBytes = ::lseek(journalFD, 0, SEEK_END) - l_bytesRead;
@ -1433,9 +1432,9 @@ int IOCoordinator::mergeJournalInMem_bigJ(boost::shared_array<uint8_t>& objData,
boost::shared_array<char> headertxt = seekToEndOfHeader1(journalFD, &l_bytesRead);
stringstream ss;
ss << headertxt.get();
boost::property_tree::ptree header;
boost::property_tree::json_parser::read_json(ss, header);
assert(header.get<int>("version") == 1);
nlohmann::json header = nlohmann::json::parse(ss);
assert(header["version"] == 1);
// start processing the entries
while (1)

View File

@ -20,20 +20,17 @@
*/
#include "MetadataFile.h"
#include <boost/filesystem.hpp>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/random_generator.hpp>
#include <cstdio>
#include <unistd.h>
#include <fstream>
#define max(x, y) (x > y ? x : y)
#define min(x, y) (x < y ? x : y)
using namespace std;
namespace bpt = boost::property_tree;
namespace bf = boost::filesystem;
namespace
@ -120,12 +117,13 @@ MetadataFile::MetadataFile(const boost::filesystem::path& filename)
{
if (boost::filesystem::exists(mFilename))
{
jsontree.reset(new bpt::ptree());
boost::property_tree::read_json(mFilename.string(), *jsontree);
std::ifstream i(mFilename.string());
jsontree.reset(new nlohmann::json);
i >> *jsontree;
jsonCache.put(mFilename, jsontree);
s.unlock();
mVersion = 1;
mRevision = jsontree->get<int>("revision");
mRevision = (*jsontree)["revision"];
}
else
{
@ -140,7 +138,7 @@ MetadataFile::MetadataFile(const boost::filesystem::path& filename)
{
s.unlock();
mVersion = 1;
mRevision = jsontree->get<int>("revision");
mRevision = (*jsontree)["revision"];;
}
++metadataFilesAccessed;
}
@ -162,12 +160,13 @@ MetadataFile::MetadataFile(const boost::filesystem::path& filename, no_create_t,
if (boost::filesystem::exists(mFilename))
{
_exists = true;
jsontree.reset(new bpt::ptree());
boost::property_tree::read_json(mFilename.string(), *jsontree);
jsontree.reset(new nlohmann::json);
std::ifstream i(mFilename.string());
i >> *jsontree;
jsonCache.put(mFilename, jsontree);
s.unlock();
mVersion = 1;
mRevision = jsontree->get<int>("revision");
mRevision = (*jsontree)["revision"];
}
else
{
@ -182,7 +181,7 @@ MetadataFile::MetadataFile(const boost::filesystem::path& filename, no_create_t,
s.unlock();
_exists = true;
mVersion = 1;
mRevision = jsontree->get<int>("revision");
mRevision = (*jsontree)["revision"];
}
++metadataFilesAccessed;
}
@ -193,11 +192,10 @@ MetadataFile::~MetadataFile()
void MetadataFile::makeEmptyJsonTree()
{
jsontree.reset(new bpt::ptree());
boost::property_tree::ptree objs;
jsontree->put("version", mVersion);
jsontree->put("revision", mRevision);
jsontree->add_child("objects", objs);
jsontree.reset(new nlohmann::json);
(*jsontree)["version"] = mVersion;
(*jsontree)["revision"] = mRevision;
(*jsontree)["objects"] = nlohmann::json::array();
}
void MetadataFile::printKPIs()
@ -219,11 +217,11 @@ size_t MetadataFile::getLength() const
{
size_t totalSize = 0;
auto& objects = jsontree->get_child("objects");
auto &objects = (*jsontree)["objects"];
if (!objects.empty())
{
auto& lastObject = objects.back().second;
totalSize = lastObject.get<off_t>("offset") + lastObject.get<size_t>("length");
auto& lastObject = objects.back();
totalSize = lastObject["offset"].get<off_t>() + lastObject["length"].get<size_t>();
}
return totalSize;
}
@ -243,10 +241,9 @@ vector<metadataObject> MetadataFile::metadataRead(off_t offset, size_t length) c
rather than write a new alg.
*/
set<metadataObject> mObjects;
BOOST_FOREACH (const boost::property_tree::ptree::value_type& v, jsontree->get_child("objects"))
for(const auto &v : (*jsontree)["objects"])
{
mObjects.insert(metadataObject(v.second.get<uint64_t>("offset"), v.second.get<uint64_t>("length"),
v.second.get<string>("key")));
mObjects.insert(metadataObject(v["offset"], v["length"], v["key"]));
}
if (mObjects.size() == 0)
@ -288,20 +285,20 @@ metadataObject MetadataFile::addMetadataObject(const boost::filesystem::path& fi
//
metadataObject addObject;
auto& objects = jsontree->get_child("objects");
auto& objects = (*jsontree)["objects"];
if (!objects.empty())
{
auto& lastObject = objects.back().second;
addObject.offset = lastObject.get<off_t>("offset") + mpConfig->mObjectSize;
auto& lastObject = objects.back();
addObject.offset = lastObject["offset"].get<off_t>() + mpConfig->mObjectSize;
}
addObject.length = length;
addObject.key = getNewKey(filename.string(), addObject.offset, addObject.length);
boost::property_tree::ptree object;
object.put("offset", addObject.offset);
object.put("length", addObject.length);
object.put("key", addObject.key);
objects.push_back(make_pair("", object));
nlohmann::json object = nlohmann::json::object();
object["offset"] = addObject.offset;
object["length"] = addObject.length;
object["key"] = addObject.key;
objects.push_back(object);
return addObject;
}
@ -312,7 +309,8 @@ int MetadataFile::writeMetadata()
if (!boost::filesystem::exists(mFilename.parent_path()))
boost::filesystem::create_directories(mFilename.parent_path());
write_json(mFilename.string(), *jsontree);
std::ofstream o(mFilename.c_str());
o << *jsontree;
_exists = true;
boost::unique_lock<boost::mutex> s(jsonCache.getMutex());
@ -324,13 +322,13 @@ int MetadataFile::writeMetadata()
bool MetadataFile::getEntry(off_t offset, metadataObject* out) const
{
metadataObject addObject;
BOOST_FOREACH (const boost::property_tree::ptree::value_type& v, jsontree->get_child("objects"))
for(auto &v: (*jsontree)["objects"])
{
if (v.second.get<off_t>("offset") == offset)
if (v["offset"].get<off_t>() == offset)
{
out->offset = offset;
out->length = v.second.get<size_t>("length");
out->key = v.second.get<string>("key");
out->length = v["length"].get<size_t>();
out->key = v["key"];
return true;
}
}
@ -339,10 +337,10 @@ bool MetadataFile::getEntry(off_t offset, metadataObject* out) const
void MetadataFile::removeEntry(off_t offset)
{
bpt::ptree& objects = jsontree->get_child("objects");
for (bpt::ptree::iterator it = objects.begin(); it != objects.end(); ++it)
auto& objects = (*jsontree)["objects"];
for (auto it = objects.begin(); it != objects.end(); ++it)
{
if (it->second.get<off_t>("offset") == offset)
if ((*it)["offset"].get<off_t>() == offset)
{
objects.erase(it);
break;
@ -352,7 +350,7 @@ void MetadataFile::removeEntry(off_t offset)
void MetadataFile::removeAllEntries()
{
jsontree->get_child("objects").clear();
(*jsontree)["objects"] = nlohmann::json::array();
}
void MetadataFile::deletedMeta(const bf::path& p)
@ -456,21 +454,21 @@ void MetadataFile::setLengthInKey(string& key, size_t newLength)
void MetadataFile::printObjects() const
{
BOOST_FOREACH (const boost::property_tree::ptree::value_type& v, jsontree->get_child("objects"))
for (auto& v : (*jsontree)["objects"])
{
printf("Name: %s Length: %zu Offset: %lld\n", v.second.get<string>("key").c_str(),
v.second.get<size_t>("length"), (long long)v.second.get<off_t>("offset"));
printf("Name: %s Length: %zu Offset: %lld\n", v["key"].get<std::string>().c_str(),
v["length"].get<size_t>(), (long long)v["offset"].get<off_t>());
}
}
void MetadataFile::updateEntry(off_t offset, const string& newName, size_t newLength)
{
for (auto& v : jsontree->get_child("objects"))
for (auto& v : (*jsontree)["objects"])
{
if (v.second.get<off_t>("offset") == offset)
if (v["offset"].get<off_t>() == offset)
{
v.second.put("key", newName);
v.second.put("length", newLength);
v["key"] = newName;
v["length"] = newLength;
return;
}
}
@ -482,11 +480,11 @@ void MetadataFile::updateEntry(off_t offset, const string& newName, size_t newLe
void MetadataFile::updateEntryLength(off_t offset, size_t newLength)
{
for (auto& v : jsontree->get_child("objects"))
for (auto& v : (*jsontree)["objects"])
{
if (v.second.get<off_t>("offset") == offset)
if (v["offset"].get<off_t>() == offset)
{
v.second.put("length", newLength);
v["length"] = newLength;
return;
}
}
@ -498,11 +496,12 @@ void MetadataFile::updateEntryLength(off_t offset, size_t newLength)
off_t MetadataFile::getMetadataNewObjectOffset()
{
auto& objects = jsontree->get_child("objects");
auto& objects = (*jsontree)["objects"];
if (objects.empty())
return 0;
auto& lastObject = jsontree->get_child("objects").back().second;
return lastObject.get<off_t>("offset") + lastObject.get<size_t>("length");
auto& lastObject = objects.back();
return lastObject["offset"].get<off_t>() + lastObject["length"].get<size_t>();
}
metadataObject::metadataObject() : offset(0), length(0)

View File

@ -28,6 +28,8 @@
#include <unordered_map>
#include <boost/filesystem/path.hpp>
#include <utils/json/json.hpp>
namespace storagemanager
{
struct metadataObject
@ -110,7 +112,7 @@ class MetadataFile
static void printKPIs();
typedef boost::shared_ptr<boost::property_tree::ptree> Jsontree_t;
typedef boost::shared_ptr<nlohmann::json> Jsontree_t;
private:
MetadataConfig* mpConfig;

View File

@ -27,12 +27,12 @@
#include <errno.h>
#include <sys/sendfile.h>
#include <boost/filesystem.hpp>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/json_parser.hpp>
#include <boost/shared_array.hpp>
#include <boost/format.hpp>
#include <iostream>
#include <utils/json/json.hpp>
using namespace std;
namespace
@ -279,12 +279,14 @@ int Replicator::addJournalEntry(const boost::filesystem::path& filename, const u
stringstream ss;
ss << headertxt.get();
headerRollback = headertxt.get();
boost::property_tree::ptree header;
nlohmann::json header;
try
{
boost::property_tree::json_parser::read_json(ss, header);
header = nlohmann::json::parse(ss);
}
catch (const boost::property_tree::json_parser::json_parser_error& e)
catch (const nlohmann::json::exception& e)
{
mpLogger->log(LOG_CRIT, "%s", e.what());
errno = EIO;
@ -296,8 +298,8 @@ int Replicator::addJournalEntry(const boost::filesystem::path& filename, const u
errno = EIO;
return -1;
}
assert(header.get<int>("version") == 1);
uint64_t currentMaxOffset = header.get<uint64_t>("max_offset");
assert(header["version"] == 1);
uint64_t currentMaxOffset = header["max_offset"];
if (thisEntryMaxOffset > currentMaxOffset)
{
bHeaderChanged = true;

View File

@ -26,9 +26,9 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/random_generator.hpp>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include "utils/json/json.hpp"
#include "Utilities.h"
using namespace std;
@ -258,12 +258,12 @@ bool S3Storage::getCredentialsFromMetadataEC2()
logger->log(LOG_ERR, "CURL fail %u", curl_res);
return false;
}
stringstream credentials(readBuffer);
boost::property_tree::ptree pt;
boost::property_tree::read_json(credentials, pt);
key = pt.get<string>("AccessKeyId");
secret = pt.get<string>("SecretAccessKey");
token = pt.get<string>("Token");
nlohmann::json pt = nlohmann::json::parse(readBuffer);
key = pt["AccessKeyId"];
secret = pt["SecretAccessKey"];
token = pt["Token"];
// logger->log(LOG_INFO, "S3Storage: key = %s secret = %s token =
// %s",key.c_str(),secret.c_str(),token.c_str());
@ -626,7 +626,7 @@ int S3Storage::copyObject(const string& _sourceKey, const string& _destKey)
#if 0
// no s3-s3 copy yet. get & put for now.
int err;
boost::shared_array<uint8_t> data;
size_t len;

View File

@ -1,5 +1,5 @@
include_directories( ${ENGINE_COMMON_INCLUDES} )
include_directories( ${ENGINE_COMMON_INCLUDES} ${ENGINE_UTILS_COMMON_INCLUDE} )
########### next target ###############
set(cspasswd_SRCS cspasswd.cpp secrets.cpp)

View File

@ -23,9 +23,8 @@
#include <openssl/rand.h>
#include <openssl/opensslv.h>
#define BOOST_SPIRIT_THREADSAFE
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include "utils/json/json.hpp"
#include "idberrorinfo.h"
#include "logger.h"
#include "mcsconfig.h"
@ -393,16 +392,16 @@ ReadKeyResult secrets_readkeys(const string& filepath)
{
// File contents should be json.
// json_error_t err;
boost::property_tree::ptree jsontree;
nlohmann::json jsontree;
try
{
boost::property_tree::read_json(filepath, jsontree);
std::ifstream i(filepath);
jsontree = nlohmann::json::parse(i);
}
catch (boost::property_tree::json_parser::json_parser_error& je)
catch (const nlohmann::json::exception& je)
{
std::cout << "Error reading JSON from secrets file: " << je.filename() << " on line: " << je.line()
<< std::endl;
std::cout << je.message() << std::endl;
std::cout << "Error reading JSON from secrets file: " << filepath << std::endl;
std::cout << je.what() << std::endl;
}
catch (...)
{
@ -410,8 +409,8 @@ ReadKeyResult secrets_readkeys(const string& filepath)
strerror(errno));
}
// json_t* obj = json_load_file(filepathc, 0, &err);
string enc_cipher = jsontree.get<string>(field_cipher);
string enc_key = jsontree.get<string>(field_key);
string enc_cipher = jsontree[field_cipher];
string enc_key = jsontree[field_key];
// const char* enc_cipher = json_string_value(json_object_get(obj, field_cipher));
// const char* enc_key = json_string_value(json_object_get(obj, field_key));
bool cipher_ok = !enc_cipher.empty() && (enc_cipher == CIPHER_NAME);
@ -648,23 +647,24 @@ bool secrets_write_keys(const ByteVec& key, const string& filepath, const string
utils::VLArray<char> key_hex(2 * keylen + 1);
bin2hex(key.data(), keylen, key_hex.data());
boost::property_tree::ptree jsontree;
jsontree.put(field_desc, desc);
jsontree.put(field_version, columnstore_version.c_str());
jsontree.put(field_cipher, CIPHER_NAME);
jsontree.put(field_key, (const char*)key_hex.data());
nlohmann::json jsontree;
jsontree[field_desc] = desc;
jsontree[field_version] = columnstore_version;
jsontree[field_cipher] = CIPHER_NAME;
jsontree[field_key] = (const char*)key_hex.data();
auto filepathc = filepath.c_str();
bool write_ok = false;
errno = 0;
try
{
write_json(filepathc, jsontree);
std::ofstream o(filepath);
o << jsontree;
}
catch (boost::property_tree::json_parser::json_parser_error& je)
catch (const nlohmann::json::exception& je)
{
std::cout << "Write to secrets file: " << je.filename() << " on line: " << je.line() << std::endl;
std::cout << je.message() << std::endl;
std::cout << "Write to secrets file: " << filepath << std::endl;
std::cout << je.what() << std::endl;
}
catch (...)
{

View File

@ -20,13 +20,8 @@
#include "logger.h"
#include <fstream>
#include <iostream>
#include <boost/regex.hpp>
#ifdef _MSC_VER
#include "unistd.h"
#include "sysinfo.h"
#else
#include <sys/sysinfo.h>
#endif
using namespace boost;
using namespace std;

View File

@ -72,7 +72,7 @@ class STLPoolAllocator
void usePoolAllocator(boost::shared_ptr<PoolAllocator> b);
boost::shared_ptr<utils::PoolAllocator> getPoolAllocator();
pointer allocate(size_type, const void* hint = 0);
pointer allocate(size_type, typename STLPoolAllocator<T>::const_pointer hint = 0);
void deallocate(pointer p, size_type n);
size_type max_size() const throw();
inline uint64_t getMemUsage() const
@ -131,7 +131,7 @@ boost::shared_ptr<utils::PoolAllocator> STLPoolAllocator<T>::getPoolAllocator()
template <class T>
typename STLPoolAllocator<T>::pointer STLPoolAllocator<T>::allocate(
typename STLPoolAllocator<T>::size_type s, typename std::allocator<void>::const_pointer hint)
typename STLPoolAllocator<T>::size_type s, typename STLPoolAllocator<T>::const_pointer hint)
{
return (pointer)pa->allocate(s * sizeof(T));
}

View File

@ -28,13 +28,8 @@
#include <string>
#include <boost/any.hpp>
#include <vector>
#ifdef _MSC_VER
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#else
#include <netinet/in.h>
#endif
#ifdef __linux__
#define POSIX_REGEX
@ -43,7 +38,7 @@
#ifdef POSIX_REGEX
#include <regex.h>
#else
#include <boost/regex.hpp>
#include <regex>
#endif
#include "mcs_datatype.h"

View File

@ -28,7 +28,7 @@ using namespace std;
#ifdef __linux__
#include <regex.h>
#else
#include <boost/regex.hpp>
#include <regex>
using namespace boost;
#endif
@ -226,8 +226,8 @@ inline bool getBool(rowgroup::Row& row, funcexp::FunctionParm& pm, bool& isNull,
return false;
#else
regex pat(pattern.c_str());
return regex_search(expr.c_str(), pat);
std::regex pat(pattern.c_str());
return std::regex_search(expr.c_str(), pat);
#endif
}

View File

@ -32,7 +32,6 @@
#include <inttypes.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
#include "dataconvert.h"

22109
utils/json/json.hpp Normal file

File diff suppressed because it is too large Load Diff

92
utils/loggingcpp/format.h Normal file
View File

@ -0,0 +1,92 @@
/*
Copyright (c) 2021 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#pragma once
#include <boost/any.hpp>
#include <cstdint>
#include <regex>
#include <stdexcept>
#include <string>
namespace logging
{
template <class T, class Iter>
void formatOne(std::string& errMsg, Iter iter, uint32_t position)
{
T arg = boost::any_cast<T>(*iter);
std::string token = std::string("%") + std::to_string(position) + std::string("%");
size_t index = 0;
while (true)
{
index = errMsg.find(token, index);
if (index == std::string::npos)
break;
if constexpr (std::is_same_v<T, std::string>)
{
errMsg.replace(index, token.length(), arg);
}
else
{
errMsg.replace(index, token.length(), std::to_string(arg));
}
index += token.length();
}
}
template <class T>
void formatMany(std::string& errMsg, const T& args)
{
auto iter = args.begin();
auto end = args.end();
uint32_t position = 1;
while (iter != end)
{
if (iter->type() == typeid(long))
{
formatOne<long>(errMsg, iter, position);
}
else if (iter->type() == typeid(uint64_t))
{
formatOne<uint64_t>(errMsg, iter, position);
}
else if (iter->type() == typeid(double))
{
formatOne<double>(errMsg, iter, position);
}
else if (iter->type() == typeid(std::string))
{
formatOne<std::string>(errMsg, iter, position);
}
else
{
throw std::logic_error("logggin::format: unexpected type in argslist");
}
++iter;
++position;
}
static std::regex restToken("%[0-9]%");
errMsg = std::regex_replace(errMsg, restToken, "");
}
} // namespace logging

View File

@ -29,7 +29,6 @@
#include <fstream>
using namespace std;
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <boost/thread.hpp>
using namespace boost;
@ -43,6 +42,8 @@ using namespace config;
#include "installdir.h"
#include "format.h"
namespace logging
{
IDBErrorInfo* IDBErrorInfo::fInstance = 0;
@ -156,43 +157,7 @@ string IDBErrorInfo::logError(const logging::LOG_TYPE logLevel, const logging::L
void IDBErrorInfo::format(string& errMsg, const Message::Args& args)
{
Message::Args::AnyVec::const_iterator iter = args.args().begin();
Message::Args::AnyVec::const_iterator end = args.args().end();
boost::format fmt(errMsg);
fmt.exceptions(boost::io::no_error_bits);
while (iter != end)
{
if (iter->type() == typeid(long))
{
long l = any_cast<long>(*iter);
fmt % l;
}
else if (iter->type() == typeid(uint64_t))
{
uint64_t u64 = any_cast<uint64_t>(*iter);
fmt % u64;
}
else if (iter->type() == typeid(double))
{
double d = any_cast<double>(*iter);
fmt % d;
}
else if (iter->type() == typeid(string))
{
string s = any_cast<string>(*iter);
fmt % s;
}
else
{
throw logic_error("IDBErrorInfo::format: unexpected type in argslist");
}
++iter;
}
errMsg = fmt.str();
formatMany(errMsg, args.args());
}
/* static */

View File

@ -29,7 +29,7 @@
#include <fstream>
using namespace std;
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <boost/thread.hpp>
using namespace boost;
@ -41,6 +41,7 @@ using namespace config;
#include "installdir.h"
#include "format.h"
namespace
{
boost::mutex mx;
@ -143,43 +144,7 @@ void Message::Args::reset()
void Message::format(const Args& args)
{
Args::AnyVec::const_iterator iter = args.args().begin();
Args::AnyVec::const_iterator end = args.args().end();
boost::format fmt(fMsg);
fmt.exceptions(boost::io::no_error_bits);
while (iter != end)
{
if (iter->type() == typeid(long))
{
long l = any_cast<long>(*iter);
fmt % l;
}
else if (iter->type() == typeid(uint64_t))
{
uint64_t u64 = any_cast<uint64_t>(*iter);
fmt % u64;
}
else if (iter->type() == typeid(double))
{
double d = any_cast<double>(*iter);
fmt % d;
}
else if (iter->type() == typeid(string))
{
string s = any_cast<string>(*iter);
fmt % s;
}
else
{
throw logic_error("Message::format: unexpected type in argslist");
}
++iter;
}
fMsg = fmt.str();
formatMany(fMsg, args.args());
}
/* static */

View File

@ -45,17 +45,10 @@ namespace rwlock
/// the layout of the shmseg
struct State
{
#ifdef _MSC_VER
volatile LONG writerswaiting;
volatile LONG writing;
volatile LONG readerswaiting;
volatile LONG reading;
#else
volatile int writerswaiting;
volatile int writing;
volatile int readerswaiting;
volatile int reading;
#endif
int writerswaiting;
int writing;
int readerswaiting;
int reading;
boost::interprocess::interprocess_semaphore sems[3];
};

View File

@ -19,7 +19,7 @@
#include <string>
using namespace std;
#include <boost/regex.hpp>
#include <regex.hpp>
#include "grepit.h"
@ -32,13 +32,13 @@ namespace winport
{
bool grepit(istream& is, const string& pattern)
{
boost::regex pat(pattern);
std::regex pat(pattern);
string cInput;
getline(is, cInput);
while (is.good())
{
if (boost::regex_match(cInput, pat))
if (std::regex_match(cInput, pat))
return true;
getline(is, cInput);

View File

@ -78,7 +78,7 @@ class TableInfo : public WeUIDGID
int fCurrentReadBuffer; // Id of current buffer being popu-
// lated by the read thread
RID fTotalReadRows; // Total number of rows read
volatile unsigned fTotalErrRows; // Total error rows among all input
unsigned fTotalErrRows; // Total error rows among all input
// for this table. Is volatile to
// insure parser & reader threads
// see the latest value.

View File

@ -891,7 +891,7 @@ void WEDataLoader::onReceiveData(ByteStream& Ibs)
if (aQsz < MAX_QSIZE)
sendDataRequest();
if (aQsz > 1.5 * MAX_QSIZE) // > 2*250
if (aQsz > 1.5 * static_cast<int>(MAX_QSIZE)) // > 2*250
{
cout << "WARNING : Data Queuing up : QSize = " << aQsz << endl;