Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 12e37678 authored by Axel Auweter's avatar Axel Auweter
Browse files

Some speedups through native Thrift API instead of CQL3. Some more speedups...

Some speedups through native Thrift API instead of CQL3. Some more speedups through bigint timestamps instead of Cassandra timestamps.
parent 2dcede03
......@@ -16,6 +16,7 @@
#include <signal.h>
#include <sys/time.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <thrift/Thrift.h>
#include <thrift/transport/TTransport.h>
......@@ -43,22 +44,68 @@ void sigHandler(int sig) {
keepRunning = 0;
}
static inline string convert(void* ptr, size_t len) {
switch (len) {
case 4:
*((uint32_t*)ptr) = __builtin_bswap32(*((uint32_t*)ptr));
break;
case 8:
*((uint64_t*)ptr) = __builtin_bswap64(*((uint64_t*)ptr));
break;
default:
// Do nothing and hope for the best...
break;
}
string res((char*)ptr, len);
return res;
}
void mqttOnMessage(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message) {
msgCtr++;
try {
CqlResult res;
std::string query;
std::stringstream datestr, sidstr;
#if 0
time_t t = time(NULL);
struct tm *now = localtime(&t);
datestr << "'" << (now->tm_year + 1900) << "-" << (now->tm_mon + 1)
<< "-" << (now->tm_mday) << " " << (now->tm_hour) << ":"
<< (now->tm_min) << ":" << (now->tm_sec) << "'";
sidstr << msgCtr;
#else
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
boost::posix_time::time_duration diff = now - epoch;
//datestr << diff.total_nanoseconds();
#endif
//sidstr << msgCtr;
#if 0
query = "INSERT INTO sensordata (sid, ts, value) VALUES ( " + sidstr.str() + ", " + datestr.str() + ", 3.141 );";
myClient->execute_cql3_query(res, query, Compression::NONE, ConsistencyLevel::ONE);
#else
ColumnParent cparent;
cparent.column_family = "sensordata";
Column c;
string key, name, value;
uint64_t ts = diff.total_nanoseconds();
uint32_t sid = msgCtr;
key = convert(&sid, sizeof(msgCtr));
name = convert(&ts, sizeof(ts));
float tmp = 3.141;
value = convert(&tmp, 4);
c.name = name;
c.value = value;
c.__isset.value = true;
c.timestamp = ts/1000;
c.__isset.timestamp = true;
myClient->insert(key, cparent, c, ConsistencyLevel::ONE);
#endif
}
catch(TTransportException te){
cout << "TP Exception: " << te.what() << "[" << te.getType() << "]\n";
......@@ -133,7 +180,7 @@ int main(void) {
if (sensordataCf<0) {
cout << "Creating sensordata column familiy...\n";
query = "CREATE TABLE sensordata ( sid int, ts timestamp, value float, PRIMARY KEY (sid, ts)) WITH COMPACT STORAGE;";
query = "CREATE TABLE sensordata ( sid int, ts bigint, value float, PRIMARY KEY (sid, ts)) WITH COMPACT STORAGE;";
cout << "Sending CQL statement: " << query;
myClient->execute_cql3_query(res, query, Compression::NONE, ConsistencyLevel::ONE);
cout << " --> Success!\n";
......
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