Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
7b5a524a
Commit
7b5a524a
authored
Jan 04, 2019
by
Micha Mueller
Browse files
Allow for empty options when creating a Cassandra table
parent
c3bd09b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/include_internal/connection_internal.h
View file @
7b5a524a
...
...
@@ -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:
...
...
lib/src/connection.cpp
View file @
7b5a524a
...
...
@@ -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 Famil
i
y "
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 Famil
i
y "
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 Famil
i
y "
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 Famil
i
y "
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment