summaryrefslogtreecommitdiff
path: root/src/mongo/s/catalog
diff options
context:
space:
mode:
authorSimon Graetzer <simon.gratzer@mongodb.com>2021-10-11 19:34:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-11 20:07:54 +0000
commitcad9dbe960c444a7dc2f02f1f77af4142d9e3919 (patch)
tree70ede585fe38d9e761d40d91d2d1bfd967831cf1 /src/mongo/s/catalog
parentdccba0661624787d8f398058928b7a29a31a2a86 (diff)
downloadmongo-cad9dbe960c444a7dc2f02f1f77af4142d9e3919.tar.gz
SERVER-60494 Add size estimate field to ChunkType
Diffstat (limited to 'src/mongo/s/catalog')
-rw-r--r--src/mongo/s/catalog/type_chunk.cpp8
-rw-r--r--src/mongo/s/catalog/type_chunk.h7
2 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp
index 85615320d18..bae8a9fc02b 100644
--- a/src/mongo/s/catalog/type_chunk.cpp
+++ b/src/mongo/s/catalog/type_chunk.cpp
@@ -58,6 +58,7 @@ const BSONField<Date_t> ChunkType::lastmod("lastmod");
const BSONField<OID> ChunkType::epoch("lastmodEpoch");
const BSONField<Timestamp> ChunkType::timestamp("lastmodTimestamp");
const BSONField<BSONObj> ChunkType::history("history");
+const BSONField<long long> ChunkType::estimatedSize("estSize");
namespace {
@@ -334,6 +335,11 @@ StatusWith<ChunkType> ChunkType::fromConfigBSON(const BSONObj& source,
chunk.setVersion(
ChunkVersion(version.majorVersion(), version.minorVersion(), epoch, timestamp));
+ auto elem = source.getField(estimatedSize.name());
+ if (!elem.eoo()) {
+ chunk._estimatedSizeBytes = elem.safeNumberLong();
+ }
+
return chunk;
}
@@ -352,6 +358,8 @@ BSONObj ChunkType::toConfigBSON() const {
if (_version) {
builder.appendTimestamp(lastmod.name(), _version->toLong());
}
+ if (_estimatedSizeBytes)
+ builder.appendNumber(estimatedSize.name(), *_estimatedSizeBytes);
if (_jumbo)
builder.append(jumbo.name(), getJumbo());
addHistoryToBSON(builder);
diff --git a/src/mongo/s/catalog/type_chunk.h b/src/mongo/s/catalog/type_chunk.h
index 925bb7075fe..02c702e1db4 100644
--- a/src/mongo/s/catalog/type_chunk.h
+++ b/src/mongo/s/catalog/type_chunk.h
@@ -210,6 +210,7 @@ public:
static const BSONField<OID> epoch;
static const BSONField<Timestamp> timestamp;
static const BSONField<BSONObj> history;
+ static const BSONField<long long> estimatedSize;
ChunkType();
ChunkType(CollectionUUID collectionUUID,
@@ -291,6 +292,10 @@ public:
}
void setShard(const ShardId& shard);
+ boost::optional<long long> getEstimatedSizeBytes() const {
+ return _estimatedSizeBytes;
+ }
+
bool getJumbo() const {
return _jumbo.get_value_or(false);
}
@@ -334,6 +339,8 @@ private:
boost::optional<ChunkVersion> _version;
// (M)(C)(S) shard this chunk lives in
boost::optional<ShardId> _shard;
+ // (O)(C) chunk size used for chunk merging operation
+ boost::optional<long long> _estimatedSizeBytes;
// (O)(C) too big to move?
boost::optional<bool> _jumbo;
// history of the chunk