Minor performance improvement in ingest code
@@ -110,7 +110,6 @@ void Ingest::updateStats()
if (statsPendingEntries.empty())
{
- //Logger::getLogger()->info("statsPendingEntries is empty, returning from updateStats()");
return;
}
@@ -125,7 +124,6 @@ void Ingest::updateStats()
{
createStatsDbEntry(it->first);
statsDbEntriesCache.insert(it->first);
- //Logger::getLogger()->info("%s:%d : Created stats entry for asset name %s and added to cache", __FUNCTION__, __LINE__, it->first.c_str());
}
if (it->second)
@@ -399,20 +397,28 @@ void Ingest::processQueue()
{
std::map<std::string, int> statsEntriesCurrQueue;
AssetTracker *tracker = AssetTracker::getAssetTracker();
+ string lastAsset = "";
+ int *lastStat;
for (vector<Reading *>::iterator it = q->begin();
it != q->end(); ++it)
{
Reading *reading = *it;
string assetName = reading->getAssetName();
- if (statsPendingEntries.find(assetName) != statsPendingEntries.end())
+ if (lastAsset.compare(assetName))
{
AssetTrackingTuple tuple(m_serviceName, m_pluginName, assetName, "Ingest");
if (!tracker->checkAssetTrackingCache(tuple))
{
tracker->addAssetTrackingTuple(tuple);
}
+ lastAsset = assetName;
+ lastStat = &(statsEntriesCurrQueue[assetName]);
+ (*lastStat)++;
+ }
+ else
+ {
+ (*lastStat)++;
}
- ++statsEntriesCurrQueue[assetName];
delete reading;
}
delete q;
@@ -540,16 +546,27 @@ void Ingest::processQueue()
// check if this requires addition of a new asset tracker tuple
// Remove the Readings in the vector
AssetTracker *tracker = AssetTracker::getAssetTracker();
+ string lastAsset = "";
+ int *lastStat;
for (vector<Reading *>::iterator it = m_data->begin(); it != m_data->end(); ++it)
{
Reading *reading = *it;
string assetName = reading->getAssetName();
+ if (lastAsset.compare(assetName))
+ {
AssetTrackingTuple tuple(m_serviceName, m_pluginName, assetName, "Ingest");
if (!tracker->checkAssetTrackingCache(tuple))
{
tracker->addAssetTrackingTuple(tuple);
}
- ++statsEntriesCurrQueue[assetName];
+ lastAsset = assetName;
+ lastStat = &statsEntriesCurrQueue[assetName];
+ (*lastStat)++;
+ }
+ else
+ {
+ (*lastStat)++;
+ }
delete reading;
}
{
