Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
e91c3bab
Commit
e91c3bab
authored
Apr 16, 2016
by
Axel Auweter
Browse files
Add a sensor property cache to speed up evaluation of virtual sensors by ~25%.
parent
e51407fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
DCDBLib/include_internal/sensorconfig_internal.h
View file @
e91c3bab
...
...
@@ -7,6 +7,7 @@
#include
<list>
#include
<string>
#include
<unordered_map>
#include
"cassandra.h"
...
...
@@ -27,6 +28,9 @@ protected:
Connection
*
connection
;
CassSession
*
session
;
typedef
std
::
unordered_map
<
std
::
string
,
PublicSensor
>
SensorPropertyCache_t
;
static
SensorPropertyCache_t
sensorPropertyCache
;
bool
validateSensorPattern
(
const
char
*
sensorPattern
);
bool
validateSensorPublicName
(
std
::
string
publicName
);
...
...
DCDBLib/src/sensorconfig.cpp
View file @
e91c3bab
...
...
@@ -11,6 +11,7 @@
#include
<string>
#include
<list>
#include
<unordered_set>
#include
<utility>
#include
"cassandra.h"
...
...
@@ -150,8 +151,9 @@ SensorConfig::~SensorConfig()
}
/*
* SensorConfigImpl protected functions
* SensorConfigImpl protected
members and
functions
*/
SensorConfigImpl
::
SensorPropertyCache_t
SensorConfigImpl
::
sensorPropertyCache
;
/*
* Validate the pattern for a Sensor to be published
...
...
@@ -600,6 +602,14 @@ SCError SensorConfigImpl::getPublicSensorsVerbose(std::list<PublicSensor>& publi
SCError
SensorConfigImpl
::
getPublicSensorByName
(
PublicSensor
&
sensor
,
const
char
*
publicName
)
{
/* Check if the sensor definition is already in the cache */
SensorPropertyCache_t
::
const_iterator
got
=
sensorPropertyCache
.
find
(
publicName
);
if
(
got
!=
sensorPropertyCache
.
end
())
{
sensor
=
got
->
second
;
return
SC_OK
;
}
/* Not in cache - query the data base */
/* Check if the session is valid */
if
(
!
session
)
{
return
SC_INVALIDSESSION
;
...
...
@@ -702,6 +712,8 @@ SCError SensorConfigImpl::getPublicSensorByName(PublicSensor& sensor, const char
sensor
.
t_zero
=
tzero
;
sensor
.
frequency
=
frequency
;
/* Add to sensorPropertyCache for later use */
sensorPropertyCache
.
insert
(
std
::
make_pair
(
publicName
,
sensor
));
}
else
{
cass_result_free
(
result
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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