summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp17
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.cpp46
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/diskindex.h12
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h24
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/memory_index.h2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/searchable.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h3
10 files changed, 65 insertions, 72 deletions
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp
index 81a43f932ca..b71927c714f 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexcollection.cpp
@@ -34,7 +34,7 @@ IndexCollection::IndexCollection(const ISourceSelector::SP & selector,
setCurrentIndex(sources.getCurrentIndex());
}
-IndexCollection::~IndexCollection() {}
+IndexCollection::~IndexCollection() = default;
void
IndexCollection::setSource(uint32_t docId)
@@ -49,12 +49,11 @@ IndexCollection::replaceAndRenumber(const ISourceSelector::SP & selector,
uint32_t id_diff,
const IndexSearchable::SP &new_source)
{
- ISearchableIndexCollection::UP new_fsc(new IndexCollection(selector));
+ auto new_fsc = std::make_unique<IndexCollection>(selector);
new_fsc->append(0, new_source);
for (size_t i = 0; i < fsc.getSourceCount(); ++i) {
if (fsc.getSourceId(i) > id_diff) {
- new_fsc->append(fsc.getSourceId(i) - id_diff,
- fsc.getSearchableSP(i));
+ new_fsc->append(fsc.getSourceId(i) - id_diff, fsc.getSearchableSP(i));
}
}
return new_fsc;
@@ -148,17 +147,17 @@ struct Mixer {
: _selector(selector), _blender() {}
void addIndex(Blueprint::UP index) {
- if (_blender.get() == NULL) {
- _blender.reset(new SourceBlenderBlueprint(_selector));
+ if ( ! _blender) {
+ _blender = std::make_unique<SourceBlenderBlueprint>(_selector);
}
_blender->addChild(std::move(index));
}
Blueprint::UP mix() {
- if (_blender.get() == NULL) {
- return Blueprint::UP(new EmptyBlueprint());
+ if (_blender) {
+ return std::move(_blender);
}
- return Blueprint::UP(_blender.release());
+ return std::make_unique<EmptyBlueprint>();
}
};
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
index a964ae1ce6a..7d8bcf032ba 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp
@@ -36,12 +36,14 @@ DiskIndex::LookupResult::LookupResult()
}
DiskIndex::Key::Key() = default;
-DiskIndex::Key::Key(const IndexList & indexes, vespalib::stringref word) :
+DiskIndex::Key::Key(IndexList indexes, vespalib::stringref word) :
_word(word),
- _indexes(indexes)
+ _indexes(std::move(indexes))
{
}
+DiskIndex::Key::Key(const Key &) = default;
+DiskIndex::Key & DiskIndex::Key::operator = (const Key &) = default;
DiskIndex::Key::~Key() = default;
DiskIndex::DiskIndex(const vespalib::string &indexDir, size_t cacheSize)
@@ -203,11 +205,11 @@ DiskIndex::lookup(uint32_t index, vespalib::stringref word)
/** Only used for testing */
IndexList indexes;
indexes.push_back(index);
- Key key(indexes, word);
- LookupResultVector resultV(indexes.size());
+ Key key(std::move(indexes), word);
+ LookupResultVector resultV(1);
LookupResult::UP result;
if ( read(key, resultV)) {
- result.reset(new LookupResult());
+ result = std::make_unique<LookupResult>();
result->swap(resultV[0]);
}
return result;
@@ -282,8 +284,7 @@ DiskIndex::read(const Key & key, LookupResultVector & result)
SchemaUtil::IndexIterator it(_schema, lr.indexId);
uint32_t fieldId = it.getIndex();
if (fieldId < _dicts.size()) {
- (void) _dicts[fieldId]->lookup(key.getWord(), wordNum,
- offsetAndCounts);
+ (void) _dicts[fieldId]->lookup(key.getWord(), wordNum,offsetAndCounts);
}
lr.wordNum = wordNum;
lr.counts.swap(offsetAndCounts._counts);
@@ -305,10 +306,7 @@ DiskIndex::readPostingList(const LookupResult &lookupRes) const
}
const uint32_t firstSegment = 0;
const uint32_t numSegments = 0; // means all segments
- handle->_file->readPostingList(lookupRes.counts,
- firstSegment,
- numSegments,
- *handle);
+ handle->_file->readPostingList(lookupRes.counts, firstSegment, numSegments,*handle);
return handle;
}
@@ -349,9 +347,9 @@ public:
_cache[word] = _diskIndex.lookup(_fieldIds, word);
it = _cache.find(word);
}
- for (size_t i(0); i < it->second.size(); i++) {
- if (it->second[i].indexId == fieldId) {
- return it->second[i];
+ for (const auto & result : it->second) {
+ if (result.indexId == fieldId) {
+ return result;
}
}
return _G_nothing;
@@ -390,10 +388,9 @@ public:
const DiskIndex::LookupResult & lookupRes = _cache.lookup(termStr, _fieldId);
if (lookupRes.valid()) {
bool useBitVector = _field.isFilter();
- DiskIndex::LookupResult::UP copy(new DiskIndex::LookupResult(lookupRes));
- setResult(make_UP(new DiskTermBlueprint(_field, _diskIndex, std::move(copy), useBitVector)));
+ setResult(std::make_unique<DiskTermBlueprint>(_field, _diskIndex, std::make_unique<DiskIndex::LookupResult>(lookupRes), useBitVector));
} else {
- setResult(make_UP(new EmptyBlueprint(_field)));
+ setResult(std::make_unique<EmptyBlueprint>(_field));
}
}
@@ -420,7 +417,7 @@ createBlueprintHelper(LookupCache & cache, DiskIndex & diskIndex, const IRequest
const_cast<Node &>(term).accept(visitor);
return visitor.getResult();
}
- return Blueprint::UP(new EmptyBlueprint(field));
+ return std::make_unique<EmptyBlueprint>(field);
}
}
@@ -438,7 +435,7 @@ Blueprint::UP
DiskIndex::createBlueprint(const IRequestContext & requestContext, const FieldSpecList &fields, const Node &term)
{
if (fields.empty()) {
- return Blueprint::UP(new EmptyBlueprint());
+ return std::make_unique<EmptyBlueprint>();
}
std::vector<uint32_t> fieldIds;
@@ -450,17 +447,16 @@ DiskIndex::createBlueprint(const IRequestContext & requestContext, const FieldSp
fieldIds.push_back(_schema.getIndexFieldId(field.getName()));
}
}
- Blueprint::UP result(new OrBlueprint());
- OrBlueprint & orbp(static_cast<OrBlueprint &>(*result));
+ auto orbp = std::make_unique<OrBlueprint>();
LookupCache cache(*this, fieldIds);
for (size_t i(0); i< fields.size(); i++) {
const FieldSpec & field = fields[i];
- orbp.addChild(createBlueprintHelper(cache, *this, requestContext, field, _schema.getIndexFieldId(field.getName()), term));
+ orbp->addChild(createBlueprintHelper(cache, *this, requestContext, field, _schema.getIndexFieldId(field.getName()), term));
}
- if (orbp.childCnt() == 1) {
- return orbp.removeChild(0);
+ if (orbp->childCnt() == 1) {
+ return orbp->removeChild(0);
} else {
- return result;
+ return orbp;
}
}
diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.h b/searchlib/src/vespa/searchlib/diskindex/diskindex.h
index 91fd33a2c4a..3b827db8b4f 100644
--- a/searchlib/src/vespa/searchlib/diskindex/diskindex.h
+++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.h
@@ -27,7 +27,7 @@ public:
struct LookupResult {
uint32_t indexId;
uint64_t wordNum;
- index::PostingListCounts counts;
+ index::PostingListCounts counts;
uint64_t bitOffset;
typedef std::unique_ptr<LookupResult> UP;
LookupResult();
@@ -45,7 +45,11 @@ public:
class Key {
public:
Key();
- Key(const IndexList & indexes, vespalib::stringref word);
+ Key(IndexList indexes, vespalib::stringref word);
+ Key(const Key &);
+ Key & operator = (const Key &);
+ Key(Key &&) = default;
+ Key & operator = (Key &&) = default;
~Key();
uint32_t hash() const {
return vespalib::hashValue(_word.c_str(), _word.size());
@@ -89,8 +93,8 @@ public:
* @param indexDir the directory where the disk index is located.
* @param cacheSize optional size (in bytes) of the disk dictionary lookup cache.
*/
- DiskIndex(const vespalib::string &indexDir, size_t cacheSize=0);
- ~DiskIndex();
+ explicit DiskIndex(const vespalib::string &indexDir, size_t cacheSize=0);
+ ~DiskIndex() override;
/**
* Setup this instance by opening and loading relevant index files.
diff --git a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp
index c42ea2476bf..194aea5344b 100644
--- a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.cpp
@@ -34,8 +34,8 @@ getName(uint32_t indexId)
}
DiskTermBlueprint::DiskTermBlueprint(const FieldSpecBase & field,
- const search::diskindex::DiskIndex & diskIndex,
- search::diskindex::DiskIndex::LookupResult::UP lookupRes,
+ const DiskIndex & diskIndex,
+ DiskIndex::LookupResult::UP lookupRes,
bool useBitVector) :
SimpleLeafBlueprint(field),
_field(field),
diff --git a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h
index f7806235533..f3e9a29dca0 100644
--- a/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h
+++ b/searchlib/src/vespa/searchlib/diskindex/disktermblueprint.h
@@ -10,17 +10,17 @@ namespace search::diskindex {
/**
* Blueprint implementation for term searching in a disk index.
**/
-class DiskTermBlueprint : public search::queryeval::SimpleLeafBlueprint
+class DiskTermBlueprint : public queryeval::SimpleLeafBlueprint
{
private:
- search::queryeval::FieldSpecBase _field;
- const search::diskindex::DiskIndex & _diskIndex;
- DiskIndex::LookupResult::UP _lookupRes;
- bool _useBitVector;
- bool _fetchPostingsDone;
- bool _hasEquivParent;
- search::index::PostingListHandle::UP _postingHandle;
- search::BitVector::UP _bitVector;
+ queryeval::FieldSpecBase _field;
+ const DiskIndex & _diskIndex;
+ DiskIndex::LookupResult::UP _lookupRes;
+ bool _useBitVector;
+ bool _fetchPostingsDone;
+ bool _hasEquivParent;
+ index::PostingListHandle::UP _postingHandle;
+ BitVector::UP _bitVector;
public:
/**
@@ -31,9 +31,9 @@ public:
* @param lookupRes the result after disk dictionary lookup.
* @param useBitVector whether or not we should use bit vector.
**/
- DiskTermBlueprint(const search::queryeval::FieldSpecBase & field,
- const search::diskindex::DiskIndex & diskIndex,
- search::diskindex::DiskIndex::LookupResult::UP lookupRes,
+ DiskTermBlueprint(const queryeval::FieldSpecBase & field,
+ const DiskIndex & diskIndex,
+ DiskIndex::LookupResult::UP lookupRes,
bool useBitVector);
// Inherit doc from Blueprint.
diff --git a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h
index 44252aa2cdc..4e20bcf81e3 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/memory_index.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/memory_index.h
@@ -172,7 +172,7 @@ public:
uint64_t getStaticMemoryFootprint() const { return _staticMemoryFootprint; }
- search::index::FieldLengthInfo get_field_length_info(const vespalib::string& field_name) const;
+ index::FieldLengthInfo get_field_length_info(const vespalib::string& field_name) const;
};
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp
index e3dac98e588..5cd74229fce 100644
--- a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.cpp
@@ -26,19 +26,18 @@ CreateBlueprintVisitorHelper::getResult()
{
return _result
? std::move(_result)
- : Blueprint::UP(new EmptyBlueprint(_field));
+ : std::make_unique<EmptyBlueprint>(_field);
}
void
CreateBlueprintVisitorHelper::visitPhrase(query::Phrase &n) {
- SimplePhraseBlueprint *phrase = new SimplePhraseBlueprint(_field, _requestContext);
- Blueprint::UP result(phrase);
+ auto phrase = std::make_unique<SimplePhraseBlueprint>(_field, _requestContext);
for (size_t i = 0; i < n.getChildren().size(); ++i) {
FieldSpecList fields;
fields.add(phrase->getNextChildField(_field));
phrase->addTerm(_searchable.createBlueprint(_requestContext, fields, *n.getChildren()[i]));
}
- setResult(std::move(result));
+ setResult(std::move(phrase));
}
void
@@ -50,9 +49,7 @@ CreateBlueprintVisitorHelper::handleNumberTermAsText(query::NumberTerm &n)
query::SimplePhrase phraseNode(n.getView(), n.getId(), n.getWeight());
phraseNode.setStateFrom(n);
for (size_t i = 0; i < splitter.parts(); ++i) {
- query::Node::UP nn;
- nn.reset(new query::SimpleStringTerm(splitter.getPart(i), "", 0, query::Weight(0)));
- phraseNode.append(std::move(nn));
+ phraseNode.append(std::make_unique<query::SimpleStringTerm>(splitter.getPart(i), "", 0, query::Weight(0)));
}
visitPhrase(phraseNode);
} else {
diff --git a/searchlib/src/vespa/searchlib/queryeval/searchable.cpp b/searchlib/src/vespa/searchlib/queryeval/searchable.cpp
index af1908117ab..c26ad3221bc 100644
--- a/searchlib/src/vespa/searchlib/queryeval/searchable.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/searchable.cpp
@@ -12,17 +12,16 @@ Searchable::createBlueprint(const IRequestContext & requestContext,
const search::query::Node &term)
{
if (fields.empty()) {
- return Blueprint::UP(new EmptyBlueprint());
+ return std::make_unique<EmptyBlueprint>();
}
if (fields.size() == 1) {
return createBlueprint(requestContext, fields[0], term);
}
- OrBlueprint *b = new OrBlueprint();
- Blueprint::UP result(b);
+ auto b = std::make_unique<OrBlueprint>();
for (size_t i = 0; i < fields.size(); ++i) {
b->addChild(createBlueprint(requestContext, fields[i], term));
}
- return result;
+ return b;
}
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp
index d2f358dea12..ed7690f605f 100644
--- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.cpp
@@ -47,12 +47,11 @@ SimplePhraseBlueprint::addTerm(Blueprint::UP term)
_estimate = childEst;
}
setEstimate(_estimate);
- _terms.push_back(term.get());
- term.release();
+ _terms.push_back(term.release());
}
SearchIterator::UP
-SimplePhraseBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmda,bool strict) const
+SimplePhraseBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const
{
assert(tfmda.size() == 1);
fef::MatchData::UP md = _layout.createMatchData();
@@ -71,10 +70,10 @@ SimplePhraseBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmd
eval_order.push_back(child.second);
}
- SimplePhraseSearch * phrase = new SimplePhraseSearch(children, std::move(md), childMatch,
- eval_order, *tfmda[0], strict);
+ auto phrase = std::make_unique<SimplePhraseSearch>(children, std::move(md), childMatch,
+ eval_order, *tfmda[0], strict);
phrase->setDoom(& _doom);
- return SearchIterator::UP(phrase);
+ return phrase;
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h
index d0e3868f34a..26668f85cb7 100644
--- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h
+++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_blueprint.h
@@ -33,8 +33,7 @@ public:
void addTerm(Blueprint::UP term);
SearchIteratorUP
- createLeafSearch(const search::fef::TermFieldMatchDataArray &tfmda,
- bool strict) const override;
+ createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const override;
void visitMembers(vespalib::ObjectVisitor &visitor) const override;
void fetchPostings(bool strict) override;
};