summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-11-02 23:36:08 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-11-02 23:36:08 +0100
commit31fd3e8170ec253082e6a62b9667724f30e83d38 (patch)
treee795f5bfd8c64442fa42b669145d06e0af6da5a4 /searchcore
parentdf911518ccf3430af062954bb6ff559306b51371 (diff)
Do not follow the nullptr.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h6
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp43
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp2
6 files changed, 28 insertions, 40 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h
index 66f12a4952c..04f3982c07c 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h
@@ -22,7 +22,7 @@ public:
search::AttributeGuard _activeLidsGuard;
public:
ReadGuard(const search::AttributeVector::SP &metaStoreAttr);
- virtual const search::IDocumentMetaStore &get() const override { return _store; }
+ const search::IDocumentMetaStore &get() const override { return _store; }
};
private:
search::AttributeVector::SP _metaStoreAttr;
@@ -45,12 +45,10 @@ public:
*/
DocumentMetaStoreContext(const search::AttributeVector::SP &metaStoreAttr);
- // Implements IDocumentMetaStoreContext
proton::IDocumentMetaStore::SP getSP() const override { return _metaStore; }
proton::IDocumentMetaStore & get() override { return *_metaStore; }
-
IReadGuard::UP getReadGuard() const override {
- return IReadGuard::UP(new ReadGuard(_metaStoreAttr));
+ return std::make_unique<ReadGuard>(_metaStoreAttr);
}
void constructFreeList() override;
diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h b/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h
index 222bec3a345..b69c66ec7ad 100644
--- a/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h
+++ b/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h
@@ -19,10 +19,9 @@ public:
DocumentDBExplorer(const DocumentDB::SP &docDb);
~DocumentDBExplorer();
- // Implements vespalib::StateExplorer
- virtual void get_state(const vespalib::slime::Inserter &inserter, bool full) const override;
- virtual std::vector<vespalib::string> get_children_names() const override;
- virtual std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override;
+ void get_state(const vespalib::slime::Inserter &inserter, bool full) const override;
+ std::vector<vespalib::string> get_children_names() const override;
+ std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override;
};
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp
index 27253e9a420..2335cd01ec8 100644
--- a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp
@@ -12,6 +12,6 @@ DocumentMetaStoreReadGuards::DocumentMetaStoreReadGuards(DocumentSubDBCollection
remdms(subDBs.getRemSubDB()->getDocumentMetaStoreContext().getReadGuard())
{ }
-DocumentMetaStoreReadGuards::~DocumentMetaStoreReadGuards() { }
+DocumentMetaStoreReadGuards::~DocumentMetaStoreReadGuards() = default;
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h
index b5d28f6048b..8dc39d1415d 100644
--- a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h
+++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h
@@ -22,16 +22,16 @@ struct DocumentMetaStoreReadGuards
~DocumentMetaStoreReadGuards();
uint32_t numActiveDocs() const {
- return readydms->get().getNumActiveLids();
+ return readydms ? readydms->get().getNumActiveLids() : 0;
}
uint32_t numIndexedDocs() const {
- return readydms->get().getNumUsedLids();
+ return readydms ? readydms->get().getNumUsedLids() : 0;
}
uint32_t numStoredDocs() const {
- return numIndexedDocs() + notreadydms->get().getNumUsedLids();
+ return numIndexedDocs() + (notreadydms ? notreadydms->get().getNumUsedLids() : 0);
}
uint32_t numRemovedDocs() const {
- return remdms->get().getNumUsedLids();
+ return remdms ? remdms->get().getNumUsedLids() : 0;
}
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
index 5babacfc4b6..4dbff7c8e58 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
@@ -1007,8 +1007,7 @@ DocumentDB::notifyAllBucketsChanged()
namespace {
void
-updateIndexMetrics(DocumentDBMetricsCollection &metrics,
- const search::SearchableStats &stats)
+updateIndexMetrics(DocumentDBMetricsCollection &metrics, const search::SearchableStats &stats)
{
DocumentDBTaggedMetrics::IndexMetrics &indexMetrics = metrics.getTaggedMetrics().index;
indexMetrics.diskUsage.set(stats.sizeOnDisk());
@@ -1051,10 +1050,8 @@ isNotReadySubDB(const IDocumentSubDB *subDb, const DocumentSubDBCollection &subD
}
void
-fillTempAttributeMetrics(TempAttributeMetrics &metrics,
- const vespalib::string &attrName,
- const MemoryUsage &memoryUsage,
- uint32_t bitVectors)
+fillTempAttributeMetrics(TempAttributeMetrics &metrics, const vespalib::string &attrName,
+ const MemoryUsage &memoryUsage, uint32_t bitVectors)
{
metrics._total._memoryUsage.merge(memoryUsage);
metrics._total._bitVectors += bitVectors;
@@ -1071,7 +1068,7 @@ fillTempAttributeMetrics(TempAttributeMetrics &totalMetrics,
{
for (const auto subDb : subDbs) {
proton::IAttributeManager::SP attrMgr(subDb->getAttributeManager());
- if (attrMgr.get()) {
+ if (attrMgr) {
TempAttributeMetrics *subMetrics =
(isReadySubDB(subDb, subDbs) ? &readyMetrics :
(isNotReadySubDB(subDb, subDbs) ? &notReadyMetrics : nullptr));
@@ -1091,8 +1088,7 @@ fillTempAttributeMetrics(TempAttributeMetrics &totalMetrics,
}
void
-updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics,
- const TempAttributeMetrics &tmpMetrics)
+updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics, const TempAttributeMetrics &tmpMetrics)
{
for (const auto &attr : tmpMetrics._attrs) {
LegacyAttributeMetrics::List::Entry *entry = metrics.list.get(attr.first);
@@ -1108,20 +1104,18 @@ updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics,
}
void
-updateAttributeMetrics(AttributeMetrics &metrics,
- const TempAttributeMetrics &tmpMetrics)
+updateAttributeMetrics(AttributeMetrics &metrics, const TempAttributeMetrics &tmpMetrics)
{
for (const auto &attr : tmpMetrics._attrs) {
auto entry = metrics.get(attr.first);
- if (entry.get()) {
+ if (entry) {
entry->memoryUsage.update(attr.second._memoryUsage);
}
}
}
void
-updateAttributeMetrics(DocumentDBMetricsCollection &metrics,
- const DocumentSubDBCollection &subDbs)
+updateAttributeMetrics(DocumentDBMetricsCollection &metrics, const DocumentSubDBCollection &subDbs)
{
TempAttributeMetrics totalMetrics;
TempAttributeMetrics readyMetrics;
@@ -1137,8 +1131,7 @@ updateAttributeMetrics(DocumentDBMetricsCollection &metrics,
}
void
-updateMatchingMetrics(LegacyDocumentDBMetrics::MatchingMetrics &metrics,
- const IDocumentSubDB &ready)
+updateMatchingMetrics(LegacyDocumentDBMetrics::MatchingMetrics &metrics, const IDocumentSubDB &ready)
{
MatchingStats stats;
for (const auto &kv : metrics.rank_profiles) {
@@ -1158,8 +1151,10 @@ updateDocstoreMetrics(LegacyDocumentDBMetrics::DocstoreMetrics &metrics,
CacheStats cache_stats;
for (const auto subDb : sub_dbs) {
const ISummaryManager::SP &summaryMgr = subDb->getSummaryManager();
- cache_stats += summaryMgr->getBackingStore().getCacheStats();
- memoryUsage += summaryMgr->getBackingStore().memoryUsed();
+ if (summaryMgr) {
+ cache_stats += summaryMgr->getBackingStore().getCacheStats();
+ memoryUsage += summaryMgr->getBackingStore().memoryUsed();
+ }
}
metrics.memoryUsage.set(memoryUsage);
size_t lookups = cache_stats.hits + cache_stats.misses;
@@ -1204,8 +1199,7 @@ updateDocumentStoreMetrics(DocumentDBTaggedMetrics::SubDBMetrics::
template <typename MetricSetType>
void
-updateLidSpaceMetrics(MetricSetType &metrics,
- const search::IDocumentMetaStore &metaStore)
+updateLidSpaceMetrics(MetricSetType &metrics, const search::IDocumentMetaStore &metaStore)
{
LidUsageStats stats = metaStore.getLidUsageStats();
metrics.lidLimit.set(stats.getLidLimit());
@@ -1257,13 +1251,10 @@ DocumentDB::
updateMetrics(DocumentDBTaggedMetrics::AttributeMetrics &metrics)
{
AttributeUsageFilter &writeFilter(_writeFilter);
- AttributeUsageStats attributeUsageStats =
- writeFilter.getAttributeUsageStats();
+ AttributeUsageStats attributeUsageStats = writeFilter.getAttributeUsageStats();
bool feedBlocked = !writeFilter.acceptWriteOperation();
- double enumStoreUsed =
- attributeUsageStats.enumStoreUsage().getUsage().usage();
- double multiValueUsed =
- attributeUsageStats.multiValueUsage().getUsage().usage();
+ double enumStoreUsed = attributeUsageStats.enumStoreUsage().getUsage().usage();
+ double multiValueUsed = attributeUsageStats.multiValueUsage().getUsage().usage();
metrics.resourceUsage.enumStore.set(enumStoreUsed);
metrics.resourceUsage.multiValue.set(multiValueUsed);
metrics.resourceUsage.feedingBlocked.set(feedBlocked ? 1 : 0);
diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
index 0b67698524b..4069a871210 100644
--- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp
@@ -301,7 +301,7 @@ SearchableDocSubDB::getNumActiveDocs() const
search::SearchableStats
SearchableDocSubDB::getSearchableStats() const
{
- return _indexMgr->getSearchableStats();
+ return _indexMgr ? _indexMgr->getSearchableStats() : search::SearchableStats();
}
IDocumentRetriever::UP