summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/list_indexes.cpp
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2021-03-23 23:31:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-25 22:48:02 +0000
commite0f87dc63d1d430c83515dacf9b7a57aa503ac44 (patch)
tree2ea4cb969c745155fe75d44f91c0b39a76dabac0 /src/mongo/db/commands/list_indexes.cpp
parent6afd283045dc43c0b249424ba03a72b89e5ad8c6 (diff)
downloadmongo-e0f87dc63d1d430c83515dacf9b7a57aa503ac44.tar.gz
SERVER-54639 make list_indexes.cpp time-series conversion helper functions generic
Diffstat (limited to 'src/mongo/db/commands/list_indexes.cpp')
-rw-r--r--src/mongo/db/commands/list_indexes.cpp47
1 files changed, 1 insertions, 46 deletions
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp
index 5d207392b6a..ee927bb7dd6 100644
--- a/src/mongo/db/commands/list_indexes.cpp
+++ b/src/mongo/db/commands/list_indexes.cpp
@@ -63,51 +63,6 @@ namespace mongo {
namespace {
/**
- * Converts buckets collection index specs to the time-series collection schema.
- * Returns a list of index specs mapped from the bucket collection schema.
- */
-std::list<BSONObj> makeTimeseriesIndexSpecs(const TimeseriesOptions& timeseriesOptions,
- const std::list<BSONObj>& bucketsIndexSpecs) {
- std::list<BSONObj> indexSpecs;
- for (const auto& bucketsIndexSpec : bucketsIndexSpecs) {
- // TODO(SERVER-54639): Map index specs from bucket collection using helper function.
- BSONObjBuilder builder;
- bool skip = false;
- for (const auto& elem : bucketsIndexSpec) {
- if (elem.fieldNameStringData() == ListIndexesReplyItem::kKeyFieldName) {
- auto key = timeseries::convertBucketsIndexSpecToTimeseriesIndexSpec(
- timeseriesOptions, elem.Obj());
- if (key.isEmpty()) {
- // Skip index spec due to failed conversion.
- skip = true;
- break;
- }
- builder.append(ListIndexesReplyItem::kKeyFieldName, key);
- continue;
- }
- // Besides 'key', fields such as 'v' and 'name' commonly appear in the spec.
- // Depending on the index options, other fields that may be appended here
- // include 'sparse', 'hidden', 'collation'.
- // {
- // v: 2,
- // name: 'mm_1',
- // ...
- // sparse: true,
- // ...
- // }
- // For a complete list, refer to:
- // https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#options-for-all-index-types
- builder.append(elem);
- }
- if (skip) {
- continue;
- }
- indexSpecs.push_back(builder.obj());
- }
- return indexSpecs;
-}
-
-/**
* Returns index specs, with resolved namespace, from the catalog for this listIndexes request.
*/
using IndexSpecsWithNamespaceString = std::pair<std::list<BSONObj>, NamespaceString>;
@@ -128,7 +83,7 @@ IndexSpecsWithNamespaceString getIndexSpecsWithNamespaceString(OperationContext*
coll);
return std::make_pair(
- makeTimeseriesIndexSpecs(
+ timeseries::createTimeseriesIndexesFromBucketsIndexes(
*timeseriesOptions,
listIndexesInLock(opCtx, coll, bucketsNss, cmd.getIncludeBuildUUIDs())),
*origNss);