You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -48,22 +48,23 @@ enum BUILD_OPTION
|
||||
SYSCATALOG_ONLY = 7, //Create systables only
|
||||
};
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
int setUp()
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
(void)system("/bin/rm -f /tmp/dbbuilder.status >/dev/null 2>&1");
|
||||
(void)system("/bin/touch /tmp/dbbuilder.status >/dev/null 2>&1");
|
||||
(void)system("/bin/rm -f /tmp/dbbuilder.status >/dev/null 2>&1");
|
||||
(void)system("/bin/touch /tmp/dbbuilder.status >/dev/null 2>&1");
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int checkNotThere(WriteEngine::FID fid)
|
||||
{
|
||||
WriteEngine::FileOp fileOp;
|
||||
WriteEngine::FileOp fileOp;
|
||||
|
||||
return (fileOp.existsOIDDir(fid) ? -1 : 0);
|
||||
return (fileOp.existsOIDDir(fid) ? -1 : 0);
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
@ -80,36 +81,37 @@ void usage()
|
||||
<< " 7 Build system tables only" << endl
|
||||
<< endl
|
||||
<< "WARNING! Using this tool improperly can render your database unusable!" << endl
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
const unsigned sysCatalogErr = logging::M0060;
|
||||
|
||||
void errorHandler(const unsigned mid,
|
||||
const string& src,
|
||||
const string& msg,
|
||||
bool isCritErr=true)
|
||||
const string& src,
|
||||
const string& msg,
|
||||
bool isCritErr = true)
|
||||
{
|
||||
logging::LoggingID lid(19);
|
||||
logging::MessageLog ml(lid);
|
||||
logging::Message::Args args;
|
||||
logging::Message message(mid);
|
||||
if (isCritErr)
|
||||
{
|
||||
args.add(string("error"));
|
||||
args.add(msg);
|
||||
message.format( args );
|
||||
ml.logCriticalMessage(message );
|
||||
cout << src << " was not successful. " << msg << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
args.add(string("status"));
|
||||
args.add(msg);
|
||||
message.format( args );
|
||||
ml.logInfoMessage(message );
|
||||
cout << src << " was not completed. " << msg << endl;
|
||||
}
|
||||
logging::LoggingID lid(19);
|
||||
logging::MessageLog ml(lid);
|
||||
logging::Message::Args args;
|
||||
logging::Message message(mid);
|
||||
|
||||
if (isCritErr)
|
||||
{
|
||||
args.add(string("error"));
|
||||
args.add(msg);
|
||||
message.format( args );
|
||||
ml.logCriticalMessage(message );
|
||||
cout << src << " was not successful. " << msg << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
args.add(string("status"));
|
||||
args.add(msg);
|
||||
message.format( args );
|
||||
ml.logInfoMessage(message );
|
||||
cout << src << " was not completed. " << msg << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -117,195 +119,212 @@ void errorHandler(const unsigned mid,
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int buildOption;
|
||||
int c;
|
||||
std::string schema("tpch");
|
||||
Oam oam;
|
||||
bool fFlg = false;
|
||||
int buildOption;
|
||||
int c;
|
||||
std::string schema("tpch");
|
||||
Oam oam;
|
||||
bool fFlg = false;
|
||||
|
||||
opterr = 0;
|
||||
opterr = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "u:fh")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'u':
|
||||
schema = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
fFlg = true;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
return (c == 'h' ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
while ((c = getopt(argc, argv, "u:fh")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'u':
|
||||
schema = optarg;
|
||||
break;
|
||||
|
||||
if ((argc - optind) < 1)
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
case 'f':
|
||||
fFlg = true;
|
||||
break;
|
||||
|
||||
oamModuleInfo_t t;
|
||||
bool parentOAMModuleFlag = false;
|
||||
case 'h':
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
return (c == 'h' ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
|
||||
//get local module info; validate running on Active Parent OAM Module
|
||||
try {
|
||||
t = oam.getModuleInfo();
|
||||
parentOAMModuleFlag = boost::get<4>(t);
|
||||
}
|
||||
catch (exception&) {
|
||||
parentOAMModuleFlag = true;
|
||||
}
|
||||
if ((argc - optind) < 1)
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( !parentOAMModuleFlag )
|
||||
{
|
||||
cerr << "Exiting, dbbuilder can only be run on the Active "
|
||||
"Parent OAM Module" << endl;
|
||||
return 1;
|
||||
}
|
||||
oamModuleInfo_t t;
|
||||
bool parentOAMModuleFlag = false;
|
||||
|
||||
buildOption = atoi(argv[optind++]);
|
||||
//get local module info; validate running on Active Parent OAM Module
|
||||
try
|
||||
{
|
||||
t = oam.getModuleInfo();
|
||||
parentOAMModuleFlag = boost::get<4>(t);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
parentOAMModuleFlag = true;
|
||||
}
|
||||
|
||||
if (buildOption != 7 && !fFlg)
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
if ( !parentOAMModuleFlag )
|
||||
{
|
||||
cerr << "Exiting, dbbuilder can only be run on the Active "
|
||||
"Parent OAM Module" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( buildOption == SYSCATALOG_ONLY )
|
||||
{
|
||||
setUp();
|
||||
buildOption = atoi(argv[optind++]);
|
||||
|
||||
bool canWrite = true;
|
||||
if (access("/tmp/dbbuilder.status", W_OK) != 0)
|
||||
canWrite = false;
|
||||
if (buildOption != 7 && !fFlg)
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (checkNotThere(1001) != 0)
|
||||
{
|
||||
string cmd = "echo 'FAILED: buildOption=" +
|
||||
oam.itoa(buildOption) +
|
||||
"' > /tmp/dbbuilder.status";
|
||||
if ( buildOption == SYSCATALOG_ONLY )
|
||||
{
|
||||
setUp();
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
errorHandler(sysCatalogErr,
|
||||
"Build system catalog",
|
||||
"System catalog appears to exist. It will remain intact "
|
||||
"for reuse. The database is not recreated.",
|
||||
false);
|
||||
return 1;
|
||||
}
|
||||
bool canWrite = true;
|
||||
|
||||
//@bug5554, make sure IDBPolicy matches the Columnstore.xml config
|
||||
try
|
||||
{
|
||||
string calpontConfigFile(startup::StartUp::installDir() + "/etc/Columnstore.xml");
|
||||
config::Config* sysConfig = config::Config::makeConfig(calpontConfigFile.c_str());
|
||||
string tmp = sysConfig->getConfig("Installation", "DBRootStorageType");
|
||||
if (boost::iequals(tmp, "hdfs"))
|
||||
{
|
||||
// HDFS is configured
|
||||
if (!IDBPolicy::useHdfs()) // error install plugin
|
||||
throw runtime_error("HDFS is not enabled, installPlugin may have failed.");
|
||||
if (access("/tmp/dbbuilder.status", W_OK) != 0)
|
||||
canWrite = false;
|
||||
|
||||
else if (!IDBFileSystem::getFs(IDBDataFile::HDFS).filesystemIsUp())
|
||||
throw runtime_error("HDFS FS is NULL, check env variables.");
|
||||
}
|
||||
}
|
||||
catch(const exception& ex)
|
||||
{
|
||||
string cmd(string("echo 'FAILED: ") + ex.what() + "' > /tmp/dbbuilder.status");
|
||||
try
|
||||
{
|
||||
if (checkNotThere(1001) != 0)
|
||||
{
|
||||
string cmd = "echo 'FAILED: buildOption=" +
|
||||
oam.itoa(buildOption) +
|
||||
"' > /tmp/dbbuilder.status";
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
errorHandler(sysCatalogErr, "Build system catalog", ex.what(), false);
|
||||
return 1;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
string cmd = "echo 'FAILED: HDFS checking.' > /tmp/dbbuilder.status";
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
errorHandler(sysCatalogErr, "Build system catalog", "HDFS check failed.", false);
|
||||
return 1;
|
||||
}
|
||||
errorHandler(sysCatalogErr,
|
||||
"Build system catalog",
|
||||
"System catalog appears to exist. It will remain intact "
|
||||
"for reuse. The database is not recreated.",
|
||||
false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//create an initial oid bitmap file
|
||||
{
|
||||
ObjectIDManager oidm;
|
||||
}
|
||||
//@bug5554, make sure IDBPolicy matches the Columnstore.xml config
|
||||
try
|
||||
{
|
||||
string calpontConfigFile(startup::StartUp::installDir() + "/etc/Columnstore.xml");
|
||||
config::Config* sysConfig = config::Config::makeConfig(calpontConfigFile.c_str());
|
||||
string tmp = sysConfig->getConfig("Installation", "DBRootStorageType");
|
||||
|
||||
SystemCatalog sysCatalog;
|
||||
sysCatalog.build();
|
||||
if (boost::iequals(tmp, "hdfs"))
|
||||
{
|
||||
// HDFS is configured
|
||||
if (!IDBPolicy::useHdfs()) // error install plugin
|
||||
throw runtime_error("HDFS is not enabled, installPlugin may have failed.");
|
||||
|
||||
std::string cmd = "echo 'OK: buildOption=" + oam.itoa(buildOption) + "' > /tmp/dbbuilder.status";
|
||||
else if (!IDBFileSystem::getFs(IDBDataFile::HDFS).filesystemIsUp())
|
||||
throw runtime_error("HDFS FS is NULL, check env variables.");
|
||||
}
|
||||
}
|
||||
catch (const exception& ex)
|
||||
{
|
||||
string cmd(string("echo 'FAILED: ") + ex.what() + "' > /tmp/dbbuilder.status");
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
|
||||
errorHandler(sysCatalogErr, "Build system catalog", ex.what(), false);
|
||||
return 1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
string cmd = "echo 'FAILED: HDFS checking.' > /tmp/dbbuilder.status";
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
|
||||
errorHandler(sysCatalogErr, "Build system catalog", "HDFS check failed.", false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//create an initial oid bitmap file
|
||||
{
|
||||
ObjectIDManager oidm;
|
||||
}
|
||||
|
||||
SystemCatalog sysCatalog;
|
||||
sysCatalog.build();
|
||||
|
||||
std::string cmd = "echo 'OK: buildOption=" + oam.itoa(buildOption) + "' > /tmp/dbbuilder.status";
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
#ifdef _MSC_VER
|
||||
(void)0;
|
||||
(void)0;
|
||||
|
||||
#else
|
||||
cerr << cmd << endl;
|
||||
cerr << cmd << endl;
|
||||
#endif
|
||||
|
||||
cmd = startup::StartUp::installDir() + "/bin/save_brm";
|
||||
if (canWrite) {
|
||||
int err;
|
||||
cmd = startup::StartUp::installDir() + "/bin/save_brm";
|
||||
|
||||
err = system(cmd.c_str());
|
||||
if (err != 0) {
|
||||
ostringstream os;
|
||||
os << "Warning: running " << cmd << " failed. This is usually non-fatal.";
|
||||
cerr << os.str() << endl;
|
||||
errorHandler(sysCatalogErr, "Save BRM", os.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
if (canWrite)
|
||||
{
|
||||
int err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > /tmp/dbbuilder.status";
|
||||
err = system(cmd.c_str());
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
errorHandler(sysCatalogErr, "Build system catalog", ex.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > /tmp/dbbuilder.status";
|
||||
if (err != 0)
|
||||
{
|
||||
ostringstream os;
|
||||
os << "Warning: running " << cmd << " failed. This is usually non-fatal.";
|
||||
cerr << os.str() << endl;
|
||||
errorHandler(sysCatalogErr, "Save BRM", os.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
string err("Caught unknown exception!");
|
||||
errorHandler(sysCatalogErr, "Build system catalog", err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > /tmp/dbbuilder.status";
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
|
||||
errorHandler(sysCatalogErr, "Build system catalog", ex.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > /tmp/dbbuilder.status";
|
||||
|
||||
if (canWrite)
|
||||
(void)system(cmd.c_str());
|
||||
else
|
||||
cerr << cmd << endl;
|
||||
|
||||
string err("Caught unknown exception!");
|
||||
errorHandler(sysCatalogErr, "Build system catalog", err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
|
@ -36,420 +36,500 @@ using namespace joblist;
|
||||
|
||||
void SystemCatalog::build()
|
||||
{
|
||||
TxnID txnID = 0;
|
||||
int rc;
|
||||
//int t= 1000;
|
||||
TxnID txnID = 0;
|
||||
int rc;
|
||||
//int t= 1000;
|
||||
|
||||
remove();
|
||||
remove();
|
||||
|
||||
cout << "Creating System Catalog..." << endl;
|
||||
cout << endl;
|
||||
// SYSTABLE
|
||||
cout << "Creating System Catalog..." << endl;
|
||||
cout << endl;
|
||||
// SYSTABLE
|
||||
|
||||
timeval startTime;
|
||||
gettimeofday( &startTime, 0);
|
||||
ostringstream msg;
|
||||
WErrorCodes ec;
|
||||
timeval startTime;
|
||||
gettimeofday( &startTime, 0);
|
||||
ostringstream msg;
|
||||
WErrorCodes ec;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Get the DBRoot count, and rotate the tables through those DBRoots.
|
||||
// All the columns in the first table (SYSTABLE) start on DBRoot1, all the
|
||||
// columns in the second table (SYSCOLUMN) start on DBRoot2, etc.
|
||||
//------------------------------------------------------------------------------
|
||||
config::Config* cf = config::Config::makeConfig();
|
||||
string root = cf->getConfig("SystemConfig","DBRootCount");
|
||||
uint32_t dbRootCount = cf->uFromText(root);
|
||||
//------------------------------------------------------------------------------
|
||||
// Get the DBRoot count, and rotate the tables through those DBRoots.
|
||||
// All the columns in the first table (SYSTABLE) start on DBRoot1, all the
|
||||
// columns in the second table (SYSCOLUMN) start on DBRoot2, etc.
|
||||
//------------------------------------------------------------------------------
|
||||
config::Config* cf = config::Config::makeConfig();
|
||||
string root = cf->getConfig("SystemConfig", "DBRootCount");
|
||||
uint32_t dbRootCount = cf->uFromText(root);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSTABLE table
|
||||
//------------------------------------------------------------------------------
|
||||
uint32_t dbRoot = 1;
|
||||
int compressionType = 0;
|
||||
uint32_t partition = 0;
|
||||
uint16_t segment=0;
|
||||
|
||||
ResourceManager *rm = ResourceManager::instance();
|
||||
std::map<uint32_t,uint32_t> oids;
|
||||
if( rm->useHdfs() )
|
||||
{
|
||||
compressionType = 2;
|
||||
oids[OID_SYSTABLE_TABLENAME] = OID_SYSTABLE_TABLENAME;
|
||||
oids[DICTOID_SYSTABLE_TABLENAME] = DICTOID_SYSTABLE_TABLENAME;
|
||||
oids[OID_SYSTABLE_SCHEMA] = OID_SYSTABLE_SCHEMA;
|
||||
oids[DICTOID_SYSTABLE_SCHEMA] = DICTOID_SYSTABLE_SCHEMA;
|
||||
oids[OID_SYSTABLE_OBJECTID] = OID_SYSTABLE_OBJECTID;
|
||||
oids[OID_SYSTABLE_CREATEDATE] = OID_SYSTABLE_CREATEDATE;
|
||||
oids[OID_SYSTABLE_LASTUPDATE] = OID_SYSTABLE_LASTUPDATE;
|
||||
oids[OID_SYSTABLE_INIT] = OID_SYSTABLE_INIT;
|
||||
oids[OID_SYSTABLE_NEXT] = OID_SYSTABLE_NEXT;
|
||||
oids[OID_SYSTABLE_NUMOFROWS] = OID_SYSTABLE_NUMOFROWS;
|
||||
oids[OID_SYSTABLE_AVGROWLEN] = OID_SYSTABLE_AVGROWLEN;
|
||||
oids[OID_SYSTABLE_NUMOFBLOCKS] = OID_SYSTABLE_NUMOFBLOCKS;
|
||||
oids[OID_SYSTABLE_AUTOINCREMENT] = OID_SYSTABLE_AUTOINCREMENT;
|
||||
}
|
||||
|
||||
fWriteEngine.setTransId(1);
|
||||
fWriteEngine.setBulkFlag(true);
|
||||
cout << "Creating SYSTABLE" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
// TableName
|
||||
msg << " Creating TableName column OID: "<< OID_SYSTABLE_TABLENAME;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_TABLENAME, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSTABLE table
|
||||
//------------------------------------------------------------------------------
|
||||
uint32_t dbRoot = 1;
|
||||
int compressionType = 0;
|
||||
uint32_t partition = 0;
|
||||
uint16_t segment = 0;
|
||||
|
||||
msg << " Creating TableName column dictionary";
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSTABLE_TABLENAME, 65, dbRoot, partition, segment, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
ResourceManager* rm = ResourceManager::instance();
|
||||
std::map<uint32_t, uint32_t> oids;
|
||||
|
||||
// Schema
|
||||
msg << " Creating Schema column OID: "<<OID_SYSTABLE_SCHEMA;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_SCHEMA, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
if ( rm->useHdfs() )
|
||||
{
|
||||
compressionType = 2;
|
||||
oids[OID_SYSTABLE_TABLENAME] = OID_SYSTABLE_TABLENAME;
|
||||
oids[DICTOID_SYSTABLE_TABLENAME] = DICTOID_SYSTABLE_TABLENAME;
|
||||
oids[OID_SYSTABLE_SCHEMA] = OID_SYSTABLE_SCHEMA;
|
||||
oids[DICTOID_SYSTABLE_SCHEMA] = DICTOID_SYSTABLE_SCHEMA;
|
||||
oids[OID_SYSTABLE_OBJECTID] = OID_SYSTABLE_OBJECTID;
|
||||
oids[OID_SYSTABLE_CREATEDATE] = OID_SYSTABLE_CREATEDATE;
|
||||
oids[OID_SYSTABLE_LASTUPDATE] = OID_SYSTABLE_LASTUPDATE;
|
||||
oids[OID_SYSTABLE_INIT] = OID_SYSTABLE_INIT;
|
||||
oids[OID_SYSTABLE_NEXT] = OID_SYSTABLE_NEXT;
|
||||
oids[OID_SYSTABLE_NUMOFROWS] = OID_SYSTABLE_NUMOFROWS;
|
||||
oids[OID_SYSTABLE_AVGROWLEN] = OID_SYSTABLE_AVGROWLEN;
|
||||
oids[OID_SYSTABLE_NUMOFBLOCKS] = OID_SYSTABLE_NUMOFBLOCKS;
|
||||
oids[OID_SYSTABLE_AUTOINCREMENT] = OID_SYSTABLE_AUTOINCREMENT;
|
||||
}
|
||||
|
||||
fWriteEngine.setTransId(1);
|
||||
fWriteEngine.setBulkFlag(true);
|
||||
cout << "Creating SYSTABLE" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
// TableName
|
||||
msg << " Creating TableName column OID: " << OID_SYSTABLE_TABLENAME;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_TABLENAME, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
msg << " Creating TableName column dictionary";
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSTABLE_TABLENAME, 65, dbRoot, partition, segment, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// Schema
|
||||
msg << " Creating Schema column OID: " << OID_SYSTABLE_SCHEMA;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_SCHEMA, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
|
||||
msg.str(" Creating Schema column dictionary");
|
||||
cout << msg.str() << endl;
|
||||
//Dictionary files
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSTABLE_SCHEMA, 65, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str(" Creating Schema column dictionary");
|
||||
cout << msg.str() << endl;
|
||||
//Dictionary files
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSTABLE_SCHEMA, 65, dbRoot, partition, segment, compressionType);
|
||||
|
||||
// ObjectId
|
||||
msg << " Creating ObjectId column OID: " <<OID_SYSTABLE_OBJECTID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_OBJECTID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
// CreateDate
|
||||
msg << " Creating CreateDate column OID: "<<OID_SYSTABLE_CREATEDATE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_CREATEDATE, CalpontSystemCatalog::DATE, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// LastUpdateDate
|
||||
msg << " Creating LastUpdate column OID: "<<OID_SYSTABLE_LASTUPDATE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_LASTUPDATE, CalpontSystemCatalog::DATE, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
// INIT
|
||||
msg << " Creating INIT column OID: "<<OID_SYSTABLE_INIT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_INIT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
// ObjectId
|
||||
msg << " Creating ObjectId column OID: " << OID_SYSTABLE_OBJECTID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_OBJECTID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
// NEXT
|
||||
msg << " Creating NEXT column OID: "<<OID_SYSTABLE_NEXT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_NEXT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
//NUMOFROWS
|
||||
msg << " Creating NUMOFROWS column OID: "<<OID_SYSTABLE_NUMOFROWS;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_NUMOFROWS, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
//AVGROWLEN
|
||||
msg << " Creating AVGROWLEN column OID: "<<OID_SYSTABLE_AVGROWLEN;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_AVGROWLEN, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
//NUMOFBLOCKS
|
||||
msg << " Creating NUMOFBLOCKS column OID: "<<OID_SYSTABLE_NUMOFBLOCKS;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_NUMOFBLOCKS, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
//AUTOINCREMENT
|
||||
msg << " Creating AUTOINCREMENT column OID: "<<OID_SYSTABLE_AUTOINCREMENT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_AUTOINCREMENT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSCOLUMN table
|
||||
//------------------------------------------------------------------------------
|
||||
//dbRoot++;
|
||||
//if (dbRoot > dbRootCount)
|
||||
// dbRoot = 1;
|
||||
// CreateDate
|
||||
msg << " Creating CreateDate column OID: " << OID_SYSTABLE_CREATEDATE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_CREATEDATE, CalpontSystemCatalog::DATE, 4, dbRoot, partition, compressionType );
|
||||
|
||||
//SYSCOLUMN
|
||||
if( rm->useHdfs() )
|
||||
{
|
||||
oids[OID_SYSCOLUMN_SCHEMA] = OID_SYSCOLUMN_SCHEMA;
|
||||
oids[DICTOID_SYSCOLUMN_SCHEMA] = DICTOID_SYSCOLUMN_SCHEMA;
|
||||
oids[OID_SYSCOLUMN_TABLENAME] = OID_SYSCOLUMN_TABLENAME;
|
||||
oids[DICTOID_SYSCOLUMN_TABLENAME] = DICTOID_SYSCOLUMN_TABLENAME;
|
||||
oids[OID_SYSCOLUMN_COLNAME] = OID_SYSCOLUMN_COLNAME;
|
||||
oids[DICTOID_SYSCOLUMN_COLNAME] = DICTOID_SYSCOLUMN_COLNAME;
|
||||
oids[OID_SYSCOLUMN_OBJECTID] = OID_SYSCOLUMN_OBJECTID;
|
||||
oids[OID_SYSCOLUMN_DICTOID] = OID_SYSCOLUMN_DICTOID;
|
||||
oids[OID_SYSCOLUMN_LISTOBJID] = OID_SYSCOLUMN_LISTOBJID;
|
||||
oids[OID_SYSCOLUMN_TREEOBJID] = OID_SYSCOLUMN_TREEOBJID;
|
||||
oids[OID_SYSCOLUMN_DATATYPE] = OID_SYSCOLUMN_DATATYPE;
|
||||
oids[OID_SYSCOLUMN_COLUMNLEN] = OID_SYSCOLUMN_COLUMNLEN;
|
||||
oids[OID_SYSCOLUMN_COLUMNPOS] = OID_SYSCOLUMN_COLUMNPOS;
|
||||
oids[OID_SYSCOLUMN_LASTUPDATE] = OID_SYSCOLUMN_LASTUPDATE;
|
||||
oids[OID_SYSCOLUMN_DEFAULTVAL] = OID_SYSCOLUMN_DEFAULTVAL;
|
||||
oids[DICTOID_SYSCOLUMN_DEFAULTVAL] = DICTOID_SYSCOLUMN_DEFAULTVAL;
|
||||
oids[OID_SYSCOLUMN_NULLABLE] = OID_SYSCOLUMN_NULLABLE;
|
||||
oids[OID_SYSCOLUMN_SCALE] = OID_SYSCOLUMN_SCALE;
|
||||
oids[OID_SYSCOLUMN_PRECISION] = OID_SYSCOLUMN_PRECISION;
|
||||
oids[OID_SYSCOLUMN_AUTOINC] = OID_SYSCOLUMN_AUTOINC;
|
||||
oids[OID_SYSCOLUMN_DISTCOUNT] = OID_SYSCOLUMN_DISTCOUNT;
|
||||
oids[OID_SYSCOLUMN_NULLCOUNT] = OID_SYSCOLUMN_NULLCOUNT;
|
||||
oids[OID_SYSCOLUMN_MINVALUE] = OID_SYSCOLUMN_MINVALUE;
|
||||
oids[DICTOID_SYSCOLUMN_MINVALUE] = DICTOID_SYSCOLUMN_MINVALUE;
|
||||
oids[OID_SYSCOLUMN_MAXVALUE] = OID_SYSCOLUMN_MAXVALUE;
|
||||
oids[DICTOID_SYSCOLUMN_MAXVALUE] = DICTOID_SYSCOLUMN_MAXVALUE;
|
||||
oids[OID_SYSCOLUMN_COMPRESSIONTYPE] = OID_SYSCOLUMN_COMPRESSIONTYPE;
|
||||
oids[OID_SYSCOLUMN_NEXTVALUE] = OID_SYSCOLUMN_NEXTVALUE;
|
||||
}
|
||||
cout<< endl;
|
||||
cout << "Creating SYSCOLUMN" << endl;
|
||||
// Schema
|
||||
cout << "---------------------------------------" << endl;
|
||||
msg << " Creating Schema column OID: "<<OID_SYSCOLUMN_SCHEMA;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_SCHEMA, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str(" Creating Schema column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_SCHEMA, 65, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
// TableName
|
||||
msg << " Creating TableName column OID: "<<OID_SYSCOLUMN_TABLENAME;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_TABLENAME, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
// LastUpdateDate
|
||||
msg << " Creating LastUpdate column OID: " << OID_SYSTABLE_LASTUPDATE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_LASTUPDATE, CalpontSystemCatalog::DATE, 4, dbRoot, partition, compressionType );
|
||||
|
||||
msg.str(" Creating TableName column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_TABLENAME, 65, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// ColumnName
|
||||
msg << " Creating ColumnName column OID: "<<OID_SYSCOLUMN_COLNAME;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COLNAME, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
msg.str(" Creating ColumnName column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_COLNAME, 65, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
// INIT
|
||||
msg << " Creating INIT column OID: " << OID_SYSTABLE_INIT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_INIT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
// ObjectID
|
||||
msg << " Creating ObjectID column OID: "<<OID_SYSCOLUMN_OBJECTID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_OBJECTID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// DictOID
|
||||
msg << " Creating DictOID column OID: "<<OID_SYSCOLUMN_DICTOID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DICTOID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
// ListOID
|
||||
msg << " Creating ListOID column OID: "<< OID_SYSCOLUMN_LISTOBJID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_LISTOBJID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
// NEXT
|
||||
msg << " Creating NEXT column OID: " << OID_SYSTABLE_NEXT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_NEXT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
// TreeOID
|
||||
msg << " Creating TreeOID column OID: "<< OID_SYSCOLUMN_TREEOBJID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_TREEOBJID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// DataType
|
||||
msg << " Creating DataType column OID: "<< OID_SYSCOLUMN_DATATYPE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DATATYPE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
// ColumnLength
|
||||
msg << " Creating ColumnLength column OID: "<< OID_SYSCOLUMN_COLUMNLEN;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COLUMNLEN, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
//NUMOFROWS
|
||||
msg << " Creating NUMOFROWS column OID: " << OID_SYSTABLE_NUMOFROWS;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_NUMOFROWS, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
// ColumnPos
|
||||
msg << " Creating ColumnPos column OID: "<<OID_SYSCOLUMN_COLUMNPOS;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COLUMNPOS, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
// LastUpdate
|
||||
msg << " Creating LastUpdate column OID: "<< OID_SYSCOLUMN_LASTUPDATE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_LASTUPDATE, CalpontSystemCatalog::DATE, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// DefaultValue
|
||||
msg << " Creating DefaultValue column OID: "<< OID_SYSCOLUMN_DEFAULTVAL;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DEFAULTVAL, CalpontSystemCatalog::VARCHAR, 8, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
msg.str(" Creating DefaultValue column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_DEFAULTVAL, 9, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
//AVGROWLEN
|
||||
msg << " Creating AVGROWLEN column OID: " << OID_SYSTABLE_AVGROWLEN;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_AVGROWLEN, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
// Nullable
|
||||
msg << " Creating Nullable column OID: "<<OID_SYSCOLUMN_NULLABLE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_NULLABLE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// Scale
|
||||
msg << " Creating Scale column OID: "<<OID_SYSCOLUMN_SCALE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_SCALE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
msg.str("");
|
||||
|
||||
// Precision
|
||||
msg << " Creating Precision column OID: "<<OID_SYSCOLUMN_PRECISION;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_PRECISION, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
//NUMOFBLOCKS
|
||||
msg << " Creating NUMOFBLOCKS column OID: " << OID_SYSTABLE_NUMOFBLOCKS;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_NUMOFBLOCKS, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
// AutoInc
|
||||
msg << " Creating AutoInc column OID: "<<OID_SYSCOLUMN_AUTOINC;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_AUTOINC, CalpontSystemCatalog::CHAR, 1, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// DISTCOUNT
|
||||
msg << " Creating DISTCOUNT column OID: "<<OID_SYSCOLUMN_DISTCOUNT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DISTCOUNT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
// NULLCOUNT
|
||||
msg << " Creating NULLCOUNT column OID: "<<OID_SYSCOLUMN_NULLCOUNT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_NULLCOUNT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
// MINVALUE
|
||||
msg << " Creating MINVALUE column OID: "<<OID_SYSCOLUMN_MINVALUE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_MINVALUE, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
msg.str(" Creating MINVALUE column dictionary...");
|
||||
cout << msg.str() << endl;
|
||||
//Dictionary files
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_MINVALUE, 65, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
// MAXVALUE
|
||||
msg << " Creating MAXVALUE column OID: "<<OID_SYSCOLUMN_MAXVALUE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_MAXVALUE, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
//AUTOINCREMENT
|
||||
msg << " Creating AUTOINCREMENT column OID: " << OID_SYSTABLE_AUTOINCREMENT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSTABLE_AUTOINCREMENT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
msg.str(" Creating MAXVALUE column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_MAXVALUE, 65, dbRoot, partition, segment, compressionType);
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// CompressionType
|
||||
msg << " Creating CompressionType column OID: "<<OID_SYSCOLUMN_COMPRESSIONTYPE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COMPRESSIONTYPE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
// nextvalue
|
||||
msg << " Creating NEXTVALUE column OID: "<<OID_SYSCOLUMN_NEXTVALUE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_NEXTVALUE, CalpontSystemCatalog::UBIGINT, 8, dbRoot, partition, compressionType );
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
msg.str("");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSCONSTRAINT table
|
||||
//------------------------------------------------------------------------------
|
||||
dbRoot++;
|
||||
if (dbRoot > dbRootCount)
|
||||
dbRoot = 1;
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSCOLUMN table
|
||||
//------------------------------------------------------------------------------
|
||||
//dbRoot++;
|
||||
//if (dbRoot > dbRootCount)
|
||||
// dbRoot = 1;
|
||||
|
||||
//SYSCOLUMN
|
||||
if ( rm->useHdfs() )
|
||||
{
|
||||
oids[OID_SYSCOLUMN_SCHEMA] = OID_SYSCOLUMN_SCHEMA;
|
||||
oids[DICTOID_SYSCOLUMN_SCHEMA] = DICTOID_SYSCOLUMN_SCHEMA;
|
||||
oids[OID_SYSCOLUMN_TABLENAME] = OID_SYSCOLUMN_TABLENAME;
|
||||
oids[DICTOID_SYSCOLUMN_TABLENAME] = DICTOID_SYSCOLUMN_TABLENAME;
|
||||
oids[OID_SYSCOLUMN_COLNAME] = OID_SYSCOLUMN_COLNAME;
|
||||
oids[DICTOID_SYSCOLUMN_COLNAME] = DICTOID_SYSCOLUMN_COLNAME;
|
||||
oids[OID_SYSCOLUMN_OBJECTID] = OID_SYSCOLUMN_OBJECTID;
|
||||
oids[OID_SYSCOLUMN_DICTOID] = OID_SYSCOLUMN_DICTOID;
|
||||
oids[OID_SYSCOLUMN_LISTOBJID] = OID_SYSCOLUMN_LISTOBJID;
|
||||
oids[OID_SYSCOLUMN_TREEOBJID] = OID_SYSCOLUMN_TREEOBJID;
|
||||
oids[OID_SYSCOLUMN_DATATYPE] = OID_SYSCOLUMN_DATATYPE;
|
||||
oids[OID_SYSCOLUMN_COLUMNLEN] = OID_SYSCOLUMN_COLUMNLEN;
|
||||
oids[OID_SYSCOLUMN_COLUMNPOS] = OID_SYSCOLUMN_COLUMNPOS;
|
||||
oids[OID_SYSCOLUMN_LASTUPDATE] = OID_SYSCOLUMN_LASTUPDATE;
|
||||
oids[OID_SYSCOLUMN_DEFAULTVAL] = OID_SYSCOLUMN_DEFAULTVAL;
|
||||
oids[DICTOID_SYSCOLUMN_DEFAULTVAL] = DICTOID_SYSCOLUMN_DEFAULTVAL;
|
||||
oids[OID_SYSCOLUMN_NULLABLE] = OID_SYSCOLUMN_NULLABLE;
|
||||
oids[OID_SYSCOLUMN_SCALE] = OID_SYSCOLUMN_SCALE;
|
||||
oids[OID_SYSCOLUMN_PRECISION] = OID_SYSCOLUMN_PRECISION;
|
||||
oids[OID_SYSCOLUMN_AUTOINC] = OID_SYSCOLUMN_AUTOINC;
|
||||
oids[OID_SYSCOLUMN_DISTCOUNT] = OID_SYSCOLUMN_DISTCOUNT;
|
||||
oids[OID_SYSCOLUMN_NULLCOUNT] = OID_SYSCOLUMN_NULLCOUNT;
|
||||
oids[OID_SYSCOLUMN_MINVALUE] = OID_SYSCOLUMN_MINVALUE;
|
||||
oids[DICTOID_SYSCOLUMN_MINVALUE] = DICTOID_SYSCOLUMN_MINVALUE;
|
||||
oids[OID_SYSCOLUMN_MAXVALUE] = OID_SYSCOLUMN_MAXVALUE;
|
||||
oids[DICTOID_SYSCOLUMN_MAXVALUE] = DICTOID_SYSCOLUMN_MAXVALUE;
|
||||
oids[OID_SYSCOLUMN_COMPRESSIONTYPE] = OID_SYSCOLUMN_COMPRESSIONTYPE;
|
||||
oids[OID_SYSCOLUMN_NEXTVALUE] = OID_SYSCOLUMN_NEXTVALUE;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
cout << "Creating SYSCOLUMN" << endl;
|
||||
// Schema
|
||||
cout << "---------------------------------------" << endl;
|
||||
msg << " Creating Schema column OID: " << OID_SYSCOLUMN_SCHEMA;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_SCHEMA, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str(" Creating Schema column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_SCHEMA, 65, dbRoot, partition, segment, compressionType);
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// TableName
|
||||
msg << " Creating TableName column OID: " << OID_SYSCOLUMN_TABLENAME;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_TABLENAME, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str(" Creating TableName column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_TABLENAME, 65, dbRoot, partition, segment, compressionType);
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// ColumnName
|
||||
msg << " Creating ColumnName column OID: " << OID_SYSCOLUMN_COLNAME;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COLNAME, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str(" Creating ColumnName column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_COLNAME, 65, dbRoot, partition, segment, compressionType);
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// ObjectID
|
||||
msg << " Creating ObjectID column OID: " << OID_SYSCOLUMN_OBJECTID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_OBJECTID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// DictOID
|
||||
msg << " Creating DictOID column OID: " << OID_SYSCOLUMN_DICTOID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DICTOID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// ListOID
|
||||
msg << " Creating ListOID column OID: " << OID_SYSCOLUMN_LISTOBJID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_LISTOBJID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// TreeOID
|
||||
msg << " Creating TreeOID column OID: " << OID_SYSCOLUMN_TREEOBJID;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_TREEOBJID, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// DataType
|
||||
msg << " Creating DataType column OID: " << OID_SYSCOLUMN_DATATYPE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DATATYPE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// ColumnLength
|
||||
msg << " Creating ColumnLength column OID: " << OID_SYSCOLUMN_COLUMNLEN;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COLUMNLEN, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// ColumnPos
|
||||
msg << " Creating ColumnPos column OID: " << OID_SYSCOLUMN_COLUMNPOS;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COLUMNPOS, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// LastUpdate
|
||||
msg << " Creating LastUpdate column OID: " << OID_SYSCOLUMN_LASTUPDATE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_LASTUPDATE, CalpontSystemCatalog::DATE, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// DefaultValue
|
||||
msg << " Creating DefaultValue column OID: " << OID_SYSCOLUMN_DEFAULTVAL;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DEFAULTVAL, CalpontSystemCatalog::VARCHAR, 8, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
msg.str(" Creating DefaultValue column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_DEFAULTVAL, 9, dbRoot, partition, segment, compressionType);
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// Nullable
|
||||
msg << " Creating Nullable column OID: " << OID_SYSCOLUMN_NULLABLE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_NULLABLE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// Scale
|
||||
msg << " Creating Scale column OID: " << OID_SYSCOLUMN_SCALE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_SCALE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// Precision
|
||||
msg << " Creating Precision column OID: " << OID_SYSCOLUMN_PRECISION;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_PRECISION, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// AutoInc
|
||||
msg << " Creating AutoInc column OID: " << OID_SYSCOLUMN_AUTOINC;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_AUTOINC, CalpontSystemCatalog::CHAR, 1, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// DISTCOUNT
|
||||
msg << " Creating DISTCOUNT column OID: " << OID_SYSCOLUMN_DISTCOUNT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_DISTCOUNT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// NULLCOUNT
|
||||
msg << " Creating NULLCOUNT column OID: " << OID_SYSCOLUMN_NULLCOUNT;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_NULLCOUNT, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// MINVALUE
|
||||
msg << " Creating MINVALUE column OID: " << OID_SYSCOLUMN_MINVALUE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_MINVALUE, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str(" Creating MINVALUE column dictionary...");
|
||||
cout << msg.str() << endl;
|
||||
//Dictionary files
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_MINVALUE, 65, dbRoot, partition, segment, compressionType);
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// MAXVALUE
|
||||
msg << " Creating MAXVALUE column OID: " << OID_SYSCOLUMN_MAXVALUE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_MAXVALUE, CalpontSystemCatalog::VARCHAR, 40, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str(" Creating MAXVALUE column dictionary...");
|
||||
//Dictionary files
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createDctnry(txnID, DICTOID_SYSCOLUMN_MAXVALUE, 65, dbRoot, partition, segment, compressionType);
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
// CompressionType
|
||||
msg << " Creating CompressionType column OID: " << OID_SYSCOLUMN_COMPRESSIONTYPE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_COMPRESSIONTYPE, CalpontSystemCatalog::INT, 4, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
// nextvalue
|
||||
msg << " Creating NEXTVALUE column OID: " << OID_SYSCOLUMN_NEXTVALUE;
|
||||
cout << msg.str() << endl;
|
||||
rc = fWriteEngine.createColumn( txnID, OID_SYSCOLUMN_NEXTVALUE, CalpontSystemCatalog::UBIGINT, 8, dbRoot, partition, compressionType );
|
||||
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
msg.str("");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Create SYSCONSTRAINT table
|
||||
//------------------------------------------------------------------------------
|
||||
dbRoot++;
|
||||
|
||||
if (dbRoot > dbRootCount)
|
||||
dbRoot = 1;
|
||||
|
||||
//flush data files
|
||||
fWriteEngine.flushDataFiles(rc, 1, oids);
|
||||
// save brm
|
||||
msg.str(" BRMWrapper saving state ");
|
||||
fWriteEngine.flushDataFiles(rc, 1, oids);
|
||||
// save brm
|
||||
msg.str(" BRMWrapper saving state ");
|
||||
|
||||
rc = BRMWrapper::getInstance()->saveState();
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
timeval endTime;
|
||||
gettimeofday( &endTime, 0);
|
||||
double elapsedTime =
|
||||
(endTime.tv_sec + (endTime.tv_usec / 1000000.0)) -
|
||||
(startTime.tv_sec + (startTime.tv_usec / 1000000.0));
|
||||
cout << "System Catalog creation took: " << elapsedTime <<
|
||||
" seconds to complete." << endl;
|
||||
rc = BRMWrapper::getInstance()->saveState();
|
||||
|
||||
cout << endl;
|
||||
cout << "System Catalog created" << endl;
|
||||
cout << endl;
|
||||
if (rc) throw runtime_error(msg.str() + ec.errorString(rc));
|
||||
|
||||
timeval endTime;
|
||||
gettimeofday( &endTime, 0);
|
||||
double elapsedTime =
|
||||
(endTime.tv_sec + (endTime.tv_usec / 1000000.0)) -
|
||||
(startTime.tv_sec + (startTime.tv_usec / 1000000.0));
|
||||
cout << "System Catalog creation took: " << elapsedTime <<
|
||||
" seconds to complete." << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "System Catalog created" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void SystemCatalog::remove()
|
||||
{
|
||||
ColumnOpCompress0 colOp;
|
||||
ColumnOpCompress0 colOp;
|
||||
|
||||
for ( int c = 1001; c <= 1074; c++ )
|
||||
colOp.deleteFile( c );
|
||||
for ( int d = 2001; d <= 2312; d++ )
|
||||
colOp.deleteFile( d );
|
||||
for ( int c = 1001; c <= 1074; c++ )
|
||||
colOp.deleteFile( c );
|
||||
|
||||
for ( int d = 2001; d <= 2312; d++ )
|
||||
colOp.deleteFile( d );
|
||||
|
||||
}
|
||||
|
@ -28,12 +28,12 @@
|
||||
class SystemCatalog
|
||||
{
|
||||
public:
|
||||
void build();
|
||||
void remove();
|
||||
void build();
|
||||
void remove();
|
||||
|
||||
private:
|
||||
WriteEngine::WriteEngineWrapper fWriteEngine;
|
||||
|
||||
WriteEngine::WriteEngineWrapper fWriteEngine;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ void TpchPopulate::populateFromFile(std::string tableName, string& fileName)
|
||||
|
||||
std::string dmlStatement;
|
||||
ifstream ifdml(fileName.c_str(), ios::in);
|
||||
|
||||
if (ifdml)
|
||||
{
|
||||
while (ifdml.good())
|
||||
@ -46,9 +47,11 @@ void TpchPopulate::populateFromFile(std::string tableName, string& fileName)
|
||||
char line[256];
|
||||
line[0] = '\0';;
|
||||
ifdml.getline(line, 256);
|
||||
|
||||
//if ( line[0] == '\0' )
|
||||
if ( strlen(line) == 0 )
|
||||
continue;
|
||||
continue;
|
||||
|
||||
dmlStatement = "insert into ";
|
||||
dmlStatement += tableName;
|
||||
dmlStatement += " values(";
|
||||
@ -85,7 +88,7 @@ void TpchPopulate::populate_part()
|
||||
|
||||
dmlStatement = "insert into tpch.part values(5, 'forest blush chiffon thistle chocolate', 'Manufac#3', 'Brand#32', 'STANDARD POLISHED TIN', 15, 'SM PKG', 905.00, 'pending, spe');";
|
||||
insert(dmlStatement);
|
||||
|
||||
|
||||
cout << endl;
|
||||
cout << "Commiting inserting to tpch.part table ..." << endl;
|
||||
std::string command("COMMIT;");
|
||||
@ -98,10 +101,11 @@ void TpchPopulate::populate_part()
|
||||
|
||||
if ( DMLPackageProcessor::NO_ERROR != result.result )
|
||||
{
|
||||
cout << "Command process failed!" << endl;
|
||||
cout << "Command process failed!" << endl;
|
||||
}
|
||||
|
||||
delete pkgProcPtr;
|
||||
delete dmlCommandPkgPtr;
|
||||
delete dmlCommandPkgPtr;
|
||||
|
||||
cout << endl;
|
||||
cout << "Finished Populating tpch.part table" << endl;
|
||||
@ -123,57 +127,57 @@ void TpchPopulate::populate_customer()
|
||||
|
||||
void TpchPopulate::populate_tpch()
|
||||
{
|
||||
std::string tableName;
|
||||
std::string filePath;
|
||||
std::string tableName;
|
||||
std::string filePath;
|
||||
cout << endl;
|
||||
cout << "Populating region table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.region";
|
||||
filePath = "region.tbl";
|
||||
filePath = "region.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating nation table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.nation";
|
||||
filePath = "nation.tbl";
|
||||
filePath = "nation.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating customer table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.customer";
|
||||
filePath = "customer.tbl";
|
||||
filePath = "customer.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating orders table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.orders";
|
||||
filePath = "orders.tbl";
|
||||
filePath = "orders.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating part table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "part.nation";
|
||||
filePath = "part.tbl";
|
||||
filePath = "part.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating supplier table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.supplier";
|
||||
filePath = "supplier.tbl";
|
||||
filePath = "supplier.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating partsupp table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.partsupp";
|
||||
filePath = "partsupp.tbl";
|
||||
filePath = "partsupp.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << "Populating lineitem table" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
tableName = "tpch.lineitem";
|
||||
filePath = "lineitem.tbl";
|
||||
filePath = "lineitem.tbl";
|
||||
populateFromFile(tableName, filePath );
|
||||
|
||||
|
||||
cout << endl;
|
||||
cout << "Finished Populating TPCH tables." << endl;
|
||||
|
||||
@ -185,7 +189,7 @@ void TpchPopulate::insert(string insertStmt)
|
||||
cout << insertStmt << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
|
||||
boost::timer theTimer;
|
||||
boost::timer theTimer;
|
||||
VendorDMLStatement dmlStmt(insertStmt, 1);
|
||||
CalpontDMLPackage* dmlPkgPtr = CalpontDMLFactory::makeCalpontDMLPackage(dmlStmt);
|
||||
|
||||
@ -193,6 +197,7 @@ void TpchPopulate::insert(string insertStmt)
|
||||
|
||||
//pkgProcPtr->setDebugLevel(DMLPackageProcessor::VERBOSE);
|
||||
DMLPackageProcessor::DMLResult result = pkgProcPtr->processPackage( *dmlPkgPtr );
|
||||
|
||||
if ( DMLPackageProcessor::NO_ERROR != result.result )
|
||||
{
|
||||
cout << "Insert failed!" << endl;
|
||||
@ -202,7 +207,7 @@ void TpchPopulate::insert(string insertStmt)
|
||||
cout << "Insert successful" << endl;
|
||||
}
|
||||
|
||||
cout << "Insert took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
cout << "Insert took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
|
||||
delete pkgProcPtr;
|
||||
delete dmlPkgPtr;
|
||||
|
@ -30,9 +30,9 @@ class TpchPopulate
|
||||
|
||||
public:
|
||||
void populate_part();
|
||||
void populate_customer();
|
||||
void populate_tpch();
|
||||
void populateFromFile(std::string tableName, std::string& fileName);
|
||||
void populate_customer();
|
||||
void populate_tpch();
|
||||
void populateFromFile(std::string tableName, std::string& fileName);
|
||||
protected:
|
||||
|
||||
|
||||
|
@ -75,44 +75,44 @@ void TpchSchema::build()
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create table tpch.partsupp( ps_partkey integer NOT NULL, ps_suppkey integer,ps_availqty integer , ps_supplycost number(9,2) , ps_comment varchar(199))";
|
||||
buildTable(createStmt);
|
||||
|
||||
|
||||
cout << endl;
|
||||
cout << "create table tpch.lineitem" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create table tpch.lineitem( l_orderkey integer NOT NULL , l_partkey integer NOT NULL,l_suppkey integer NOT NULL, l_linenumber integer NOT NULL, l_quantity number(9,2) NOT NULL,l_extendedprice number(9,2) NOT NULL, l_discount number(9,2) NOT NULL, l_tax number(9,2) NOT NULL, l_returnflag char(1) , l_linestatus char(1) , l_shipdate date , l_commitdate date,l_receiptdate date , l_shipinstruct char(25), l_shipmode char(10),l_comment varchar(44))";
|
||||
buildTable(createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
#if 0
|
||||
cout << "create index l_partkey_idx ON tpch.lineitem(l_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_partkey_idx ON tpch.lineitem(l_partkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index l_suppkey_idx ON tpch.lineitem(l_suppkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_suppkey_idx ON tpch.lineitem(l_suppkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
cout << "create index l_orderkey_idx ON tpch.lineitem(l_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_orderkey_idx ON tpch.lineitem(l_orderkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index o_orderkey_idx ON tpch.orders(o_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index o_orderkey_idx ON tpch.orders(o_orderkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index p_partkey_idx ON tpch.part(p_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index p_partkey_idx ON tpch.part(p_partkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
|
||||
cout << endl;
|
||||
#endif
|
||||
cout << "Finished creating tpch database" << endl;
|
||||
@ -127,93 +127,93 @@ void TpchSchema::buildTpchTables(std::string schema)
|
||||
std::string createStart("create table ");
|
||||
std::string createFirst = createStart + schema;
|
||||
std::string createStmt = ".region( r_regionkey integer NOT NULL, r_name char(25) ,r_comment varchar(152));";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".nation" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".nation( n_nationkey integer NOT NULL , n_name char(25) ,n_regionkey integer NOT NULL,n_comment varchar(152))";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".customer" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".customer(c_custkey integer NOT NULL, c_name varchar(25) ,c_address varchar(40), c_nationkey integer ,c_phone char(15) ,c_acctbal number(9,2) , c_mktsegment char(10) , c_comment varchar(117))";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".orders" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".orders(o_orderkey integer NOT NULL, o_custkey integer , o_orderstatus char(1), o_totalprice number(9,2) , o_orderdate date , o_orderpriority char(15) , o_clerk char(15), o_shippriority integer,o_comment varchar(79))";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".part" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".part( p_partkey integer NOT NULL ,p_name varchar(55) , p_mfgr char(25), p_brand char(10) , p_type varchar(25) , p_size integer , p_container char(10) ,p_retailprice number(9,2) , p_comment varchar(23))";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".supplier" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".supplier( s_suppkey integer NOT NULL, s_name char(25) , s_address varchar(40), s_nationkey integer , s_phone char(15) , s_acctbal number(9,2), s_comment varchar(101))";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".partsupp" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".partsupp( ps_partkey integer NOT NULL, ps_suppkey integer,ps_availqty integer , ps_supplycost number(9,2) , ps_comment varchar(199))";
|
||||
buildTable(createFirst+createStmt);
|
||||
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << "create table " << schema << ".lineitem" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem( l_orderkey integer NOT NULL , l_partkey integer NOT NULL,l_suppkey integer NOT NULL, l_linenumber integer NOT NULL, l_quantity number(9,2) NOT NULL,l_extendedprice number(9,2) NOT NULL, l_discount number(9,2) NOT NULL, l_tax number(9,2) NOT NULL, l_returnflag char(1) , l_linestatus char(1) , l_shipdate date , l_commitdate date,l_receiptdate date , l_shipinstruct char(25), l_shipmode char(10),l_comment varchar(44))";
|
||||
buildTable(createFirst+createStmt);
|
||||
buildTable(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
#if 0
|
||||
createStart = "create index ";
|
||||
std::string createIndex("l_partkey_idx");
|
||||
std::string on(" ON ");
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index l_partkey_idx ON " << schema << ".lineitem(l_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem(l_partkey)";
|
||||
createindex(createFirst+createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "l_suppkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index l_suppkey_idx ON " << schema << ".lineitem(l_suppkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem(l_suppkey)";
|
||||
createindex(createFirst+createStmt);
|
||||
createStart = "create index ";
|
||||
std::string createIndex("l_partkey_idx");
|
||||
std::string on(" ON ");
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index l_partkey_idx ON " << schema << ".lineitem(l_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem(l_partkey)";
|
||||
createindex(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "l_suppkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index l_suppkey_idx ON " << schema << ".lineitem(l_suppkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem(l_suppkey)";
|
||||
createindex(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "l_orderkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index l_orderkey_idx ON " << schema << ".lineitem(l_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem(l_orderkey)";
|
||||
createindex(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "o_orderkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index o_orderkey_idx ON " << schema << ".orders(o_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".orders(o_orderkey)";
|
||||
createindex(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "p_partkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index p_partkey_idx ON " << schema << ".part(p_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".part(p_partkey)";
|
||||
createindex(createFirst + createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "l_orderkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index l_orderkey_idx ON " << schema << ".lineitem(l_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".lineitem(l_orderkey)";
|
||||
createindex(createFirst+createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "o_orderkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index o_orderkey_idx ON " << schema << ".orders(o_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".orders(o_orderkey)";
|
||||
createindex(createFirst+createStmt);
|
||||
|
||||
cout << endl;
|
||||
createIndex = "p_partkey_idx";
|
||||
createFirst = createStart + createIndex + on + schema;
|
||||
cout << "create index p_partkey_idx ON " << schema << ".part(p_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = ".part(p_partkey)";
|
||||
createindex(createFirst+createStmt);
|
||||
|
||||
cout << endl;
|
||||
#endif
|
||||
cout << "Finished creating tpch database" << endl;
|
||||
@ -263,39 +263,39 @@ void TpchSchema::buildMultiColumnIndex()
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create table tpch.partsupp( ps_partkey integer NOT NULL, ps_suppkey integer,ps_availqty integer , ps_supplycost number(9,2) , ps_comment varchar(199))";
|
||||
buildTable(createStmt);
|
||||
|
||||
|
||||
cout << endl;
|
||||
cout << "create table tpch.lineitem" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create table tpch.lineitem( l_orderkey integer NOT NULL , l_partkey integer NOT NULL,l_suppkey integer NOT NULL, l_linenumber integer NOT NULL, l_quantity number(9,2) NOT NULL,l_extendedprice number(9,2) NOT NULL, l_discount number(9,2) NOT NULL, l_tax number(9,2) NOT NULL, l_returnflag char(1) , l_linestatus char(1) , l_shipdate date , l_commitdate date,l_receiptdate date , l_shipinstruct char(25), l_shipmode char(10),l_comment varchar(44))";
|
||||
buildTable(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
#if 0
|
||||
cout << "create index l_partkey_idx ON tpch.lineitem(l_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_partkey_idx ON tpch.lineitem(l_partkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index l_suppkey_idx ON tpch.lineitem(l_suppkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_suppkey_idx ON tpch.lineitem(l_suppkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
cout << "create index l_orderkey_idx ON tpch.lineitem(l_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_orderkey_idx ON tpch.lineitem(l_orderkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index TestMulticolKey ON tpch.lineitem(l_orderkey,l_linenumber )" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index TestMulticolKey ON tpch.lineitem(l_orderkey, l_linenumber)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index o_orderkey_idx ON tpch.orders(o_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index o_orderkey_idx ON tpch.orders(o_orderkey)";
|
||||
@ -350,7 +350,7 @@ void TpchSchema::buildTable()
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create table tpch.partsupp( ps_partkey integer NOT NULL, ps_suppkey integer,ps_availqty integer , ps_supplycost number(9,2) , ps_comment varchar(199))";
|
||||
buildTable(createStmt);
|
||||
|
||||
|
||||
cout << endl;
|
||||
cout << "create table tpch.lineitem" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
@ -362,95 +362,101 @@ void TpchSchema::buildTable()
|
||||
}
|
||||
void TpchSchema::buildTable(string createText)
|
||||
{
|
||||
cout << endl;
|
||||
cout << createText << endl;
|
||||
cout << endl;
|
||||
cout << createText << endl;
|
||||
|
||||
boost::timer theTimer;
|
||||
boost::timer theTimer;
|
||||
ddlpackage::SqlParser parser;
|
||||
parser.Parse(createText.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ddlpackage::ParseTree &ptree = parser.GetParseTree();
|
||||
const ddlpackage::ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
try
|
||||
{
|
||||
cout << ptree << endl;
|
||||
cout << ptree << endl;
|
||||
ddlpackageprocessor::CreateTableProcessor processor;
|
||||
processor.setDebugLevel(ddlpackageprocessor::CreateTableProcessor::VERBOSE);
|
||||
|
||||
ddlpackage::SqlStatement &stmt = *ptree.fList[0];
|
||||
ddlpackage::SqlStatement& stmt = *ptree.fList[0];
|
||||
ddlpackageprocessor::CreateTableProcessor::DDLResult result;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog( 1 );
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog( 1 );
|
||||
result = processor.processPackage(dynamic_cast<ddlpackage::CreateTableStatement&>(stmt));
|
||||
systemCatalogPtr->removeCalpontSystemCatalog(1);
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
cout << "Create table took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
|
||||
cout << "Create table took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void TpchSchema::createindex(string createText)
|
||||
{
|
||||
cout << endl;
|
||||
cout << createText << endl;
|
||||
cout << endl;
|
||||
cout << createText << endl;
|
||||
|
||||
boost::timer theTimer;
|
||||
boost::timer theTimer;
|
||||
ddlpackage::SqlParser parser;
|
||||
parser.Parse(createText.c_str());
|
||||
|
||||
if (parser.Good())
|
||||
{
|
||||
const ddlpackage::ParseTree &ptree = parser.GetParseTree();
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
//processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
const ddlpackage::ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
SqlStatement &stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog( 1 );
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
systemCatalogPtr->removeCalpontSystemCatalog(1);
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
try
|
||||
{
|
||||
CreateIndexProcessor processor;
|
||||
//processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog( 1 );
|
||||
result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
systemCatalogPtr->removeCalpontSystemCatalog(1);
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
cout << "Create index took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
|
||||
cout << "Create index took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
}
|
||||
|
||||
void TpchSchema::buildIndex()
|
||||
{
|
||||
std::string createStmt;
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index l_partkey_idx ON tpch.lineitem(l_partkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_partkey_idx ON tpch.lineitem(l_partkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index l_suppkey_idx ON tpch.lineitem(l_suppkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_suppkey_idx ON tpch.lineitem(l_suppkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
cout << "create index l_orderkey_idx ON tpch.lineitem(l_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index l_orderkey_idx ON tpch.lineitem(l_orderkey)";
|
||||
createindex(createStmt);
|
||||
|
||||
cout << endl;
|
||||
|
||||
cout << endl;
|
||||
cout << "create index o_orderkey_idx ON tpch.orders(o_orderkey)" << endl;
|
||||
cout << "---------------------------------------" << endl;
|
||||
createStmt = "create index o_orderkey_idx ON tpch.orders(o_orderkey)";
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
void buildTpchTables(std::string schema);
|
||||
void buildTable();
|
||||
void buildMultiColumnIndex();
|
||||
void buildIndex();
|
||||
void buildIndex();
|
||||
protected:
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user