summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-08-22 13:58:58 +0200
committerGitHub <noreply@github.com>2019-08-22 13:58:58 +0200
commit63513d5f76fd005f18a72ea9a458b46581ee42f6 (patch)
treed8f54c1cdcfd37ff32bc56531653e55f817b3e8d
parenta112f7bb1e0f4a378d4388cd6bcc2d12b34eb8ef (diff)
parent55baedfd0f39397ddaf78ada8df864a31fff6eb2 (diff)
Merge pull request #10371 from vespa-engine/geirst/attribute-code-cleanup
Geirst/attribute code cleanup.
-rw-r--r--searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp15
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumattribute.hpp20
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp17
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp40
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h65
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h69
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp143
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistattribute.h47
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp23
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp36
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h58
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp37
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h66
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp39
18 files changed, 322 insertions, 368 deletions
diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
index 620708f8c9b..2d91ac7c689 100644
--- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
+++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp
@@ -452,9 +452,8 @@ PostingListAttributeTest::checkPostingList(const VectorType & vec, const std::ve
const uint32_t docBegin = range.getBegin(i);
const uint32_t docEnd = range.getEnd(i);
- typename VectorType::DictionaryIterator itr =
- dict.find(typename VectorType::EnumIndex(),
- typename VectorType::ComparatorType(enumStore, values[i]));
+ auto itr = dict.find(typename VectorType::EnumIndex(),
+ typename VectorType::ComparatorType(enumStore, values[i]));
ASSERT_TRUE(itr.valid());
typename VectorType::PostingList::Iterator postings;
@@ -672,9 +671,8 @@ PostingListAttributeTest::checkPostingList(AttributeType & vec, ValueType value,
const typename AttributeType::EnumStore & enumStore = vec.getEnumStore();
const typename AttributeType::Dictionary & dict = enumStore.getPostingDictionary();
const typename AttributeType::PostingList & postingList = vec.getPostingList();
- typename AttributeType::DictionaryIterator itr =
- dict.find(typename AttributeType::EnumIndex(),
- typename AttributeType::ComparatorType(vec.getEnumStore(), value));
+ auto itr = dict.find(typename AttributeType::EnumIndex(),
+ typename AttributeType::ComparatorType(vec.getEnumStore(), value));
ASSERT_TRUE(itr.valid());
typename AttributeType::PostingList::Iterator postings;
@@ -693,9 +691,8 @@ void
PostingListAttributeTest::checkNonExistantPostingList(AttributeType & vec, ValueType value)
{
const typename AttributeType::Dictionary & dict = vec.getEnumStore().getPostingDictionary();
- typename AttributeType::DictionaryIterator itr =
- dict.find(typename AttributeType::EnumIndex(),
- typename AttributeType::ComparatorType(vec.getEnumStore(), value));
+ auto itr = dict.find(typename AttributeType::EnumIndex(),
+ typename AttributeType::ComparatorType(vec.getEnumStore(), value));
EXPECT_TRUE(!itr.valid());
}
diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
index 51ef16155b5..44254ed82b2 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.hpp
@@ -28,22 +28,22 @@ void EnumAttribute<B>::fillEnum(LoadedVector & loaded)
{
typename EnumStore::Builder builder;
if (!loaded.empty()) {
- typename LoadedVector::Type v = loaded.read();
- LoadedValueType prev = v.getValue();
+ auto value = loaded.read();
+ LoadedValueType prev = value.getValue();
uint32_t prevRefCount(0);
- EnumIndex index = builder.insert(v.getValue(), v._pidx.ref());
- for(size_t i(0), m(loaded.size()); i < m; ++i, loaded.next()) {
- v = loaded.read();
- if (EnumStore::ComparatorType::compare(prev, v.getValue()) != 0) {
+ EnumIndex index = builder.insert(value.getValue(), value._pidx.ref());
+ for (size_t i(0), m(loaded.size()); i < m; ++i, loaded.next()) {
+ value = loaded.read();
+ if (EnumStore::ComparatorType::compare(prev, value.getValue()) != 0) {
builder.updateRefCount(prevRefCount);
- index = builder.insert(v.getValue(), v._pidx.ref());
- prev = v.getValue();
+ index = builder.insert(value.getValue(), value._pidx.ref());
+ prev = value.getValue();
prevRefCount = 1;
} else {
prevRefCount++;
}
- v.setEidx(index);
- loaded.write(v);
+ value.setEidx(index);
+ loaded.write(value);
}
builder.updateRefCount(prevRefCount);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp
index a88bb186f8a..d1364854e41 100644
--- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp
@@ -67,12 +67,12 @@ MultiValueEnumAttribute<B, M>::applyValueChanges(const DocIndices& docIndices, E
{
// set new set of indices for documents with changes
ValueModifier valueGuard(this->getValueModifier());
- for (typename DocIndices::const_iterator iter = docIndices.begin(); iter != docIndices.end(); ++iter) {
- vespalib::ConstArrayRef<WeightedIndex> oldIndices(this->_mvMapping.get(iter->first));
+ for (const auto& doc_values : docIndices) {
+ vespalib::ConstArrayRef<WeightedIndex> oldIndices(this->_mvMapping.get(doc_values.first));
uint32_t valueCount = oldIndices.size();
- this->_mvMapping.set(iter->first, iter->second);
- for (uint32_t i = 0; i < iter->second.size(); ++i) {
- updater.inc_ref_count(iter->second[i]);
+ this->_mvMapping.set(doc_values.first, doc_values.second);
+ for (uint32_t i = 0; i < doc_values.second.size(); ++i) {
+ updater.inc_ref_count(doc_values.second[i]);
}
for (uint32_t i = 0; i < valueCount; ++i) {
updater.dec_ref_count(oldIndices[i]);
@@ -90,7 +90,7 @@ MultiValueEnumAttribute<B, M>::fillValues(LoadedVector & loaded)
WeightedIndexVector indices;
this->_mvMapping.prepareLoadFromMultiValue();
for (DocId doc = 0; doc < numDocs; ++doc) {
- for(const typename LoadedVector::Type * v = & loaded.read();(count < numValues) && (v->_docId == doc); count++, loaded.next(), v = & loaded.read()) {
+ for(const auto* v = & loaded.read();(count < numValues) && (v->_docId == doc); count++, loaded.next(), v = & loaded.read()) {
indices.push_back(WeightedIndex(v->getEidx(), v->getWeight()));
}
this->checkSetMaxValueCount(indices.size());
@@ -147,7 +147,8 @@ extract(const IWeightedIndexVector::WeightedIndex * values) {
template <typename B, typename M>
uint32_t
-MultiValueEnumAttribute<B, M>::getEnumHandles(DocId doc, const IWeightedIndexVector::WeightedIndex * & values) const {
+MultiValueEnumAttribute<B, M>::getEnumHandles(DocId doc, const IWeightedIndexVector::WeightedIndex * & values) const
+{
WeightedIndexArrayRef indices(this->_mvMapping.get(doc));
values = extract(&indices[0]);
return indices.size();
@@ -218,7 +219,7 @@ std::unique_ptr<AttributeSaver>
MultiValueEnumAttribute<B, M>::onInitSave(vespalib::stringref fileName)
{
this->_enumStore.reEnumerate();
- vespalib::GenerationHandler::Guard guard(this->getGenerationHandler().takeGuard());
+ auto guard = this->getGenerationHandler().takeGuard();
return std::make_unique<MultiValueEnumAttributeSaver<WeightedIndex>>
(std::move(guard), this->createAttributeHeader(fileName), this->_mvMapping, this->_enumStore);
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp
index 6a212b8d8b6..83f7563de12 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.hpp
@@ -95,13 +95,15 @@ MultiValueNumericEnumAttribute<B, M>::onLoad()
AttributeReader attrReader(*this);
bool ok(attrReader.getHasLoadData());
- if (!ok)
+ if (!ok) {
return false;
+ }
this->setCreateSerialNum(attrReader.getCreateSerialNum());
- if (attrReader.getEnumerated())
+ if (attrReader.getEnumerated()) {
return onLoadEnumerated(attrReader);
+ }
size_t numDocs = attrReader.getNumIdx() - 1;
uint32_t numValues = attrReader.getNumValues();
@@ -148,7 +150,8 @@ MultiValueNumericEnumAttribute<B, M>::SetSearchContext::SetSearchContext(QueryTe
template <typename B, typename M>
Int64Range
-MultiValueNumericEnumAttribute<B, M>::SetSearchContext::getAsIntegerTerm() const {
+MultiValueNumericEnumAttribute<B, M>::SetSearchContext::getAsIntegerTerm() const
+{
return this->getRange();
}
@@ -160,15 +163,13 @@ MultiValueNumericEnumAttribute<B, M>::SetSearchContext::createFilterIterator(fef
return std::make_unique<queryeval::EmptySearch>();
}
if (getIsFilter()) {
- return queryeval::SearchIterator::UP
- (strict
- ? new FilterAttributeIteratorStrict<SetSearchContext>(*this, matchData)
- : new FilterAttributeIteratorT<SetSearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<FilterAttributeIteratorStrict<SetSearchContext>>(*this, matchData)
+ : std::make_unique<FilterAttributeIteratorT<SetSearchContext>>(*this, matchData);
}
- return queryeval::SearchIterator::UP
- (strict
- ? new AttributeIteratorStrict<SetSearchContext>(*this, matchData)
- : new AttributeIteratorT<SetSearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<AttributeIteratorStrict<SetSearchContext>>(*this, matchData)
+ : std::make_unique<AttributeIteratorT<SetSearchContext>>(*this, matchData);
}
template <typename B, typename M>
@@ -179,15 +180,13 @@ MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::createFilterIterator(f
return std::make_unique<queryeval::EmptySearch>();
}
if (getIsFilter()) {
- return queryeval::SearchIterator::UP
- (strict
- ? new FilterAttributeIteratorStrict<ArraySearchContext>(*this, matchData)
- : new FilterAttributeIteratorT<ArraySearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<FilterAttributeIteratorStrict<ArraySearchContext>>(*this, matchData)
+ : std::make_unique<FilterAttributeIteratorT<ArraySearchContext>>(*this, matchData);
}
- return queryeval::SearchIterator::UP
- (strict
- ? new AttributeIteratorStrict<ArraySearchContext>(*this, matchData)
- : new AttributeIteratorT<ArraySearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<AttributeIteratorStrict<ArraySearchContext>>(*this, matchData)
+ : std::make_unique<AttributeIteratorT<ArraySearchContext>>(*this, matchData);
}
template <typename B, typename M>
@@ -199,7 +198,8 @@ MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::ArraySearchContext(Que
template <typename B, typename M>
Int64Range
-MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::getAsIntegerTerm() const {
+MultiValueNumericEnumAttribute<B, M>::ArraySearchContext::getAsIntegerTerm() const
+{
return this->getRange();
}
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
index b06cc419400..e990a1030f5 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h
@@ -8,7 +8,7 @@
namespace search {
-/*
+/**
* Implementation of multi value numeric attribute that in addition to enum store and
* multi value mapping uses an underlying posting list to provide faster search.
* This class is used for both array and weighted set types.
@@ -26,9 +26,13 @@ class MultiValueNumericPostingAttribute
typename B::LoadedValueType,
typename B::EnumStore>
{
+public:
+ using EnumStore = typename B::EnumStore;
+ using EnumIndex = typename EnumStore::Index;
+ using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
+
private:
- struct DocumentWeightAttributeAdapter : IDocumentWeightAttribute
- {
+ struct DocumentWeightAttributeAdapter : IDocumentWeightAttribute {
const MultiValueNumericPostingAttribute &self;
DocumentWeightAttributeAdapter(const MultiValueNumericPostingAttribute &self_in) : self(self_in) {}
virtual LookupResult lookup(const vespalib::string &term) const override final;
@@ -40,37 +44,32 @@ private:
friend class PostingListAttributeTest;
template <typename, typename, typename>
friend class attribute::PostingSearchContext; // getEnumStore()
- typedef MultiValueNumericPostingAttribute<B, M> SelfType;
-public:
- typedef typename B::EnumStore EnumStore;
- typedef typename EnumStore::Index EnumIndex;
- using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
-private:
- typedef typename B::DocId DocId;
- typedef typename B::LoadedVector LoadedVector;
- typedef attribute::LoadedEnumAttributeVector LoadedEnumAttributeVector;
- typedef PostingListAttributeSubBase<AttributeWeightPosting, LoadedVector,
- typename B::LoadedValueType, EnumStore> PostingParent;
- typedef typename PostingParent::PostingList PostingList;
- typedef typename PostingParent::PostingMap PostingMap;
- typedef typename PostingParent::Posting Posting;
- typedef EnumPostingTree Dictionary;
- typedef typename Dictionary::Iterator DictionaryIterator;
- typedef typename Dictionary::ConstIterator DictionaryConstIterator;
- typedef typename Dictionary::FrozenView FrozenDictionary;
- typedef typename EnumStore::ComparatorType ComparatorType;
-
- typedef typename MultiValueNumericEnumAttribute<B, M>::DocIndices DocIndices;
- typedef typename MultiValueNumericEnumAttribute<B, M>::generation_t generation_t;
- typedef typename MultiValueNumericEnumAttribute<B, M>::WeightedIndex WeightedIndex;
-
- typedef typename MultiValueNumericEnumAttribute<B, M>::ArraySearchContext ArraySearchContext;
- typedef typename MultiValueNumericEnumAttribute<B, M>::SetSearchContext SetSearchContext;
- typedef ArraySearchContext ArrayNumericSearchContext;
- typedef SetSearchContext SetNumericSearchContext;
+
+ using SelfType = MultiValueNumericPostingAttribute<B, M>;
+ using LoadedVector = typename B::LoadedVector;
+ using PostingParent = PostingListAttributeSubBase<AttributeWeightPosting, LoadedVector,
+ typename B::LoadedValueType, EnumStore>;
+
+ using ArraySearchContext = typename MultiValueNumericEnumAttribute<B, M>::ArraySearchContext;
+ using ArrayNumericSearchContext = ArraySearchContext;
+ using ArrayPostingSearchContext = attribute::NumericPostingSearchContext<ArrayNumericSearchContext, SelfType, int32_t>;
+ using ComparatorType = typename EnumStore::ComparatorType;
+ using Dictionary = EnumPostingTree;
+ using DictionaryConstIterator = typename Dictionary::ConstIterator;
+ using DocId = typename B::DocId;
+ using DocIndices = typename MultiValueNumericEnumAttribute<B, M>::DocIndices;
+ using FrozenDictionary = typename Dictionary::FrozenView;
+ using LoadedEnumAttributeVector = attribute::LoadedEnumAttributeVector;
+ using Posting = typename PostingParent::Posting;
+ using PostingList = typename PostingParent::PostingList;
+ using PostingMap = typename PostingParent::PostingMap;
using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
- typedef attribute::NumericPostingSearchContext<ArrayNumericSearchContext, SelfType, int32_t> ArrayPostingSearchContext;
- typedef attribute::NumericPostingSearchContext<SetNumericSearchContext, SelfType, int32_t> SetPostingSearchContext;
+ using SetSearchContext = typename MultiValueNumericEnumAttribute<B, M>::SetSearchContext;
+ using SetNumericSearchContext = SetSearchContext;
+ using SetPostingSearchContext = attribute::NumericPostingSearchContext<SetNumericSearchContext, SelfType, int32_t>;
+ using WeightedIndex = typename MultiValueNumericEnumAttribute<B, M>::WeightedIndex;
+ using generation_t = typename MultiValueNumericEnumAttribute<B, M>::generation_t;
+
using PostingParent::_postingList;
using PostingParent::clearAllPostings;
using PostingParent::handleFillPostings;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
index afe08ba204e..27744e6d4b3 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp
@@ -25,7 +25,7 @@ void
MultiValueNumericPostingAttribute<B, M>::applyValueChanges(const DocIndices& docIndices,
EnumStoreBatchUpdater& updater)
{
- typedef PostingChangeComputerT<WeightedIndex, PostingMap> PostingChangeComputer;
+ using PostingChangeComputer = PostingChangeComputerT<WeightedIndex, PostingMap>;
EnumStore & enumStore = this->getEnumStore();
ComparatorType compare(enumStore);
@@ -35,7 +35,6 @@ MultiValueNumericPostingAttribute<B, M>::applyValueChanges(const DocIndices& doc
MultiValueNumericEnumAttribute<B, M>::applyValueChanges(docIndices, updater);
}
-
template <typename B, typename M>
MultiValueNumericPostingAttribute<B, M>::MultiValueNumericPostingAttribute(const vespalib::string & name,
const AttributeVector::Config & cfg)
@@ -53,7 +52,6 @@ MultiValueNumericPostingAttribute<B, M>::~MultiValueNumericPostingAttribute()
clearAllPostings();
}
-
template <typename B, typename M>
void
MultiValueNumericPostingAttribute<B, M>::removeOldGenerations(generation_t firstUsed)
@@ -84,7 +82,6 @@ MultiValueNumericPostingAttribute<B, M>::getSearch(QueryTermSimpleUP qTerm,
return sc;
}
-
template <typename B, typename M>
IDocumentWeightAttribute::LookupResult
MultiValueNumericPostingAttribute<B, M>::DocumentWeightAttributeAdapter::lookup(const vespalib::string &term) const
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
index 7ce887f9292..7602a71a691 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringattribute.hpp
@@ -25,7 +25,7 @@ MultiValueStringAttributeT(const vespalib::string &name,
{ }
template <typename B, typename M>
-MultiValueStringAttributeT<B, M>::~MultiValueStringAttributeT() { }
+MultiValueStringAttributeT<B, M>::~MultiValueStringAttributeT() = default;
template <typename B, typename M>
@@ -94,7 +94,7 @@ template <typename B, typename M>
int32_t
MultiValueStringAttributeT<B, M>::StringImplSearchContext::onFind(DocId doc, int32_t elemId) const
{
- const MultiValueStringAttributeT<B, M> & attr(static_cast< const MultiValueStringAttributeT<B, M> & > (attribute()));
+ const auto& attr = static_cast<const MultiValueStringAttributeT<B, M>&>(attribute());
WeightedIndexArrayRef indices(attr._mvMapping.get(doc));
for (uint32_t i(elemId); i < indices.size(); i++) {
if (isMatch(attr._enumStore.getValue(indices[i].value()))) {
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
index a0be96ab3e9..88df7ec9704 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h
@@ -8,7 +8,7 @@
namespace search {
-/*
+/**
* Implementation of multi value string attribute that in addition to enum store and
* multi value mapping uses an underlying posting list to provide faster search.
* This class is used for both array and weighted set types.
@@ -25,9 +25,12 @@ class MultiValueStringPostingAttributeT
typename B::LoadedValueType,
typename B::EnumStore>
{
+public:
+ using EnumStore = typename MultiValueStringAttributeT<B, T>::EnumStore;
+ using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
+
private:
- struct DocumentWeightAttributeAdapter : IDocumentWeightAttribute
- {
+ struct DocumentWeightAttributeAdapter : IDocumentWeightAttribute {
const MultiValueStringPostingAttributeT &self;
DocumentWeightAttributeAdapter(const MultiValueStringPostingAttributeT &self_in) : self(self_in) {}
virtual LookupResult lookup(const vespalib::string &term) const override final;
@@ -40,38 +43,34 @@ private:
template <typename, typename, typename>
friend class attribute::PostingSearchContext; // getEnumStore()
friend class StringAttributeTest;
- typedef MultiValueStringPostingAttributeT<B, T> SelfType;
- typedef typename B::LoadedVector LoadedVector;
- typedef attribute::LoadedEnumAttributeVector LoadedEnumAttributeVector;
- typedef PostingListAttributeSubBase<AttributeWeightPosting,
- LoadedVector,
- typename B::LoadedValueType,
- typename B::EnumStore> PostingParent;
- typedef typename MultiValueStringAttributeT<B, T>::DocId DocId;
-public:
- typedef typename MultiValueStringAttributeT<B, T>::EnumStore EnumStore;
- typedef typename EnumStore::BatchUpdater EnumStoreBatchUpdater;
-private:
- typedef typename MultiValueStringAttributeT<B, T>::WeightedIndex WeightedIndex;
- typedef typename MultiValueStringAttributeT<B, T>::DocIndices DocIndices;
- typedef typename MultiValueStringAttributeT<B, T>::generation_t generation_t;
- typedef typename PostingParent::PostingList PostingList;
- typedef typename PostingParent::PostingMap PostingMap;
- typedef typename PostingParent::Posting Posting;
+
+ using LoadedVector = typename B::LoadedVector;
+ using PostingParent = PostingListAttributeSubBase<AttributeWeightPosting,
+ LoadedVector,
+ typename B::LoadedValueType,
+ typename B::EnumStore>;
+
+ using ComparatorType = typename EnumStore::ComparatorType;
+ using Dictionary = EnumPostingTree;
+ using DictionaryConstIterator = typename Dictionary::ConstIterator;
+ using DocId = typename MultiValueStringAttributeT<B, T>::DocId;
+ using DocIndices = typename MultiValueStringAttributeT<B, T>::DocIndices;
+ using EnumIndex = typename EnumStore::Index;
+ using FoldedComparatorType = typename EnumStore::FoldedComparatorType;
+ using FrozenDictionary = typename Dictionary::FrozenView;
+ using LoadedEnumAttributeVector = attribute::LoadedEnumAttributeVector;
+ using Posting = typename PostingParent::Posting;
+ using PostingList = typename PostingParent::PostingList;
+ using PostingMap = typename PostingParent::PostingMap;
using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
+ using SelfType = MultiValueStringPostingAttributeT<B, T>;
+ using StringArrayImplSearchContext = typename MultiValueStringAttributeT<B, T>::StringArrayImplSearchContext;
+ using StringArrayPostingSearchContext = attribute::StringPostingSearchContext<StringArrayImplSearchContext, SelfType, int32_t>;
+ using StringSetImplSearchContext = typename MultiValueStringAttributeT<B, T>::StringSetImplSearchContext;
+ using StringSetPostingSearchContext = attribute::StringPostingSearchContext<StringSetImplSearchContext, SelfType, int32_t>;
+ using WeightedIndex = typename MultiValueStringAttributeT<B, T>::WeightedIndex;
+ using generation_t = typename MultiValueStringAttributeT<B, T>::generation_t;
- typedef typename MultiValueStringAttributeT<B, T>::StringSetImplSearchContext StringSetImplSearchContext;
- typedef typename MultiValueStringAttributeT<B, T>::StringArrayImplSearchContext StringArrayImplSearchContext;
- typedef attribute::StringPostingSearchContext<StringSetImplSearchContext, SelfType, int32_t> StringSetPostingSearchContext;
- typedef attribute::StringPostingSearchContext<StringArrayImplSearchContext, SelfType, int32_t> StringArrayPostingSearchContext;
-
- typedef EnumPostingTree Dictionary;
- typedef typename EnumStore::Index EnumIndex;
- typedef typename EnumStore::ComparatorType ComparatorType;
- typedef typename EnumStore::FoldedComparatorType FoldedComparatorType;
- typedef typename Dictionary::Iterator DictionaryIterator;
- typedef typename Dictionary::ConstIterator DictionaryConstIterator;
- typedef typename Dictionary::FrozenView FrozenDictionary;
using PostingParent::_postingList;
using PostingParent::clearAllPostings;
using PostingParent::handleFillPostings;
@@ -113,8 +112,8 @@ public:
}
};
-typedef MultiValueStringPostingAttributeT<EnumAttribute<StringAttribute>, multivalue::Value<EnumStoreBase::Index> > ArrayStringPostingAttribute;
-typedef MultiValueStringPostingAttributeT<EnumAttribute<StringAttribute>, multivalue::WeightedValue<EnumStoreBase::Index> > WeightedSetStringPostingAttribute;
+using ArrayStringPostingAttribute = MultiValueStringPostingAttributeT<EnumAttribute<StringAttribute>, multivalue::Value<EnumStoreBase::Index> >;
+using WeightedSetStringPostingAttribute = MultiValueStringPostingAttributeT<EnumAttribute<StringAttribute>, multivalue::WeightedValue<EnumStoreBase::Index> >;
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
index 92b06b50258..8268d1ace20 100644
--- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp
@@ -41,7 +41,7 @@ void
MultiValueStringPostingAttributeT<B, T>::
applyValueChanges(const DocIndices& docIndices, EnumStoreBatchUpdater &updater)
{
- typedef PostingChangeComputerT<WeightedIndex, PostingMap> PostingChangeComputer;
+ using PostingChangeComputer = PostingChangeComputerT<WeightedIndex, PostingMap>;
EnumStore &enumStore(this->getEnumStore());
Dictionary &dict(enumStore.getPostingDictionary());
FoldedComparatorType compare(enumStore);
@@ -66,7 +66,6 @@ MultiValueStringPostingAttributeT<B, T>::mergeMemoryStats(vespalib::MemoryUsage
total.merge(this->_postingList.getMemoryUsage());
}
-
template <typename B, typename T>
void
MultiValueStringPostingAttributeT<B, T>::removeOldGenerations(generation_t firstUsed)
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
index 53fdf81f505..aa515e82c94 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
@@ -21,12 +21,8 @@ PostingListAttributeBase(AttributeVector &attr,
_esb(enumStore)
{ }
-
template <typename P>
-PostingListAttributeBase<P>::~PostingListAttributeBase()
-{
-}
-
+PostingListAttributeBase<P>::~PostingListAttributeBase() = default;
template <typename P>
void
@@ -34,7 +30,7 @@ PostingListAttributeBase<P>::clearAllPostings()
{
_postingList.clearBuilder();
_attr.incGeneration(); // Force freeze
- EnumPostingTree::Iterator itr(_dict.begin());
+ auto itr = _dict.begin();
EntryRef prev;
while (itr.valid()) {
EntryRef ref = itr.getData();
@@ -53,36 +49,34 @@ PostingListAttributeBase<P>::clearAllPostings()
template <typename P>
void
-PostingListAttributeBase<P>::fillPostingsFixupEnumBase(
- const LoadedEnumAttributeVector &loaded)
+PostingListAttributeBase<P>::fillPostingsFixupEnumBase(const LoadedEnumAttributeVector &loaded)
{
clearAllPostings();
uint32_t docIdLimit = _attr.getNumDocs();
EnumStoreBase &enumStore = _esb;
EntryRef newIndex;
PostingChange<P> postings;
- if ( loaded.empty() )
+ if (loaded.empty()) {
return;
- typedef LoadedEnumAttributeVector::const_iterator LoadedIT;
+ }
uint32_t preve = 0;
uint32_t refCount = 0;
- typedef EnumPostingTree::Iterator DictIT;
-
- DictIT di(_dict.begin());
- DictIT pdi(di);
- assert(di.valid());
- for(LoadedIT i(loaded.begin()), ie(loaded.end()); i != ie; ++i) {
- if (preve != i->getEnum()) {
- assert(preve < i->getEnum());
- enumStore.fixupRefCount(di.getKey(), refCount);
+
+ auto itr = _dict.begin();
+ auto posting_itr = itr;
+ assert(itr.valid());
+ for (const auto& elem : loaded) {
+ if (preve != elem.getEnum()) {
+ assert(preve < elem.getEnum());
+ enumStore.fixupRefCount(itr.getKey(), refCount);
refCount = 0;
- while (preve != i->getEnum()) {
- ++di;
- assert(di.valid());
+ while (preve != elem.getEnum()) {
+ ++itr;
+ assert(itr.valid());
++preve;
}
- assert(di.valid());
- if (enumStore.foldedChange(pdi.getKey(), di.getKey())) {
+ assert(itr.valid());
+ if (enumStore.foldedChange(posting_itr.getKey(), itr.getKey())) {
postings.removeDups();
newIndex = EntryRef();
_postingList.apply(newIndex,
@@ -92,20 +86,20 @@ PostingListAttributeBase<P>::fillPostingsFixupEnumBase(
&postings._removals[0],
&postings._removals[0] +
postings._removals.size());
- pdi.writeData(newIndex);
- while (pdi != di) {
- ++pdi;
+ posting_itr.writeData(newIndex);
+ while (posting_itr != itr) {
+ ++posting_itr;
}
postings.clear();
}
}
++refCount;
- assert(i->getDocId() < docIdLimit);
+ assert(elem.getDocId() < docIdLimit);
(void) docIdLimit;
- postings.add(i->getDocId(), i->getWeight());
+ postings.add(elem.getDocId(), elem.getWeight());
}
assert(refCount != 0);
- enumStore.fixupRefCount(di.getKey(), refCount);
+ enumStore.fixupRefCount(itr.getKey(), refCount);
postings.removeDups();
newIndex = EntryRef();
_postingList.apply(newIndex,
@@ -113,22 +107,19 @@ PostingListAttributeBase<P>::fillPostingsFixupEnumBase(
&postings._additions[0] + postings._additions.size(),
&postings._removals[0],
&postings._removals[0] + postings._removals.size());
- pdi.writeData(newIndex);
+ posting_itr.writeData(newIndex);
enumStore.freeUnusedEnums(false);
}
-
template <typename P>
void
PostingListAttributeBase<P>::updatePostings(PostingMap &changePost,
EnumStoreComparator &cmp)
{
- for (typename PostingMap::iterator
- it(changePost.begin()), mt(changePost.end()); it != mt; it++) {
- PostingChange<P> &change(it->second);
- EnumIndex idx(it->first.getEnumIdx());
- typename EnumPostingTree::Iterator dictItr =
- _dict.lowerBound(idx, cmp);
+ for (auto& elem : changePost) {
+ auto& change = elem.second;
+ EnumIndex idx = elem.first.getEnumIdx();
+ auto dictItr = _dict.lowerBound(idx, cmp);
assert(dictItr.valid() && dictItr.getKey() == idx);
EntryRef newPosting = dictItr.getData();
@@ -144,23 +135,24 @@ PostingListAttributeBase<P>::updatePostings(PostingMap &changePost,
}
}
-
template <typename P>
bool
PostingListAttributeBase<P>::forwardedOnAddDoc(DocId doc,
size_t wantSize,
size_t wantCapacity)
{
- if (!_postingList._enableBitVectors)
+ if (!_postingList._enableBitVectors) {
return false;
- if (doc >= wantSize)
+ }
+ if (doc >= wantSize) {
wantSize = doc + 1;
- if (doc >= wantCapacity)
+ }
+ if (doc >= wantCapacity) {
wantCapacity = doc + 1;
+ }
return _postingList.resizeBitVectors(wantSize, wantCapacity);
}
-
template <typename P>
void
PostingListAttributeBase<P>::
@@ -175,12 +167,11 @@ clearPostings(attribute::IAttributeVector::EnumHandle eidx,
postings.remove(lid);
}
- typedef EnumPostingTree::Iterator DictIT;
EntryRef er(eidx);
- DictIT di(_dict.lowerBound(er, cmp));
- assert(di.valid());
+ auto itr = _dict.lowerBound(er, cmp);
+ assert(itr.valid());
- EntryRef newPosting = di.getData();
+ EntryRef newPosting = itr.getData();
assert(newPosting.valid());
_postingList.apply(newPosting,
@@ -190,11 +181,10 @@ clearPostings(attribute::IAttributeVector::EnumHandle eidx,
&postings._removals[0],
&postings._removals[0] +
postings._removals.size());
- _dict.thaw(di);
- di.writeData(newPosting);
+ _dict.thaw(itr);
+ itr.writeData(newPosting);
}
-
template <typename P>
void
PostingListAttributeBase<P>::forwardedShrinkLidSpace(uint32_t newSize)
@@ -219,14 +209,10 @@ PostingListAttributeSubBase(AttributeVector &attr,
{
}
-
template <typename P, typename LoadedVector, typename LoadedValueType,
typename EnumStoreType>
PostingListAttributeSubBase<P, LoadedVector, LoadedValueType, EnumStoreType>::
-~PostingListAttributeSubBase()
-{
-}
-
+~PostingListAttributeSubBase() = default;
template <typename P, typename LoadedVector, typename LoadedValueType,
typename EnumStoreType>
@@ -241,17 +227,17 @@ handleFillPostings(LoadedVector &loaded)
_postingList.resizeBitVectors(docIdLimit, docIdLimit);
if ( ! loaded.empty() ) {
vespalib::Array<typename LoadedVector::Type> similarValues;
- typename LoadedVector::Type v = loaded.read();
- LoadedValueType prev = v.getValue();
- for(size_t i(0), m(loaded.size()); i < m; i++, loaded.next()) {
- v = loaded.read();
- if (FoldedComparatorType::compareFolded(prev, v.getValue()) == 0) {
+ auto value = loaded.read();
+ LoadedValueType prev = value.getValue();
+ for (size_t i(0), m(loaded.size()); i < m; i++, loaded.next()) {
+ value = loaded.read();
+ if (FoldedComparatorType::compareFolded(prev, value.getValue()) == 0) {
// for single value attributes loaded[numDocs] is used
// for default value but we don't want to add an
// invalid docId to the posting list.
- if (v._docId < docIdLimit) {
- postings.add(v._docId, v.getWeight());
- similarValues.push_back(v);
+ if (value._docId < docIdLimit) {
+ postings.add(value._docId, value.getWeight());
+ similarValues.push_back(value);
}
} else {
postings.removeDups();
@@ -265,16 +251,16 @@ handleFillPostings(LoadedVector &loaded)
&postings._removals[0] +
postings._removals.size());
postings.clear();
- if (v._docId < docIdLimit) {
- postings.add(v._docId, v.getWeight());
+ if (value._docId < docIdLimit) {
+ postings.add(value._docId, value.getWeight());
}
similarValues[0]._pidx = newIndex;
- for(size_t j(0), k(similarValues.size()); j < k; j++) {
+ for (size_t j(0), k(similarValues.size()); j < k; j++) {
loaded.write(similarValues[j]);
}
similarValues.clear();
- similarValues.push_back(v);
- prev = v.getValue();
+ similarValues.push_back(value);
+ prev = value.getValue();
}
}
@@ -287,7 +273,7 @@ handleFillPostings(LoadedVector &loaded)
&postings._removals[0],
&postings._removals[0] + postings._removals.size());
similarValues[0]._pidx = newIndex;
- for(size_t i(0), m(similarValues.size()); i < m; i++) {
+ for (size_t i(0), m(similarValues.size()); i < m; i++) {
loaded.write(similarValues[i]);
}
}
@@ -319,27 +305,20 @@ clearPostings(attribute::IAttributeVector::EnumHandle eidx,
}
-
template class PostingListAttributeBase<AttributePosting>;
template class PostingListAttributeBase<AttributeWeightPosting>;
-typedef SequentialReadModifyWriteInterface<LoadedNumericValue<int8_t> >
-LoadedInt8Vector;
+using LoadedInt8Vector = SequentialReadModifyWriteInterface<LoadedNumericValue<int8_t> >;
-typedef SequentialReadModifyWriteInterface<LoadedNumericValue<int16_t> >
-LoadedInt16Vector;
+using LoadedInt16Vector = SequentialReadModifyWriteInterface<LoadedNumericValue<int16_t> >;
-typedef SequentialReadModifyWriteInterface<LoadedNumericValue<int32_t> >
-LoadedInt32Vector;
+using LoadedInt32Vector = SequentialReadModifyWriteInterface<LoadedNumericValue<int32_t> >;
-typedef SequentialReadModifyWriteInterface<LoadedNumericValue<int64_t> >
-LoadedInt64Vector;
+using LoadedInt64Vector = SequentialReadModifyWriteInterface<LoadedNumericValue<int64_t> >;
-typedef SequentialReadModifyWriteInterface<LoadedNumericValue<float> >
-LoadedFloatVector;
+using LoadedFloatVector = SequentialReadModifyWriteInterface<LoadedNumericValue<float> >;
-typedef SequentialReadModifyWriteInterface<LoadedNumericValue<double> >
-LoadedDoubleVector;
+using LoadedDoubleVector = SequentialReadModifyWriteInterface<LoadedNumericValue<double> >;
template class
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h
index c35e02f7519..539b362534b 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.h
@@ -32,18 +32,19 @@ public:
template <typename P>
-class PostingListAttributeBase : public attribute::IPostingListAttributeBase
-{
+class PostingListAttributeBase : public attribute::IPostingListAttributeBase {
protected:
- typedef P Posting;
- typedef typename Posting::DataType DataType;
- typedef attribute::PostingListTraits<DataType> AggregationTraits;
- typedef typename AggregationTraits::PostingList PostingList;
- typedef AttributeVector::DocId DocId;
- typedef std::map<EnumPostingPair, PostingChange<P> > PostingMap;
- typedef datastore::EntryRef EntryRef;
- typedef attribute::LoadedEnumAttributeVector LoadedEnumAttributeVector;
- typedef EnumStoreBase::Index EnumIndex;
+ using Posting = P;
+ using DataType = typename Posting::DataType;
+
+ using AggregationTraits = attribute::PostingListTraits<DataType>;
+ using DocId = AttributeVector::DocId;
+ using EntryRef = datastore::EntryRef;
+ using EnumIndex = EnumStoreBase::Index;
+ using LoadedEnumAttributeVector = attribute::LoadedEnumAttributeVector;
+ using PostingList = typename AggregationTraits::PostingList;
+ using PostingMap = std::map<EnumPostingPair, PostingChange<P> >;
+
PostingList _postingList;
AttributeVector &_attr;
EnumPostingTree &_dict;
@@ -74,20 +75,18 @@ public:
template <typename P, typename LoadedVector, typename LoadedValueType,
typename EnumStoreType>
-class PostingListAttributeSubBase : public PostingListAttributeBase<P>
-{
+class PostingListAttributeSubBase : public PostingListAttributeBase<P> {
public:
- typedef PostingListAttributeBase<P> Parent;
- typedef EnumStoreType EnumStore;
- typedef EnumPostingTree Dictionary;
- typedef typename Dictionary::Iterator DictionaryIterator;
- typedef EnumStoreBase::Index EnumIndex;
- typedef typename EnumStore::FoldedComparatorType FoldedComparatorType;
- typedef datastore::EntryRef EntryRef;
- typedef typename Parent::PostingMap PostingMap;
- typedef typename Parent::PostingList PostingList;
- typedef typename PostingList::Iterator PostingIterator;
- typedef attribute::LoadedEnumAttributeVector LoadedEnumAttributeVector;
+ using Parent = PostingListAttributeBase<P>;
+
+ using Dictionary = EnumPostingTree;
+ using EntryRef = datastore::EntryRef;
+ using EnumIndex = EnumStoreBase::Index;
+ using EnumStore = EnumStoreType;
+ using FoldedComparatorType = typename EnumStore::FoldedComparatorType;
+ using LoadedEnumAttributeVector = attribute::LoadedEnumAttributeVector;
+ using PostingList = typename Parent::PostingList;
+ using PostingMap = typename Parent::PostingMap;
using Parent::clearAllPostings;
using Parent::updatePostings;
diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp
index 22ac5be64b2..7b9ba6f61d2 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp
@@ -26,7 +26,9 @@ SingleValueEnumAttribute<B>::~SingleValueEnumAttribute()
}
template <typename B>
-bool SingleValueEnumAttribute<B>::onAddDoc(DocId doc) {
+bool
+SingleValueEnumAttribute<B>::onAddDoc(DocId doc)
+{
if (doc < _enumIndices.capacity()) {
_enumIndices.reserve(doc+1);
return true;
@@ -36,7 +38,8 @@ bool SingleValueEnumAttribute<B>::onAddDoc(DocId doc) {
template <typename B>
void
-SingleValueEnumAttribute<B>::onAddDocs(DocId limit) {
+SingleValueEnumAttribute<B>::onAddDocs(DocId limit)
+{
_enumIndices.reserve(limit);
}
@@ -174,13 +177,13 @@ void
SingleValueEnumAttribute<B>::applyValueChanges(EnumStoreBatchUpdater& updater)
{
ValueModifier valueGuard(this->getValueModifier());
- for (ChangeVectorIterator iter = this->_changes.begin(), end = this->_changes.end(); iter != end; ++iter) {
- if (iter->_type == ChangeBase::UPDATE) {
- applyUpdateValueChange(*iter, updater);
- } else if (iter->_type >= ChangeBase::ADD && iter->_type <= ChangeBase::DIV) {
- applyArithmeticValueChange(*iter, updater);
- } else if (iter->_type == ChangeBase::CLEARDOC) {
- this->_defaultValue._doc = iter->_doc;
+ for (const auto& change : this->_changes) {
+ if (change._type == ChangeBase::UPDATE) {
+ applyUpdateValueChange(change, updater);
+ } else if (change._type >= ChangeBase::ADD && change._type <= ChangeBase::DIV) {
+ applyArithmeticValueChange(change, updater);
+ } else if (change._type == ChangeBase::CLEARDOC) {
+ this->_defaultValue._doc = change._doc;
applyUpdateValueChange(this->_defaultValue, updater);
}
}
@@ -306,7 +309,7 @@ std::unique_ptr<AttributeSaver>
SingleValueEnumAttribute<B>::onInitSave(vespalib::stringref fileName)
{
this->_enumStore.reEnumerate();
- vespalib::GenerationHandler::Guard guard(this->getGenerationHandler().takeGuard());
+ auto guard = this->getGenerationHandler().takeGuard();
return std::make_unique<SingleValueEnumAttributeSaver>
(std::move(guard),
this->createAttributeHeader(fileName),
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
index 13b923a894a..3b037561483 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp
@@ -26,7 +26,7 @@ void
SingleValueNumericEnumAttribute<B>::considerArithmeticAttributeChange(const Change & c, UniqueSet & newUniques)
{
T oldValue;
- typename std::map<DocId, T>::const_iterator iter = _currDocValues.find(c._doc);
+ auto iter = _currDocValues.find(c._doc);
if (iter != _currDocValues.end()) {
oldValue = iter->second;
} else {
@@ -65,7 +65,7 @@ SingleValueNumericEnumAttribute(const vespalib::string & baseFileName,
}
template <typename B>
-SingleValueNumericEnumAttribute<B>::~SingleValueNumericEnumAttribute() {}
+SingleValueNumericEnumAttribute<B>::~SingleValueNumericEnumAttribute() = default;
template <typename B>
void
@@ -118,13 +118,15 @@ SingleValueNumericEnumAttribute<B>::onLoad()
PrimitiveReader<T> attrReader(*this);
bool ok(attrReader.getHasLoadData());
- if (!ok)
+ if (!ok) {
return false;
+ }
this->setCreateSerialNum(attrReader.getCreateSerialNum());
- if (attrReader.getEnumerated())
+ if (attrReader.getEnumerated()) {
return onLoadEnumerated(attrReader);
+ }
const uint32_t numDocs(attrReader.getDataCount());
SequentialReadModifyWriteVector<LoadedNumericValueT> loaded(numDocs);
@@ -168,7 +170,11 @@ SingleValueNumericEnumAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
}
template <typename B>
-bool SingleValueNumericEnumAttribute<B>::SingleSearchContext::valid() const { return this->isValid(); }
+bool
+SingleValueNumericEnumAttribute<B>::SingleSearchContext::valid() const
+{
+ return this->isValid();
+}
template <typename B>
SingleValueNumericEnumAttribute<B>::SingleSearchContext::SingleSearchContext(QueryTermSimpleUP qTerm, const NumericAttribute & toBeSearched) :
@@ -178,7 +184,9 @@ SingleValueNumericEnumAttribute<B>::SingleSearchContext::SingleSearchContext(Que
{ }
template <typename B>
-Int64Range SingleValueNumericEnumAttribute<B>::SingleSearchContext::getAsIntegerTerm() const {
+Int64Range
+SingleValueNumericEnumAttribute<B>::SingleSearchContext::getAsIntegerTerm() const
+{
return this->getRange();
}
@@ -188,18 +196,16 @@ SingleValueNumericEnumAttribute<B>::SingleSearchContext::createFilterIterator(fe
bool strict)
{
if (!valid()) {
- return queryeval::SearchIterator::UP(new queryeval::EmptySearch());
+ return std::make_unique<queryeval::EmptySearch>();
}
if (getIsFilter()) {
- return queryeval::SearchIterator::UP
- (strict
- ? new FilterAttributeIteratorStrict<SingleSearchContext>(*this, matchData)
- : new FilterAttributeIteratorT<SingleSearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<FilterAttributeIteratorStrict<SingleSearchContext>>(*this, matchData)
+ : std::make_unique<FilterAttributeIteratorT<SingleSearchContext>>(*this, matchData);
}
- return queryeval::SearchIterator::UP
- (strict
- ? new AttributeIteratorStrict<SingleSearchContext>(*this, matchData)
- : new AttributeIteratorT<SingleSearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<AttributeIteratorStrict<SingleSearchContext>>(*this, matchData)
+ : std::make_unique<AttributeIteratorT<SingleSearchContext>>(*this, matchData);
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h
index 805103efdc1..4895eb2256a 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h
@@ -8,7 +8,7 @@
namespace search {
-/*
+/**
* Implementation of single value numeric attribute that in addition to enum store
* uses an underlying posting list to provide faster search.
*
@@ -22,45 +22,37 @@ class SingleValueNumericPostingAttribute
typename B::LoadedValueType,
typename B::EnumStore>
{
+public:
+ using T = typename SingleValueNumericEnumAttribute<B>::T;
+ using Dictionary = EnumPostingTree;
+ using EnumStore = typename SingleValueNumericEnumAttribute<B>::EnumStore;
+ using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
+
private:
friend class PostingListAttributeTest;
template <typename, typename, typename>
friend class attribute::PostingSearchContext; // getEnumStore()
- typedef SingleValueNumericPostingAttribute<B> SelfType;
- typedef typename B::LoadedVector LoadedVector;
- typedef attribute::LoadedEnumAttributeVector LoadedEnumAttributeVector;
- typedef PostingListAttributeSubBase<AttributePosting,
- LoadedVector,
- typename B::LoadedValueType,
- typename B::EnumStore> PostingParent;
-public:
- typedef typename SingleValueNumericEnumAttribute<B>::EnumStore EnumStore;
- using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
-private:
- typedef typename SingleValueEnumAttributeBase::EnumIndex EnumIndex;
- typedef typename SingleValueNumericEnumAttribute<B>::generation_t generation_t;
-public:
- typedef typename SingleValueNumericEnumAttribute<B>::T T;
-private:
- using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
- typedef typename SingleValueNumericEnumAttribute<B>::SingleSearchContext SingleSearchContext;
- typedef SingleSearchContext SingleNumericSearchContext;
- typedef attribute::NumericPostingSearchContext<SingleNumericSearchContext, SelfType, btree::BTreeNoLeafData> SinglePostingSearchContext;
+ using LoadedVector = typename B::LoadedVector;
+ using PostingParent = PostingListAttributeSubBase<AttributePosting,
+ LoadedVector,
+ typename B::LoadedValueType,
+ typename B::EnumStore>;
- typedef typename PostingParent::PostingMap PostingMap;
- typedef typename B::BaseClass::Change Change;
- typedef typename B::BaseClass::ChangeVector ChangeVector;
- typedef typename B::BaseClass::ChangeVector::const_iterator ChangeVectorIterator;
- typedef typename B::BaseClass::DocId DocId;
- typedef typename B::BaseClass::ValueModifier ValueModifier;
+ using Change = typename B::BaseClass::Change;
+ using ComparatorType = typename EnumStore::ComparatorType;
+ using DocId = typename B::BaseClass::DocId;
+ using EnumIndex = typename SingleValueEnumAttributeBase::EnumIndex;
+ using LoadedEnumAttributeVector = attribute::LoadedEnumAttributeVector;
+ using PostingMap = typename PostingParent::PostingMap;
+ using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
+ using SelfType = SingleValueNumericPostingAttribute<B>;
+ using SingleSearchContext = typename SingleValueNumericEnumAttribute<B>::SingleSearchContext;
+ using SingleNumericSearchContext = SingleSearchContext;
+ using SinglePostingSearchContext = attribute::NumericPostingSearchContext<SingleNumericSearchContext, SelfType, btree::BTreeNoLeafData>;
+ using ValueModifier = typename B::BaseClass::ValueModifier;
+ using generation_t = typename SingleValueNumericEnumAttribute<B>::generation_t;
-public:
- typedef EnumPostingTree Dictionary;
-private:
- typedef typename Dictionary::Iterator DictionaryIterator;
- typedef typename Dictionary::ConstIterator DictionaryConstIterator;
- typedef typename EnumStore::ComparatorType ComparatorType;
using PostingParent::_postingList;
using PostingParent::clearAllPostings;
using PostingParent::handleFillPostings;
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
index 2c7f187d2f4..0b80c7cbf4a 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp
@@ -57,12 +57,10 @@ makePostingChange(const EnumStoreComparator *cmpa,
const std::map<DocId, EnumIndex> &currEnumIndices,
PostingMap &changePost)
{
- typedef typename std::map<DocId, EnumIndex>::const_iterator EnumIter;
- for (EnumIter iter = currEnumIndices.begin(), end = currEnumIndices.end();
- iter != end; ++iter) {
- uint32_t docId = iter->first;
+ for (const auto& elem : currEnumIndices) {
+ uint32_t docId = elem.first;
EnumIndex oldIdx = this->_enumIndices[docId];
- EnumIndex newIdx = iter->second;
+ EnumIndex newIdx = elem.second;
// add new posting
changePost[EnumPostingPair(newIdx, cmpa)].add(docId, 1);
@@ -87,29 +85,29 @@ SingleValueNumericPostingAttribute<B>::applyValueChanges(EnumStoreBatchUpdater&
// used to make sure several arithmetic operations on the same document in a single commit works
std::map<DocId, EnumIndex> currEnumIndices;
- for (ChangeVectorIterator iter = this->_changes.begin(), end = this->_changes.end(); iter != end; ++iter) {
- typename std::map<DocId, EnumIndex>::const_iterator enumIter = currEnumIndices.find(iter->_doc);
+ for (const auto& change : this->_changes) {
+ auto enumIter = currEnumIndices.find(change._doc);
EnumIndex oldIdx;
if (enumIter != currEnumIndices.end()) {
oldIdx = enumIter->second;
} else {
- oldIdx = this->_enumIndices[iter->_doc];
+ oldIdx = this->_enumIndices[change._doc];
}
- if (iter->_type == ChangeBase::UPDATE) {
- applyUpdateValueChange(*iter, enumStore,
+ if (change._type == ChangeBase::UPDATE) {
+ applyUpdateValueChange(change, enumStore,
currEnumIndices);
- } else if (iter->_type >= ChangeBase::ADD && iter->_type <= ChangeBase::DIV) {
+ } else if (change._type >= ChangeBase::ADD && change._type <= ChangeBase::DIV) {
if (oldIdx.valid()) {
T oldValue = enumStore.getValue(oldIdx);
- T newValue = this->applyArithmetic(oldValue, *iter);
+ T newValue = this->applyArithmetic(oldValue, change);
- DictionaryIterator addItr = dict.find(EnumIndex(), ComparatorType(enumStore, newValue));
+ auto addItr = dict.find(EnumIndex(), ComparatorType(enumStore, newValue));
EnumIndex newIdx = addItr.getKey();
- currEnumIndices[iter->_doc] = newIdx;
+ currEnumIndices[change._doc] = newIdx;
}
- } else if(iter->_type == ChangeBase::CLEARDOC) {
- this->_defaultValue._doc = iter->_doc;
+ } else if(change._type == ChangeBase::CLEARDOC) {
+ this->_defaultValue._doc = change._doc;
applyUpdateValueChange(this->_defaultValue, enumStore,
currEnumIndices);
}
@@ -143,10 +141,9 @@ AttributeVector::SearchContext::UP
SingleValueNumericPostingAttribute<B>::getSearch(QueryTermSimple::UP qTerm,
const attribute::SearchContextParams & params) const
{
- return std::unique_ptr<AttributeVector::SearchContext>
- (new SinglePostingSearchContext(std::move(qTerm),
- params,
- *this));
+ return std::make_unique<SinglePostingSearchContext>(std::move(qTerm),
+ params,
+ *this);
}
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
index 4925cee023c..05914cfee14 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
@@ -29,7 +29,8 @@ SingleValueStringAttributeT<B>::~SingleValueStringAttributeT() = default;
template <typename B>
void
-SingleValueStringAttributeT<B>::freezeEnumDictionary() {
+SingleValueStringAttributeT<B>::freezeEnumDictionary()
+{
this->getEnumStore().freezeTree();
}
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h
index edaa7260880..5afbc5aee1b 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h
@@ -7,7 +7,7 @@
namespace search {
-/*
+/**
* Implementation of single value string attribute that in addition to enum store
* uses an underlying posting list to provide faster search.
*
@@ -21,47 +21,41 @@ class SingleValueStringPostingAttributeT
typename B::LoadedValueType,
typename B::EnumStore>
{
+public:
+ using EnumStore = typename SingleValueStringAttributeT<B>::EnumStore;
+ using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
+
private:
friend class PostingListAttributeTest;
template <typename, typename, typename>
friend class attribute::PostingSearchContext; // getEnumStore()
friend class StringAttributeTest;
- typedef SingleValueStringPostingAttributeT<B> SelfType;
- typedef typename B::LoadedVector LoadedVector;
- typedef attribute::LoadedEnumAttributeVector LoadedEnumAttributeVector;
- typedef PostingListAttributeSubBase<AttributePosting,
- LoadedVector,
- typename B::LoadedValueType,
- typename B::EnumStore> PostingParent;
- typedef typename SingleValueStringAttributeT<B>::DocId DocId;
-public:
- typedef typename SingleValueStringAttributeT<B>::EnumStore EnumStore;
- using EnumStoreBatchUpdater = typename EnumStore::BatchUpdater;
-private:
- typedef typename SingleValueStringAttributeT<B>::EnumIndex EnumIndex;
- typedef typename SingleValueStringAttributeT<B>::generation_t generation_t;
- typedef typename SingleValueStringAttributeT<B>::ValueModifier ValueModifier;
-
- typedef typename SingleValueStringAttributeT<B>::StringSingleImplSearchContext StringSingleImplSearchContext;
- typedef attribute::StringPostingSearchContext<StringSingleImplSearchContext,
- SelfType,
- btree::BTreeNoLeafData>
- StringSinglePostingSearchContext;
-
- typedef StringAttribute::Change Change;
- typedef StringAttribute::ChangeVector ChangeVector;
- using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
- typedef typename PostingParent::PostingList PostingList;
- typedef typename PostingParent::PostingMap PostingMap;
- // typedef typename PostingParent::Posting Posting;
+ using LoadedVector = typename B::LoadedVector;
+ using PostingParent = PostingListAttributeSubBase<AttributePosting,
+ LoadedVector,
+ typename B::LoadedValueType,
+ typename B::EnumStore>;
+
+ using Change = StringAttribute::Change;
+ using ChangeVector = StringAttribute::ChangeVector;
+ using ComparatorType = typename EnumStore::ComparatorType;
+ using Dictionary = EnumPostingTree;
+ using DocId = typename SingleValueStringAttributeT<B>::DocId;
+ using EnumIndex = typename SingleValueStringAttributeT<B>::EnumIndex;
+ using FoldedComparatorType = typename EnumStore::FoldedComparatorType;
+ using LoadedEnumAttributeVector = attribute::LoadedEnumAttributeVector;
+ using PostingList = typename PostingParent::PostingList;
+ using PostingMap = typename PostingParent::PostingMap;
+ using QueryTermSimpleUP = AttributeVector::QueryTermSimpleUP;
+ using SelfType = SingleValueStringPostingAttributeT<B>;
+ using StringSingleImplSearchContext = typename SingleValueStringAttributeT<B>::StringSingleImplSearchContext;
+ using StringSinglePostingSearchContext = attribute::StringPostingSearchContext<StringSingleImplSearchContext,
+ SelfType,
+ btree::BTreeNoLeafData>;
+ using ValueModifier = typename SingleValueStringAttributeT<B>::ValueModifier;
+ using generation_t = typename SingleValueStringAttributeT<B>::generation_t;
- typedef EnumPostingTree Dictionary;
- typedef typename EnumStore::ComparatorType ComparatorType;
- typedef typename EnumStore::FoldedComparatorType FoldedComparatorType;
- typedef typename Dictionary::Iterator DictionaryIterator;
- typedef typename Dictionary::ConstIterator DictionaryConstIterator;
- typedef typename Dictionary::FrozenView FrozenDictionary;
using PostingParent::_postingList;
using PostingParent::clearAllPostings;
using PostingParent::handleFillPostings;
@@ -120,6 +114,6 @@ public:
}
};
-typedef SingleValueStringPostingAttributeT<EnumAttribute<StringAttribute> > SingleValueStringPostingAttribute;
+using SingleValueStringPostingAttribute = SingleValueStringPostingAttributeT<EnumAttribute<StringAttribute> >;
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
index 2b1c358974c..8374647311e 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp
@@ -46,10 +46,8 @@ SingleValueStringPostingAttributeT<B>::applyUpdateValueChange(const Change & c,
enumStore.findIndex(c._data.raw(), newIdx);
currEnumIndices[c._doc] = newIdx;
-
}
-
template <typename B>
void
SingleValueStringPostingAttributeT<B>::
@@ -58,27 +56,23 @@ makePostingChange(const EnumStoreComparator *cmpa,
const std::map<DocId, EnumIndex> &currEnumIndices,
PostingMap &changePost)
{
- typedef typename std::map<DocId, EnumIndex>::const_iterator EnumIter;
- for (EnumIter iter = currEnumIndices.begin(), end = currEnumIndices.end();
- iter != end; ++iter) {
-
- uint32_t docId = iter->first;
+ for (const auto& elem : currEnumIndices) {
+ uint32_t docId = elem.first;
EnumIndex oldIdx = this->_enumIndices[docId];
- EnumIndex newIdx = iter->second;
+ EnumIndex newIdx = elem.second;
// add new posting
- DictionaryIterator addItr = dict.find(newIdx, *cmpa);
+ auto addItr = dict.find(newIdx, *cmpa);
changePost[EnumPostingPair(addItr.getKey(), cmpa)].add(docId, 1);
// remove old posting
if ( oldIdx.valid()) {
- DictionaryIterator rmItr = dict.find(oldIdx, *cmpa);
+ auto rmItr = dict.find(oldIdx, *cmpa);
changePost[EnumPostingPair(rmItr.getKey(), cmpa)].remove(docId);
}
}
}
-
template <typename B>
void
SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater& updater)
@@ -91,20 +85,19 @@ SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater&
// used to make sure several arithmetic operations on the same document in a single commit works
std::map<DocId, EnumIndex> currEnumIndices;
- typedef ChangeVector::const_iterator CVIterator;
- for (CVIterator iter = this->_changes.begin(), end = this->_changes.end(); iter != end; ++iter) {
- typename std::map<DocId, EnumIndex>::const_iterator enumIter = currEnumIndices.find(iter->_doc);
+ for (const auto& change : this->_changes) {
+ auto enumIter = currEnumIndices.find(change._doc);
EnumIndex oldIdx;
if (enumIter != currEnumIndices.end()) {
oldIdx = enumIter->second;
} else {
- oldIdx = this->_enumIndices[iter->_doc];
+ oldIdx = this->_enumIndices[change._doc];
}
- if (iter->_type == ChangeBase::UPDATE) {
- applyUpdateValueChange(*iter, enumStore,
+ if (change._type == ChangeBase::UPDATE) {
+ applyUpdateValueChange(change, enumStore,
currEnumIndices);
- } else if (iter->_type == ChangeBase::CLEARDOC) {
- this->_defaultValue._doc = iter->_doc;
+ } else if (change._type == ChangeBase::CLEARDOC) {
+ this->_defaultValue._doc = change._doc;
applyUpdateValueChange(this->_defaultValue, enumStore,
currEnumIndices);
}
@@ -139,12 +132,10 @@ AttributeVector::SearchContext::UP
SingleValueStringPostingAttributeT<B>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams & params) const
{
- return std::unique_ptr<search::AttributeVector::SearchContext>
- (new StringSinglePostingSearchContext(std::move(qTerm),
- params.useBitVector(),
- *this));
+ return std::make_unique<StringSinglePostingSearchContext>(std::move(qTerm),
+ params.useBitVector(),
+ *this);
}
-
} // namespace search