diff options
Diffstat (limited to 'searchlib/src/tests/attribute')
6 files changed, 25 insertions, 24 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/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index 92c3da40fe9..90127e9ae7b 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -21,6 +21,7 @@ #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/compress.h> +#include <vespa/vespalib/util/memory.h> #include <vespa/vespalib/stllike/asciistream.h> #include <limits> #include <cmath> @@ -184,8 +185,8 @@ MemAttr::bufEqual(const Buffer &lhs, const Buffer &rhs) const return true; if (!EXPECT_TRUE(lhs->getDataLen() == rhs->getDataLen())) return false; - if (!EXPECT_TRUE(memcmp(lhs->getData(), rhs->getData(), - lhs->getDataLen()) == 0)) + if (!EXPECT_TRUE(vespalib::memcmp_safe(lhs->getData(), rhs->getData(), + lhs->getDataLen()) == 0)) return false; return true; } @@ -480,7 +481,7 @@ EnumeratedSaveTest::getSearch(const V &vec, const T &term, bool prefix) buildTermQuery(query, vec.getName(), ss.str(), prefix); return (static_cast<const AttributeVector &>(vec)). - getSearch(vespalib::stringref(&query[0], query.size()), + getSearch(vespalib::stringref(query.data(), query.size()), SearchContextParams()); } 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) { |