aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-02-15 12:02:26 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-02-15 12:02:26 +0000
commit40e7d157350efdc491485a45283bbb6fa93dac55 (patch)
tree2f8bd266a7ef78726983216c57882e7969e86711 /searchcore/src
parent502825dab6d7783773dd5815f2b7e3c9ba1333ab (diff)
Avoid copying BucketState, when you only need BucketInfo.
Diffstat (limited to 'searchcore/src')
-rw-r--r--searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp13
-rw-r--r--searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/buckethandler.cpp2
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));