diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2022-03-25 11:04:48 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahooinc.com> | 2022-03-25 11:04:48 +0100 |
commit | fd60321d53748744e2ee19e9290ba63968630de5 (patch) | |
tree | ad0097ad78df21da3ac19fbcb2ba769c81aa7da2 /searchcore | |
parent | c681593a3c3c38ef569fe4288deea7356f17d1b4 (diff) |
Add private member functions to get meta data view.
Diffstat (limited to 'searchcore')
4 files changed, 26 insertions, 21 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index d4b0f173087..75cb8dfa6b3 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -262,7 +262,7 @@ DocumentMetaStore::onInitSave(vespalib::stringref fileName) return std::make_unique<DocumentMetaStoreSaver> (std::move(guard), createAttributeHeader(fileName), _gidToLidMap.getFrozenView().begin(), - vespalib::ConstArrayRef(&_metaDataStore[0], getCommittedDocIdLimit())); + make_meta_data_view()); } DocumentMetaStore::DocId @@ -330,7 +330,7 @@ DocumentMetaStore::lowerBound(const BucketId &bucketId, const TreeView &treeView) const { document::GlobalId first(document::GlobalId::calculateFirstInBucket(bucketId)); - KeyComp lowerComp(first, _metaDataStore); + KeyComp lowerComp(first, acquire_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(first); return treeView.lowerBound(find_key, lowerComp); } @@ -341,7 +341,7 @@ DocumentMetaStore::upperBound(const BucketId &bucketId, const TreeView &treeView) const { document::GlobalId last(document::GlobalId::calculateLastInBucket(bucketId)); - KeyComp upperComp(last, _metaDataStore); + KeyComp upperComp(last, acquire_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(last); return treeView.upperBound(find_key, upperComp); } @@ -447,7 +447,7 @@ DocumentMetaStore::Result DocumentMetaStore::inspectExisting(const GlobalId &gid, uint64_t prepare_serial_num) { Result res; - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(gid); auto& itr = _gid_to_lid_map_write_itr; itr.lower_bound(_gidToLidMap.getRoot(), find_key, comp); @@ -466,7 +466,7 @@ DocumentMetaStore::inspect(const GlobalId &gid, uint64_t prepare_serial_num) { assert(_lidAlloc.isFreeListConstructed()); Result res; - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(gid); auto& itr = _gid_to_lid_map_write_itr; itr.lower_bound(_gidToLidMap.getRoot(), find_key, comp); @@ -494,7 +494,7 @@ DocumentMetaStore::put(const GlobalId &gid, { Result res; RawDocumentMetaData metaData(gid, bucketId, timestamp, docSize); - KeyComp comp(metaData, _metaDataStore); + KeyComp comp(metaData, get_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(gid); auto& itr = _gid_to_lid_map_write_itr; if (prepare_serial_num == 0u || _gid_to_lid_map_write_itr_prepare_serial_num != prepare_serial_num) { @@ -570,7 +570,7 @@ RawDocumentMetaData DocumentMetaStore::removeInternal(DocId lid, uint64_t prepare_serial_num) { const GlobalId & gid = getRawGid(lid); - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); GidToLidMapKey find_key(lid, gid); auto& itr = _gid_to_lid_map_write_itr; if (prepare_serial_num == 0u || _gid_to_lid_map_write_itr_prepare_serial_num != prepare_serial_num) { @@ -623,7 +623,7 @@ DocumentMetaStore::move(DocId fromLid, DocId toLid, uint64_t prepare_serial_num) _lidAlloc.moveLidBegin(fromLid, toLid); _metaDataStore[toLid] = _metaDataStore[fromLid]; const GlobalId & gid = getRawGid(fromLid); - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); GidToLidMapKey find_key(fromLid, gid); auto& itr = _gid_to_lid_map_write_itr; if (prepare_serial_num == 0u || _gid_to_lid_map_write_itr_prepare_serial_num != prepare_serial_num) { @@ -651,7 +651,7 @@ DocumentMetaStore::remove_batch_internal_btree(std::vector<LidAndRawDocumentMeta auto lid = lid_and_meta.first; auto& meta = lid_and_meta.second; const GlobalId& gid = meta.getGid(); - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); GidToLidMapKey find_key(lid, gid); if (itr.valid() && comp(itr.getKey(), find_key)) { itr.binarySeek(find_key, comp); @@ -728,7 +728,7 @@ bool DocumentMetaStore::getLid(const GlobalId &gid, DocId &lid) const { GlobalId value(gid); - KeyComp comp(value, _metaDataStore); + KeyComp comp(value, acquire_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(gid); TreeType::ConstIterator itr = _gidToLidMap.getFrozenView().find(find_key, comp); if (!itr.valid()) { @@ -835,7 +835,7 @@ DocumentMetaStore::Iterator DocumentMetaStore::lowerBound(const GlobalId &gid) const { // Called by writer thread - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(gid); return _gidToLidMap.lowerBound(find_key, comp); } @@ -844,7 +844,7 @@ DocumentMetaStore::Iterator DocumentMetaStore::upperBound(const GlobalId &gid) const { // Called by writer thread - KeyComp comp(gid, _metaDataStore); + KeyComp comp(gid, get_unbound_meta_data_view()); auto find_key = GidToLidMapKey::make_find_key(gid); return _gidToLidMap.upperBound(find_key, comp); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h index 305b81d58a6..16763ccdc9f 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h @@ -43,6 +43,8 @@ public: typedef documentmetastore::IStore::GlobalId GlobalId; typedef documentmetastore::IStore::BucketId BucketId; typedef documentmetastore::IStore::Timestamp Timestamp; + using MetaDataView = vespalib::ConstArrayRef<RawDocumentMetaData>; + using UnboundMetaDataView = const RawDocumentMetaData *; // If using proton::DocumentMetaStore directly, the // DocumentMetaStoreAttribute functions here are used instead of @@ -131,6 +133,10 @@ private: RawDocumentMetaData removeInternal(DocId lid, uint64_t cached_iterator_sequence_id); void remove_batch_internal_btree(std::vector<LidAndRawDocumentMetaData>& removed); + MetaDataView make_meta_data_view() { return vespalib::ConstArrayRef(&_metaDataStore[0], getCommittedDocIdLimit()); } + UnboundMetaDataView acquire_unbound_meta_data_view() const noexcept { return &_metaDataStore.acquire_elem_ref(0); } + UnboundMetaDataView get_unbound_meta_data_view() const noexcept { return &_metaDataStore[0]; } + public: typedef TreeType::Iterator Iterator; typedef TreeType::ConstIterator ConstIterator; diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp index 40cd3c89a6d..e44b883e4e8 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp @@ -5,17 +5,17 @@ namespace proton::documentmetastore { LidGidKeyComparator::LidGidKeyComparator(const document::GlobalId &gid, - const MetaDataStore &metaDataStore) + UnboundMetaDataView metaDataView) : _gid(gid), - _metaDataView(&metaDataStore.acquire_elem_ref(0)), + _metaDataView(metaDataView), _gidCompare() { } LidGidKeyComparator::LidGidKeyComparator(const RawDocumentMetaData &metaData, - const MetaDataStore &metaDataStore) + UnboundMetaDataView metaDataView) : _gid(metaData.getGid()), - _metaDataView(&metaDataStore.acquire_elem_ref(0)), + _metaDataView(metaDataView), _gidCompare() { } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.h index 5970342c750..d53fca12b74 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.h @@ -6,7 +6,6 @@ #include "gid_to_lid_map_key.h" #include <vespa/document/base/globalid.h> #include <vespa/searchlib/common/idocumentmetastore.h> -#include <vespa/vespalib/util/rcuvector.h> namespace proton::documentmetastore { @@ -18,10 +17,10 @@ class LidGidKeyComparator { private: typedef search::IDocumentMetaStore::DocId DocId; - typedef vespalib::RcuVectorBase<RawDocumentMetaData> MetaDataStore; + using UnboundMetaDataView = const RawDocumentMetaData *; const document::GlobalId &_gid; - const RawDocumentMetaData* _metaDataView; + UnboundMetaDataView _metaDataView; const document::GlobalId::BucketOrderCmp _gidCompare; const document::GlobalId &getGid(const GidToLidMapKey &key) const { @@ -38,10 +37,10 @@ public: * used to map from lid -> metadata (including gid). **/ LidGidKeyComparator(const document::GlobalId &gid, - const MetaDataStore &metaDataStore); + UnboundMetaDataView metaDataView); LidGidKeyComparator(const RawDocumentMetaData &metaData, - const MetaDataStore &metaDataStore); + UnboundMetaDataView metaDataView); bool operator()(const GidToLidMapKey &lhs, const GidToLidMapKey &rhs) const { if (lhs.get_gid_key() != rhs.get_gid_key()) { |