本文整理汇总了C++中PlanStage::getCommonStats方法的典型用法代码示例。如果您正苦于以下问题:C++ PlanStage::getCommonStats方法的具体用法?C++ PlanStage::getCommonStats怎么用?C++ PlanStage::getCommonStats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlanStage
的用法示例。
在下文中一共展示了PlanStage::getCommonStats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSummaryStats
// static
void Explain::getSummaryStats(PlanExecutor* exec, PlanSummaryStats* statsOut) {
invariant(NULL != statsOut);
PlanStage* root = exec->getRootStage();
// We can get some of the fields we need from the common stats stored in the
// root stage of the plan tree.
const CommonStats* common = root->getCommonStats();
statsOut->nReturned = common->advanced;
statsOut->executionTimeMillis = common->executionTimeMillis;
// Generate the plan summary string.
statsOut->summaryStr = getPlanSummary(root);
// The other fields are aggregations over the stages in the plan tree. We flatten
// the tree into a list and then compute these aggregations.
vector<PlanStage*> stages;
flattenExecTree(root, &stages);
for (size_t i = 0; i < stages.size(); i++) {
statsOut->totalKeysExamined += getKeysExamined(stages[i]->stageType(),
stages[i]->getSpecificStats());
statsOut->totalDocsExamined += getDocsExamined(stages[i]->stageType(),
stages[i]->getSpecificStats());
if (STAGE_IDHACK == stages[i]->stageType()) {
statsOut->isIdhack = true;
}
if (STAGE_SORT == stages[i]->stageType()) {
statsOut->hasSortStage = true;
}
}
}
示例2: getSummaryStats
void Explain::getSummaryStats(PlanExecutor* exec, PlanSummaryStats* statsOut) {
invariant(NULL != statsOut);
PlanStage* root = exec->getStages();
// We can get some of the fields we need from the common stats stored in the
// root stage of the plan tree.
const CommonStats* common = root->getCommonStats();
statsOut->nReturned = common->advanced;
statsOut->executionTimeMillis = common->executionTimeMillis;
// The other fields are aggregations over the stages in the plan tree. We flatten
// the tree into a list and then compute these aggregations.
vector<PlanStage*> stages;
flattenExecTree(root, &stages);
// Use this stream to build the plan summary string.
mongoutils::str::stream ss;
bool seenLeaf = false;
for (size_t i = 0; i < stages.size(); i++) {
statsOut->totalKeysExamined += getKeysExamined(stages[i]->stageType(),
stages[i]->getSpecificStats());
statsOut->totalDocsExamined += getDocsExamined(stages[i]->stageType(),
stages[i]->getSpecificStats());
if (STAGE_IDHACK == stages[i]->stageType()) {
statsOut->isIdhack = true;
}
if (STAGE_SORT == stages[i]->stageType()) {
statsOut->hasSortStage = true;
}
if (stages[i]->getChildren().empty()) {
// This is a leaf node. Add to the plan summary string accordingly. Unless
// this is the first leaf we've seen, add a delimiting string first.
if (seenLeaf) {
ss << ", ";
}
else {
seenLeaf = true;
}
addStageSummaryStr(stages[i], ss);
}
}
statsOut->summaryStr = ss;
}