diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2022-07-27 12:07:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-07-27 12:53:37 +0000 |
commit | c42b4e0287cee7894cc4fc6d295a28c03f49baaa (patch) | |
tree | e19e3efb6f97d7c1c90484bde543f4d728e1b430 | |
parent | 01828ab1447a3a016ed3b7e68b7d8ecedd661665 (diff) | |
download | mongo-c42b4e0287cee7894cc4fc6d295a28c03f49baaa.tar.gz |
SERVER-68130 adjust autoSplitVector's estimatedAdditionalBytesPerItemInBSONArray
-rw-r--r-- | src/mongo/db/s/auto_split_vector.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/db/s/auto_split_vector.cpp b/src/mongo/db/s/auto_split_vector.cpp index 510fdba2d97..0100bd4e31f 100644 --- a/src/mongo/db/s/auto_split_vector.cpp +++ b/src/mongo/db/s/auto_split_vector.cpp @@ -49,7 +49,16 @@ namespace mongo { namespace { -constexpr int estimatedAdditionalBytesPerItemInBSONArray{2}; +/* + * BSON arrays are serialized as BSON objects with the index of each element as a string key: for + * example, the array ["a","b","c"] is going to be serialized as {"0":"a","1":"b","2":"c"}. The + * minimum size for a BSON object is `BSONObj::kMinBSONLength`. + * + * Given that the `vector<BSONObj>` returned by `autoSplitVector` can't be greater than 16MB when + * serialized, pessimistically assume that each key occupies the highest possible number of bytes. + */ +const int estimatedAdditionalBytesPerItemInBSONArray{ + (int)std::to_string(BSONObjMaxUserSize / BSONObj::kMinBSONLength).length()}; constexpr int kMaxSplitPointsToReposition{3}; |