diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-04-09 12:41:09 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-04-09 12:41:09 +0000 |
commit | 6344fbc3b60f858cc04fb85f7e65a24497478b14 (patch) | |
tree | e4bf36112cc7f481f40934064624f912c860dc1f /searchlib | |
parent | 2c51937708c1a2a56840a6d84711505a0a0ed049 (diff) |
Rename search::memoryindex::MemoryFieldIndex -> FieldIndex.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/CMakeLists.txt | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/dictionary.cpp | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/dictionary.h | 10 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/field_index.cpp (renamed from searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.cpp) | 70 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/field_index.h (renamed from searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h) | 67 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h | 18 |
9 files changed, 93 insertions, 82 deletions
diff --git a/searchlib/src/vespa/searchlib/memoryindex/CMakeLists.txt b/searchlib/src/vespa/searchlib/memoryindex/CMakeLists.txt index f1127a3f554..31bfb72b69b 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/memoryindex/CMakeLists.txt @@ -6,8 +6,8 @@ vespa_add_library(searchlib_memoryindex OBJECT documentinverter.cpp document_remover.cpp featurestore.cpp + field_index.cpp fieldinverter.cpp - memoryfieldindex.cpp memoryindex.cpp ordereddocumentinserter.cpp postingiterator.cpp diff --git a/searchlib/src/vespa/searchlib/memoryindex/dictionary.cpp b/searchlib/src/vespa/searchlib/memoryindex/dictionary.cpp index 028f2b564d7..918e1c24598 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/dictionary.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/dictionary.cpp @@ -31,7 +31,7 @@ Dictionary::Dictionary(const Schema & schema) _numFields(schema.getNumIndexFields()) { for (uint32_t fieldId = 0; fieldId < _numFields; ++fieldId) { - auto fieldIndex = std::make_unique<MemoryFieldIndex>(schema, fieldId); + auto fieldIndex = std::make_unique<FieldIndex>(schema, fieldId); _fieldIndexes.push_back(std::move(fieldIndex)); } } diff --git a/searchlib/src/vespa/searchlib/memoryindex/dictionary.h b/searchlib/src/vespa/searchlib/memoryindex/dictionary.h index 62c5a0ff561..d9dc3d35326 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/dictionary.h +++ b/searchlib/src/vespa/searchlib/memoryindex/dictionary.h @@ -2,7 +2,7 @@ #pragma once -#include "memoryfieldindex.h" +#include "field_index.h" namespace search::memoryindex { @@ -11,12 +11,12 @@ class FieldInverter; class Dictionary { public: - using PostingList = MemoryFieldIndex::PostingList; + using PostingList = FieldIndex::PostingList; private: using GenerationHandler = vespalib::GenerationHandler; - std::vector<std::unique_ptr<MemoryFieldIndex> > _fieldIndexes; + std::vector<std::unique_ptr<FieldIndex>> _fieldIndexes; uint32_t _numFields; public: @@ -46,11 +46,11 @@ public: MemoryUsage getMemoryUsage() const; - MemoryFieldIndex *getFieldIndex(uint32_t fieldId) const { + FieldIndex *getFieldIndex(uint32_t fieldId) const { return _fieldIndexes[fieldId].get(); } - const std::vector<std::unique_ptr<MemoryFieldIndex> > & + 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/documentinverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp index a4efa6ad487..7f18439089a 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/documentinverter.cpp @@ -184,7 +184,7 @@ DocumentInverter::pushDocuments(Dictionary &dict, auto indexFieldIterator = dict.getFieldIndexes().begin(); uint32_t fieldId = 0; for (auto &inverter : _inverters) { - MemoryFieldIndex &fieldIndex(**indexFieldIterator); + FieldIndex &fieldIndex(**indexFieldIterator); DocumentRemover &remover(fieldIndex.getDocumentRemover()); OrderedDocumentInserter &inserter(fieldIndex.getInserter()); _pushThreads.execute(fieldId, diff --git a/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp index 6623f93770c..4d42b9ae493 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "memoryfieldindex.h" +#include "field_index.h" #include "ordereddocumentinserter.h" #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/exceptions.h> @@ -23,13 +23,13 @@ namespace search::memoryindex { using datastore::EntryRef; vespalib::asciistream & -operator<<(vespalib::asciistream & os, const MemoryFieldIndex::WordKey & rhs) +operator<<(vespalib::asciistream & os, const FieldIndex::WordKey & rhs) { os << "wr(" << rhs._wordRef.ref() << ")"; return os; } -MemoryFieldIndex::MemoryFieldIndex(const Schema & schema, uint32_t fieldId) +FieldIndex::FieldIndex(const Schema & schema, uint32_t fieldId) : _wordStore(), _numUniqueWords(0), _generationHandler(), @@ -41,7 +41,7 @@ MemoryFieldIndex::MemoryFieldIndex(const Schema & schema, uint32_t fieldId) _inserter(std::make_unique<OrderedDocumentInserter>(*this)) { } -MemoryFieldIndex::~MemoryFieldIndex() +FieldIndex::~FieldIndex() { _postingListStore.disableFreeLists(); _postingListStore.disableElemHoldList(); @@ -68,8 +68,8 @@ MemoryFieldIndex::~MemoryFieldIndex() trimHoldLists(); } -MemoryFieldIndex::PostingList::Iterator -MemoryFieldIndex::find(const vespalib::stringref word) const +FieldIndex::PostingList::Iterator +FieldIndex::find(const vespalib::stringref word) const { DictionaryTree::Iterator itr = _dict.find(WordKey(EntryRef()), KeyComp(_wordStore, word)); if (itr.valid()) { @@ -78,8 +78,8 @@ MemoryFieldIndex::find(const vespalib::stringref word) const return PostingList::Iterator(); } -MemoryFieldIndex::PostingList::ConstIterator -MemoryFieldIndex::findFrozen(const vespalib::stringref word) const +FieldIndex::PostingList::ConstIterator +FieldIndex::findFrozen(const vespalib::stringref word) const { auto itr = _dict.getFrozenView().find(WordKey(EntryRef()), KeyComp(_wordStore, word)); if (itr.valid()) { @@ -90,7 +90,7 @@ MemoryFieldIndex::findFrozen(const vespalib::stringref word) const void -MemoryFieldIndex::compactFeatures() +FieldIndex::compactFeatures() { std::vector<uint32_t> toHold; @@ -147,7 +147,7 @@ MemoryFieldIndex::compactFeatures() } void -MemoryFieldIndex::dump(search::index::IndexBuilder & indexBuilder) +FieldIndex::dump(search::index::IndexBuilder & indexBuilder) { vespalib::stringref word; FeatureStore::DecodeContextCooked decoder(nullptr); @@ -220,7 +220,7 @@ MemoryFieldIndex::dump(search::index::IndexBuilder & indexBuilder) MemoryUsage -MemoryFieldIndex::getMemoryUsage() const +FieldIndex::getMemoryUsage() const { MemoryUsage usage; usage.merge(_wordStore.getMemoryUsage()); @@ -236,78 +236,78 @@ MemoryFieldIndex::getMemoryUsage() const namespace search::btree { template -class BTreeNodeDataWrap<memoryindex::MemoryFieldIndex::WordKey, BTreeDefaultTraits::LEAF_SLOTS>; +class BTreeNodeDataWrap<memoryindex::FieldIndex::WordKey, BTreeDefaultTraits::LEAF_SLOTS>; template -class BTreeNodeT<memoryindex::MemoryFieldIndex::WordKey, BTreeDefaultTraits::INTERNAL_SLOTS>; +class BTreeNodeT<memoryindex::FieldIndex::WordKey, BTreeDefaultTraits::INTERNAL_SLOTS>; #if 0 template -class BTreeNodeT<memoryindex::MemoryFieldIndex::WordKey, +class BTreeNodeT<memoryindex::FieldIndex::WordKey, BTreeDefaultTraits::LEAF_SLOTS>; #endif template -class BTreeNodeTT<memoryindex::MemoryFieldIndex::WordKey, +class BTreeNodeTT<memoryindex::FieldIndex::WordKey, datastore::EntryRef, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS>; template -class BTreeNodeTT<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeNodeTT<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::LEAF_SLOTS>; template -class BTreeInternalNode<memoryindex::MemoryFieldIndex::WordKey, +class BTreeInternalNode<memoryindex::FieldIndex::WordKey, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS>; template -class BTreeLeafNode<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeLeafNode<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::LEAF_SLOTS>; template -class BTreeNodeStore<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeNodeStore<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; template -class BTreeIterator<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeIterator<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, - const memoryindex::MemoryFieldIndex::KeyComp, + const memoryindex::FieldIndex::KeyComp, BTreeDefaultTraits>; template -class BTree<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTree<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, - const memoryindex::MemoryFieldIndex::KeyComp, + const memoryindex::FieldIndex::KeyComp, BTreeDefaultTraits>; template -class BTreeRoot<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeRoot<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, - const memoryindex::MemoryFieldIndex::KeyComp, + const memoryindex::FieldIndex::KeyComp, BTreeDefaultTraits>; template -class BTreeRootBase<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeRootBase<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; template -class BTreeNodeAllocator<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeNodeAllocator<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; diff --git a/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h b/searchlib/src/vespa/searchlib/memoryindex/field_index.h index 515a38e222c..4a27e30b47a 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memoryfieldindex.h +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.h @@ -17,10 +17,21 @@ namespace search::memoryindex { class OrderedDocumentInserter; -/* + +/** * Memory index for a single field. + * + * It consists of the following components: + * - WordStore containing all unique words in this field (across all documents). + * - B-Tree dictionary that maps from unique word (32-bit ref) -> posting list (32-bit ref). + * - B-Tree posting lists that maps from document id (32-bit) -> features (32-bit ref). + * - BTreeStore containing all the posting lists. + * - FeatureStore containing information on where a (word, document) pair matched this field. + * This information is unpacked and used during ranking. + * + * Elements in the three stores are accessed using 32-bit references / handles. */ -class MemoryFieldIndex { +class FieldIndex { public: // Mapping from docid -> feature ref using PostingList = btree::BTreeRoot<uint32_t, uint32_t, search::btree::NoAggregated>; @@ -97,8 +108,8 @@ public: return _featureStore.addFeatures(_fieldId, features).first; } - MemoryFieldIndex(const index::Schema &schema, uint32_t fieldId); - ~MemoryFieldIndex(); + FieldIndex(const index::Schema &schema, uint32_t fieldId); + ~FieldIndex(); PostingList::Iterator find(const vespalib::stringref word) const; PostingList::ConstIterator @@ -186,80 +197,80 @@ public: namespace search::btree { extern template -class BTreeNodeDataWrap<memoryindex::MemoryFieldIndex::WordKey, +class BTreeNodeDataWrap<memoryindex::FieldIndex::WordKey, BTreeDefaultTraits::LEAF_SLOTS>; extern template -class BTreeNodeT<memoryindex::MemoryFieldIndex::WordKey, +class BTreeNodeT<memoryindex::FieldIndex::WordKey, BTreeDefaultTraits::INTERNAL_SLOTS>; #if 0 extern template -class BTreeNodeT<memoryindex::MemoryFieldIndex::WordKey, +class BTreeNodeT<memoryindex::FieldIndex::WordKey, BTreeDefaultTraits::LEAF_SLOTS>; #endif extern template -class BTreeNodeTT<memoryindex::MemoryFieldIndex::WordKey, +class BTreeNodeTT<memoryindex::FieldIndex::WordKey, datastore::EntryRef, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS>; extern template -class BTreeNodeTT<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeNodeTT<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::LEAF_SLOTS>; extern template -class BTreeInternalNode<memoryindex::MemoryFieldIndex::WordKey, +class BTreeInternalNode<memoryindex::FieldIndex::WordKey, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS>; extern template -class BTreeLeafNode<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeLeafNode<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::LEAF_SLOTS>; extern template -class BTreeNodeStore<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeNodeStore<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; extern template -class BTreeIterator<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeIterator<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, - const memoryindex::MemoryFieldIndex::KeyComp, + const memoryindex::FieldIndex::KeyComp, BTreeDefaultTraits>; extern template -class BTree<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTree<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, - const memoryindex::MemoryFieldIndex::KeyComp, + const memoryindex::FieldIndex::KeyComp, BTreeDefaultTraits>; extern template -class BTreeRoot<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeRoot<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, - const memoryindex::MemoryFieldIndex::KeyComp, + const memoryindex::FieldIndex::KeyComp, BTreeDefaultTraits>; extern template -class BTreeRootBase<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeRootBase<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; extern template -class BTreeNodeAllocator<memoryindex::MemoryFieldIndex::WordKey, - memoryindex::MemoryFieldIndex::PostingListPtr, +class BTreeNodeAllocator<memoryindex::FieldIndex::WordKey, + memoryindex::FieldIndex::PostingListPtr, search::btree::NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; diff --git a/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp b/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp index c8d3a212958..251ee86ac90 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/memoryindex.cpp @@ -207,7 +207,7 @@ public: const vespalib::string termStr = queryeval::termAsString(n); LOG(debug, "searching for '%s' in '%s'", termStr.c_str(), _field.getName().c_str()); - MemoryFieldIndex *fieldIndex = _dictionary.getFieldIndex(_fieldId); + FieldIndex *fieldIndex = _dictionary.getFieldIndex(_fieldId); GenerationHandler::Guard genGuard = fieldIndex->takeGenerationGuard(); Dictionary::PostingList::ConstIterator pitr = fieldIndex->findFrozen(termStr); diff --git a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp index 8231dfdff5b..3c4fca5b044 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.cpp @@ -27,7 +27,7 @@ const vespalib::string emptyWord = ""; } -OrderedDocumentInserter::OrderedDocumentInserter(MemoryFieldIndex &fieldIndex) +OrderedDocumentInserter::OrderedDocumentInserter(FieldIndex &fieldIndex) : _word(), _prevDocId(noDocId), _prevAdd(false), diff --git a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h index 9645c3890e2..328346e9eee 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h +++ b/searchlib/src/vespa/searchlib/memoryindex/ordereddocumentinserter.h @@ -3,7 +3,7 @@ #pragma once #include "iordereddocumentinserter.h" -#include "memoryfieldindex.h" +#include "field_index.h" #include <limits> namespace search::memoryindex { @@ -12,7 +12,7 @@ class IDocumentInsertListener; /** - * Class for inserting updates to MemoryFieldIndex in an ordered manner + * 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) @@ -22,12 +22,12 @@ class OrderedDocumentInserter : public IOrderedDocumentInserter vespalib::stringref _word; uint32_t _prevDocId; bool _prevAdd; - using DictionaryTree = MemoryFieldIndex::DictionaryTree; - using PostingListStore = MemoryFieldIndex::PostingListStore; - using KeyComp = MemoryFieldIndex::KeyComp; - using WordKey = MemoryFieldIndex::WordKey; - using PostingListKeyDataType = MemoryFieldIndex::PostingListKeyDataType; - MemoryFieldIndex &_fieldIndex; + using DictionaryTree = FieldIndex::DictionaryTree; + using PostingListStore = FieldIndex::PostingListStore; + using KeyComp = FieldIndex::KeyComp; + using WordKey = FieldIndex::WordKey; + using PostingListKeyDataType = FieldIndex::PostingListKeyDataType; + FieldIndex &_fieldIndex; DictionaryTree::Iterator _dItr; IDocumentInsertListener &_listener; @@ -47,7 +47,7 @@ class OrderedDocumentInserter : public IOrderedDocumentInserter void flushWord(); public: - OrderedDocumentInserter(MemoryFieldIndex &fieldIndex); + OrderedDocumentInserter(FieldIndex &fieldIndex); ~OrderedDocumentInserter() override; void setNextWord(const vespalib::stringref word) override; void add(uint32_t docId, const index::DocIdAndFeatures &features) override; |