本文整理汇总了C++中StatsMap::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ StatsMap::clear方法的具体用法?C++ StatsMap::clear怎么用?C++ StatsMap::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatsMap
的用法示例。
在下文中一共展示了StatsMap::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertAndValidate
Status ViewGraph::insertAndValidate(const ViewDefinition& view,
const std::vector<NamespaceString>& refs,
int pipelineSize) {
insertWithoutValidating(view, refs, pipelineSize);
// Perform validation on this newly inserted view. Note, if the graph was put in an invalid
// state through unvalidated inserts (e.g. if the user manually edits system.views)
// this may not necessarily be detected. We only check for errors introduced by this view.
const auto& viewNss = view.name();
uint64_t nodeId = _getNodeId(viewNss);
// If the graph fails validation for any reason, the insert is automatically rolled back on
// exiting this method.
auto rollBackInsert = [&]() -> auto {
remove(viewNss);
};
auto guard = MakeGuard(rollBackInsert);
// Check for cycles and get the height of the children.
StatsMap statsMap;
std::vector<uint64_t> cycleVertices;
cycleVertices.reserve(kMaxViewDepth);
auto childRes = _validateChildren(nodeId, nodeId, 0, &statsMap, &cycleVertices);
if (!childRes.isOK()) {
return childRes;
}
// Subtract one since the child height includes the non-view leaf node(s).
int childrenHeight = statsMap[nodeId].height - 1;
int childrenSize = statsMap[nodeId].cumulativeSize;
// Get the height of the parents to obtain the diameter through this node, as well as the size
// of the pipeline to check if if the combined pipeline exceeds the max size.
statsMap.clear();
auto parentRes = _validateParents(nodeId, 0, &statsMap);
if (!parentRes.isOK()) {
return parentRes;
}
// Check the combined heights of the children and parents.
int parentsHeight = statsMap[nodeId].height;
// Subtract one since the parent and children heights include the current node.
int diameter = parentsHeight + childrenHeight - 1;
if (diameter > kMaxViewDepth) {
return {ErrorCodes::ViewDepthLimitExceeded,
str::stream() << "View depth limit exceeded; maximum depth is " << kMaxViewDepth};
}
// Check the combined sizes of the children and parents.
int parentsSize = statsMap[nodeId].cumulativeSize;
// Subtract the current node's size since the parent and children sizes include the current
// node.
const Node& currentNode = _graph[nodeId];
int pipelineTotalSize = parentsSize + childrenSize - currentNode.size;
if (pipelineTotalSize > kMaxViewPipelineSizeBytes) {
return {ErrorCodes::ViewPipelineMaxSizeExceeded,
str::stream() << "Operation would result in a resolved view pipeline that exceeds "
"the maximum size of "
<< kMaxViewPipelineSizeBytes
<< " bytes"};
}
guard.Dismiss();
return Status::OK();
}