本文整理汇总了C++中intrusive_ptr::getValueComparator方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::getValueComparator方法的具体用法?C++ intrusive_ptr::getValueComparator怎么用?C++ intrusive_ptr::getValueComparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::getValueComparator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DocumentSource
DocumentSourceSampleFromRandomCursor::DocumentSourceSampleFromRandomCursor(
const intrusive_ptr<ExpressionContext>& pExpCtx,
long long size,
std::string idField,
long long nDocsInCollection)
: DocumentSource(pExpCtx),
_size(size),
_idField(std::move(idField)),
_seenDocs(pExpCtx->getValueComparator().makeUnorderedValueSet()),
_nDocsInColl(nDocsInCollection) {}
示例2: vps
vector<intrusive_ptr<DocumentSource>> DocumentSourceBucket::createFromBson(
BSONElement elem, const intrusive_ptr<ExpressionContext>& pExpCtx) {
uassert(40201,
str::stream() << "Argument to $bucket stage must be an object, but found type: "
<< typeName(elem.type())
<< ".",
elem.type() == BSONType::Object);
const BSONObj bucketObj = elem.embeddedObject();
BSONObjBuilder groupObjBuilder;
BSONObjBuilder switchObjBuilder;
VariablesIdGenerator idGenerator;
VariablesParseState vps(&idGenerator);
vector<Value> boundaryValues;
BSONElement groupByField;
Value defaultValue;
bool outputFieldSpecified = false;
for (auto&& argument : bucketObj) {
const auto argName = argument.fieldNameStringData();
if ("groupBy" == argName) {
groupByField = argument;
const bool groupByIsExpressionInObject = groupByField.type() == BSONType::Object &&
groupByField.embeddedObject().firstElementFieldName()[0] == '$';
const bool groupByIsPrefixedPath =
groupByField.type() == BSONType::String && groupByField.valueStringData()[0] == '$';
uassert(40202,
str::stream() << "The $bucket 'groupBy' field must be defined as a $-prefixed "
"path or an expression, but found: "
<< groupByField.toString(false, false)
<< ".",
groupByIsExpressionInObject || groupByIsPrefixedPath);
} else if ("boundaries" == argName) {
uassert(
40200,
str::stream() << "The $bucket 'boundaries' field must be an array, but found type: "
<< typeName(argument.type())
<< ".",
argument.type() == BSONType::Array);
for (auto&& boundaryElem : argument.embeddedObject()) {
auto exprConst = getExpressionConstant(boundaryElem, vps);
uassert(40191,
str::stream() << "The $bucket 'boundaries' field must be an array of "
"constant values, but found value: "
<< boundaryElem.toString(false, false)
<< ".",
exprConst);
boundaryValues.push_back(exprConst->getValue());
}
uassert(40192,
str::stream()
<< "The $bucket 'boundaries' field must have at least 2 values, but found "
<< boundaryValues.size()
<< " value(s).",
boundaryValues.size() >= 2);
// Make sure that the boundaries are unique, sorted in ascending order, and have the
// same canonical type.
for (size_t i = 1; i < boundaryValues.size(); ++i) {
Value lower = boundaryValues[i - 1];
Value upper = boundaryValues[i];
int lowerCanonicalType = canonicalizeBSONType(lower.getType());
int upperCanonicalType = canonicalizeBSONType(upper.getType());
uassert(40193,
str::stream() << "All values in the the 'boundaries' option to $bucket "
"must have the same type. Found conflicting types "
<< typeName(lower.getType())
<< " and "
<< typeName(upper.getType())
<< ".",
lowerCanonicalType == upperCanonicalType);
uassert(40194,
str::stream()
<< "The 'boundaries' option to $bucket must be sorted, but elements "
<< i - 1
<< " and "
<< i
<< " are not in ascending order ("
<< lower.toString()
<< " is not less than "
<< upper.toString()
<< ").",
pExpCtx->getValueComparator().evaluate(lower < upper));
}
} else if ("default" == argName) {
// If there is a default, make sure that it parses to a constant expression then add
// default to switch.
auto exprConst = getExpressionConstant(argument, vps);
uassert(40195,
str::stream()
<< "The $bucket 'default' field must be a constant expression, but found: "
<< argument.toString(false, false)
<< ".",
//.........这里部分代码省略.........