本文整理汇总了C++中intrusive_ptr::getCollator方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::getCollator方法的具体用法?C++ intrusive_ptr::getCollator怎么用?C++ intrusive_ptr::getCollator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::getCollator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uassert
list<intrusive_ptr<DocumentSource>> DocumentSourceChangeStream::createFromBson(
BSONElement elem, const intrusive_ptr<ExpressionContext>& expCtx) {
// TODO: Add sharding support here (SERVER-29141).
uassert(
40470, "The $changeStream stage is not supported on sharded systems.", !expCtx->inRouter);
uassert(40471,
"Only default collation is allowed when using a $changeStream stage.",
!expCtx->getCollator());
auto replCoord = repl::ReplicationCoordinator::get(expCtx->opCtx);
uassert(40573, "The $changeStream stage is only supported on replica sets", replCoord);
Timestamp startFrom = replCoord->getLastCommittedOpTime().getTimestamp();
intrusive_ptr<DocumentSourceCheckResumeToken> resumeStage = nullptr;
auto spec = DocumentSourceChangeStreamSpec::parse(IDLParserErrorContext("$changeStream"),
elem.embeddedObject());
if (auto resumeAfter = spec.getResumeAfter()) {
ResumeToken token = resumeAfter.get();
startFrom = token.getTimestamp();
DocumentSourceCheckResumeTokenSpec spec;
spec.setResumeToken(std::move(token));
resumeStage = DocumentSourceCheckResumeToken::create(expCtx, std::move(spec));
}
const bool changeStreamIsResuming = resumeStage != nullptr;
auto fullDocOption = spec.getFullDocument();
uassert(40575,
str::stream() << "unrecognized value for the 'fullDocument' option to the "
"$changeStream stage. Expected \"default\" or "
"\"updateLookup\", got \""
<< fullDocOption
<< "\"",
fullDocOption == "updateLookup"_sd || fullDocOption == "default"_sd);
const bool shouldLookupPostImage = (fullDocOption == "updateLookup"_sd);
auto oplogMatch = DocumentSourceOplogMatch::create(
buildMatchFilter(expCtx->ns, startFrom, changeStreamIsResuming), expCtx);
auto transformation = createTransformationStage(elem.embeddedObject(), expCtx);
list<intrusive_ptr<DocumentSource>> stages = {oplogMatch, transformation};
if (resumeStage) {
stages.push_back(resumeStage);
}
auto closeCursorSource = DocumentSourceCloseCursor::create(expCtx);
stages.push_back(closeCursorSource);
if (shouldLookupPostImage) {
stages.push_back(DocumentSourceLookupChangePostImage::create(expCtx));
}
return stages;
}
示例2: uassert
list<intrusive_ptr<DocumentSource>> DocumentSourceChangeStream::createFromBson(
BSONElement elem, const intrusive_ptr<ExpressionContext>& expCtx) {
// TODO: Add sharding support here (SERVER-29141).
uassert(
40470, "The $changeStream stage is not supported on sharded systems.", !expCtx->inMongos);
uassert(40471,
"Only default collation is allowed when using a $changeStream stage.",
!expCtx->getCollator());
auto replCoord = repl::ReplicationCoordinator::get(expCtx->opCtx);
uassert(40573,
"The $changeStream stage is only supported on replica sets",
replCoord &&
replCoord->getReplicationMode() == repl::ReplicationCoordinator::Mode::modeReplSet);
Timestamp startFrom = replCoord->getMyLastAppliedOpTime().getTimestamp();
intrusive_ptr<DocumentSource> resumeStage = nullptr;
auto spec = DocumentSourceChangeStreamSpec::parse(IDLParserErrorContext("$changeStream"),
elem.embeddedObject());
if (auto resumeAfter = spec.getResumeAfter()) {
ResumeToken token = resumeAfter.get();
auto resumeNamespace = UUIDCatalog::get(expCtx->opCtx).lookupNSSByUUID(token.getUuid());
uassert(40615,
"The resume token UUID does not exist. Has the collection been dropped?",
!resumeNamespace.isEmpty());
startFrom = token.getTimestamp();
if (expCtx->needsMerge) {
DocumentSourceShardCheckResumabilitySpec spec;
spec.setResumeToken(std::move(token));
resumeStage = DocumentSourceShardCheckResumability::create(expCtx, std::move(spec));
} else {
DocumentSourceEnsureResumeTokenPresentSpec spec;
spec.setResumeToken(std::move(token));
resumeStage = DocumentSourceEnsureResumeTokenPresent::create(expCtx, std::move(spec));
}
}
const bool changeStreamIsResuming = resumeStage != nullptr;
auto fullDocOption = spec.getFullDocument();
uassert(40575,
str::stream() << "unrecognized value for the 'fullDocument' option to the "
"$changeStream stage. Expected \"default\" or "
"\"updateLookup\", got \""
<< fullDocOption
<< "\"",
fullDocOption == "updateLookup"_sd || fullDocOption == "default"_sd);
const bool shouldLookupPostImage = (fullDocOption == "updateLookup"_sd);
auto oplogMatch = DocumentSourceOplogMatch::create(
buildMatchFilter(expCtx->ns, startFrom, changeStreamIsResuming), expCtx);
auto transformation = createTransformationStage(elem.embeddedObject(), expCtx);
list<intrusive_ptr<DocumentSource>> stages = {oplogMatch, transformation};
if (resumeStage) {
stages.push_back(resumeStage);
}
auto closeCursorSource = DocumentSourceCloseCursor::create(expCtx);
stages.push_back(closeCursorSource);
if (shouldLookupPostImage) {
stages.push_back(DocumentSourceLookupChangePostImage::create(expCtx));
}
return stages;
}
示例3: pSort
intrusive_ptr<DocumentSourceSort> DocumentSourceSort::create(
const intrusive_ptr<ExpressionContext>& pExpCtx,
BSONObj sortOrder,
long long limit,
boost::optional<uint64_t> maxMemoryUsageBytes) {
intrusive_ptr<DocumentSourceSort> pSort(new DocumentSourceSort(pExpCtx));
pSort->_maxMemoryUsageBytes = maxMemoryUsageBytes
? *maxMemoryUsageBytes
: internalDocumentSourceSortMaxBlockingSortBytes.load();
pSort->_rawSort = sortOrder.getOwned();
for (auto&& keyField : sortOrder) {
auto fieldName = keyField.fieldNameStringData();
SortPatternPart patternPart;
if (keyField.type() == Object) {
BSONObj metaDoc = keyField.Obj();
// this restriction is due to needing to figure out sort direction
uassert(17312,
"$meta is the only expression supported by $sort right now",
metaDoc.firstElement().fieldNameStringData() == "$meta");
uassert(ErrorCodes::FailedToParse,
"Cannot have additional keys in a $meta sort specification",
metaDoc.nFields() == 1);
VariablesParseState vps = pExpCtx->variablesParseState;
patternPart.expression = ExpressionMeta::parse(pExpCtx, metaDoc.firstElement(), vps);
// If sorting by textScore, sort highest scores first. If sorting by randVal, order
// doesn't matter, so just always use descending.
patternPart.isAscending = false;
pSort->_sortPattern.push_back(std::move(patternPart));
continue;
}
uassert(15974,
"$sort key ordering must be specified using a number or {$meta: 'textScore'}",
keyField.isNumber());
int sortOrder = keyField.numberInt();
uassert(15975,
"$sort key ordering must be 1 (for ascending) or -1 (for descending)",
((sortOrder == 1) || (sortOrder == -1)));
patternPart.fieldPath = FieldPath{fieldName};
patternPart.isAscending = (sortOrder > 0);
pSort->_paths.insert(patternPart.fieldPath->fullPath());
pSort->_sortPattern.push_back(std::move(patternPart));
}
uassert(15976, "$sort stage must have at least one sort key", !pSort->_sortPattern.empty());
pSort->_sortKeyGen = SortKeyGenerator{
// The SortKeyGenerator expects the expressions to be serialized in order to detect a sort
// by a metadata field.
pSort->sortKeyPattern(SortKeySerialization::kForPipelineSerialization).toBson(),
pExpCtx->getCollator()};
if (limit > 0) {
pSort->setLimitSrc(DocumentSourceLimit::create(pExpCtx, limit));
}
return pSort;
}