You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -40,7 +40,7 @@
|
||||
using namespace std;
|
||||
using namespace bulkloadxml;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
const int DEBUG_LVL_TO_DUMP_SYSCAT_RPT = 4;
|
||||
#ifdef _MSC_VER
|
||||
@ -51,69 +51,76 @@ int main(int argc, char **argv)
|
||||
setlocale(LC_ALL, "");
|
||||
WriteEngine::Config::initConfigCache(); // load Columnstore.xml config settings
|
||||
|
||||
//Bug 6137
|
||||
std::string aBulkRoot = WriteEngine::Config::getBulkRoot();
|
||||
if (!aBulkRoot.empty())
|
||||
{
|
||||
if (!boost::filesystem::exists(aBulkRoot.c_str()))
|
||||
{
|
||||
cout << "Creating directory : " << aBulkRoot <<endl;
|
||||
boost::filesystem::create_directories(aBulkRoot.c_str());
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(aBulkRoot.c_str()))
|
||||
{
|
||||
std::ostringstream aSS;
|
||||
aSS << aBulkRoot;
|
||||
aSS << "/job";
|
||||
std::string jobDir = aSS.str();
|
||||
if (!boost::filesystem::exists(jobDir.c_str()))
|
||||
{
|
||||
cout << "Creating directory : " << jobDir << endl;
|
||||
bool aSuccess = boost::filesystem::create_directories(jobDir.c_str());
|
||||
if (!aSuccess)
|
||||
{
|
||||
cout << "\nFailed to create job directory, please check permissions\n" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//Bug 6137
|
||||
std::string aBulkRoot = WriteEngine::Config::getBulkRoot();
|
||||
|
||||
std::ostringstream aSS2;
|
||||
aSS2 << aBulkRoot;
|
||||
aSS2 << "/log";
|
||||
std::string logDir = aSS2.str();
|
||||
if (!boost::filesystem::exists(logDir.c_str()))
|
||||
{
|
||||
cout << "Creating directory : " << logDir << endl;
|
||||
bool aSuccess = boost::filesystem::create_directories(logDir.c_str());
|
||||
if (!aSuccess)
|
||||
{
|
||||
cout << "\nFailed to create directory, please check permissions\n" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nFailed to create bulk directory, check for permissions\n" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nBulkRoot is empty in config file. Failed to create job file.\n\n";
|
||||
return -1;
|
||||
}
|
||||
if (!aBulkRoot.empty())
|
||||
{
|
||||
if (!boost::filesystem::exists(aBulkRoot.c_str()))
|
||||
{
|
||||
cout << "Creating directory : " << aBulkRoot << endl;
|
||||
boost::filesystem::create_directories(aBulkRoot.c_str());
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(aBulkRoot.c_str()))
|
||||
{
|
||||
std::ostringstream aSS;
|
||||
aSS << aBulkRoot;
|
||||
aSS << "/job";
|
||||
std::string jobDir = aSS.str();
|
||||
|
||||
if (!boost::filesystem::exists(jobDir.c_str()))
|
||||
{
|
||||
cout << "Creating directory : " << jobDir << endl;
|
||||
bool aSuccess = boost::filesystem::create_directories(jobDir.c_str());
|
||||
|
||||
if (!aSuccess)
|
||||
{
|
||||
cout << "\nFailed to create job directory, please check permissions\n" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream aSS2;
|
||||
aSS2 << aBulkRoot;
|
||||
aSS2 << "/log";
|
||||
std::string logDir = aSS2.str();
|
||||
|
||||
if (!boost::filesystem::exists(logDir.c_str()))
|
||||
{
|
||||
cout << "Creating directory : " << logDir << endl;
|
||||
bool aSuccess = boost::filesystem::create_directories(logDir.c_str());
|
||||
|
||||
if (!aSuccess)
|
||||
{
|
||||
cout << "\nFailed to create directory, please check permissions\n" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nFailed to create bulk directory, check for permissions\n" << endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nBulkRoot is empty in config file. Failed to create job file.\n\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
InputMgr mgr("299"); //@bug 391
|
||||
|
||||
if (! mgr.input(argc, argv))
|
||||
return 1;
|
||||
|
||||
int debugLevel = atoi(mgr.getParm(
|
||||
WriteEngine::XMLGenData::RPT_DEBUG).c_str());
|
||||
WriteEngine::XMLGenData::RPT_DEBUG).c_str());
|
||||
|
||||
bool bUseLogFile = true;
|
||||
bool bSysCatRpt = false;
|
||||
|
||||
if (debugLevel == DEBUG_LVL_TO_DUMP_SYSCAT_RPT)
|
||||
{
|
||||
cout << "\nRunning colxml to dump system catalog report:\n\n";
|
||||
@ -126,33 +133,39 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
WriteEngine::XMLGenProc curJob(&mgr, bUseLogFile, bSysCatRpt);
|
||||
if( debugLevel > 0 && debugLevel <= 3 ) {
|
||||
|
||||
if ( debugLevel > 0 && debugLevel <= 3 )
|
||||
{
|
||||
curJob.setDebugLevel( debugLevel );
|
||||
cout << "\nDebug level is set to " << debugLevel << endl;
|
||||
}
|
||||
|
||||
BRM::DBRM dbrm;
|
||||
|
||||
if (dbrm.getSystemReady() < 1)
|
||||
{
|
||||
std::string errMsg(
|
||||
"System is not ready. Verify that InfiniDB is up and ready "
|
||||
"before running colxml.");
|
||||
|
||||
if (bUseLogFile)
|
||||
curJob.logErrorMessage(errMsg);
|
||||
else
|
||||
cout << errMsg << endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool rc = false;
|
||||
|
||||
const WriteEngine::XMLGenData::TableList& tables = mgr.getTables();
|
||||
|
||||
try
|
||||
{
|
||||
if (tables.empty())
|
||||
mgr.loadCatalogTables();
|
||||
|
||||
if (tables.empty())
|
||||
if (tables.empty())
|
||||
{
|
||||
string msg = "Either schema name is invalid or no table "
|
||||
"is in the schema.";
|
||||
@ -163,10 +176,11 @@ int main(int argc, char **argv)
|
||||
curJob.startXMLFile( );
|
||||
|
||||
for (InputMgr::TableList::const_iterator tbl = tables.begin();
|
||||
tbl != tables.end() ; ++tbl)
|
||||
tbl != tables.end() ; ++tbl)
|
||||
{
|
||||
curJob.makeTableData( *tbl );
|
||||
rc = curJob.makeColumnData(*tbl);
|
||||
|
||||
if (!rc)
|
||||
cout << "No columns for " << tbl->table << endl;
|
||||
}
|
||||
@ -175,10 +189,10 @@ int main(int argc, char **argv)
|
||||
catch (runtime_error& ex)
|
||||
{
|
||||
curJob.logErrorMessage(string( "colxml runtime exception: ") +
|
||||
ex.what() );
|
||||
ex.what() );
|
||||
cout << curJob.errorString() << endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
curJob.logErrorMessage(string( "colxml exception: ") + ex.what() );
|
||||
@ -190,9 +204,9 @@ int main(int argc, char **argv)
|
||||
curJob.logErrorMessage(string("colxml unknown exception "));
|
||||
cout << curJob.errorString() << endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc)
|
||||
if (rc)
|
||||
{
|
||||
if (debugLevel == DEBUG_LVL_TO_DUMP_SYSCAT_RPT)
|
||||
{
|
||||
@ -207,9 +221,10 @@ int main(int argc, char **argv)
|
||||
curJob.writeXMLFile( xmlFileName );
|
||||
cout << "File completed for tables:\n\t";
|
||||
}
|
||||
|
||||
copy(tables.begin(), tables.end(),
|
||||
ostream_iterator<execplan::CalpontSystemCatalog::TableName>
|
||||
(cout, "\n\t"));
|
||||
ostream_iterator<execplan::CalpontSystemCatalog::TableName>
|
||||
(cout, "\n\t"));
|
||||
cout << "\nNormal exit.\n";
|
||||
}
|
||||
else
|
||||
|
@ -41,7 +41,7 @@ namespace bulkloadxml
|
||||
// InputMgr constructor
|
||||
//------------------------------------------------------------------------------
|
||||
InputMgr::InputMgr(const string& job)
|
||||
{
|
||||
{
|
||||
fParms[ JOBID] = job; // add or override default value
|
||||
}
|
||||
|
||||
@ -57,7 +57,8 @@ InputMgr::~InputMgr( )
|
||||
// printUsage
|
||||
//------------------------------------------------------------------------------
|
||||
void InputMgr::printUsage()
|
||||
{ //@bug 391
|
||||
{
|
||||
//@bug 391
|
||||
cerr << "Usage: " << "colxml [options] dbName" << endl << endl;
|
||||
cerr << "Options: " << endl;
|
||||
cerr << " -d Delimiter (default '|')\n";
|
||||
@ -77,8 +78,8 @@ void InputMgr::printUsage()
|
||||
cerr << " -E EnclosedByChar (if data has enclosed values)\n";
|
||||
cerr << " -C EscapeChar\n";
|
||||
cerr << " -b Debug level (1-3)\n\n";
|
||||
cerr << " dbName - Required parm specifying the name of the database;"<<
|
||||
endl << " all others are optional\n\n" ;
|
||||
cerr << " dbName - Required parm specifying the name of the database;" <<
|
||||
endl << " all others are optional\n\n" ;
|
||||
cerr << "Example:\n\t" << "colxml -t lineitem -j 123 tpch\n";
|
||||
// exit(0);
|
||||
}
|
||||
@ -86,14 +87,14 @@ void InputMgr::printUsage()
|
||||
//------------------------------------------------------------------------------
|
||||
// Provide input to this class through argc/argv interface.
|
||||
//------------------------------------------------------------------------------
|
||||
bool InputMgr::input(int argc, char **argv)
|
||||
bool InputMgr::input(int argc, char** argv)
|
||||
{
|
||||
std::vector<std::string> l_tableList;
|
||||
int ch;
|
||||
|
||||
while( (ch=getopt(argc,argv,"b:d:s:j:l:e:n:p:t:u:r:c:w:x:hE:C:")) != EOF )
|
||||
while ( (ch = getopt(argc, argv, "b:d:s:j:l:e:n:p:t:u:r:c:w:x:hE:C:")) != EOF )
|
||||
{
|
||||
switch(ch)
|
||||
switch (ch)
|
||||
{
|
||||
case 't':
|
||||
{
|
||||
@ -114,29 +115,30 @@ bool InputMgr::input(int argc, char **argv)
|
||||
case 'b':
|
||||
case 'e':
|
||||
{
|
||||
if (verifyArgument(optarg) < 0)
|
||||
if (verifyArgument(optarg) < 0)
|
||||
{
|
||||
cout << "Argument associated with option -" <<
|
||||
(char)ch << " is not a number." << endl;
|
||||
(char)ch << " is not a number." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
long lValue = strtol(optarg, 0, 10);
|
||||
|
||||
if (errno != 0)
|
||||
{
|
||||
cout << "Option -" << (char)ch <<
|
||||
" is invalid or out of range" << endl;
|
||||
" is invalid or out of range" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Limit to INT_MAX because we eventually store in an "int"
|
||||
if ( ((ch == 'e') && (lValue < 0)) ||
|
||||
((ch != 'e') && (lValue < 1)) ||
|
||||
(lValue > INT_MAX))
|
||||
((ch != 'e') && (lValue < 1)) ||
|
||||
(lValue > INT_MAX))
|
||||
{
|
||||
cout << "Option -" << (char)ch <<
|
||||
" is invalid or out of range." << endl;
|
||||
" is invalid or out of range." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -152,10 +154,12 @@ bool InputMgr::input(int argc, char **argv)
|
||||
case 'C':
|
||||
{
|
||||
char l_option[4];
|
||||
snprintf(l_option,sizeof(l_option),"-%c",ch);
|
||||
snprintf(l_option, sizeof(l_option), "-%c", ch);
|
||||
ParmList::iterator p = fParms.find(l_option);
|
||||
|
||||
if ( fParms.end() != p )
|
||||
p->second = optarg;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -168,36 +172,37 @@ bool InputMgr::input(int argc, char **argv)
|
||||
default :
|
||||
{
|
||||
cout << "Try '" << argv[0] <<
|
||||
" -h' for more information."<< endl;
|
||||
" -h' for more information." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
if (optind < argc)
|
||||
{
|
||||
fSchema = argv[optind++];
|
||||
if ( optind < argc )
|
||||
|
||||
if ( optind < argc )
|
||||
{
|
||||
cout << "Extraneous arguments are ignored." << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
cout << "Schema value is required." << endl;
|
||||
cout << "Try '" << argv[0] << " -h' for more information."<< endl;
|
||||
cout << "Try '" << argv[0] << " -h' for more information." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (unsigned ndx = 0; ndx < l_tableList.size(); ndx++)
|
||||
{
|
||||
fTables.push_back(execplan::CalpontSystemCatalog::TableName(
|
||||
fSchema, l_tableList[ndx]));
|
||||
fSchema, l_tableList[ndx]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Get list of tables for fSchema, and store the list in fTables.
|
||||
//------------------------------------------------------------------------------
|
||||
@ -205,12 +210,13 @@ bool InputMgr::loadCatalogTables()
|
||||
{
|
||||
boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatPtr =
|
||||
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(
|
||||
BULK_SYSCAT_SESSION_ID);
|
||||
BULK_SYSCAT_SESSION_ID);
|
||||
systemCatPtr->identity(execplan::CalpontSystemCatalog::EC);
|
||||
const vector< pair<CalpontSystemCatalog::OID, CalpontSystemCatalog::TableName> > tables
|
||||
= systemCatPtr->getTables( fSchema );
|
||||
const vector< pair<CalpontSystemCatalog::OID, CalpontSystemCatalog::TableName> > tables
|
||||
= systemCatPtr->getTables( fSchema );
|
||||
|
||||
for (vector<pair<CalpontSystemCatalog::OID, CalpontSystemCatalog::TableName> >::const_iterator it = tables.begin();
|
||||
it != tables.end(); ++it)
|
||||
it != tables.end(); ++it)
|
||||
{
|
||||
fTables.push_back((*it).second);
|
||||
}
|
||||
@ -221,16 +227,18 @@ bool InputMgr::loadCatalogTables()
|
||||
//------------------------------------------------------------------------------
|
||||
// Verify that string argument is numeric
|
||||
//------------------------------------------------------------------------------
|
||||
int InputMgr::verifyArgument(char *arg)
|
||||
int InputMgr::verifyArgument(char* arg)
|
||||
{
|
||||
while(*arg != 0)
|
||||
while (*arg != 0)
|
||||
{
|
||||
if (!isdigit(*arg))
|
||||
{
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
arg++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -251,21 +259,22 @@ std::ostream& operator<<(std::ostream& os, const InputMgr& m)
|
||||
os << "\n\tSchema:\t" << m.fSchema << "\n\t" << "Tables:\t";
|
||||
|
||||
for ( InputMgr::TableList::const_iterator i = m.fTables.begin();
|
||||
i != m.fTables.end(); ++i)
|
||||
i != m.fTables.end(); ++i)
|
||||
os << i->table << " ";
|
||||
|
||||
os << "\n\t" << "Load Files: ";
|
||||
|
||||
for ( InputMgr::LoadNames::const_iterator i = m.fLoadNames.begin();
|
||||
i != m.fLoadNames.end(); ++i)
|
||||
i != m.fLoadNames.end(); ++i)
|
||||
os << *i << " ";
|
||||
|
||||
for (InputMgr::ParmList::const_iterator i = m.fParms.begin();
|
||||
i != m.fParms.end(); ++i)
|
||||
i != m.fParms.end(); ++i)
|
||||
{
|
||||
// Don't report the enclosedBy if not enabled by user
|
||||
if ((i->first == XMLGenData::ENCLOSED_BY_CHAR) &&
|
||||
(i->second.length() < 1))
|
||||
continue;
|
||||
(i->second.length() < 1))
|
||||
continue;
|
||||
|
||||
os << "\n\t" << i->first << "\t" << i->second;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace bulkloadxml
|
||||
*/
|
||||
class InputMgr : public WriteEngine::XMLGenData
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
/** @brief Constructor to manage colxml input.
|
||||
*
|
||||
@ -41,14 +41,14 @@ class InputMgr : public WriteEngine::XMLGenData
|
||||
*/
|
||||
InputMgr(const std::string& job);
|
||||
virtual ~InputMgr( );
|
||||
|
||||
|
||||
/** @brief Specify parameter data to be written to Job XML file
|
||||
*
|
||||
* @param argc Number of arguments in argv
|
||||
* @param argv Input arguments
|
||||
* @return Return true if input accepted; false indicates an error
|
||||
*/
|
||||
bool input(int argc, char **argv);
|
||||
bool input(int argc, char** argv);
|
||||
|
||||
/** @brief Load list of tables in system catalog for relevant schema.
|
||||
*/
|
||||
@ -57,12 +57,12 @@ class InputMgr : public WriteEngine::XMLGenData
|
||||
/** @brief Print contents of this object
|
||||
*/
|
||||
virtual void print(std::ostream& os) const;
|
||||
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const InputMgr& m);
|
||||
|
||||
private:
|
||||
private:
|
||||
void printUsage();
|
||||
int verifyArgument(char *arg);
|
||||
int verifyArgument(char* arg);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by colxml.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by colxml.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user