diff options
author | Håvard Pettersen <havardpe@yahooinc.com> | 2022-06-21 11:26:58 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@yahooinc.com> | 2022-06-21 14:15:01 +0000 |
commit | 60e28dcd0b4c1ea9eff2e4f26da7ec53ed24e64a (patch) | |
tree | 80a479d5f62a8bb7c5ce52a5d531a434075cfe57 /searchlib | |
parent | 1f9c4d5b83b314785cd9c83bbecec21cb00b192b (diff) |
avoid nullptr deref
Diffstat (limited to 'searchlib')
18 files changed, 62 insertions, 61 deletions
diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index bb516c3b451..a0906e2a488 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -791,7 +791,7 @@ AttributeTest::checkCount(const AttributePtr & ptr, uint32_t doc, uint32_t value if (!result) { return false; } - EXPECT_EQ(valueCount, ptr->get(doc, &buffer[0], buffer.size())) << (result = false, ""); + EXPECT_EQ(valueCount, ptr->get(doc, buffer.data(), buffer.size())) << (result = false, ""); if (!result) { return false; } @@ -807,7 +807,7 @@ AttributeTest::checkContent(const AttributePtr & ptr, uint32_t doc, uint32_t val std::vector<BufferType> buffer(valueCount); bool retval = true; EXPECT_TRUE((retval = retval && (static_cast<uint32_t>(ptr->getValueCount(doc)) == valueCount))); - EXPECT_TRUE((retval = retval && (ptr->get(doc, &buffer[0], buffer.size()) == valueCount))); + EXPECT_TRUE((retval = retval && (ptr->get(doc, buffer.data(), buffer.size()) == valueCount))); for (uint32_t i = 0; i < valueCount; ++i) { EXPECT_TRUE((retval = retval && (buffer[i] == values[i % range]))); } @@ -868,7 +868,7 @@ AttributeTest::testSingle(const AttributePtr & ptr, const std::vector<BufferType ptr->clearDoc(doc); } ptr->commit(); - EXPECT_EQ(1u, ptr->get(doc, &buffer[0], buffer.size())); + EXPECT_EQ(1u, ptr->get(doc, buffer.data(), buffer.size())); if (doc % 2 == 0) { if (smallUInt) { expectZero(buffer[0]); @@ -1156,7 +1156,7 @@ AttributeTest::testWeightedSet(const AttributePtr & ptr, const std::vector<Buffe EXPECT_TRUE(v.append(doc, values[j].getValue(), values[j].getWeight())); } commit(ptr); - ASSERT_TRUE(ptr->get(doc, &buffer[0], buffer.size()) == valueCount); + ASSERT_TRUE(ptr->get(doc, buffer.data(), buffer.size()) == valueCount); std::sort(buffer.begin(), buffer.begin() + valueCount, order_by_weight()); for (uint32_t j = 0; j < valueCount; ++j) { EXPECT_TRUE(buffer[j].getValue() == ordered_values[j].getValue()); @@ -1173,20 +1173,20 @@ AttributeTest::testWeightedSet(const AttributePtr & ptr, const std::vector<Buffe // append non-existent value EXPECT_TRUE(v.append(doc, values[doc].getValue(), values[doc].getWeight())); commit(ptr); - ASSERT_TRUE(ptr->get(doc, &buffer[0], buffer.size()) == valueCount + 1); + ASSERT_TRUE(ptr->get(doc, buffer.data(), buffer.size()) == valueCount + 1); EXPECT_TRUE(contains(buffer, valueCount + 1, values[doc])); // append existent value EXPECT_TRUE(v.append(doc, values[doc].getValue(), values[doc].getWeight() + 10)); commit(ptr); - ASSERT_TRUE(ptr->get(doc, &buffer[0], buffer.size()) == valueCount + 1); + ASSERT_TRUE(ptr->get(doc, buffer.data(), buffer.size()) == valueCount + 1); EXPECT_TRUE(contains(buffer, valueCount + 1, BufferType(values[doc].getValue(), values[doc].getWeight() + 10))); // append non-existent value two times EXPECT_TRUE(v.append(doc, values[doc + 1].getValue(), values[doc + 1].getWeight())); EXPECT_TRUE(v.append(doc, values[doc + 1].getValue(), values[doc + 1].getWeight() + 10)); commit(ptr); - ASSERT_TRUE(ptr->get(doc, &buffer[0], buffer.size()) == valueCount + 2); + ASSERT_TRUE(ptr->get(doc, buffer.data(), buffer.size()) == valueCount + 2); EXPECT_TRUE(contains(buffer, valueCount + 2, BufferType(values[doc + 1].getValue(), values[doc + 1].getWeight() + 10))); } EXPECT_EQ(ptr->getStatus().getUpdateCount(), numDocs + (numDocs*(numDocs-1))/2 + numDocs*4); @@ -1203,11 +1203,11 @@ AttributeTest::testWeightedSet(const AttributePtr & ptr, const std::vector<Buffe EXPECT_TRUE(static_cast<uint32_t>(v.getValueCount(doc)) == valueCount + 2); // remove existent value - ASSERT_TRUE(ptr->get(doc, &buffer[0], buffer.size()) == valueCount + 2); + ASSERT_TRUE(ptr->get(doc, buffer.data(), buffer.size()) == valueCount + 2); EXPECT_TRUE(contains_value(buffer, valueCount + 2, values[doc + 1].getValue())); EXPECT_TRUE(v.remove(doc, values[doc + 1].getValue(), 0)); commit(ptr); - ASSERT_TRUE(ptr->get(doc, &buffer[0], buffer.size()) == valueCount + 1); + ASSERT_TRUE(ptr->get(doc, buffer.data(), buffer.size()) == valueCount + 1); EXPECT_FALSE(contains_value(buffer, valueCount + 1, values[doc + 1].getValue())); } EXPECT_EQ(ptr->getStatus().getUpdateCount(), numDocs + (numDocs*(numDocs-1))/2 + numDocs*4 + numDocs * 2); diff --git a/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp b/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp index 5c1c49d8eb5..e27065f1c25 100644 --- a/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp +++ b/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp @@ -47,7 +47,7 @@ public: for (auto& key : keys) { adds.emplace_back(KeyData(key, 1)); } - _postings.apply(_trees[idx], &*adds.begin(), &*adds.end(), &*removes.begin(), &*removes.end()); + _postings.apply(_trees[idx], adds.data(), adds.data() + adds.size(), removes.data(), removes.data() + removes.size()); } void clear_tree(size_t idx) { diff --git a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp index 10cc14012dd..573284ffa35 100644 --- a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp +++ b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp @@ -83,8 +83,8 @@ protected: additions.emplace_back(i, 0); } _store.apply(root, - &additions[0], &additions[0] + additions.size(), - &removals[0], &removals[0] + removals.size()); + additions.data(), additions.data() + additions.size(), + removals.data(), removals.data() + removals.size()); return root; } static std::vector<int> make_exp_sequence(int start_key, int end_key) diff --git a/searchlib/src/tests/attribute/postinglist/postinglist.cpp b/searchlib/src/tests/attribute/postinglist/postinglist.cpp index 446aeaf22a7..54efb3261c8 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -379,8 +379,8 @@ insertRandomValues(Tree &tree, std::vector<AttributePosting> additions; std::vector<uint32_t> removals; additions.push_back(newPosting); - postings.apply(newIdx, &additions[0], &additions[0] + additions.size(), - &removals[0], &removals[0] + removals.size()); + postings.apply(newIdx, additions.data(), additions.data() + additions.size(), + removals.data(), removals.data() + removals.size()); std::atomic_thread_fence(std::memory_order_release); itr.writeData(newIdx); @@ -461,8 +461,8 @@ removeRandomValues(Tree &tree, std::vector<AttributePosting> additions; std::vector<uint32_t> removals; removals.push_back(i->_docId); - postings.apply(newIdx, &additions[0], &additions[0]+additions.size(), - &removals[0], &removals[0] + removals.size()); + postings.apply(newIdx, additions.data(), additions.data() + additions.size(), + removals.data(), removals.data() + removals.size()); if (newIdx != oldIdx) { std::atomic_thread_fence(std::memory_order_release); itr.writeData(newIdx); diff --git a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp index aa2c475e7b6..96039bee15b 100644 --- a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp +++ b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp @@ -48,7 +48,7 @@ checkCount(Attribute & vec, uint32_t doc, uint32_t valueCount, { std::vector<vespalib::string> buffer(valueCount); EXPECT_TRUE(static_cast<uint32_t>(vec.getValueCount(doc)) == valueCount); - EXPECT_TRUE(vec.get(doc, &buffer[0], buffer.size()) == valueCount); + EXPECT_TRUE(vec.get(doc, buffer.data(), buffer.size()) == valueCount); EXPECT_TRUE(std::count(buffer.begin(), buffer.end(), value) == numValues); } @@ -125,10 +125,10 @@ testMultiValue(Attribute & attr, uint32_t numDocs) // test get all std::vector<vespalib::string> values(valueCount); - ASSERT_TRUE(attr.get(doc, &values[0], valueCount) == valueCount); + ASSERT_TRUE(attr.get(doc, values.data(), valueCount) == valueCount); std::vector<uint32_t> enums(valueCount); - ASSERT_TRUE((static_cast<search::attribute::IAttributeVector &>(attr)).get(doc, &enums[0], valueCount) == valueCount); + ASSERT_TRUE((static_cast<search::attribute::IAttributeVector &>(attr)).get(doc, enums.data(), valueCount) == valueCount); auto combined = zipped_and_sorted_by_first(values, enums); for (uint32_t j = 0; j < valueCount; ++j) { @@ -167,10 +167,10 @@ testMultiValue(Attribute & attr, uint32_t numDocs) // test get all std::vector<vespalib::string> values(valueCount); - EXPECT_TRUE(attr.get(doc, &values[0], valueCount) == valueCount); + EXPECT_TRUE(attr.get(doc, values.data(), valueCount) == valueCount); std::vector<uint32_t> enums(valueCount); - EXPECT_TRUE((static_cast<search::attribute::IAttributeVector &>(attr)).get(doc, &enums[0], valueCount) == valueCount); + EXPECT_TRUE((static_cast<search::attribute::IAttributeVector &>(attr)).get(doc, enums.data(), valueCount) == valueCount); auto combined = zipped_and_sorted_by_first(values, enums); for (uint32_t j = 0; j < valueCount; ++j) { diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index fffa1778c85..0865e2c199a 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -18,6 +18,7 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/size_literals.h> +#include <vespa/vespalib/util/memory.h> #include <iomanip> using document::BucketId; @@ -275,7 +276,7 @@ void fetchAndTest(IDataStore & datastore, uint32_t lid, const void *a, size_t sz vespalib::DataBuffer buf; EXPECT_EQUAL(static_cast<ssize_t>(sz), datastore.read(lid, buf)); EXPECT_EQUAL(buf.getDataLen(), sz); - EXPECT_TRUE(memcmp(a, buf.getData(), sz) == 0); + EXPECT_TRUE(vespalib::memcmp_safe(a, buf.getData(), sz) == 0); } TEST("testTruncatedIdxFile"){ diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp index 57980237f21..55577b3916c 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp @@ -111,7 +111,7 @@ public: void operator()(IAttributeVector &attributeVector) override { OP op(attributeVector, _operand); if (op.valid()) { - const RankedHit *hits = &_result.second[0]; + const RankedHit *hits = _result.second.data(); size_t numHits = _result.second.size(); std::for_each(hits, hits+numHits, [&op](RankedHit hit) { op(hit.getDocId()); }); if (_result.first) { diff --git a/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.cpp b/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.cpp index b514275f75d..80e9b28139a 100644 --- a/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.cpp +++ b/searchlib/src/vespa/searchlib/attribute/loadedenumvalue.cpp @@ -13,7 +13,7 @@ sortLoadedByEnum(LoadedEnumAttributeVector &loaded) LoadedEnumAttribute::EnumCompare, 56>:: radix_sort(LoadedEnumAttribute::EnumRadix(), LoadedEnumAttribute::EnumCompare(), - &loaded[0], loaded.size(), 16); + loaded.data(), loaded.size(), 16); } } diff --git a/searchlib/src/vespa/searchlib/attribute/loadednumericvalue.cpp b/searchlib/src/vespa/searchlib/attribute/loadednumericvalue.cpp index 0ffd6e2c845..4d3912ae24d 100644 --- a/searchlib/src/vespa/searchlib/attribute/loadednumericvalue.cpp +++ b/searchlib/src/vespa/searchlib/attribute/loadednumericvalue.cpp @@ -14,7 +14,7 @@ sortLoadedByValue(SequentialReadModifyWriteVector<LoadedNumericValue<T>> & loade typename LoadedNumericValue<T>::ValueCompare, 56>:: radix_sort(typename LoadedNumericValue<T>::ValueRadix(), typename LoadedNumericValue<T>::ValueCompare(), - &loaded[0], + loaded.data(), loaded.size(), 16); } @@ -29,7 +29,7 @@ sortLoadedByDocId(SequentialReadModifyWriteVector<LoadedNumericValue<T>> & loade typename LoadedNumericValue<T>::DocOrderCompare, 56>:: radix_sort(typename LoadedNumericValue<T>::DocRadix(), typename LoadedNumericValue<T>::DocOrderCompare(), - &loaded[0], + loaded.data(), loaded.size(), 16); } diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h index cc128b0eef1..0a29b4af48d 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h @@ -49,7 +49,7 @@ protected: using WType = MultiValueType; uint32_t get(DocId doc, const WType * & values) const { MultiValueArrayRef array(this->_mvMapping.get(doc)); - values = &array[0]; + values = array.data(); return array.size(); } diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp index 0e0dceaf254..79276ce6f55 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp @@ -69,11 +69,11 @@ PostingListAttributeBase<P>::handle_load_posting_lists_and_update_enum_store(enu postings.removeDups(); newIndex = EntryRef(); _postingList.apply(newIndex, - &postings._additions[0], - &postings._additions[0] + + postings._additions.data(), + postings._additions.data() + postings._additions.size(), - &postings._removals[0], - &postings._removals[0] + + postings._removals.data(), + postings._removals.data() + postings._removals.size()); posting_indexes[posting_enum] = newIndex; postings.clear(); @@ -91,10 +91,10 @@ PostingListAttributeBase<P>::handle_load_posting_lists_and_update_enum_store(enu postings.removeDups(); newIndex = EntryRef(); _postingList.apply(newIndex, - &postings._additions[0], - &postings._additions[0] + postings._additions.size(), - &postings._removals[0], - &postings._removals[0] + postings._removals.size()); + postings._additions.data(), + postings._additions.data() + postings._additions.size(), + postings._removals.data(), + postings._removals.data() + postings._removals.size()); posting_indexes[posting_enum] = newIndex; loader.build_dictionary(); loader.free_unused_values(); @@ -158,10 +158,10 @@ clearPostings(attribute::IAttributeVector::EnumHandle eidx, auto updater = [this, &postings](EntryRef posting_idx) -> EntryRef { _postingList.apply(posting_idx, - &postings._additions[0], - &postings._additions[0] + postings._additions.size(), - &postings._removals[0], - &postings._removals[0] + postings._removals.size()); + postings._additions.data(), + postings._additions.data() + postings._additions.size(), + postings._removals.data(), + postings._removals.data() + postings._removals.size()); return posting_idx; }; _dictionary.update_posting_list(er, cmp, updater); @@ -240,11 +240,11 @@ handle_load_posting_lists(LoadedVector& loaded) postings.removeDups(); newIndex = EntryRef(); _postingList.apply(newIndex, - &postings._additions[0], - &postings._additions[0] + + postings._additions.data(), + postings._additions.data() + postings._additions.size(), - &postings._removals[0], - &postings._removals[0] + + postings._removals.data(), + postings._removals.data() + postings._removals.size()); postings.clear(); if (value._docId < docIdLimit) { @@ -262,11 +262,11 @@ handle_load_posting_lists(LoadedVector& loaded) postings.removeDups(); newIndex = EntryRef(); _postingList.apply(newIndex, - &postings._additions[0], - &postings._additions[0] + + postings._additions.data(), + postings._additions.data() + postings._additions.size(), - &postings._removals[0], - &postings._removals[0] + postings._removals.size()); + postings._removals.data(), + postings._removals.data() + postings._removals.size()); similarValues[0]._pidx = newIndex; for (size_t i(0), m(similarValues.size()); i < m; i++) { loaded.write(similarValues[i]); diff --git a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp index 9a711a028fb..b0a201d913e 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp @@ -365,7 +365,7 @@ PageDict4SPWriter::flushPage() _prevL3Size - wordsSize * 8; e.padBits(padding); if (wordsSize > 0) { - e.writeBytes(vespalib::ConstArrayRef<char>(&_words[0], wordsSize)); + e.writeBytes(vespalib::ConstArrayRef<char>(_words.data(), wordsSize)); } assert((e.getWriteOffset() & (getPageBitSize() - 1)) == 0); _l6Word = _l3Word; @@ -676,7 +676,7 @@ PageDict4PWriter::flushPage() _countsSize - _countsWordOffset * 8; e.padBits(padding); if (_countsWordOffset > 0) { - e.writeBytes(vespalib::ConstArrayRef(&_words[0], _countsWordOffset)); + e.writeBytes(vespalib::ConstArrayRef(_words.data(), _countsWordOffset)); } assert((e.getWriteOffset() & (getPageBitSize() - 1)) == 0); _l3Word = _pendingCountsWord; @@ -1055,7 +1055,7 @@ lookup(vespalib::stringref key) L7Vector::const_iterator l7lb; l7lb = std::lower_bound(_l7.begin(), _l7.end(), key); - l7Pos = &*l7lb - &_l7[0]; + l7Pos = l7lb - _l7.cbegin(); StartOffset startOffset; uint64_t pageNum = _pFirstPageNum; uint32_t sparsePageNum = _spFirstPageNum; @@ -1863,7 +1863,7 @@ PageDict4Reader::setupPage() uint32_t padding = (getPageBitSize() - wordsSize * 8 - pageOffset) & (getPageBitSize() - 1); _pd.skipBits(padding); _words.resize(wordsSize); - _pd.readBytes(reinterpret_cast<uint8_t *>(&_words[0]), wordsSize); + _pd.readBytes(reinterpret_cast<uint8_t *>(_words.data()), wordsSize); _wc = _words.begin(); _we = _words.end(); checkWordOffsets(_words, _l1SkipChecks, _l2SkipChecks); @@ -1985,7 +1985,7 @@ PageDict4Reader::setupSPage() uint32_t padding = getPageBitSize() - wordsSize * 8 - pageOffset; _spd.skipBits(padding); _spwords.resize(wordsSize); - _spd.readBytes(reinterpret_cast<uint8_t *>(&_spwords[0]), wordsSize); + _spd.readBytes(reinterpret_cast<uint8_t *>(_spwords.data()), wordsSize); _spwc = _spwords.begin(); _spwe = _spwords.end(); checkWordOffsets(_spwords, _l4SkipChecks, _l5SkipChecks); diff --git a/searchlib/src/vespa/searchlib/common/resultset.cpp b/searchlib/src/vespa/searchlib/common/resultset.cpp index 2e1e431ad82..3a88a310fe8 100644 --- a/searchlib/src/vespa/searchlib/common/resultset.cpp +++ b/searchlib/src/vespa/searchlib/common/resultset.cpp @@ -99,7 +99,7 @@ ResultSet::mergeWithBitOverflow(HitRank default_value) void ResultSet::sort(FastS_IResultSorter & sorter, unsigned int ntop) { - sorter.sortResults(&_rankedHitsArray[0], _rankedHitsArray.size(), ntop); + sorter.sortResults(_rankedHitsArray.data(), _rankedHitsArray.size(), ntop); } std::pair<std::unique_ptr<BitVector>, vespalib::Array<RankedHit>> diff --git a/searchlib/src/vespa/searchlib/common/resultset.h b/searchlib/src/vespa/searchlib/common/resultset.h index 6824fc4170d..a4823d2f372 100644 --- a/searchlib/src/vespa/searchlib/common/resultset.h +++ b/searchlib/src/vespa/searchlib/common/resultset.h @@ -26,7 +26,7 @@ public: void allocArray(unsigned int arrayAllocated); void setBitOverflow(std::unique_ptr<BitVector> newBitOverflow); - const RankedHit * getArray() const { return &_rankedHitsArray[0]; } + const RankedHit * getArray() const { return _rankedHitsArray.data(); } RankedHit & operator [](uint32_t i) { return _rankedHitsArray[i]; } void push_back(RankedHit hit) { _rankedHitsArray.push_back_fast(hit); } unsigned int getArrayUsed() const { return _rankedHitsArray.size(); } diff --git a/searchlib/src/vespa/searchlib/diskindex/docidmapper.h b/searchlib/src/vespa/searchlib/diskindex/docidmapper.h index 90bfa658a72..7c6f53720f2 100644 --- a/searchlib/src/vespa/searchlib/diskindex/docidmapper.h +++ b/searchlib/src/vespa/searchlib/diskindex/docidmapper.h @@ -42,9 +42,9 @@ public: { } void setup(const DocIdMapping &mapping) { - _selector = (mapping._selector != nullptr) ? &((*mapping._selector)[0]) : nullptr; + _selector = (mapping._selector != nullptr) ? mapping._selector->data() : nullptr; _docIdLimit = mapping._docIdLimit; - _selectorLimit = (mapping._selector != nullptr) ? (*mapping._selector).size() : 0u; + _selectorLimit = (mapping._selector != nullptr) ? mapping._selector->size() : 0u; _selectorId = mapping._selectorId; } diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp index 77781d583cb..4eaa5b3eb65 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp @@ -135,7 +135,7 @@ ProtoConverter::search_reply_to_proto(const SearchReply &reply, ProtoSearchReply } } } - proto.set_grouping_blob(&reply.groupResult[0], reply.groupResult.size()); + proto.set_grouping_blob(reply.groupResult.data(), reply.groupResult.size()); const auto &slime_trace = reply.propertiesMap.trace().lookup("slime"); proto.set_slime_trace(slime_trace.get().data(), slime_trace.get().size()); if (reply.my_issues) { diff --git a/searchlib/src/vespa/searchlib/queryeval/hitcollector.cpp b/searchlib/src/vespa/searchlib/queryeval/hitcollector.cpp index b851fc50518..8664b0fc14b 100644 --- a/searchlib/src/vespa/searchlib/queryeval/hitcollector.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/hitcollector.cpp @@ -18,7 +18,7 @@ HitCollector::sortHitsByScore(size_t topn) _scoreOrder.push_back(i); } ShiftBasedRadixSorter<uint32_t, IndirectScoreRadix, IndirectScoreComparator, 56, true>:: - radix_sort(IndirectScoreRadix(&_hits[0]), IndirectScoreComparator(&_hits[0]), &_scoreOrder[0], _scoreOrder.size(), 16, topn); + radix_sort(IndirectScoreRadix(_hits.data()), IndirectScoreComparator(_hits.data()), _scoreOrder.data(), _scoreOrder.size(), 16, topn); _scoreOrder.resize(topn); } } @@ -28,7 +28,7 @@ HitCollector::sortHitsByDocId() { if (_hitsSortOrder != SortOrder::DOC_ID) { ShiftBasedRadixSorter<Hit, DocIdRadix, DocIdComparator, 24>:: - radix_sort(DocIdRadix(), DocIdComparator(), &_hits[0], _hits.size(), 16); + radix_sort(DocIdRadix(), DocIdComparator(), _hits.data(), _hits.size(), 16); _hitsSortOrder = SortOrder::DOC_ID; _scoreOrder.clear(); } @@ -170,7 +170,7 @@ HitCollector::getSortedHitSequence(size_t max_hits) { size_t num_hits = std::min(_hits.size(), max_hits); sortHitsByScore(num_hits); - return SortedHitSequence(&_hits[0], &_scoreOrder[0], num_hits); + return SortedHitSequence(_hits.data(), _scoreOrder.data(), num_hits); } void diff --git a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp index a668387e5bd..58e625e6aca 100644 --- a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp @@ -68,7 +68,7 @@ struct MyFastValueView final : Value { { const StringIdVector &labels = handle_view; for (size_t i = 0; i < num_spaces; ++i) { - ConstArrayRef<string_id> addr(&labels[i * num_mapped], num_mapped); + ConstArrayRef<string_id> addr(labels.data() + (i * num_mapped), num_mapped); my_index.map.add_mapping(FastAddrMap::hash_labels(addr)); } assert(my_index.map.size() == num_spaces); |