1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-06-16 14:20:56 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@ -16,9 +16,9 @@
MA 02110-1301, USA. */
/******************************************************************************************
* $Id: message.cpp 3495 2013-01-21 14:09:51Z rdempsey $
*
******************************************************************************************/
* $Id: message.cpp 3495 2013-01-21 14:09:51Z rdempsey $
*
******************************************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
@ -43,7 +43,6 @@ using namespace config;
namespace
{
boost::mutex mx;
bool catalogLoaded = false;
@ -53,182 +52,179 @@ CatMap catmap;
void loadCatalog()
{
Config* cf = Config::makeConfig();
string configFile(cf->getConfig("MessageLog", "MessageLogFile"));
Config* cf = Config::makeConfig();
string configFile(cf->getConfig("MessageLog", "MessageLogFile"));
if (configFile.length() == 0)
configFile = std::string(MCSSYSCONFDIR) + "/columnstore/MessageFile.txt";
if (configFile.length() == 0)
configFile = std::string(MCSSYSCONFDIR) + "/columnstore/MessageFile.txt";
ifstream msgFile(configFile.c_str());
ifstream msgFile(configFile.c_str());
while (msgFile.good())
while (msgFile.good())
{
stringbuf* sb = new stringbuf;
msgFile.get(*sb);
string m = sb->str();
delete sb;
if (m.length() > 0 && m[0] != '#')
{
stringbuf* sb = new stringbuf;
msgFile.get(*sb);
string m = sb->str();
delete sb;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("\t");
tokenizer tokens(m, sep);
tokenizer::iterator tok_iter = tokens.begin();
if (m.length() > 0 && m[0] != '#')
if (tok_iter != tokens.end())
{
int msgid = atoi(tok_iter->c_str());
++tok_iter;
if (tok_iter != tokens.end())
{
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("\t");
tokenizer tokens(m, sep);
tokenizer::iterator tok_iter = tokens.begin();
if (tok_iter != tokens.end())
{
int msgid = atoi(tok_iter->c_str());
++tok_iter;
if (tok_iter != tokens.end())
{
string msgtext = *tok_iter;
catmap[msgid] = msgtext;
}
}
string msgtext = *tok_iter;
catmap[msgid] = msgtext;
}
ios_base::iostate st = msgFile.rdstate();
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
msgFile.clear();
(void)msgFile.get();
}
}
ios_base::iostate st = msgFile.rdstate();
if ((st & ios_base::failbit) && !(st & ios_base::eofbit))
msgFile.clear();
(void)msgFile.get();
}
}
}
} // namespace
namespace logging
{
Message::Message(const MessageID msgid) :
fMsgID(msgid), fMsg(lookupMessage(msgid)), fConfig(Config::makeConfig())
Message::Message(const MessageID msgid)
: fMsgID(msgid), fMsg(lookupMessage(msgid)), fConfig(Config::makeConfig())
{
}
Message::Message(const string msg):
fMsgID(0), fMsg(msg), fConfig(Config::makeConfig())
Message::Message(const string msg) : fMsgID(0), fMsg(msg), fConfig(Config::makeConfig())
{
}
void Message::swap(Message& rhs)
{
std::swap(fMsgID, rhs.fMsgID);
std::swap(fMsg, rhs.fMsg);
std::swap(fConfig, rhs.fConfig);
std::swap(fMsgID, rhs.fMsgID);
std::swap(fMsg, rhs.fMsg);
std::swap(fConfig, rhs.fConfig);
}
void Message::Args::add(int i)
{
fArgs.push_back(long(i));
fArgs.push_back(long(i));
}
void Message::Args::add(uint64_t u64)
{
fArgs.push_back(u64);
fArgs.push_back(u64);
}
void Message::Args::add(const string& s)
{
fArgs.push_back(s);
fArgs.push_back(s);
}
void Message::Args::add(double d)
{
fArgs.push_back(d);
fArgs.push_back(d);
}
void Message::Args::reset()
{
fArgs.clear();
fArgs.clear();
}
void Message::format(const Args& args)
{
Args::AnyVec::const_iterator iter = args.args().begin();
Args::AnyVec::const_iterator end = args.args().end();
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);
boost::format fmt(fMsg);
fmt.exceptions(boost::io::no_error_bits);
while (iter != end)
while (iter != end)
{
if (iter->type() == typeid(long))
{
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;
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");
}
fMsg = fmt.str();
++iter;
}
fMsg = fmt.str();
}
/* static */
const string Message::lookupMessage(const MessageID& msgid)
{
if (!catalogLoaded)
{
boost::mutex::scoped_lock lock(mx);
if (!catalogLoaded)
{
boost::mutex::scoped_lock lock(mx);
if (!catalogLoaded)
{
loadCatalog();
catalogLoaded = true;
}
loadCatalog();
catalogLoaded = true;
}
}
string msgstr;
CatMap::const_iterator iter = catmap.find(msgid);
string msgstr;
CatMap::const_iterator iter = catmap.find(msgid);
if (iter == catmap.end())
{
iter = catmap.find(0);
if (iter == catmap.end())
{
iter = catmap.find(0);
if (iter == catmap.end())
{
msgstr = "%1% %2% %3% %4% %5%";
}
else
{
msgstr = iter->second;
}
msgstr = "%1% %2% %3% %4% %5%";
}
else
{
msgstr = iter->second;
msgstr = iter->second;
}
}
else
{
msgstr = iter->second;
}
ostringstream oss;
oss << "CAL" << setw(4) << setfill('0') << msgid << ": " << msgstr;
return oss.str();
ostringstream oss;
oss << "CAL" << setw(4) << setfill('0') << msgid << ": " << msgstr;
return oss.str();
}
void Message::reset()
{
fMsg = lookupMessage(fMsgID);
}
fMsg = lookupMessage(fMsgID);
}
} // namespace logging