diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/timeseries/bucket_catalog.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/timeseries/bucket_catalog.h | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp index 1d25e6036a6..396e58dddec 100644 --- a/src/mongo/db/timeseries/bucket_catalog.cpp +++ b/src/mongo/db/timeseries/bucket_catalog.cpp @@ -767,7 +767,7 @@ const BucketCatalog::BucketHandle& BucketCatalog::WriteBatch::bucket() const { return _bucket; } -const std::vector<BSONObj>& BucketCatalog::WriteBatch::measurements() const { +const BucketCatalog::BatchMeasurements& BucketCatalog::WriteBatch::measurements() const { return _measurements; } @@ -797,9 +797,9 @@ bool BucketCatalog::WriteBatch::finished() const { BSONObj BucketCatalog::WriteBatch::toBSON() const { auto toFieldName = [](const auto& nameHashPair) { return nameHashPair.first; }; - return BSON("docs" << _measurements << "bucketMin" << _min << "bucketMax" << _max - << "numCommittedMeasurements" << int(_numPreviouslyCommittedMeasurements) - << "newFieldNamesToBeInserted" + return BSON("docs" << std::vector<BSONObj>(_measurements.begin(), _measurements.end()) + << "bucketMin" << _min << "bucketMax" << _max << "numCommittedMeasurements" + << int(_numPreviouslyCommittedMeasurements) << "newFieldNamesToBeInserted" << std::set<std::string>( boost::make_transform_iterator(_newFieldNamesToBeInserted.begin(), toFieldName), diff --git a/src/mongo/db/timeseries/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog.h index bc907eadccf..5880ca39dff 100644 --- a/src/mongo/db/timeseries/bucket_catalog.h +++ b/src/mongo/db/timeseries/bucket_catalog.h @@ -53,6 +53,10 @@ protected: static constexpr std::size_t kNumStaticNewFields = 10; using NewFieldNames = boost::container::small_vector<StringMapHashedKey, kNumStaticNewFields>; + // Number of measurements we can hold in a batch without needing to allocate memory. + static constexpr std::size_t kNumStaticBatchMeasurements = 10; + using BatchMeasurements = boost::container::small_vector<BSONObj, kNumStaticBatchMeasurements>; + using StripeNumber = std::uint8_t; using EraCountMap = std::map<uint64_t, uint64_t>; @@ -208,7 +212,7 @@ public: */ const BucketHandle& bucket() const; - const std::vector<BSONObj>& measurements() const; + const BatchMeasurements& measurements() const; const BSONObj& min() const; const BSONObj& max() const; const StringMap<std::size_t>& newFieldNamesToBeInserted() const; @@ -255,7 +259,7 @@ public: OperationId _opId; ExecutionStatsController _stats; - std::vector<BSONObj> _measurements; + BatchMeasurements _measurements; BSONObj _min; // Batch-local min; full if first batch, updates otherwise. BSONObj _max; // Batch-local max; full if first batch, updates otherwise. uint32_t _numPreviouslyCommittedMeasurements = 0; |