mirror of https://github.com/mongodb/mongo
SERVER-115175 Add dedicated `LiteParsed` classes for search stages (#45076)
GitOrigin-RevId: d7d4108b7255cee4dee6adf72f4215cd6d59ad43
This commit is contained in:
parent
1bbf2dd26e
commit
ec63eb8bbe
|
|
@ -65,10 +65,10 @@ StringData removePrefixWorkaround(StringData key, StringData pre) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
ALLOCATE_STAGE_PARAMS_ID(searchStage, SearchStageStageParams::id);
|
||||
ALLOCATE_STAGE_PARAMS_ID(search, SearchStageParams::id);
|
||||
|
||||
REGISTER_DOCUMENT_SOURCE(search,
|
||||
LiteParsedSearchStage::parse,
|
||||
SearchLiteParsed::parse,
|
||||
DocumentSourceSearch::createFromBson,
|
||||
AllowedWithApiStrict::kNeverInVersion1);
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ ALLOCATE_DOCUMENT_SOURCE_ID(search, DocumentSourceSearch::id)
|
|||
// $searchBeta is supported as an alias for $search for compatibility with applications that used
|
||||
// search during its beta period.
|
||||
REGISTER_DOCUMENT_SOURCE(searchBeta,
|
||||
LiteParsedSearchStage::parse,
|
||||
SearchLiteParsed::parse,
|
||||
DocumentSourceSearch::createFromBson,
|
||||
AllowedWithApiStrict::kNeverInVersion1);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "mongo/db/pipeline/document_source_set_variable_from_subpipeline.h"
|
||||
#include "mongo/db/pipeline/lite_parsed_document_source.h"
|
||||
#include "mongo/db/pipeline/search/document_source_internal_search_mongot_remote.h"
|
||||
#include "mongo/db/pipeline/search/lite_parsed_search.h"
|
||||
#include "mongo/db/pipeline/search/search_helper.h"
|
||||
#include "mongo/db/query/search/internal_search_mongot_remote_spec_gen.h"
|
||||
#include "mongo/db/query/search/mongot_cursor.h"
|
||||
|
|
@ -41,6 +42,8 @@
|
|||
|
||||
namespace mongo {
|
||||
|
||||
DEFINE_LITE_PARSED_SEARCH_STAGE_DERIVED(Search);
|
||||
|
||||
/**
|
||||
* The $search stage expands to multiple internal stages when parsed, namely
|
||||
* $_internalSearchMongotRemote and $_internalSearchIdLookup. $setVariableFromSubPipeline may also
|
||||
|
|
|
|||
|
|
@ -61,8 +61,10 @@ auto cloneEachOne(std::list<boost::intrusive_ptr<DocumentSource>> stages, const
|
|||
}
|
||||
} // namespace
|
||||
|
||||
ALLOCATE_STAGE_PARAMS_ID(searchMeta, SearchMetaStageParams::id);
|
||||
|
||||
REGISTER_DOCUMENT_SOURCE(searchMeta,
|
||||
LiteParsedSearchStage::parse,
|
||||
SearchMetaLiteParsed::parse,
|
||||
DocumentSourceSearchMeta::createFromBson,
|
||||
AllowedWithApiStrict::kNeverInVersion1);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,13 @@
|
|||
|
||||
#include "mongo/db/pipeline/document_source.h"
|
||||
#include "mongo/db/pipeline/search/document_source_internal_search_mongot_remote.h"
|
||||
#include "mongo/db/pipeline/search/lite_parsed_search.h"
|
||||
#include "mongo/util/modules.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
DEFINE_LITE_PARSED_SEARCH_STAGE_DERIVED(SearchMeta);
|
||||
|
||||
/**
|
||||
* The $searchMeta stage is similar to the $_internalMongotRemote stage except that it consumes
|
||||
* metadata cursors.
|
||||
|
|
|
|||
|
|
@ -49,8 +49,10 @@ namespace mongo {
|
|||
|
||||
using boost::intrusive_ptr;
|
||||
|
||||
ALLOCATE_STAGE_PARAMS_ID(vectorSearch, VectorSearchStageParams::id);
|
||||
|
||||
REGISTER_DOCUMENT_SOURCE(vectorSearch,
|
||||
LiteParsedSearchStage::parse,
|
||||
VectorSearchLiteParsed::parse,
|
||||
DocumentSourceVectorSearch::createFromBson,
|
||||
AllowedWithApiStrict::kNeverInVersion1);
|
||||
ALLOCATE_DOCUMENT_SOURCE_ID(vectorSearch, DocumentSourceVectorSearch::id)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "mongo/bson/bsonobj.h"
|
||||
#include "mongo/db/pipeline/document_source.h"
|
||||
#include "mongo/db/pipeline/document_source_limit.h"
|
||||
#include "mongo/db/pipeline/search/lite_parsed_search.h"
|
||||
#include "mongo/db/query/query_knobs_gen.h"
|
||||
#include "mongo/db/query/search/internal_search_mongot_remote_spec_gen.h"
|
||||
#include "mongo/util/modules.h"
|
||||
|
|
@ -42,6 +43,8 @@
|
|||
|
||||
namespace mongo {
|
||||
|
||||
DEFINE_LITE_PARSED_SEARCH_STAGE_DERIVED(VectorSearch);
|
||||
|
||||
/**
|
||||
* Interface used to retrieve the execution stats of explain().
|
||||
*
|
||||
|
|
|
|||
|
|
@ -34,20 +34,12 @@
|
|||
|
||||
namespace mongo {
|
||||
|
||||
DECLARE_STAGE_PARAMS_DERIVED_DEFAULT(SearchStage);
|
||||
|
||||
/**
|
||||
* A 'LiteParsed' representation of either a $search or $searchMeta stage.
|
||||
* This is the parent class for the $listSearchIndexes stage.
|
||||
* A 'LiteParsed' representation of a search stage. This is the parent class for the
|
||||
* $listSearchIndexes stage.
|
||||
*/
|
||||
class LiteParsedSearchStage : public LiteParsedDocumentSource {
|
||||
class LiteParsedSearchStageBase : public LiteParsedDocumentSource {
|
||||
public:
|
||||
static std::unique_ptr<LiteParsedSearchStage> parse(const NamespaceString& nss,
|
||||
const BSONElement& spec,
|
||||
const LiteParserOptions& options) {
|
||||
return std::make_unique<LiteParsedSearchStage>(spec, std::move(nss));
|
||||
}
|
||||
|
||||
stdx::unordered_set<NamespaceString> getInvolvedNamespaces() const override {
|
||||
// There are no foreign namespaces.
|
||||
return stdx::unordered_set<NamespaceString>{};
|
||||
|
|
@ -75,14 +67,28 @@ public:
|
|||
transactionNotSupported(getParseTimeName());
|
||||
}
|
||||
|
||||
std::unique_ptr<StageParams> getStageParams() const final {
|
||||
return std::make_unique<SearchStageStageParams>(_originalBson);
|
||||
}
|
||||
|
||||
explicit LiteParsedSearchStage(const BSONElement& spec, NamespaceString nss)
|
||||
explicit LiteParsedSearchStageBase(const BSONElement& spec, NamespaceString nss)
|
||||
: LiteParsedDocumentSource(spec), _nss(std::move(nss)) {}
|
||||
|
||||
private:
|
||||
const NamespaceString _nss;
|
||||
};
|
||||
|
||||
#define DEFINE_LITE_PARSED_SEARCH_STAGE_DERIVED(stageName) \
|
||||
DECLARE_STAGE_PARAMS_DERIVED_DEFAULT(stageName); \
|
||||
class stageName##LiteParsed : public mongo::LiteParsedSearchStageBase { \
|
||||
public: \
|
||||
stageName##LiteParsed(const mongo::BSONElement& originalBson, mongo::NamespaceString nss) \
|
||||
: mongo::LiteParsedSearchStageBase(originalBson, nss) {} \
|
||||
static std::unique_ptr<stageName##LiteParsed> parse( \
|
||||
const mongo::NamespaceString& nss, \
|
||||
const mongo::BSONElement& spec, \
|
||||
const mongo::LiteParserOptions& options) { \
|
||||
return std::make_unique<stageName##LiteParsed>(spec, nss); \
|
||||
} \
|
||||
std::unique_ptr<mongo::StageParams> getStageParams() const final { \
|
||||
return std::make_unique<stageName##StageParams>(_originalBson); \
|
||||
} \
|
||||
};
|
||||
|
||||
} // namespace mongo
|
||||
|
|
|
|||
Loading…
Reference in New Issue