Commit 7b5a524a authored by Micha Mueller's avatar Micha Mueller
Browse files

Allow for empty options when creating a Cassandra table

parent c3bd09b2
......@@ -110,7 +110,7 @@ protected:
* @param primaryKey A primary key definition (one or more fields)
* @param options A Cassandra WITH statement for keyspace generation
*/
void createColumnFamily(std::string name, std::string fields, std::string primaryKey, std::string options);
void createColumnFamily(std::string name, std::string fields, std::string primaryKey, std::string options = "");
public:
......
......@@ -264,8 +264,13 @@ void ConnectionImpl::createColumnFamily(std::string name, std::string fields, st
/* FIXME: Secure this and use proper types for fields, primaryKey, and options. */
query << "CREATE TABLE " << name
<< " ( " << fields << ", PRIMARY KEY (" << primaryKey << "))"
<< " WITH " << options << ";";
<< " ( " << fields << ", PRIMARY KEY (" << primaryKey << "))";
if (options != "") {
query << " WITH " << options;
}
query << ";";
executeSimpleQuery(query.str());
}
......@@ -412,7 +417,7 @@ bool ConnectionImpl::initSchema() {
}
if (!existsColumnFamily(CF_PUBLISHEDSENSORS)) {
std::cout << "Creating Column Familiy " CF_PUBLISHEDSENSORS "...\n";
std::cout << "Creating Column Family " CF_PUBLISHEDSENSORS "...\n";
createColumnFamily(CF_PUBLISHEDSENSORS,
"name varchar, " /* Public name */
"virtual boolean, " /* Whether it is a published physical sensor or a virtual sensor */
......@@ -445,7 +450,7 @@ bool ConnectionImpl::initSchema() {
}
if (!existsColumnFamily(CF_SENSORDATA)) {
std::cout << "Creating Column Familiy " CF_SENSORDATA "...\n";
std::cout << "Creating Column Family " CF_SENSORDATA "...\n";
createColumnFamily(CF_SENSORDATA,
"sid blob, ts bigint, value bigint",
"sid, ts",
......@@ -453,7 +458,7 @@ bool ConnectionImpl::initSchema() {
}
if (!existsColumnFamily(CF_VIRTUALSENSORS)) {
std::cout << "Creating Column Familiy " CF_VIRTUALSENSORS "...\n";
std::cout << "Creating Column Family " CF_VIRTUALSENSORS "...\n";
createColumnFamily(CF_VIRTUALSENSORS,
"sid blob, ts bigint, value bigint",
"sid, ts",
......@@ -474,7 +479,7 @@ bool ConnectionImpl::initSchema() {
}
if (!existsColumnFamily(CF_JOBDATA)) {
std::cout << "Creating Column Familiy " CF_JOBDATA "...\n";
std::cout << "Creating Column Family " CF_JOBDATA "...\n";
createColumnFamily(CF_JOBDATA,
"jid bigint, " /* Job Id */
"uid bigint, " /* User Id */
......@@ -482,8 +487,8 @@ bool ConnectionImpl::initSchema() {
"end_ts bigint, " /* End timestamp of the job */
"nodes set<varchar>", /* Set of nodes used by the job */
"jid", /* Make the "jid" column the primary key */
""); /* No further options required */
"jid" /* Make the "jid" column the primary key */
); /* No further options required */
}
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment