diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-15 12:02:26 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-15 12:02:26 +0000 |
commit | 40e7d157350efdc491485a45283bbb6fa93dac55 (patch) | |
tree | 2f8bd266a7ef78726983216c57882e7969e86711 /searchcore/src | |
parent | 502825dab6d7783773dd5815f2b7e3c9ba1333ab (diff) |
Avoid copying BucketState, when you only need BucketInfo.
Diffstat (limited to 'searchcore/src')
3 files changed, 15 insertions, 1 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp index 3ced0f509b5..e80543368d4 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp @@ -119,6 +119,19 @@ BucketDB::cachedGet(const BucketId &bucketId) const return get(bucketId); } +storage::spi::BucketInfo +BucketDB::cachedGetBucketInfo(const BucketId &bucketId) const +{ + if (isCachedBucket(bucketId)) { + return _cachedBucketState; + } + auto itr = _map.find(bucketId); + if (itr != _map.end()) { + return itr->second; + } + return BucketState(); +} + bool BucketDB::hasBucket(const BucketId &bucketId) const { diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h index e64cc53d4a2..05388931e20 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h @@ -51,6 +51,7 @@ public: void cacheBucket(const BucketId &bucketId); void uncacheBucket(); bool isCachedBucket(const BucketId &bucketId) const; + storage::spi::BucketInfo cachedGetBucketInfo(const BucketId &bucketId) const; BucketState cachedGet(const BucketId &bucketId) const; bool hasBucket(const BucketId &bucketId) const; void getBuckets(BucketId::List & buckets) const; diff --git a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp index 1d3b2165c80..57f1ee74e60 100644 --- a/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp @@ -116,7 +116,7 @@ BucketHandler::handleGetBucketInfo(const Bucket &bucket, // Called by SPI thread. // BucketDBOwner ensures synchronization between SPI thread and // master write thread in document database. - BucketInfo bucketInfo = _ready->getBucketDB().takeGuard()->cachedGet(bucket); + BucketInfo bucketInfo = _ready->getBucketDB().takeGuard()->cachedGetBucketInfo(bucket); LOG(spam, "handleGetBucketInfo(%s): %s", bucket.toString().c_str(), bucketInfo.toString().c_str()); resultHandler.handle(BucketInfoResult(bucketInfo)); |