本文整理汇总了C++中intrusive_ptr::setInShard方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::setInShard方法的具体用法?C++ intrusive_ptr::setInShard怎么用?C++ intrusive_ptr::setInShard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::setInShard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmdElement
intrusive_ptr<Pipeline> Pipeline::parseCommand(
string &errmsg, BSONObj &cmdObj,
const intrusive_ptr<ExpressionContext> &pCtx) {
intrusive_ptr<Pipeline> pPipeline(new Pipeline(pCtx));
vector<BSONElement> pipeline;
/* gather the specification for the aggregation */
for(BSONObj::iterator cmdIterator = cmdObj.begin();
cmdIterator.more(); ) {
BSONElement cmdElement(cmdIterator.next());
const char *pFieldName = cmdElement.fieldName();
// ignore top-level fields prefixed with $. They are for the command processor, not us.
if (pFieldName[0] == '$') {
continue;
}
/* look for the aggregation command */
if (!strcmp(pFieldName, commandName)) {
pPipeline->collectionName = cmdElement.String();
continue;
}
/* check for the collection name */
if (!strcmp(pFieldName, pipelineName)) {
pipeline = cmdElement.Array();
continue;
}
/* check for explain option */
if (!strcmp(pFieldName, explainName)) {
pPipeline->explain = cmdElement.Bool();
continue;
}
/* if the request came from the router, we're in a shard */
if (!strcmp(pFieldName, fromRouterName)) {
pCtx->setInShard(cmdElement.Bool());
continue;
}
/* check for debug options */
if (!strcmp(pFieldName, splitMongodPipelineName)) {
pPipeline->splitMongodPipeline = true;
continue;
}
/* we didn't recognize a field in the command */
ostringstream sb;
sb <<
"unrecognized field \"" <<
cmdElement.fieldName();
errmsg = sb.str();
return intrusive_ptr<Pipeline>();
}
/*
If we get here, we've harvested the fields we expect for a pipeline.
Set up the specified document source pipeline.
*/
SourceContainer& sources = pPipeline->sources; // shorthand
/* iterate over the steps in the pipeline */
const size_t nSteps = pipeline.size();
for(size_t iStep = 0; iStep < nSteps; ++iStep) {
/* pull out the pipeline element as an object */
BSONElement pipeElement(pipeline[iStep]);
uassert(15942, str::stream() << "pipeline element " <<
iStep << " is not an object",
pipeElement.type() == Object);
BSONObj bsonObj(pipeElement.Obj());
// Parse a pipeline stage from 'bsonObj'.
uassert(16435, "A pipeline stage specification object must contain exactly one field.",
bsonObj.nFields() == 1);
BSONElement stageSpec = bsonObj.firstElement();
const char* stageName = stageSpec.fieldName();
// Create a DocumentSource pipeline stage from 'stageSpec'.
StageDesc key;
key.pName = stageName;
const StageDesc* pDesc = (const StageDesc*)
bsearch(&key, stageDesc, nStageDesc, sizeof(StageDesc),
stageDescCmp);
uassert(16436,
str::stream() << "Unrecognized pipeline stage name: '" << stageName << "'",
pDesc);
intrusive_ptr<DocumentSource> stage = (*pDesc->pFactory)(&stageSpec, pCtx);
verify(stage);
stage->setPipelineStep(iStep);
sources.push_back(stage);
}
/* if there aren't any pipeline stages, there's nothing more to do */
if (sources.empty())
return pPipeline;
/*
//.........这里部分代码省略.........
示例2: cmdElement
intrusive_ptr<Pipeline> Pipeline::parseCommand(
string &errmsg, BSONObj &cmdObj,
const intrusive_ptr<ExpressionContext> &pCtx) {
intrusive_ptr<Pipeline> pPipeline(new Pipeline(pCtx));
vector<BSONElement> pipeline;
/* gather the specification for the aggregation */
for(BSONObj::iterator cmdIterator = cmdObj.begin();
cmdIterator.more(); ) {
BSONElement cmdElement(cmdIterator.next());
const char *pFieldName = cmdElement.fieldName();
/* look for the aggregation command */
if (!strcmp(pFieldName, commandName)) {
pPipeline->collectionName = cmdElement.String();
continue;
}
/* check for the collection name */
if (!strcmp(pFieldName, pipelineName)) {
pipeline = cmdElement.Array();
continue;
}
/* check for explain option */
if (!strcmp(pFieldName, explainName)) {
pPipeline->explain = cmdElement.Bool();
continue;
}
/* if the request came from the router, we're in a shard */
if (!strcmp(pFieldName, fromRouterName)) {
pCtx->setInShard(cmdElement.Bool());
continue;
}
/* check for debug options */
if (!strcmp(pFieldName, splitMongodPipelineName)) {
pPipeline->splitMongodPipeline = true;
continue;
}
/* Ignore $auth information sent along with the command. The authentication system will
* use it, it's not a part of the pipeline.
*/
if (!strcmp(pFieldName, AuthenticationTable::fieldName.c_str())) {
continue;
}
/* we didn't recognize a field in the command */
ostringstream sb;
sb <<
"unrecognized field \"" <<
cmdElement.fieldName();
errmsg = sb.str();
return intrusive_ptr<Pipeline>();
}
/*
If we get here, we've harvested the fields we expect for a pipeline.
Set up the specified document source pipeline.
*/
SourceVector *pSourceVector = &pPipeline->sourceVector; // shorthand
/* iterate over the steps in the pipeline */
const size_t nSteps = pipeline.size();
for(size_t iStep = 0; iStep < nSteps; ++iStep) {
/* pull out the pipeline element as an object */
BSONElement pipeElement(pipeline[iStep]);
uassert(15942, str::stream() << "pipeline element " <<
iStep << " is not an object",
pipeElement.type() == Object);
BSONObj bsonObj(pipeElement.Obj());
// Parse a pipeline stage from 'bsonObj'.
uassert(16435, "A pipeline stage specification object must contain exactly one field.",
bsonObj.nFields() == 1);
BSONElement stageSpec = bsonObj.firstElement();
const char* stageName = stageSpec.fieldName();
// Create a DocumentSource pipeline stage from 'stageSpec'.
StageDesc key;
key.pName = stageName;
const StageDesc* pDesc = (const StageDesc*)
bsearch(&key, stageDesc, nStageDesc, sizeof(StageDesc),
stageDescCmp);
uassert(16436,
str::stream() << "Unrecognized pipeline stage name: '" << stageName << "'",
pDesc);
intrusive_ptr<DocumentSource> stage = (*pDesc->pFactory)(&stageSpec, pCtx);
verify(stage);
stage->setPipelineStep(iStep);
pSourceVector->push_back(stage);
}
/* if there aren't any pipeline stages, there's nothing more to do */
if (!pSourceVector->size())
return pPipeline;
//.........这里部分代码省略.........