diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-10 10:18:33 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-10 10:18:33 +0000 |
commit | c87ff6862f65d72558d3745c8115041f8784609d (patch) | |
tree | 0495bd9a518a761469e623b4a7ac7d15d387413a /searchlib | |
parent | 9a44c50bca0023acf086facb53a64938a7239b6c (diff) |
Guard against following the nullptr
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/common/bitvectorcache.cpp | 15 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/predicate/predicate_index.cpp | 8 |
2 files changed, 12 insertions, 11 deletions
diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp index e124cc05448..4b5fc8a06c9 100644 --- a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp +++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp @@ -18,9 +18,7 @@ BitVectorCache::BitVectorCache(GenerationHolder &genHolder) : { } -BitVectorCache::~BitVectorCache() -{ -} +BitVectorCache::~BitVectorCache() = default; void BitVectorCache::computeCountVector(KeySet & keys, CountVector & v) const @@ -148,14 +146,19 @@ BitVectorCache::populate(Key2Index & newKeys, CondensedBitVector & chunk, const m.chunkIndex(index); LOG(info, "Populating bitvector %2d with feature %" PRIu64 " and %ld bits set. Cost is %8f = %2.2f%%, accumulated cost is %2.2f%%", index, e.first, m.bitCount(), m.cost(), percentage, accum); - index++; assert(m.isCached()); assert(newKeys[e.first].isCached()); assert(&m == &newKeys[e.first]); PopulateInterface::Iterator::UP iterator = lookup.lookup(e.first); - for (int32_t docId(iterator->getNext()); docId >= 0; docId = iterator->getNext()) { - chunk.set(m.chunkIndex(), docId, true); + if (iterator) { + for (int32_t docId(iterator->getNext()); docId >= 0; docId = iterator->getNext()) { + chunk.set(m.chunkIndex(), docId, true); + } + } else { + LOG(error, "Unable to to find a valid iterator for feature %" PRIu64 " and %ld bits set at while populating bitvector %2d. This should in theory be impossible.", + e.first, m.bitCount(), index); } + index++; } } } diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp b/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp index 99861db31c9..19935d2e339 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp +++ b/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp @@ -194,10 +194,8 @@ void PredicateIndex::removeDocument(uint32_t doc_id) { auto features = _features_store.get(doc_id); if (!features.empty()) { for (auto feature : features) { - removeFromIndex(feature, doc_id, _interval_index, - _interval_store); - removeFromIndex(feature, doc_id, _bounds_index, - _interval_store); + removeFromIndex(feature, doc_id, _interval_index, _interval_store); + removeFromIndex(feature, doc_id, _bounds_index, _interval_store); } _cache.removeIndex(doc_id); } @@ -242,7 +240,7 @@ PredicateIndex::lookup(uint64_t key) const if (dictIterator.valid()) { auto it = _interval_index.getBTreePostingList(dictIterator.getData()); if (it.valid()) { - return PopulateInterface::Iterator::UP(new DocIdIterator(it)); + return std::make_unique<DocIdIterator>(it); } } return PopulateInterface::Iterator::UP(); |