Commit b8e1afc1 authored by Michael Ott's avatar Michael Ott
Browse files

Make parameters to SensorDataStore functions const where possible. Requires...

Make parameters to SensorDataStore functions const where possible. Requires recompiling of binaries that depend on libdcdb!
parent 419e47c2
...@@ -219,7 +219,7 @@ void CARestAPI::POST_write(endpointArgs) { ...@@ -219,7 +219,7 @@ void CARestAPI::POST_write(endpointArgs) {
DCDB::SensorId sid; DCDB::SensorId sid;
if (sid.mqttTopicConvert(mqttTopic)) { if (sid.mqttTopicConvert(mqttTopic)) {
_sensorCache->storeSensor(sid, ts.getRaw(), value); _sensorCache->storeSensor(sid, ts.getRaw(), value);
_sensorDataStore->insert(&sid, ts.getRaw(), value); _sensorDataStore->insert(sid, ts.getRaw(), value);
_influxCounter++; _influxCounter++;
if (_influxSettings->publish && (_influxSensors.find(sid.getId()) == _influxSensors.end())) { if (_influxSettings->publish && (_influxSensors.find(sid.getId()) == _influxSensors.end())) {
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
#endif #endif
SensorDataStoreReading(); SensorDataStoreReading();
SensorDataStoreReading(SensorId& sid, uint64_t ts, int64_t value); SensorDataStoreReading(const SensorId& sid, const uint64_t ts, const int64_t value);
virtual ~SensorDataStoreReading(); virtual ~SensorDataStoreReading();
}; };
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
* @param value The value of the sensor reading * @param value The value of the sensor reading
* @param ttl Time to live (in seconds) for the inserted reading * @param ttl Time to live (in seconds) for the inserted reading
*/ */
void insert(SensorId* sid, uint64_t ts, int64_t value, int64_t ttl=-1); void insert(const SensorId& sid, const uint64_t ts, const int64_t value, const int64_t ttl=-1);
/** /**
* @brief This function inserts a single sensor reading into * @brief This function inserts a single sensor reading into
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
* @param reading A SensorDataStoreReading object * @param reading A SensorDataStoreReading object
* @param ttl Time to live (in seconds) for the inserted reading * @param ttl Time to live (in seconds) for the inserted reading
*/ */
void insert(SensorDataStoreReading& reading, int64_t ttl=-1); void insert(const SensorDataStoreReading& reading, const int64_t ttl=-1);
/** /**
* @brief This function inserts a single sensor reading into * @brief This function inserts a single sensor reading into
...@@ -134,19 +134,19 @@ public: ...@@ -134,19 +134,19 @@ public:
* @param readings A list of SensorDataStoreReading object * @param readings A list of SensorDataStoreReading object
* @param ttl Time to live (in seconds) for the inserted readings * @param ttl Time to live (in seconds) for the inserted readings
*/ */
void insertBatch(std::list<SensorDataStoreReading>& readings, int64_t ttl=-1); void insertBatch(const std::list<SensorDataStoreReading>& readings, const int64_t ttl=-1);
/** /**
* @brief Set the TTL for newly inserted sensor data. * @brief Set the TTL for newly inserted sensor data.
* @param ttl The TTL for the sensor data in seconds. * @param ttl The TTL for the sensor data in seconds.
*/ */
void setTTL(uint64_t ttl); void setTTL(const uint64_t ttl);
/** /**
* @brief Enables or disables logging of Cassandra insert errors * @brief Enables or disables logging of Cassandra insert errors
* @param dl true to enable logging, false otherwise * @param dl true to enable logging, false otherwise
*/ */
void setDebugLog(bool dl); void setDebugLog(const bool dl);
/** /**
* @brief This function queries a sensor's values in * @brief This function queries a sensor's values in
...@@ -156,7 +156,7 @@ public: ...@@ -156,7 +156,7 @@ public:
* @param start Start of the time series. * @param start Start of the time series.
* @param end End of the time series. * @param end End of the time series.
*/ */
void query(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate=AGGREGATE_NONE); void query(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate=AGGREGATE_NONE);
/** /**
* @brief This function queries a the values of * @brief This function queries a the values of
...@@ -169,7 +169,7 @@ public: ...@@ -169,7 +169,7 @@ public:
* @param end End of the time series. * @param end End of the time series.
* @param storeSid If true, Sensor IDs will be retrieved for each reading. * @param storeSid If true, Sensor IDs will be retrieved for each reading.
*/ */
void query(std::list<SensorDataStoreReading>& result, std::list<SensorId>& sids, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate=AGGREGATE_NONE, bool storeSids=true); void query(std::list<SensorDataStoreReading>& result, const std::list<SensorId>& sids, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate=AGGREGATE_NONE, const bool storeSids=true);
/** /**
* @brief This function performs a fuzzy query and returns the * @brief This function performs a fuzzy query and returns the
...@@ -179,7 +179,7 @@ public: ...@@ -179,7 +179,7 @@ public:
* @param ts The target timestamp. * @param ts The target timestamp.
* @param tol_ns Tolerance of the fuzzy query in nanoseconds. * @param tol_ns Tolerance of the fuzzy query in nanoseconds.
*/ */
void fuzzyQuery(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& ts, uint64_t tol_ns=3600000000000); void fuzzyQuery(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& ts, const uint64_t tol_ns=3600000000000);
/** /**
* @brief This function performs a fuzzy query and returns the closest * @brief This function performs a fuzzy query and returns the closest
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
* @param tol_ns Tolerance of the fuzzy query in nanoseconds. * @param tol_ns Tolerance of the fuzzy query in nanoseconds.
* @param storeSid If true, Sensor IDs will be retrieved for each reading. * @param storeSid If true, Sensor IDs will be retrieved for each reading.
*/ */
void fuzzyQuery(std::list<SensorDataStoreReading>& result, std::list<SensorId>& sids, TimeStamp& ts, uint64_t tol_ns=3600000000000, bool storeSids=true); void fuzzyQuery(std::list<SensorDataStoreReading>& result, const std::list<SensorId>& sids, const TimeStamp& ts, const uint64_t tol_ns=3600000000000, const bool storeSids=true);
typedef void (*QueryCbFunc)(SensorDataStoreReading& reading, void* userData); typedef void (*QueryCbFunc)(SensorDataStoreReading& reading, void* userData);
/** /**
...@@ -204,14 +204,14 @@ public: ...@@ -204,14 +204,14 @@ public:
* @param start Start of the time series. * @param start Start of the time series.
* @param end End of the time series. * @param end End of the time series.
*/ */
void queryCB(QueryCbFunc cbFunc, void* userData, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate=AGGREGATE_NONE); void queryCB(QueryCbFunc cbFunc, void* userData, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate=AGGREGATE_NONE);
/** /**
* @brief This function truncates all sensor data that is older than * @brief This function truncates all sensor data that is older than
* the specified week. * the specified week.
* @param weekStamp The 16-bit weekstamp generated from a cut-off date * @param weekStamp The 16-bit weekstamp generated from a cut-off date
*/ */
void truncBeforeWeek(uint16_t weekStamp); void truncBeforeWeek(const uint16_t weekStamp);
/** /**
* @brief A shortcut constructor for a SensorDataStore object * @brief A shortcut constructor for a SensorDataStore object
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
* @param value The sensor reading as 64-bit integer * @param value The sensor reading as 64-bit integer
* @param ttl Time to live (in seconds) for the inserted reading * @param ttl Time to live (in seconds) for the inserted reading
*/ */
void insert(SensorId* sid, uint64_t ts, int64_t value, int64_t ttl=-1); void insert(const SensorId& sid, const uint64_t ts, const int64_t value, const int64_t ttl=-1);
/** /**
* @brief This function inserts a single sensor reading into * @brief This function inserts a single sensor reading into
...@@ -98,7 +98,7 @@ public: ...@@ -98,7 +98,7 @@ public:
* @param reading A SensorDataStoreReading object * @param reading A SensorDataStoreReading object
* @param ttl Time to live (in seconds) for the inserted reading * @param ttl Time to live (in seconds) for the inserted reading
*/ */
void insert(SensorDataStoreReading& reading, int64_t ttl=-1); void insert(const SensorDataStoreReading& reading, const int64_t ttl=-1);
/** /**
* @brief This function inserts a single sensor reading into * @brief This function inserts a single sensor reading into
...@@ -106,19 +106,19 @@ public: ...@@ -106,19 +106,19 @@ public:
* @param readings A list of SensorDataStoreReading object * @param readings A list of SensorDataStoreReading object
* @param ttl Time to live (in seconds) for the inserted readings * @param ttl Time to live (in seconds) for the inserted readings
*/ */
void insertBatch(std::list<SensorDataStoreReading>& readings, int64_t ttl=-1); void insertBatch(const std::list<SensorDataStoreReading>& readings, const int64_t ttl=-1);
/** /**
* @brief This function sets the TTL of newly inserted readings. * @brief This function sets the TTL of newly inserted readings.
* @param ttl The TTL to be used for new inserts in seconds. * @param ttl The TTL to be used for new inserts in seconds.
*/ */
void setTTL(uint64_t ttl); void setTTL(const uint64_t ttl);
/** /**
* @brief Enables or disables logging of Cassandra insert errors * @brief Enables or disables logging of Cassandra insert errors
* @param dl true to enable logging, false otherwise * @param dl true to enable logging, false otherwise
*/ */
void setDebugLog(bool dl); void setDebugLog(const bool dl);
/** /**
* @brief This function queries a sensor's values in * @brief This function queries a sensor's values in
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
* @param start Start of the time series. * @param start Start of the time series.
* @param end End of the time series. * @param end End of the time series.
*/ */
void query(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate); void query(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate);
/** /**
* @brief This function queries a the values of * @brief This function queries a the values of
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
* @param end End of the time series. * @param end End of the time series.
* @param storeSid If true, Sensor IDs will be retrieved for each reading. * @param storeSid If true, Sensor IDs will be retrieved for each reading.
*/ */
void query(std::list<SensorDataStoreReading>& result, std::list<SensorId>& sids, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate, bool storeSids); void query(std::list<SensorDataStoreReading>& result, const std::list<SensorId>& sids, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate, const bool storeSids);
/** /**
* @brief This function performs a fuzzy query and returns the * @brief This function performs a fuzzy query and returns the
...@@ -151,7 +151,7 @@ public: ...@@ -151,7 +151,7 @@ public:
* @param ts The target timestamp. * @param ts The target timestamp.
* @param tol_ns Tolerance of the fuzzy query in nanoseconds. * @param tol_ns Tolerance of the fuzzy query in nanoseconds.
*/ */
void fuzzyQuery(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& ts, uint64_t tol_ns=3600000000000); void fuzzyQuery(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& ts, const uint64_t tol_ns=3600000000000);
/** /**
* @brief This function performs a fuzzy query and returns the closest * @brief This function performs a fuzzy query and returns the closest
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
* @param tol_ns Tolerance of the fuzzy query in nanoseconds. * @param tol_ns Tolerance of the fuzzy query in nanoseconds.
* @param storeSid If true, Sensor IDs will be retrieved for each reading. * @param storeSid If true, Sensor IDs will be retrieved for each reading.
*/ */
void fuzzyQuery(std::list<SensorDataStoreReading>& result, std::list<SensorId>& sids, TimeStamp& ts, uint64_t tol_ns=3600000000000, bool storeSids=true); void fuzzyQuery(std::list<SensorDataStoreReading>& result, const std::list<SensorId>& sids, const TimeStamp& ts, const uint64_t tol_ns=3600000000000, const bool storeSids=true);
/** /**
* @brief This function queries a sensor's values in * @brief This function queries a sensor's values in
...@@ -175,20 +175,20 @@ public: ...@@ -175,20 +175,20 @@ public:
* @param start Start of the time series. * @param start Start of the time series.
* @param end End of the time series. * @param end End of the time series.
*/ */
void queryCB(SensorDataStore::QueryCbFunc cbFunc, void* userData, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate); void queryCB(SensorDataStore::QueryCbFunc cbFunc, void* userData, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate);
/** /**
* @brief This function truncates all sensor data that is older than * @brief This function truncates all sensor data that is older than
* the specified week. * the specified week.
* @param weekStamp The 16-bit weekstamp generated from a cut-off date * @param weekStamp The 16-bit weekstamp generated from a cut-off date
*/ */
void truncBeforeWeek(uint16_t weekStamp); void truncBeforeWeek(const uint16_t weekStamp);
/** /**
* @brief This function deletes a row from the sensordatastore. * @brief This function deletes a row from the sensordatastore.
* @param sid SensorId object that identifies the row to be deleted. * @param sid SensorId object that identifies the row to be deleted.
*/ */
void deleteRow(SensorId& sid); void deleteRow(const SensorId& sid);
/** /**
* @brief This is the standard constructor of the SensorDataStoreImpl class. * @brief This is the standard constructor of the SensorDataStoreImpl class.
......
...@@ -68,7 +68,7 @@ using namespace DCDB; ...@@ -68,7 +68,7 @@ using namespace DCDB;
SensorDataStoreReading::SensorDataStoreReading() { SensorDataStoreReading::SensorDataStoreReading() {
} }
SensorDataStoreReading::SensorDataStoreReading(SensorId& sid, uint64_t ts, int64_t value) { SensorDataStoreReading::SensorDataStoreReading(const SensorId& sid, const uint64_t ts, const int64_t value) {
this->sensorId = sid; this->sensorId = sid;
this->timeStamp = TimeStamp(ts); this->timeStamp = TimeStamp(ts);
this->value = value; this->value = value;
...@@ -83,7 +83,7 @@ SensorDataStoreReading::~SensorDataStoreReading() { ...@@ -83,7 +83,7 @@ SensorDataStoreReading::~SensorDataStoreReading() {
* insert CQL query in advance and only bind it on the actual * insert CQL query in advance and only bind it on the actual
* insert. * insert.
*/ */
void SensorDataStoreImpl::prepareInsert(uint64_t ttl) void SensorDataStoreImpl::prepareInsert(const uint64_t ttl)
{ {
CassError rc = CASS_OK; CassError rc = CASS_OK;
CassFuture* future = NULL; CassFuture* future = NULL;
...@@ -142,7 +142,7 @@ void SensorDataStoreImpl::prepareInsert(uint64_t ttl) ...@@ -142,7 +142,7 @@ void SensorDataStoreImpl::prepareInsert(uint64_t ttl)
* Applications should not call this function directly, but * Applications should not call this function directly, but
* use the insert function provided by the SensorDataStore class. * use the insert function provided by the SensorDataStore class.
*/ */
void SensorDataStoreImpl::insert(SensorId* sid, uint64_t ts, int64_t value, int64_t ttl) void SensorDataStoreImpl::insert(const SensorId& sid, const uint64_t ts, const int64_t value, const int64_t ttl)
{ {
#if 0 #if 0
std::cout << "Inserting@SensorDataStoreImpl (" << sid->raw[0] << " " << sid->raw[1] << ", " << ts << ", " << value << ")" << std::endl; std::cout << "Inserting@SensorDataStoreImpl (" << sid->raw[0] << " " << sid->raw[1] << ", " << ts << ", " << value << ")" << std::endl;
...@@ -150,12 +150,11 @@ void SensorDataStoreImpl::insert(SensorId* sid, uint64_t ts, int64_t value, int6 ...@@ -150,12 +150,11 @@ void SensorDataStoreImpl::insert(SensorId* sid, uint64_t ts, int64_t value, int6
/* Calculate and insert week number */ /* Calculate and insert week number */
uint16_t week = ts / 604800000000000; uint16_t week = ts / 604800000000000;
sid->setRsvd(week);
int64_t ttlReal = (ttl<0 ? defaultTTL : ttl); int64_t ttlReal = (ttl<0 ? defaultTTL : ttl);
std::string sidStr = sid.getId();
CassStatement* statement = cass_prepared_bind(ttlReal<=0 ? preparedInsert_noTTL : preparedInsert); CassStatement* statement = cass_prepared_bind(ttlReal<=0 ? preparedInsert_noTTL : preparedInsert);
cass_statement_bind_string_by_name(statement, "sid", sid->getId().c_str()); cass_statement_bind_string_by_name(statement, "sid", sidStr.c_str());
cass_statement_bind_int16_by_name(statement, "ws", week); cass_statement_bind_int16_by_name(statement, "ws", week);
cass_statement_bind_int64_by_name(statement, "ts", ts); cass_statement_bind_int64_by_name(statement, "ts", ts);
cass_statement_bind_int64_by_name(statement, "value", value); cass_statement_bind_int64_by_name(statement, "value", value);
...@@ -169,19 +168,18 @@ void SensorDataStoreImpl::insert(SensorId* sid, uint64_t ts, int64_t value, int6 ...@@ -169,19 +168,18 @@ void SensorDataStoreImpl::insert(SensorId* sid, uint64_t ts, int64_t value, int6
cass_future_free(future); cass_future_free(future);
} }
void SensorDataStoreImpl::insert(SensorDataStoreReading& reading, int64_t ttl) { void SensorDataStoreImpl::insert(const SensorDataStoreReading& reading, const int64_t ttl) {
insert(&reading.sensorId, reading.timeStamp.getRaw(), reading.value, ttl); insert(reading.sensorId, reading.timeStamp.getRaw(), reading.value, ttl);
} }
void SensorDataStoreImpl::insertBatch(std::list<SensorDataStoreReading>& readings, int64_t ttl) { void SensorDataStoreImpl::insertBatch(const std::list<SensorDataStoreReading>& readings, const int64_t ttl) {
CassBatch* batch = cass_batch_new(CASS_BATCH_TYPE_UNLOGGED); CassBatch* batch = cass_batch_new(CASS_BATCH_TYPE_UNLOGGED);
int64_t ttlReal = (ttl<0 ? defaultTTL : ttl); int64_t ttlReal = (ttl<0 ? defaultTTL : ttl);
for (auto r: readings) { for (auto r: readings) {
/* Calculate and insert week number */ /* Calculate week number */
uint16_t week = r.timeStamp.getRaw() / 604800000000000; uint16_t week = r.timeStamp.getRaw() / 604800000000000;
r.sensorId.setRsvd(week);
/* Add insert statement to batch */ /* Add insert statement to batch */
CassStatement* statement = cass_prepared_bind(ttlReal<=0 ? preparedInsert_noTTL : preparedInsert); CassStatement* statement = cass_prepared_bind(ttlReal<=0 ? preparedInsert_noTTL : preparedInsert);
...@@ -211,7 +209,7 @@ void SensorDataStoreImpl::insertBatch(std::list<SensorDataStoreReading>& reading ...@@ -211,7 +209,7 @@ void SensorDataStoreImpl::insertBatch(std::list<SensorDataStoreReading>& reading
* This function updates the prepared statement for inserts * This function updates the prepared statement for inserts
* with the new TTL value. * with the new TTL value.
*/ */
void SensorDataStoreImpl::setTTL(uint64_t ttl) void SensorDataStoreImpl::setTTL(const uint64_t ttl)
{ {
prepareInsert(ttl); prepareInsert(ttl);
} }
...@@ -220,7 +218,7 @@ void SensorDataStoreImpl::setTTL(uint64_t ttl) ...@@ -220,7 +218,7 @@ void SensorDataStoreImpl::setTTL(uint64_t ttl)
* @brief Enables or disables logging of Cassandra insert errors * @brief Enables or disables logging of Cassandra insert errors
* @param dl true to enable logging, false otherwise * @param dl true to enable logging, false otherwise
*/ */
void SensorDataStoreImpl::setDebugLog(bool dl) void SensorDataStoreImpl::setDebugLog(const bool dl)
{ {
debugLog = dl; debugLog = dl;
} }
...@@ -231,7 +229,7 @@ void SensorDataStoreImpl::setDebugLog(bool dl) ...@@ -231,7 +229,7 @@ void SensorDataStoreImpl::setDebugLog(bool dl)
* and creates a SensorDataStoreReading object for each * and creates a SensorDataStoreReading object for each
* entry which is stored in the result list. * entry which is stored in the result list.
*/ */
void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate) { void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate) {
CassError rc = CASS_OK; CassError rc = CASS_OK;
CassStatement* statement = NULL; CassStatement* statement = NULL;
CassFuture *future = NULL; CassFuture *future = NULL;
...@@ -328,7 +326,7 @@ void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, Senso ...@@ -328,7 +326,7 @@ void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, Senso
* and creates a SensorDataStoreReading object for each * and creates a SensorDataStoreReading object for each
* entry which is stored in the result list. * entry which is stored in the result list.
*/ */
void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, std::list<SensorId>& sids, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate, bool storeSids) { void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, const std::list<SensorId>& sids, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate, const bool storeSids) {
if(sids.empty()) if(sids.empty())
return; return;
...@@ -445,7 +443,7 @@ void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, std:: ...@@ -445,7 +443,7 @@ void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, std::
* picking a single sensor readings that is closest to * picking a single sensor readings that is closest to
* the one given as input * the one given as input
*/ */
void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& ts, uint64_t tol_ns) { void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& ts, const uint64_t tol_ns) {
/* Find the readings before time t */ /* Find the readings before time t */
CassError rc = CASS_OK; CassError rc = CASS_OK;
CassStatement* statement = NULL; CassStatement* statement = NULL;
...@@ -508,7 +506,7 @@ void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result, ...@@ -508,7 +506,7 @@ void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result,
* picking readings from a set of sensors that are closest to * picking readings from a set of sensors that are closest to
* the timestamp given as input * the timestamp given as input
*/ */
void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result, std::list<SensorId>& sids, TimeStamp& ts, uint64_t tol_ns, bool storeSids) { void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result, const std::list<SensorId>& sids, const TimeStamp& ts, const uint64_t tol_ns, const bool storeSids) {
if(sids.empty()) if(sids.empty())
return; return;
...@@ -600,7 +598,7 @@ void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result, ...@@ -600,7 +598,7 @@ void SensorDataStoreImpl::fuzzyQuery(std::list<SensorDataStoreReading>& result,
* This function issues a regular query to the data store * This function issues a regular query to the data store
* and calls cbFunc for every reading. * and calls cbFunc for every reading.
*/ */
void SensorDataStoreImpl::queryCB(SensorDataStore::QueryCbFunc cbFunc, void* userData, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate) void SensorDataStoreImpl::queryCB(SensorDataStore::QueryCbFunc cbFunc, void* userData, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate)
{ {
CassError rc = CASS_OK; CassError rc = CASS_OK;
CassStatement* statement = NULL; CassStatement* statement = NULL;
...@@ -682,7 +680,7 @@ void SensorDataStoreImpl::queryCB(SensorDataStore::QueryCbFunc cbFunc, void* use ...@@ -682,7 +680,7 @@ void SensorDataStoreImpl::queryCB(SensorDataStore::QueryCbFunc cbFunc, void* use
* This function deletes all data from the sensordata store * This function deletes all data from the sensordata store
* that is older than weekStamp-1 weeks. * that is older than weekStamp-1 weeks.
*/ */
void SensorDataStoreImpl::truncBeforeWeek(uint16_t weekStamp) void SensorDataStoreImpl::truncBeforeWeek(const uint16_t weekStamp)
{ {
/* List of rows that should be deleted */ /* List of rows that should be deleted */
std::list<SensorId> deleteList; std::list<SensorId> deleteList;
...@@ -742,7 +740,7 @@ void SensorDataStoreImpl::truncBeforeWeek(uint16_t weekStamp) ...@@ -742,7 +740,7 @@ void SensorDataStoreImpl::truncBeforeWeek(uint16_t weekStamp)
* @details * @details
* Deleting entire rows is rather efficient compared to deleting individual columns. * Deleting entire rows is rather efficient compared to deleting individual columns.
*/ */
void SensorDataStoreImpl::deleteRow(SensorId& sid) void SensorDataStoreImpl::deleteRow(const SensorId& sid)
{ {
CassError rc = CASS_OK; CassError rc = CASS_OK;
CassStatement* statement = NULL; CassStatement* statement = NULL;
...@@ -815,17 +813,17 @@ SensorDataStoreImpl::~SensorDataStoreImpl() ...@@ -815,17 +813,17 @@ SensorDataStoreImpl::~SensorDataStoreImpl()
* forwards to the insert function of the SensorDataStoreImpl * forwards to the insert function of the SensorDataStoreImpl
* class. * class.
*/ */
void SensorDataStore::insert(SensorId* sid, uint64_t ts, int64_t value, int64_t ttl) void SensorDataStore::insert(const SensorId& sid, const uint64_t ts, const int64_t value, const int64_t ttl)
{ {
impl->insert(sid, ts, value, ttl); impl->insert(sid, ts, value, ttl);
} }
void SensorDataStore::insert(SensorDataStoreReading& reading, int64_t ttl) void SensorDataStore::insert(const SensorDataStoreReading& reading, const int64_t ttl)
{ {
impl->insert(reading, ttl); impl->insert(reading, ttl);
} }
void SensorDataStore::insertBatch(std::list<SensorDataStoreReading>& readings, int64_t ttl) { void SensorDataStore::insertBatch(const std::list<SensorDataStoreReading>& readings, const int64_t ttl) {
impl->insertBatch(readings, ttl); impl->insertBatch(readings, ttl);
} }
...@@ -835,7 +833,7 @@ void SensorDataStore::insertBatch(std::list<SensorDataStoreReading>& readings, i ...@@ -835,7 +833,7 @@ void SensorDataStore::insertBatch(std::list<SensorDataStoreReading>& readings, i
* forwards to the insert function of the SensorDataStoreImpl * forwards to the insert function of the SensorDataStoreImpl
* class. * class.
*/ */
void SensorDataStore::setTTL(uint64_t ttl) void SensorDataStore::setTTL(const uint64_t ttl)
{ {
impl->setTTL(ttl); impl->setTTL(ttl);
} }
...@@ -844,7 +842,7 @@ void SensorDataStore::setTTL(uint64_t ttl) ...@@ -844,7 +842,7 @@ void SensorDataStore::setTTL(uint64_t ttl)
* @brief Enables or disables logging of Cassandra insert errors * @brief Enables or disables logging of Cassandra insert errors
* @param dl true to enable logging, false otherwise * @param dl true to enable logging, false otherwise
*/ */
void SensorDataStore::setDebugLog(bool dl) void SensorDataStore::setDebugLog(const bool dl)
{ {
impl->setDebugLog(dl); impl->setDebugLog(dl);
} }
...@@ -855,7 +853,7 @@ void SensorDataStore::setDebugLog(bool dl) ...@@ -855,7 +853,7 @@ void SensorDataStore::setDebugLog(bool dl)
* forwards to the insert function of the SensorDataStoreImpl * forwards to the insert function of the SensorDataStoreImpl
* class. * class.
*/ */
void SensorDataStore::query(std::list<SensorDataStoreReading>& result, SensorId& sid, TimeStamp& start, TimeStamp& end, QueryAggregate aggregate) void SensorDataStore::query(std::list<SensorDataStoreReading>& result, const SensorId& sid, const TimeStamp& start, const TimeStamp& end, const QueryAggregate aggregate)
{ {
impl->query(result, sid, start, end, aggregate); impl->query(result, sid, start, end, aggregate);
}