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:
@ -42,157 +42,178 @@ bool dflg;
|
||||
|
||||
void usage()
|
||||
{
|
||||
cout << "usage: dmldriver [-vhd] [-c intvl] [-f file] [-s sid] [-t flgs] [-r file] [-p cnt] [sql_text]" << endl;
|
||||
cout << " -c intvl \tcommit every intvl statements" << endl;
|
||||
cout << " -f file \tread statements from file (max 15KB/stmt)" << endl;
|
||||
cout << " -s sid \tset sid as session id" << endl;
|
||||
cout << " -t flgs \tset trace flags" << endl;
|
||||
cout << " -v \tdisplay affected row count(s)" << endl;
|
||||
cout << " -d \tdisplay debug info" << endl;
|
||||
cout << " -r file \tread orderkeys from file for TPC-H RF2" << endl;
|
||||
cout << " -p cnt \tpack cnt orderkeys into each delete stmt (only w/ -r)" << endl;
|
||||
cout << " -e schema\tset the schema name (only w/ -r)" << endl;
|
||||
cout << " -h \tdisplay this help text" << endl;
|
||||
cout << "usage: dmldriver [-vhd] [-c intvl] [-f file] [-s sid] [-t flgs] [-r file] [-p cnt] [sql_text]" << endl;
|
||||
cout << " -c intvl \tcommit every intvl statements" << endl;
|
||||
cout << " -f file \tread statements from file (max 15KB/stmt)" << endl;
|
||||
cout << " -s sid \tset sid as session id" << endl;
|
||||
cout << " -t flgs \tset trace flags" << endl;
|
||||
cout << " -v \tdisplay affected row count(s)" << endl;
|
||||
cout << " -d \tdisplay debug info" << endl;
|
||||
cout << " -r file \tread orderkeys from file for TPC-H RF2" << endl;
|
||||
cout << " -p cnt \tpack cnt orderkeys into each delete stmt (only w/ -r)" << endl;
|
||||
cout << " -e schema\tset the schema name (only w/ -r)" << endl;
|
||||
cout << " -h \tdisplay this help text" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int c;
|
||||
int c;
|
||||
|
||||
opterr = 0;
|
||||
opterr = 0;
|
||||
|
||||
vflg = false;
|
||||
dflg = false;
|
||||
vflg = false;
|
||||
dflg = false;
|
||||
|
||||
bool fflg = false;
|
||||
string infilename;
|
||||
bool fflg = false;
|
||||
string infilename;
|
||||
|
||||
int cIntvl = numeric_limits<int>::max();
|
||||
int cIntvl = numeric_limits<int>::max();
|
||||
|
||||
uint32_t sessionID = time(0) & 0x7fffffff;
|
||||
uint32_t sessionID = time(0) & 0x7fffffff;
|
||||
|
||||
bool rflg = false;
|
||||
bool rflg = false;
|
||||
|
||||
int packCnt = 1;
|
||||
int packCnt = 1;
|
||||
|
||||
uint32_t tflg = 0;
|
||||
uint32_t tflg = 0;
|
||||
|
||||
string schema;
|
||||
string schema;
|
||||
|
||||
while ((c = getopt(argc, argv, "e:t:s:c:f:r:p:vhd")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'v':
|
||||
vflg = true;
|
||||
break;
|
||||
case 'd':
|
||||
dflg = true;
|
||||
break;
|
||||
case 'f':
|
||||
fflg = true;
|
||||
infilename = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
cIntvl = static_cast<int>(strtol(optarg, 0, 0));
|
||||
break;
|
||||
case 's':
|
||||
sessionID = static_cast<uint32_t>(strtoul(optarg, 0, 0));
|
||||
break;
|
||||
case 't':
|
||||
tflg = static_cast<uint32_t>(strtoul(optarg, 0, 0));
|
||||
break;
|
||||
case 'r':
|
||||
rflg = true;
|
||||
infilename = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
packCnt = static_cast<int>(strtol(optarg, 0, 0));
|
||||
break;
|
||||
case 'e':
|
||||
schema = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
return (c == 'h' ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
while ((c = getopt(argc, argv, "e:t:s:c:f:r:p:vhd")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'v':
|
||||
vflg = true;
|
||||
break;
|
||||
|
||||
if (!fflg && !rflg && ((argc - optind) < 1))
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
case 'd':
|
||||
dflg = true;
|
||||
break;
|
||||
|
||||
if (fflg && rflg)
|
||||
{
|
||||
cout << "-f and -r are mutually exclusive!" << endl << endl;
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
case 'f':
|
||||
fflg = true;
|
||||
infilename = optarg;
|
||||
break;
|
||||
|
||||
if (!schema.empty() && !rflg)
|
||||
{
|
||||
cout << "-e requires -r!" << endl << endl;
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
case 'c':
|
||||
cIntvl = static_cast<int>(strtol(optarg, 0, 0));
|
||||
break;
|
||||
|
||||
string stmtStr;
|
||||
if (!fflg && !rflg)
|
||||
stmtStr = argv[optind++];
|
||||
case 's':
|
||||
sessionID = static_cast<uint32_t>(strtoul(optarg, 0, 0));
|
||||
break;
|
||||
|
||||
int rc = 0;
|
||||
case 't':
|
||||
tflg = static_cast<uint32_t>(strtoul(optarg, 0, 0));
|
||||
break;
|
||||
|
||||
dmlif::DMLIF dmlif(sessionID, tflg, dflg, vflg);
|
||||
case 'r':
|
||||
rflg = true;
|
||||
infilename = optarg;
|
||||
break;
|
||||
|
||||
if (fflg)
|
||||
{
|
||||
ifstream ifs(infilename.c_str());
|
||||
if (!ifs.good())
|
||||
{
|
||||
cerr << "Error accessing file " << infilename << endl;
|
||||
return 1;
|
||||
}
|
||||
const streamsize ilinelen = 15 * 1024;
|
||||
scoped_array<char> iline(new char[ilinelen]);
|
||||
int cnt = 0;
|
||||
for (;;)
|
||||
{
|
||||
ifs.getline(iline.get(), ilinelen);
|
||||
if (ifs.eof())
|
||||
break;
|
||||
rc = dmlif.sendOne(iline.get());
|
||||
if (rc != 0)
|
||||
break;
|
||||
cnt++;
|
||||
if ((cnt % cIntvl) == 0)
|
||||
dmlif.sendOne("COMMIT;");
|
||||
}
|
||||
}
|
||||
else if (rflg)
|
||||
{
|
||||
ifstream ifs(infilename.c_str());
|
||||
if (!ifs.good())
|
||||
{
|
||||
cerr << "Error accessing file " << infilename << endl;
|
||||
return 1;
|
||||
}
|
||||
if (schema.empty())
|
||||
schema = "tpch";
|
||||
tpch::RF2 rf2(schema, sessionID, tflg, cIntvl, packCnt, dflg, vflg);
|
||||
rc = rf2.run(ifs);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = dmlif.sendOne(stmtStr);
|
||||
}
|
||||
case 'p':
|
||||
packCnt = static_cast<int>(strtol(optarg, 0, 0));
|
||||
break;
|
||||
|
||||
if (rc == 0)
|
||||
dmlif.sendOne("COMMIT;");
|
||||
case 'e':
|
||||
schema = optarg;
|
||||
break;
|
||||
|
||||
return 0;
|
||||
case 'h':
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
return (c == 'h' ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fflg && !rflg && ((argc - optind) < 1))
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fflg && rflg)
|
||||
{
|
||||
cout << "-f and -r are mutually exclusive!" << endl << endl;
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!schema.empty() && !rflg)
|
||||
{
|
||||
cout << "-e requires -r!" << endl << endl;
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
string stmtStr;
|
||||
|
||||
if (!fflg && !rflg)
|
||||
stmtStr = argv[optind++];
|
||||
|
||||
int rc = 0;
|
||||
|
||||
dmlif::DMLIF dmlif(sessionID, tflg, dflg, vflg);
|
||||
|
||||
if (fflg)
|
||||
{
|
||||
ifstream ifs(infilename.c_str());
|
||||
|
||||
if (!ifs.good())
|
||||
{
|
||||
cerr << "Error accessing file " << infilename << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const streamsize ilinelen = 15 * 1024;
|
||||
scoped_array<char> iline(new char[ilinelen]);
|
||||
int cnt = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ifs.getline(iline.get(), ilinelen);
|
||||
|
||||
if (ifs.eof())
|
||||
break;
|
||||
|
||||
rc = dmlif.sendOne(iline.get());
|
||||
|
||||
if (rc != 0)
|
||||
break;
|
||||
|
||||
cnt++;
|
||||
|
||||
if ((cnt % cIntvl) == 0)
|
||||
dmlif.sendOne("COMMIT;");
|
||||
}
|
||||
}
|
||||
else if (rflg)
|
||||
{
|
||||
ifstream ifs(infilename.c_str());
|
||||
|
||||
if (!ifs.good())
|
||||
{
|
||||
cerr << "Error accessing file " << infilename << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (schema.empty())
|
||||
schema = "tpch";
|
||||
|
||||
tpch::RF2 rf2(schema, sessionID, tflg, cIntvl, packCnt, dflg, vflg);
|
||||
rc = rf2.run(ifs);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = dmlif.sendOne(stmtStr);
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
dmlif.sendOne("COMMIT;");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user