summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-04-10 07:12:58 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-04-11 06:48:56 +0000
commit0101c4f13c184ea0bea5c357d23179126cff38e4 (patch)
tree567553e7d1781d795e0da1279b2d32927a340819 /searchlib
parente27da71b2609e16e88cb4c037bab587da39c8b20 (diff)
Style changes.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.h12
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/document_remover.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/document_remover.h7
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/documentinverter.h3
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/featurestore.h18
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_index.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_index.h48
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_index_collection.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_index_collection.h10
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp30
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/fieldinverter.h139
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/i_document_insert_listener.h3
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/i_document_remove_listener.h3
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/memoryindex.h19
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h5
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/postingiterator.h3
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp27
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.h12
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/wordstore.h6
23 files changed, 107 insertions, 288 deletions
diff --git a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.h b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.h
index ced7ec241bd..50988d5121a 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.h
@@ -14,14 +14,12 @@ namespace search::memoryindex {
* into the memory index dictionary. These tuples are later used when removing
* all remains of a document from the posting lists of the dictionary.
*/
-class CompactDocumentWordsStore
-{
+class CompactDocumentWordsStore {
public:
/**
* Builder used to collect all wordRefs for a field.
*/
- class Builder
- {
+ class Builder {
public:
using UP = std::unique_ptr<Builder>;
using WordRefVector = vespalib::Array<datastore::EntryRef>;
@@ -41,8 +39,7 @@ public:
/**
* Iterator over all {wordRef, fieldId} pairs for a document.
*/
- class Iterator
- {
+ class Iterator {
private:
const uint32_t *_buf;
uint32_t _remainingWords;
@@ -63,8 +60,7 @@ public:
/**
* Store for all {wordRef, fieldId} pairs among all documents.
*/
- class Store
- {
+ class Store {
public:
using DataStoreType = datastore::DataStoreT<datastore::EntryRefT<22>>;
using RefType = DataStoreType::RefType;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/document_remover.cpp b/searchlib/src/vespa/searchlib/memoryindex/document_remover.cpp
index 67b519bbadc..469de8987b1 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/document_remover.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/document_remover.cpp
@@ -17,8 +17,7 @@ DocumentRemover::DocumentRemover(const WordStore &wordStore)
{
}
-DocumentRemover::~DocumentRemover() {
-}
+DocumentRemover::~DocumentRemover() = default;
void
DocumentRemover::remove(uint32_t docId, IDocumentRemoveListener &listener)
@@ -39,7 +38,6 @@ DocumentRemover::insert(datastore::EntryRef wordRef, uint32_t docId)
_wordFieldDocTuples.emplace_back(wordRef, docId);
}
-
void
DocumentRemover::flush()
{
@@ -60,5 +58,4 @@ DocumentRemover::flush()
_wordFieldDocTuples.clear();
}
-
}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/document_remover.h b/searchlib/src/vespa/searchlib/memoryindex/document_remover.h
index 5d44a666ff9..3cf37cab410 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/document_remover.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/document_remover.h
@@ -12,11 +12,9 @@ class WordStore;
/**
* Class used to remove documents from the memory index dictionary.
*/
-class DocumentRemover : public IDocumentInsertListener
-{
+class DocumentRemover : public IDocumentInsertListener {
private:
- struct WordFieldDocTuple
- {
+ struct WordFieldDocTuple {
datastore::EntryRef _wordRef;
uint32_t _docId;
WordFieldDocTuple() :
@@ -38,7 +36,6 @@ private:
return wft._docId;
}
};
-
};
CompactDocumentWordsStore _store;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp
index 1501ff7d2fc..5bc7c96fe8e 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp
@@ -39,7 +39,6 @@ using index::DocIdAndPosOccFeatures;
using index::Schema;
using search::util::URL;
-
DocumentInverter::DocumentInverter(const Schema &schema,
ISequencedTaskExecutor &invertThreads,
ISequencedTaskExecutor &pushThreads)
@@ -74,14 +73,12 @@ DocumentInverter::DocumentInverter(const Schema &schema,
}
}
-
DocumentInverter::~DocumentInverter()
{
_invertThreads.sync();
_pushThreads.sync();
}
-
void
DocumentInverter::addFieldPath(const document::DocumentType &docType,
uint32_t fieldId)
@@ -100,9 +97,9 @@ DocumentInverter::addFieldPath(const document::DocumentType &docType,
_indexedFieldPaths[fieldId] = std::move(fp);
}
-
-void DocumentInverter::buildFieldPath(const document::DocumentType &docType,
- const document::DataType *dataType)
+void
+DocumentInverter::buildFieldPath(const document::DocumentType &docType,
+ const document::DataType *dataType)
{
_indexedFieldPaths.clear();
_indexedFieldPaths.resize(_schema.getNumIndexFields());
@@ -115,7 +112,6 @@ void DocumentInverter::buildFieldPath(const document::DocumentType &docType,
_dataType = dataType;
}
-
void
DocumentInverter::invertDocument(uint32_t docId, const Document &doc)
{
@@ -154,7 +150,6 @@ DocumentInverter::invertDocument(uint32_t docId, const Document &doc)
}
}
-
void
DocumentInverter::removeDocument(uint32_t docId)
{
@@ -175,7 +170,6 @@ DocumentInverter::removeDocument(uint32_t docId)
}
}
-
void
DocumentInverter::pushDocuments(FieldIndexCollection &fieldIndexes,
const std::shared_ptr<IDestructorCallback> &onWriteDone)
diff --git a/searchlib/src/vespa/searchlib/memoryindex/documentinverter.h b/searchlib/src/vespa/searchlib/memoryindex/documentinverter.h
index fa8d13d98fc..081d875be4f 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/documentinverter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/documentinverter.h
@@ -24,8 +24,7 @@ class FieldInverter;
class UrlFieldInverter;
class FieldIndexCollection;
-class DocumentInverter
-{
+class DocumentInverter {
private:
DocumentInverter(const DocumentInverter &) = delete;
DocumentInverter &operator=(const DocumentInverter &) = delete;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp b/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
index c032bb33217..ae30af41d0a 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/featurestore.cpp
@@ -26,7 +26,6 @@ FeatureStore::writeFeatures(uint32_t packedIndex, const DocIdAndFeatures &featur
return oldOffset;
}
-
datastore::EntryRef
FeatureStore::addFeatures(const uint8_t *src, uint64_t byteLen)
{
@@ -43,7 +42,6 @@ FeatureStore::addFeatures(const uint8_t *src, uint64_t byteLen)
return result.ref;
}
-
std::pair<datastore::EntryRef, uint64_t>
FeatureStore::addFeatures(uint64_t beginOffset, uint64_t endOffset)
{
@@ -58,7 +56,6 @@ FeatureStore::addFeatures(uint64_t beginOffset, uint64_t endOffset)
return std::make_pair(ref, bitLen);
}
-
datastore::EntryRef
FeatureStore::moveFeatures(datastore::EntryRef ref, uint64_t bitLen)
{
@@ -70,7 +67,6 @@ FeatureStore::moveFeatures(datastore::EntryRef ref, uint64_t bitLen)
return newRef;
}
-
FeatureStore::FeatureStore(const Schema &schema)
: _store(),
_f(nullptr),
@@ -95,13 +91,11 @@ FeatureStore::FeatureStore(const Schema &schema)
_store.initActiveBuffers();
}
-
FeatureStore::~FeatureStore()
{
_store.dropBuffers();
}
-
std::pair<datastore::EntryRef, uint64_t>
FeatureStore::addFeatures(uint32_t packedIndex, const DocIdAndFeatures &features)
{
@@ -111,8 +105,6 @@ FeatureStore::addFeatures(uint32_t packedIndex, const DocIdAndFeatures &features
return addFeatures(oldOffset, newOffset);
}
-
-
void
FeatureStore::getFeatures(uint32_t packedIndex, datastore::EntryRef ref, DocIdAndFeatures &features)
{
@@ -121,7 +113,6 @@ FeatureStore::getFeatures(uint32_t packedIndex, datastore::EntryRef ref, DocIdAn
_d.readFeatures(features);
}
-
size_t
FeatureStore::bitSize(uint32_t packedIndex, datastore::EntryRef ref)
{
@@ -135,7 +126,6 @@ FeatureStore::bitSize(uint32_t packedIndex, datastore::EntryRef ref)
return bitLen;
}
-
datastore::EntryRef
FeatureStore::moveFeatures(uint32_t packedIndex, datastore::EntryRef ref)
{
diff --git a/searchlib/src/vespa/searchlib/memoryindex/featurestore.h b/searchlib/src/vespa/searchlib/memoryindex/featurestore.h
index ef75b9f6d31..94d44eaf44d 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/featurestore.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/featurestore.h
@@ -9,8 +9,7 @@
namespace search::memoryindex {
-class FeatureStore
-{
+class FeatureStore {
public:
using DataStoreType = datastore::DataStoreT<datastore::AlignedEntryRefT<22, 2>>;
using RefType = DataStoreType::RefType;
@@ -122,9 +121,7 @@ public:
* @param packedIndex The field or field collection owning features
* @param decoder The feature decoder
*/
- void
- setupForField(uint32_t packedIndex, DecodeContextCooked &decoder) const
- {
+ void setupForField(uint32_t packedIndex, DecodeContextCooked &decoder) const {
decoder._fieldsParams = &_fieldsParams[packedIndex];
}
@@ -135,9 +132,7 @@ public:
* @param ref Reference to stored features
* @param decoder The feature decoder
*/
- void
- setupForReadFeatures(datastore::EntryRef ref, DecodeContextCooked &decoder) const
- {
+ void setupForReadFeatures(datastore::EntryRef ref, DecodeContextCooked &decoder) const {
const uint8_t * bits = getBits(ref);
decoder.setByteCompr(bits);
uint32_t bufferId = RefType(ref).bufferId();
@@ -155,9 +150,7 @@ public:
* @param ref Reference to stored features
* @param decoder The feature decoder
*/
- void
- setupForUnpackFeatures(datastore::EntryRef ref, DecodeContextCooked &decoder) const
- {
+ void setupForUnpackFeatures(datastore::EntryRef ref, DecodeContextCooked &decoder) const {
decoder.setByteCompr(getBits(ref));
}
@@ -169,8 +162,7 @@ public:
* @param ref Reference to stored features
* @return size of features in bits
*/
- size_t
- bitSize(uint32_t packedIndex, datastore::EntryRef ref);
+ size_t bitSize(uint32_t packedIndex, datastore::EntryRef ref);
/**
* Get byte address of stored features
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp
index 4d42b9ae493..ef186175ae3 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp
@@ -88,7 +88,6 @@ FieldIndex::findFrozen(const vespalib::stringref word) const
return PostingList::Iterator();
}
-
void
FieldIndex::compactFeatures()
{
@@ -218,7 +217,6 @@ FieldIndex::dump(search::index::IndexBuilder & indexBuilder)
}
}
-
MemoryUsage
FieldIndex::getMemoryUsage() const
{
@@ -231,7 +229,7 @@ FieldIndex::getMemoryUsage() const
return usage;
}
-} // namespace search::memoryindex
+}
namespace search::btree {
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index.h b/searchlib/src/vespa/searchlib/memoryindex/field_index.h
index 4a27e30b47a..04f1cbc23ab 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_index.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.h
@@ -56,9 +56,7 @@ public:
const WordStore &_wordStore;
const vespalib::stringref _word;
- const char *
- getWord(datastore::EntryRef wordRef) const
- {
+ const char *getWord(datastore::EntryRef wordRef) const {
if (wordRef.valid()) {
return _wordStore.getWord(wordRef);
}
@@ -71,9 +69,7 @@ public:
_word(word)
{ }
- bool
- operator()(const WordKey & lhs, const WordKey & rhs) const
- {
+ bool operator()(const WordKey & lhs, const WordKey & rhs) const {
int cmpres = strcmp(getWord(lhs._wordRef), getWord(rhs._wordRef));
return cmpres < 0;
}
@@ -102,9 +98,7 @@ public:
return _wordStore.addWord(word);
}
- datastore::EntryRef
- addFeatures(const index::DocIdAndFeatures &features)
- {
+ datastore::EntryRef addFeatures(const index::DocIdAndFeatures &features) {
return _featureStore.addFeatures(_fieldId, features).first;
}
@@ -126,9 +120,7 @@ private:
_dict.getAllocator().freeze();
}
- void
- trimHoldLists()
- {
+ void trimHoldLists() {
GenerationHandler::generation_t usedGen =
_generationHandler.getFirstUsedGeneration();
_postingListStore.trimHoldLists(usedGen);
@@ -136,9 +128,7 @@ private:
_featureStore.trimHoldLists(usedGen);
}
- void
- transferHoldLists()
- {
+ void transferHoldLists() {
GenerationHandler::generation_t generation =
_generationHandler.getCurrentGeneration();
_postingListStore.transferHoldLists(generation);
@@ -146,9 +136,7 @@ private:
_featureStore.transferHoldLists(generation);
}
- void
- incGeneration()
- {
+ void incGeneration() {
_generationHandler.incGeneration();
}
@@ -163,27 +151,11 @@ public:
void dump(search::index::IndexBuilder & indexBuilder);
MemoryUsage getMemoryUsage() const;
+ DictionaryTree &getDictionaryTree() { return _dict; }
+ PostingListStore &getPostingListStore() { return _postingListStore; }
+ DocumentRemover &getDocumentRemover() { return _remover; }
- DictionaryTree &
- getDictionaryTree()
- {
- return _dict;
- }
-
- PostingListStore &
- getPostingListStore()
- {
- return _postingListStore;
- }
-
- DocumentRemover &
- getDocumentRemover()
- {
- return _remover;
- }
-
- void commit()
- {
+ void commit() {
_remover.flush();
freeze();
transferHoldLists();
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.cpp
index 45431f0e8ef..05da10696c4 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.cpp
@@ -40,7 +40,6 @@ FieldIndexCollection::~FieldIndexCollection()
{
}
-
void
FieldIndexCollection::dump(search::index::IndexBuilder &indexBuilder)
{
@@ -61,6 +60,5 @@ FieldIndexCollection::getMemoryUsage() const
return usage;
}
-
}
}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.h b/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.h
index 3b8e63626bf..f2fc08f0e82 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_index_collection.h
@@ -29,14 +29,11 @@ public:
FieldIndexCollection(const index::Schema &schema);
~FieldIndexCollection();
PostingList::Iterator find(const vespalib::stringref word,
- uint32_t fieldId) const
- {
+ uint32_t fieldId) const {
return _fieldIndexes[fieldId]->find(word);
}
- PostingList::ConstIterator
- findFrozen(const vespalib::stringref word, uint32_t fieldId) const
- {
+ PostingList::ConstIterator findFrozen(const vespalib::stringref word, uint32_t fieldId) const {
return _fieldIndexes[fieldId]->findFrozen(word);
}
@@ -56,8 +53,7 @@ public:
return _fieldIndexes[fieldId].get();
}
- const std::vector<std::unique_ptr<FieldIndex>> &
- getFieldIndexes() const { return _fieldIndexes; }
+ const std::vector<std::unique_ptr<FieldIndex>> &getFieldIndexes() const { return _fieldIndexes; }
uint32_t getNumFields() const { return _numFields; }
};
diff --git a/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp
index fa261a4e90a..10d42640be1 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp
@@ -48,23 +48,17 @@ using search::index::schema::CollectionType;
using search::util::URL;
using vespalib::make_string;
-namespace documentinverterkludge {
-
-namespace linguistics {
+namespace documentinverterkludge::linguistics {
const vespalib::string SPANTREE_NAME("linguistics");
}
-}
-
using namespace documentinverterkludge;
-namespace
-{
+namespace {
-class SpanFinder : public SpanTreeVisitor
-{
+class SpanFinder : public SpanTreeVisitor {
public:
int32_t begin_pos;
int32_t end_pos;
@@ -165,7 +159,6 @@ FieldInverter::processAnnotations(const StringFieldValue &value)
}
}
-
void
FieldInverter::reset()
{
@@ -228,14 +221,12 @@ FieldInverter::sortWords()
}
}
-
void
FieldInverter::startElement(int32_t weight)
{
_elems.push_back(ElemInfo(weight)); // Fill in length later
}
-
void
FieldInverter::endElement()
{
@@ -270,7 +261,6 @@ FieldInverter::saveWord(const vespalib::stringref word)
return wordRef;
}
-
uint32_t
FieldInverter::saveWord(const document::FieldValue &fv)
{
@@ -280,7 +270,6 @@ FieldInverter::saveWord(const document::FieldValue &fv)
return saveWord(vespalib::stringref(sRef.first, sRef.second));
}
-
void
FieldInverter::remove(const vespalib::stringref word, uint32_t docId)
{
@@ -289,7 +278,6 @@ FieldInverter::remove(const vespalib::stringref word, uint32_t docId)
_positions.emplace_back(wordRef, docId);
}
-
void
FieldInverter::processNormalDocTextField(const StringFieldValue &field)
{
@@ -298,7 +286,6 @@ FieldInverter::processNormalDocTextField(const StringFieldValue &field)
endElement();
}
-
void
FieldInverter::processNormalDocArrayTextField(const ArrayFieldValue &field)
{
@@ -314,7 +301,6 @@ FieldInverter::processNormalDocArrayTextField(const ArrayFieldValue &field)
}
}
-
void
FieldInverter::processNormalDocWeightedSetTextField(const WeightedSetFieldValue &field)
{
@@ -331,7 +317,6 @@ FieldInverter::processNormalDocWeightedSetTextField(const WeightedSetFieldValue
}
}
-
FieldInverter::FieldInverter(const Schema &schema, uint32_t fieldId)
: _fieldId(fieldId),
_elem(0u),
@@ -352,7 +337,6 @@ FieldInverter::FieldInverter(const Schema &schema, uint32_t fieldId)
{
}
-
void
FieldInverter::abortPendingDoc(uint32_t docId)
{
@@ -365,7 +349,6 @@ FieldInverter::abortPendingDoc(uint32_t docId)
}
}
-
void
FieldInverter::moveNotAbortedDocs(uint32_t &dstIdx,
uint32_t srcIdx,
@@ -390,7 +373,6 @@ FieldInverter::moveNotAbortedDocs(uint32_t &dstIdx,
dstIdx += size;
}
-
void
FieldInverter::trimAbortedDocs()
{
@@ -413,7 +395,6 @@ FieldInverter::trimAbortedDocs()
_abortedDocs.clear();
}
-
void
FieldInverter::invertField(uint32_t docId, const FieldValue::UP &val)
{
@@ -424,7 +405,6 @@ FieldInverter::invertField(uint32_t docId, const FieldValue::UP &val)
endDoc();
}
-
void
FieldInverter::invertNormalDocTextField(const FieldValue &val)
{
@@ -467,7 +447,6 @@ FieldInverter::invertNormalDocTextField(const FieldValue &val)
}
}
-
namespace {
struct FullRadix {
@@ -479,7 +458,6 @@ struct FullRadix {
}
-
void
FieldInverter::applyRemoves(DocumentRemover &remover)
{
@@ -489,7 +467,6 @@ FieldInverter::applyRemoves(DocumentRemover &remover)
_removeDocs.clear();
}
-
void
FieldInverter::pushDocuments(IOrderedDocumentInserter &inserter)
{
@@ -568,6 +545,5 @@ FieldInverter::pushDocuments(IOrderedDocumentInserter &inserter)
reset();
}
-
}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.h b/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.h
index 69cfd370041..e05cf643bf8 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.h
@@ -18,11 +18,9 @@ namespace search::memoryindex {
class IOrderedDocumentInserter;
class DocumentRemover;
-class FieldInverter : public IDocumentRemoveListener
-{
+class FieldInverter : public IDocumentRemoveListener {
public:
- class PosInfo
- {
+ class PosInfo {
public:
uint32_t _wordNum; // XXX: Initially word reference
uint32_t _docId;
@@ -54,7 +52,6 @@ public:
{
}
-
PosInfo(uint32_t wordRef,
uint32_t docId)
: _wordNum(wordRef),
@@ -65,22 +62,19 @@ public:
{
}
- bool
- removed() const
- {
- return _elemId == _elemRemoved;
- }
+ bool removed() const { return _elemId == _elemRemoved; }
- bool
- operator<(const PosInfo &rhs) const
- {
- if (_wordNum != rhs._wordNum)
+ bool operator<(const PosInfo &rhs) const {
+ if (_wordNum != rhs._wordNum) {
return _wordNum < rhs._wordNum;
- if (_docId != rhs._docId)
+ }
+ if (_docId != rhs._docId) {
return _docId < rhs._docId;
+ }
if (_elemId != rhs._elemId) {
- if (removed() != rhs.removed())
+ if (removed() != rhs.removed()) {
return removed() && !rhs.removed();
+ }
return _elemId < rhs._elemId;
}
return _wordPos < rhs._wordPos;
@@ -95,8 +89,7 @@ private:
using WordBuffer = vespalib::Array<char>;
- class ElemInfo
- {
+ class ElemInfo {
public:
int32_t _weight;
uint32_t _len;
@@ -107,18 +100,13 @@ private:
{
}
- void
- setLen(uint32_t len)
- {
- _len = len;
- }
+ void setLen(uint32_t len) { _len = len; }
};
using ElemInfoVec = std::vector<ElemInfo>;
using PosInfoVec = std::vector<PosInfo>;
- class CompareWordRef
- {
+ class CompareWordRef {
const char *const _wordBuffer;
public:
@@ -127,15 +115,11 @@ private:
{
}
- const char *
- getWord(uint32_t wordRef) const
- {
+ const char *getWord(uint32_t wordRef) const {
return &_wordBuffer[static_cast<size_t>(wordRef) << 2];
}
- bool
- operator()(const uint32_t lhs, const uint32_t rhs) const
- {
+ bool operator()(const uint32_t lhs, const uint32_t rhs) const {
return strcmp(getWord(lhs), getWord(rhs)) < 0;
}
};
@@ -143,8 +127,7 @@ private:
/*
* Range in _positions vector used to represent a document put.
*/
- class PositionRange
- {
+ class PositionRange {
uint32_t _start;
uint32_t _len;
@@ -155,9 +138,7 @@ private:
{
}
- bool
- operator<(const PositionRange &rhs) const
- {
+ bool operator<(const PositionRange &rhs) const {
if (_start != rhs._start) {
return _start < rhs._start;
}
@@ -202,14 +183,12 @@ public:
*
* @param weight element weight
*/
- void
- startElement(int32_t weight);
+ void startElement(int32_t weight);
/**
* End an element.
*/
- void
- endElement();
+ void endElement();
private:
/**
@@ -220,8 +199,7 @@ private:
*
* @return word reference
*/
- VESPA_DLL_LOCAL uint32_t
- saveWord(const vespalib::stringref word);
+ VESPA_DLL_LOCAL uint32_t saveWord(const vespalib::stringref word);
/**
* Save field value as word in word buffer.
@@ -230,8 +208,7 @@ private:
*
* @return word reference
*/
- VESPA_DLL_LOCAL uint32_t
- saveWord(const document::FieldValue &fv);
+ VESPA_DLL_LOCAL uint32_t saveWord(const document::FieldValue &fv);
/**
* Get pointer to saved word from a word reference.
@@ -240,9 +217,7 @@ private:
*
* @return saved word
*/
- const char *
- getWordFromRef(uint32_t wordRef) const
- {
+ const char *getWordFromRef(uint32_t wordRef) const {
return &_words[static_cast<size_t>(wordRef) << 2];
}
@@ -253,9 +228,7 @@ private:
*
* @return saved word
*/
- const char *
- getWordFromNum(uint32_t wordNum) const
- {
+ const char *getWordFromNum(uint32_t wordNum) const {
return getWordFromRef(_wordRefs[wordNum]);
}
@@ -266,9 +239,7 @@ private:
*
* @return word number
*/
- uint32_t
- getWordNum(uint32_t wordRef) const
- {
+ uint32_t getWordNum(uint32_t wordRef) const {
const char *p = &_words[static_cast<size_t>(wordRef - 1) << 2];
return *reinterpret_cast<const uint32_t *>(p);
}
@@ -279,9 +250,7 @@ private:
* @param wordRef word reference
* @param wordNum word number
*/
- void
- updateWordNum(uint32_t wordRef, uint32_t wordNum)
- {
+ void updateWordNum(uint32_t wordRef, uint32_t wordNum) {
char *p = &_words[static_cast<size_t>(wordRef - 1) << 2];
*reinterpret_cast<uint32_t *>(p) = wordNum;
}
@@ -292,17 +261,12 @@ private:
*
* @param wordRef word reference
*/
- void
- add(uint32_t wordRef) {
+ void add(uint32_t wordRef) {
_positions.emplace_back(wordRef, _docId, _elem,
_wpos, _elems.size() - 1);
}
- void
- stepWordPos()
- {
- ++_wpos;
- }
+ void stepWordPos() { ++_wpos; }
public:
VESPA_DLL_LOCAL void
@@ -323,30 +287,22 @@ private:
*
* @return schema used by this index
*/
- const index::Schema &
- getSchema() const
- {
- return _schema;
- }
+ const index::Schema &getSchema() const { return _schema; }
/**
* Clear internal memory structures.
*/
- void
- reset();
+ void reset();
/**
* Calculate word numbers and replace word references with word
* numbers in internal memory structures.
*/
- void
- sortWords();
+ void sortWords();
- void
- moveNotAbortedDocs(uint32_t &dstIdx, uint32_t srcIdx, uint32_t nextTrimIdx);
+ void moveNotAbortedDocs(uint32_t &dstIdx, uint32_t srcIdx, uint32_t nextTrimIdx);
- void
- trimAbortedDocs();
+ void trimAbortedDocs();
/*
* Abort a pending document that has already been inverted.
@@ -354,8 +310,7 @@ private:
* @param docId local id for document
*
*/
- void
- abortPendingDoc(uint32_t docId);
+ void abortPendingDoc(uint32_t docId);
public:
/**
@@ -371,8 +326,7 @@ public:
*
* @param remover document remover
*/
- void
- applyRemoves(DocumentRemover &remover);
+ void applyRemoves(DocumentRemover &remover);
/**
* Push inverted documents to memory index structure.
@@ -382,31 +336,24 @@ public:
*
* @param inserter ordered document inserter
*/
- void
- pushDocuments(IOrderedDocumentInserter &inserter);
+ void pushDocuments(IOrderedDocumentInserter &inserter);
/*
* Invert a normal text field, based on annotations.
*/
- void
- invertField(uint32_t docId, const document::FieldValue::UP &val);
+ void invertField(uint32_t docId, const document::FieldValue::UP &val);
/*
* Setup remove of word in old version of document.
*/
- virtual void
- remove(const vespalib::stringref word, uint32_t docId) override;
+ virtual void remove(const vespalib::stringref word, uint32_t docId) override;
- void
- removeDocument(uint32_t docId)
- {
+ void removeDocument(uint32_t docId) {
abortPendingDoc(docId);
_removeDocs.push_back(docId);
}
- void
- startDoc(uint32_t docId)
- {
+ void startDoc(uint32_t docId) {
assert(_docId == 0);
assert(docId != 0);
abortPendingDoc(docId);
@@ -416,9 +363,7 @@ public:
_wpos = 0;
}
- void
- endDoc()
- {
+ void endDoc() {
uint32_t newPosSize = static_cast<uint32_t>(_positions.size());
_pendingDocs.insert({ _docId,
{ _oldPosSize, newPosSize - _oldPosSize } });
@@ -426,9 +371,7 @@ public:
_oldPosSize = newPosSize;
}
- void
- addWord(const vespalib::stringref word)
- {
+ void addWord(const vespalib::stringref word) {
uint32_t wordRef = saveWord(word);
if (wordRef != 0u) {
add(wordRef);
diff --git a/searchlib/src/vespa/searchlib/memoryindex/i_document_insert_listener.h b/searchlib/src/vespa/searchlib/memoryindex/i_document_insert_listener.h
index 194a98ef8ba..40b7356386e 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/i_document_insert_listener.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/i_document_insert_listener.h
@@ -8,8 +8,7 @@ namespace search::memoryindex {
* Interface used to track which {wordRef, fieldId} pairs that are
* inserted into the memory index dictionary for a document.
*/
-class IDocumentInsertListener
-{
+class IDocumentInsertListener {
public:
virtual ~IDocumentInsertListener() {}
virtual void insert(datastore::EntryRef wordRef, uint32_t docId) = 0;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/i_document_remove_listener.h b/searchlib/src/vespa/searchlib/memoryindex/i_document_remove_listener.h
index 436ee0a49e3..6edbe4d3eaf 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/i_document_remove_listener.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/i_document_remove_listener.h
@@ -10,8 +10,7 @@ namespace search::memoryindex {
* Interface used to track which {wordRef, fieldId} pairs that are
* removed from the memory index dictionary for a document.
*/
-class IDocumentRemoveListener
-{
+class IDocumentRemoveListener {
public:
virtual ~IDocumentRemoveListener() {}
virtual void remove(const vespalib::stringref word, uint32_t docId) = 0;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp b/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp
index 90036c83efb..3c3f17a2357 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp
@@ -118,7 +118,6 @@ MemoryIndex::commit(const std::shared_ptr<IDestructorCallback> &onWriteDone)
flipInverter();
}
-
void
MemoryIndex::flipInverter()
{
@@ -139,8 +138,7 @@ MemoryIndex::dump(IndexBuilder &indexBuilder)
namespace {
-class MemTermBlueprint : public queryeval::SimpleLeafBlueprint
-{
+class MemTermBlueprint : public queryeval::SimpleLeafBlueprint {
private:
GenerationHandler::Guard _genGuard;
FieldIndex::PostingList::ConstIterator _pitr;
@@ -167,8 +165,7 @@ public:
setEstimate(estimate);
}
- SearchIterator::UP
- createLeafSearch(const TermFieldMatchDataArray &tfmda, bool) const override {
+ SearchIterator::UP createLeafSearch(const TermFieldMatchDataArray &tfmda, bool) const override {
auto search = std::make_unique<PostingIterator>(_pitr, _featureStore, _fieldId, tfmda);
if (_useBitVector) {
LOG(debug, "Return BooleanMatchIteratorWrapper: fieldId(%u), docCount(%zu)",
@@ -185,8 +182,7 @@ public:
/**
* Determines the correct Blueprint to use.
**/
-class CreateBlueprintVisitor : public CreateBlueprintVisitorHelper
-{
+class CreateBlueprintVisitor : public CreateBlueprintVisitorHelper {
private:
const FieldSpec &_field;
const uint32_t _fieldId;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/memoryindex.h b/searchlib/src/vespa/searchlib/memoryindex/memoryindex.h
index 621c72d56a3..0b74e05c619 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/memoryindex.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/memoryindex.h
@@ -23,8 +23,7 @@ class FieldIndexCollection;
* Lock-free implementation of a memory-based index
* using the document inverter and dictionary classes from searchlib.
**/
-class MemoryIndex : public queryeval::Searchable
-{
+class MemoryIndex : public queryeval::Searchable {
private:
index::Schema _schema;
ISequencedTaskExecutor &_invertThreads;
@@ -136,15 +135,13 @@ public:
void dump(index::IndexBuilder &indexBuilder);
// implements Searchable
- queryeval::Blueprint::UP
- createBlueprint(const queryeval::IRequestContext & requestContext,
- const queryeval::FieldSpec &field,
- const query::Node &term) override;
-
- queryeval::Blueprint::UP
- createBlueprint(const queryeval::IRequestContext & requestContext,
- const queryeval::FieldSpecList &fields,
- const query::Node &term) override {
+ queryeval::Blueprint::UP createBlueprint(const queryeval::IRequestContext & requestContext,
+ const queryeval::FieldSpec &field,
+ const query::Node &term) override;
+
+ queryeval::Blueprint::UP createBlueprint(const queryeval::IRequestContext & requestContext,
+ const queryeval::FieldSpecList &fields,
+ const query::Node &term) override {
return queryeval::Searchable::createBlueprint(requestContext, fields, term);
}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp
index 3c4fca5b044..183f8692377 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp
@@ -44,7 +44,6 @@ OrderedDocumentInserter::~OrderedDocumentInserter()
flush();
}
-
void
OrderedDocumentInserter::flushWord()
{
@@ -68,7 +67,6 @@ OrderedDocumentInserter::flushWord()
_adds.clear();
}
-
void
OrderedDocumentInserter::flush()
{
@@ -76,7 +74,6 @@ OrderedDocumentInserter::flush()
_listener.flush();
}
-
void
OrderedDocumentInserter::setNextWord(const vespalib::stringref word)
{
@@ -103,7 +100,6 @@ OrderedDocumentInserter::setNextWord(const vespalib::stringref word)
assert(_word == wordStore.getWord(_dItr.getKey()._wordRef));
}
-
void
OrderedDocumentInserter::add(uint32_t docId,
const index::DocIdAndFeatures &features)
@@ -118,7 +114,6 @@ OrderedDocumentInserter::add(uint32_t docId,
_prevAdd = true;
}
-
void
OrderedDocumentInserter::remove(uint32_t docId)
{
@@ -129,7 +124,6 @@ OrderedDocumentInserter::remove(uint32_t docId)
_prevAdd = false;
}
-
void
OrderedDocumentInserter::rewind()
{
@@ -140,7 +134,6 @@ OrderedDocumentInserter::rewind()
_dItr.begin();
}
-
datastore::EntryRef
OrderedDocumentInserter::getWordRef() const
{
diff --git a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h
index 328346e9eee..0efb775487c 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h
@@ -10,15 +10,14 @@ namespace search::memoryindex {
class IDocumentInsertListener;
-
/**
* Class for inserting updates to FieldIndex in an ordered manner
* (single pass scan of dictionary tree)
*
* Insert order must be properly sorted, by (word, docId)
*/
-class OrderedDocumentInserter : public IOrderedDocumentInserter
-{
+class OrderedDocumentInserter : public IOrderedDocumentInserter {
+private:
vespalib::stringref _word;
uint32_t _prevDocId;
bool _prevAdd;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/postingiterator.h b/searchlib/src/vespa/searchlib/memoryindex/postingiterator.h
index 2838c65c5eb..de337ef49f3 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/postingiterator.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/postingiterator.h
@@ -10,8 +10,7 @@ namespace search::memoryindex {
/**
* Search iterator for memory field index posting list.
*/
-class PostingIterator : public queryeval::RankedSearchIteratorBase
-{
+class PostingIterator : public queryeval::RankedSearchIteratorBase {
private:
FieldIndex::PostingList::ConstIterator _itr;
const FeatureStore &_featureStore;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp
index 2c290f17782..77435096c27 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp
@@ -46,7 +46,6 @@ lowercaseToken(vespalib::string &dest, const char *src, size_t srcSize)
}
-
using document::ArrayFieldValue;
using document::DataType;
using document::FieldValue;
@@ -61,7 +60,6 @@ using search::index::schema::CollectionType;
using search::util::URL;
using vespalib::make_string;
-
void
UrlFieldInverter::startDoc(uint32_t docId)
{
@@ -75,7 +73,6 @@ UrlFieldInverter::startDoc(uint32_t docId)
_hostname->startDoc(docId);
}
-
void
UrlFieldInverter::endDoc()
{
@@ -89,7 +86,6 @@ UrlFieldInverter::endDoc()
_hostname->endDoc();
}
-
void
UrlFieldInverter::startElement(int32_t weight)
{
@@ -103,7 +99,6 @@ UrlFieldInverter::startElement(int32_t weight)
_hostname->startElement(weight);
}
-
void
UrlFieldInverter::endElement()
{
@@ -117,7 +112,6 @@ UrlFieldInverter::endElement()
_hostname->endElement();
}
-
void
UrlFieldInverter::processUrlSubField(FieldInverter *inverter,
const StructFieldValue &field,
@@ -145,7 +139,6 @@ UrlFieldInverter::processUrlSubField(FieldInverter *inverter,
}
}
-
void
UrlFieldInverter::processAnnotatedUrlField(const StructFieldValue & field)
{
@@ -159,7 +152,6 @@ UrlFieldInverter::processAnnotatedUrlField(const StructFieldValue & field)
processUrlSubField(_hostname, field, UrlDataType::FIELD_HOST, true);
}
-
void
UrlFieldInverter::processUrlField(const FieldValue &url_field)
{
@@ -207,7 +199,9 @@ UrlFieldInverter::processUrlField(const FieldValue &url_field)
processUrlOldStyle(s);
}
-void UrlFieldInverter::processUrlOldStyle(const vespalib::string &s) {
+void
+UrlFieldInverter::processUrlOldStyle(const vespalib::string &s)
+{
URL url(reinterpret_cast<const unsigned char *>(s.data()), s.size());
_hostname->addWord(HOSTNAME_BEGIN);
@@ -264,7 +258,6 @@ void UrlFieldInverter::processUrlOldStyle(const vespalib::string &s) {
_hostname->addWord(HOSTNAME_END);
}
-
void
UrlFieldInverter::processArrayUrlField(const ArrayFieldValue &field)
{
@@ -276,7 +269,6 @@ UrlFieldInverter::processArrayUrlField(const ArrayFieldValue &field)
}
}
-
void
UrlFieldInverter::processWeightedSetUrlField(const WeightedSetFieldValue &field)
{
@@ -292,13 +284,16 @@ UrlFieldInverter::processWeightedSetUrlField(const WeightedSetFieldValue &field)
}
namespace {
-bool isUriType(const DataType &type) {
+
+bool
+isUriType(const DataType &type)
+{
return type == UrlDataType::getInstance()
- || type == *DataType::STRING
- || type == *DataType::URI;
+ || type == *DataType::STRING
+ || type == *DataType::URI;
}
-} // namespace
+}
void
UrlFieldInverter::invertUrlField(const FieldValue &val)
@@ -366,7 +361,6 @@ UrlFieldInverter::removeDocument(uint32_t docId)
_hostname->removeDocument(docId);
}
-
UrlFieldInverter::UrlFieldInverter(index::Schema::CollectionType collectionType,
FieldInverter *all,
FieldInverter *scheme,
@@ -389,6 +383,5 @@ UrlFieldInverter::UrlFieldInverter(index::Schema::CollectionType collectionType,
{
}
-
}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.h b/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.h
index c902feaf5a6..1659e460af3 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.h
@@ -9,8 +9,7 @@ namespace search::memoryindex {
class FieldInverter;
-class UrlFieldInverter
-{
+class UrlFieldInverter {
FieldInverter *_all;
FieldInverter *_scheme;
FieldInverter *_host;
@@ -31,11 +30,10 @@ class UrlFieldInverter
void endElement();
- void
- processUrlSubField(FieldInverter *inverter,
- const document::StructFieldValue &field,
- vespalib::stringref subField,
- bool addAnchors);
+ void processUrlSubField(FieldInverter *inverter,
+ const document::StructFieldValue &field,
+ vespalib::stringref subField,
+ bool addAnchors);
void processAnnotatedUrlField(const document::StructFieldValue &field);
diff --git a/searchlib/src/vespa/searchlib/memoryindex/wordstore.h b/searchlib/src/vespa/searchlib/memoryindex/wordstore.h
index b909f26157f..4c1526df527 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/wordstore.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/wordstore.h
@@ -7,8 +7,7 @@
namespace search::memoryindex {
-class WordStore
-{
+class WordStore {
public:
using DataStoreType = datastore::DataStoreT<datastore::AlignedEntryRefT<22, 2>>;
using RefType = DataStoreType::RefType;
@@ -23,8 +22,7 @@ public:
WordStore();
~WordStore();
datastore::EntryRef addWord(const vespalib::stringref word);
- const char * getWord(datastore::EntryRef ref) const
- {
+ const char *getWord(datastore::EntryRef ref) const {
RefType internalRef(ref);
return _store.getEntry<char>(internalRef);
}