aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/tests/attribute/attribute_test.cpp18
-rw-r--r--searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp2
-rw-r--r--searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp7
-rw-r--r--searchlib/src/tests/attribute/posting_store/posting_store_test.cpp4
-rw-r--r--searchlib/src/tests/attribute/postinglist/postinglist.cpp8
-rw-r--r--searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp10
-rw-r--r--searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attribute_operation.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/loadedenumvalue.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/loadednumericvalue.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp40
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/compression.h47
-rw-r--r--searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/common/geo_location.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/common/geo_location_parser.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/resultset.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/resultset.h2
-rw-r--r--searchlib/src/vespa/searchlib/common/sortresults.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/docidmapper.h4
-rw-r--r--searchlib/src/vespa/searchlib/engine/proto_converter.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/hitcollector.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/util/comprfile.cpp13
-rw-r--r--searchlib/src/vespa/searchlib/util/comprfile.h2
27 files changed, 114 insertions, 113 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) {
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/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
index c17627a5026..d8426ce1a45 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
@@ -20,8 +20,8 @@ PostingListSearchContext(const IEnumStoreDictionary& dictionary,
const ISearchContext &baseSearchCtx)
: _dictionary(dictionary),
_frozenDictionary(_dictionary.get_has_btree_dictionary() ? _dictionary.get_posting_dictionary().getFrozenView() : FrozenDictionary()),
- _lowerDictItr(BTreeNode::Ref(), _frozenDictionary.getAllocator()),
- _upperDictItr(BTreeNode::Ref(), _frozenDictionary.getAllocator()),
+ _lowerDictItr(_dictionary.get_has_btree_dictionary() ? DictionaryConstIterator(BTreeNode::Ref(), _frozenDictionary.getAllocator()) : DictionaryConstIterator()),
+ _upperDictItr(_dictionary.get_has_btree_dictionary() ? DictionaryConstIterator(BTreeNode::Ref(), _frozenDictionary.getAllocator()) : DictionaryConstIterator()),
_uniqueValues(0u),
_docIdLimit(docIdLimit),
_dictSize(_frozenDictionary.size()),
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.h b/searchlib/src/vespa/searchlib/bitcompression/compression.h
index 45005d499fb..441fac3aef1 100644
--- a/searchlib/src/vespa/searchlib/bitcompression/compression.h
+++ b/searchlib/src/vespa/searchlib/bitcompression/compression.h
@@ -165,8 +165,7 @@ public:
#define UC64BE_DECODEEXPGOLOMB(val, valI, preRead, cacheInt, k, EC) \
do { \
- length = \
- 63 - ::search::bitcompression::EncodeContext64BE::asmlog2(val); \
+ length = __builtin_clzl(val); \
unsigned int olength = length; \
val <<= length; \
if (__builtin_expect(length * 2 + 1 + (k) > 64, false)) { \
@@ -174,8 +173,9 @@ public:
length = 0; \
} \
val64 = (val >> (63 - olength - (k))) - (UINT64_C(1) << (k)); \
- val <<= olength + 1 + (k); \
- if (__builtin_expect(olength + 1 + (k) == 64, false)) { \
+ if (__builtin_expect(olength + 1 + (k) != 64, true)) { \
+ val <<= olength + 1 + (k); \
+ } else { \
val = 0; \
} \
length += olength + 1 + (k); \
@@ -193,8 +193,7 @@ public:
#define UC64BE_DECODEEXPGOLOMB_SMALL(val, valI, preRead, cacheInt, k, \
EC) \
do { \
- length = \
- 63 - ::search::bitcompression::EncodeContext64BE::asmlog2(val); \
+ length = __builtin_clzl(val); \
val <<= length; \
val64 = (val >> (63 - length - (k))) - (UINT64_C(1) << (k)); \
val <<= length + 1 + (k); \
@@ -219,8 +218,7 @@ public:
#define UC64BE_DECODEEXPGOLOMB_SMALL_APPLY(val, valI, preRead, cacheInt, \
k, EC, resop) \
do { \
- length = \
- 63 - ::search::bitcompression::EncodeContext64BE::asmlog2(val); \
+ length = __builtin_clzl(val); \
val <<= length; \
resop (val >> (63 - length - (k))) - (UINT64_C(1) << (k)); \
val <<= length + 1 + (k); \
@@ -231,16 +229,16 @@ public:
#define UC64BE_SKIPEXPGOLOMB(val, valI, preRead, cacheInt, k, EC) \
do { \
- length = \
- 63 - ::search::bitcompression::EncodeContext64BE::asmlog2(val); \
+ length = __builtin_clzl(val); \
unsigned int olength = length; \
val <<= length; \
if (__builtin_expect(length * 2 + 1 + (k) > 64, false)) { \
UC64BE_READBITS(val, valI, preRead, cacheInt, EC); \
length = 0; \
} \
- val <<= olength + 1 + (k); \
- if (__builtin_expect(olength + 1 + (k) == 64, false)) { \
+ if (__builtin_expect(olength + 1 + (k) != 64, true)) { \
+ val <<= olength + 1 + (k); \
+ } else { \
val = 0; \
} \
length += olength + 1 + (k); \
@@ -258,8 +256,7 @@ public:
#define UC64BE_SKIPEXPGOLOMB_SMALL(val, valI, preRead, cacheInt, k, \
EC) \
do { \
- length = \
- 63 - ::search::bitcompression::EncodeContext64BE::asmlog2(val); \
+ length = __builtin_clzl(val); \
val <<= length; \
val <<= length + 1 + (k); \
length += length + 1 + (k); \
@@ -394,11 +391,11 @@ public:
#define UC64LE_DECODEEXPGOLOMB(val, valI, preRead, cacheInt, k, EC) \
do { \
- unsigned int olength = \
- ::search::bitcompression::EncodeContext64LE::ffsl(val); \
+ unsigned int olength = __builtin_ctzl(val); \
length = olength + 1; \
- val >>= length; \
- if (__builtin_expect(length == 64, false)) { \
+ if (__builtin_expect(length != 64, true)) { \
+ val >>= length; \
+ } else { \
val = 0; \
} \
if (__builtin_expect(olength * 2 + 1 + (k) > 64, false)) { \
@@ -423,7 +420,7 @@ public:
#define UC64LE_DECODEEXPGOLOMB_SMALL(val, valI, preRead, cacheInt, k, \
EC) \
do { \
- length = ::search::bitcompression::EncodeContext64LE::ffsl(val); \
+ length = __builtin_ctzl(val); \
val >>= length + 1; \
val64 = (val & ((UINT64_C(1) << (length + (k))) - 1)) + \
(UINT64_C(1) << (length + (k))) - (UINT64_C(1) << (k)); \
@@ -449,7 +446,7 @@ public:
#define UC64LE_DECODEEXPGOLOMB_SMALL_APPLY(val, valI, preRead, cacheInt, \
k, EC, resop) \
do { \
- length = ::search::bitcompression::EncodeContext64LE::ffsl(val); \
+ length = __builtin_ctzl(val); \
val >>= length + 1; \
resop (val & ((UINT64_C(1) << (length + (k))) - 1)) + \
(UINT64_C(1) << (length + (k))) - (UINT64_C(1) << (k)); \
@@ -461,11 +458,11 @@ public:
#define UC64LE_SKIPEXPGOLOMB(val, valI, preRead, cacheInt, k, EC) \
do { \
- unsigned int olength = \
- ::search::bitcompression::EncodeContext64LE::ffsl(val); \
+ unsigned int olength = __builtin_ctzl(val); \
length = olength + 1; \
- val >>= length; \
- if (__builtin_expect(length == 64, false)) { \
+ if (__builtin_expect(length != 64, true)) { \
+ val >>= length; \
+ } else { \
val = 0; \
} \
if (__builtin_expect(olength * 2 + 1 + (k) > 64, false)) { \
@@ -488,7 +485,7 @@ public:
#define UC64LE_SKIPEXPGOLOMB_SMALL(val, valI, preRead, cacheInt, k, \
EC) \
do { \
- length = ::search::bitcompression::EncodeContext64LE::ffsl(val); \
+ length = __builtin_ctzl(val); \
val >>= length + 1; \
val >>= length + (k); \
length += length + 1 + (k); \
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/geo_location.cpp b/searchlib/src/vespa/searchlib/common/geo_location.cpp
index 1806ba1338c..20408a93a82 100644
--- a/searchlib/src/vespa/searchlib/common/geo_location.cpp
+++ b/searchlib/src/vespa/searchlib/common/geo_location.cpp
@@ -8,6 +8,12 @@ namespace search::common {
namespace {
+uint64_t abs_diff(int32_t a, int32_t b) {
+ return (a > b)
+ ? (int64_t(a) - int64_t(b))
+ : (int64_t(b) - int64_t(a));
+}
+
ZCurve::BoundingBox to_z(GeoLocation::Box box) {
return ZCurve::BoundingBox(box.x.low, box.x.high,
box.y.low, box.y.high);
@@ -158,13 +164,13 @@ GeoLocation::GeoLocation(Box b, Point p, uint32_t r, Aspect xa)
uint64_t GeoLocation::sq_distance_to(Point p) const {
if (has_point) {
- uint64_t dx = (p.x > point.x) ? (p.x - point.x) : (point.x - p.x);
+ uint64_t dx = abs_diff(p.x, point.x);
if (x_aspect.active()) {
// x_aspect is a 32-bit fixed-point number in range [0,1]
// this implements dx = (dx * x_aspect)
dx = (dx * x_aspect.multiplier) >> 32;
}
- uint64_t dy = (p.y > point.y) ? (p.y - point.y) : (point.y - p.y);
+ uint64_t dy = abs_diff(p.y, point.y);
return dx*dx + dy*dy;
}
return 0;
diff --git a/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp b/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp
index 8794169b4a6..d829e1b93e4 100644
--- a/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp
+++ b/searchlib/src/vespa/searchlib/common/geo_location_parser.cpp
@@ -15,7 +15,7 @@ LOG_SETUP(".searchlib.common.geo_location_parser");
namespace {
int getInt(const char * &p) {
- int val;
+ uint32_t val;
bool isminus;
val = 0;
isminus = false;
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/common/sortresults.cpp b/searchlib/src/vespa/searchlib/common/sortresults.cpp
index f1756712d2c..59a47dd3312 100644
--- a/searchlib/src/vespa/searchlib/common/sortresults.cpp
+++ b/searchlib/src/vespa/searchlib/common/sortresults.cpp
@@ -209,9 +209,9 @@ FastS_SortSpec::realloc(uint32_t n, size_t & variableWidth, uint32_t & available
variableWidth *= 2;
available += variableWidth * n;
dataSize += variableWidth * n;
- uint32_t byteUsed = mySortData - &_binarySortData[0];
+ uint32_t byteUsed = mySortData - _binarySortData.data();
_binarySortData.resize(dataSize);
- return &_binarySortData[0] + byteUsed;
+ return _binarySortData.data() + byteUsed;
}
void
@@ -237,7 +237,7 @@ FastS_SortSpec::initSortData(const RankedHit *hits, uint32_t n)
uint32_t dataSize = (fixedWidth + variableWidth) * n;
uint32_t available = dataSize;
_binarySortData.resize(dataSize);
- uint8_t *mySortData = &_binarySortData[0];
+ uint8_t *mySortData = _binarySortData.data();
_sortDataArray.resize(n);
@@ -342,7 +342,7 @@ void
FastS_SortSpec::copySortData(uint32_t offset, uint32_t n,
uint32_t *idx, char *buf)
{
- const uint8_t * sortData = &_binarySortData[0];
+ const uint8_t * sortData = _binarySortData.data();
uint32_t totalLen = 0;
for (uint32_t i = offset; i < (offset + n); ++i, ++idx) {
const uint8_t * src = sortData + _sortDataArray[i]._idx;
@@ -378,7 +378,7 @@ inline int
FastS_SortSpec::Compare(const FastS_SortSpec *self, const SortData &a,
const SortData &b)
{
- const uint8_t * ref = &(self->_binarySortData[0]);
+ const uint8_t * ref = self->_binarySortData.data();
uint32_t len = a._len < b._len ? a._len : b._len;
int retval = memcmp(ref + a._idx,
ref + b._idx, len);
@@ -448,10 +448,10 @@ void
FastS_SortSpec::sortResults(RankedHit a[], uint32_t n, uint32_t topn)
{
initSortData(a, n);
- SortData * sortData = &_sortDataArray[0];
+ SortData * sortData = _sortDataArray.data();
{
Array<uint32_t> radixScratchPad(n, Alloc::alloc(0, MMAP_LIMIT));
- search::radix_sort(SortDataRadix(&_binarySortData[0]), StdSortDataCompare(&_binarySortData[0]), SortDataEof(), 1, sortData, n, &radixScratchPad[0], 0, 96, topn);
+ search::radix_sort(SortDataRadix(_binarySortData.data()), StdSortDataCompare(_binarySortData.data()), SortDataEof(), 1, sortData, n, radixScratchPad.data(), 0, 96, topn);
}
for (uint32_t i(0), m(_sortDataArray.size()); i < m; ++i) {
a[i]._rankValue = _sortDataArray[i]._rankValue;
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);
diff --git a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp
index d240e5a7c6c..d1bb464fc37 100644
--- a/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp
+++ b/searchlib/src/vespa/searchlib/test/imported_attribute_fixture.cpp
@@ -10,10 +10,7 @@ namespace search {
namespace {
struct MockReadGuard : public IDocumentMetaStoreContext::IReadGuard {
- virtual const search::IDocumentMetaStore &get() const override {
- search::IDocumentMetaStore *nullStore = nullptr;
- return static_cast<search::IDocumentMetaStore &>(*nullStore);
- }
+ virtual const search::IDocumentMetaStore &get() const override { abort(); }
};
}
diff --git a/searchlib/src/vespa/searchlib/util/comprfile.cpp b/searchlib/src/vespa/searchlib/util/comprfile.cpp
index 61eeca6fc2d..bde246a1239 100644
--- a/searchlib/src/vespa/searchlib/util/comprfile.cpp
+++ b/searchlib/src/vespa/searchlib/util/comprfile.cpp
@@ -155,7 +155,7 @@ ComprFileReadBase::SetPosition(uint64_t newPosition,
bool readAll,
ComprFileDecodeContext &decodeContext,
int &bitOffset,
- FastOS_FileInterface &file,
+ FastOS_FileInterface *file,
uint64_t &fileReadByteOffset,
uint64_t fileSize,
ComprBuffer &cbuf)
@@ -176,7 +176,7 @@ ComprFileReadBase::SetPosition(uint64_t newPosition,
readAll,
decodeContext,
bitOffset,
- file,
+ *file,
fileReadByteOffset,
fileSize,
cbuf);
@@ -200,7 +200,7 @@ ComprFileReadBase::SetPosition(uint64_t newPosition,
readAll,
decodeContext,
bitOffset,
- file,
+ *file,
fileReadByteOffset,
fileSize,
cbuf);
@@ -221,9 +221,8 @@ ComprFileReadBase::SetPosition(uint64_t newPosition,
(cbuf.getUnitBitSize() - 1));
assert(pos <= static_cast<int64_t>(fileSize));
-
- file.SetPosition(pos);
- assert(pos == file.GetPosition());
+ file->SetPosition(pos);
+ assert(pos == file->GetPosition());
decodeContext.emptyBuffer(newPosition);
assert(decodeContext.getBitPos(bitOffset,
@@ -337,7 +336,7 @@ ComprFileReadContext::setPosition(uint64_t newPosition)
_readAll,
*_decodeContext,
_bitOffset,
- *_file,
+ _file,
_fileReadByteOffset,
_fileSize,
*this);
diff --git a/searchlib/src/vespa/searchlib/util/comprfile.h b/searchlib/src/vespa/searchlib/util/comprfile.h
index 2ee95a53235..dc8cf6185fc 100644
--- a/searchlib/src/vespa/searchlib/util/comprfile.h
+++ b/searchlib/src/vespa/searchlib/util/comprfile.h
@@ -76,7 +76,7 @@ public:
bool readAll,
ComprFileDecodeContext &decodeContext,
int &bitOffset,
- FastOS_FileInterface &file,
+ FastOS_FileInterface *file,
uint64_t &fileReadByteOffset,
uint64_t fileSize,
ComprBuffer &cbuf);