本文整理汇总了C++中BSONObjSet::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ BSONObjSet::erase方法的具体用法?C++ BSONObjSet::erase怎么用?C++ BSONObjSet::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSONObjSet
的用法示例。
在下文中一共展示了BSONObjSet::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doBreadthFirstSearch
void DocumentSourceGraphLookUp::doBreadthFirstSearch() {
long long depth = 0;
bool shouldPerformAnotherQuery;
do {
shouldPerformAnotherQuery = false;
// Check whether each key in the frontier exists in the cache or needs to be queried.
BSONObjSet cached = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
auto matchStage = makeMatchStageFromFrontier(&cached);
ValueUnorderedSet queried = pExpCtx->getValueComparator().makeUnorderedValueSet();
_frontier->swap(queried);
_frontierUsageBytes = 0;
// Process cached values, populating '_frontier' for the next iteration of search.
while (!cached.empty()) {
auto it = cached.begin();
shouldPerformAnotherQuery =
addToVisitedAndFrontier(*it, depth) || shouldPerformAnotherQuery;
cached.erase(it);
checkMemoryUsage();
}
if (matchStage) {
// Query for all keys that were in the frontier and not in the cache, populating
// '_frontier' for the next iteration of search.
// We've already allocated space for the trailing $match stage in '_fromPipeline'.
_fromPipeline.back() = *matchStage;
auto pipeline = uassertStatusOK(_mongod->makePipeline(_fromPipeline, _fromExpCtx));
while (auto next = pipeline->output()->getNext()) {
uassert(40271,
str::stream()
<< "Documents in the '"
<< _from.ns()
<< "' namespace must contain an _id for de-duplication in $graphLookup",
!(*next)["_id"].missing());
BSONObj result = next->toBson();
shouldPerformAnotherQuery =
addToVisitedAndFrontier(result.getOwned(), depth) || shouldPerformAnotherQuery;
addToCache(result, queried);
}
checkMemoryUsage();
}
++depth;
} while (shouldPerformAnotherQuery && depth < std::numeric_limits<long long>::max() &&
(!_maxDepth || depth <= *_maxDepth));
_frontier->clear();
_frontierUsageBytes = 0;
}
示例2: doBreadthFirstSearch
void DocumentSourceGraphLookUp::doBreadthFirstSearch() {
long long depth = 0;
bool shouldPerformAnotherQuery;
do {
shouldPerformAnotherQuery = false;
// Check whether each key in the frontier exists in the cache or needs to be queried.
BSONObjSet cached;
auto query = constructQuery(&cached);
std::unordered_set<Value, Value::Hash> queried;
_frontier.swap(queried);
_frontierUsageBytes = 0;
// Process cached values, populating '_frontier' for the next iteration of search.
while (!cached.empty()) {
auto it = cached.begin();
shouldPerformAnotherQuery =
addToVisitedAndFrontier(*it, depth) || shouldPerformAnotherQuery;
cached.erase(it);
checkMemoryUsage();
}
if (query) {
// Query for all keys that were in the frontier and not in the cache, populating
// '_frontier' for the next iteration of search.
unique_ptr<DBClientCursor> cursor = _mongod->directClient()->query(_from.ns(), *query);
// Iterate the cursor.
while (cursor->more()) {
BSONObj result = cursor->nextSafe();
shouldPerformAnotherQuery =
addToVisitedAndFrontier(result.getOwned(), depth) || shouldPerformAnotherQuery;
addToCache(result, queried);
}
checkMemoryUsage();
}
++depth;
} while (shouldPerformAnotherQuery && depth < std::numeric_limits<long long>::max() &&
(!_maxDepth || depth <= *_maxDepth));
_frontier.clear();
_frontierUsageBytes = 0;
}