本文整理汇总了C++中NamespaceString::getCommandNS方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceString::getCommandNS方法的具体用法?C++ NamespaceString::getCommandNS怎么用?C++ NamespaceString::getCommandNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceString
的用法示例。
在下文中一共展示了NamespaceString::getCommandNS方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildMatchFilter
BSONObj DocumentSourceChangeStream::buildMatchFilter(const NamespaceString& nss,
Timestamp startFrom,
bool isResume) {
auto target = nss.ns();
// 1) Supported commands that have the target db namespace (e.g. test.$cmd) in "ns" field.
auto dropDatabase = BSON("o.dropDatabase" << 1);
auto dropCollection = BSON("o.drop" << nss.coll());
auto renameCollection = BSON("o.renameCollection" << target);
// Commands that are on target db and one of the above.
auto commandsOnTargetDb =
BSON("ns" << nss.getCommandNS().ns() << "$or"
<< BSON_ARRAY(dropDatabase << dropCollection << renameCollection));
// 2) Supported commands that have arbitrary db namespaces in "ns" field.
auto renameDropTarget = BSON("o.to" << target);
// 3) All supported commands that are either (1) or (2).
auto commandMatch = BSON("op"
<< "c"
<< "$or"
<< BSON_ARRAY(commandsOnTargetDb << renameDropTarget));
// 4) Normal CRUD ops on the target collection.
auto opMatch = BSON("ns" << target);
// Match oplog entries after "start" and are either (3) supported commands or (4) CRUD ops,
// excepting those tagged "fromMigrate".
// Include the resume token, if resuming, so we can verify it was still present in the oplog.
return BSON("$and" << BSON_ARRAY(BSON("ts" << (isResume ? GTE : GT) << startFrom)
<< BSON("$or" << BSON_ARRAY(opMatch << commandMatch))
<< BSON("fromMigrate" << NE << true)));
}
示例2: makeCreateCollectionOplogEntry
/**
* Creates a create collection oplog entry with given optime.
*/
OplogEntry makeCreateCollectionOplogEntry(OpTime opTime,
const NamespaceString& nss = NamespaceString("test.t")) {
BSONObjBuilder bob;
bob.appendElements(opTime.toBSON());
bob.append("h", 1LL);
bob.append("op", "c");
bob.append("ns", nss.getCommandNS());
bob.append("o", BSON("create" << nss.coll()));
return OplogEntry(bob.obj());
}
示例3: buildMatchFilter
BSONObj DocumentSourceChangeStream::buildMatchFilter(const NamespaceString& nss,
Timestamp startFrom,
bool isResume) {
auto target = nss.ns();
// 1) Supported commands that have the target db namespace (e.g. test.$cmd) in "ns" field.
auto dropDatabase = BSON("o.dropDatabase" << 1);
auto dropCollection = BSON("o.drop" << nss.coll());
auto renameCollection = BSON("o.renameCollection" << target);
// 1.1) Commands that are on target db and one of the above.
auto commandsOnTargetDb =
BSON("ns" << nss.getCommandNS().ns() << OR(dropDatabase, dropCollection, renameCollection));
// 1.2) Supported commands that have arbitrary db namespaces in "ns" field.
auto renameDropTarget = BSON("o.to" << target);
// All supported commands that are either (1.1) or (1.2).
BSONObj commandMatch = BSON("op"
<< "c"
<< OR(commandsOnTargetDb, renameDropTarget));
// 2.1) Normal CRUD ops on the target collection.
auto normalOpTypeMatch = BSON("op" << NE << "n");
// 2.2) A chunk gets migrated to a new shard that doesn't have any chunks.
auto chunkMigratedMatch = BSON("op"
<< "n"
<< "o2.type"
<< "migrateChunkToNewShard");
// 2) Supported operations on the target namespace.
auto opMatch = BSON("ns" << target << OR(normalOpTypeMatch, chunkMigratedMatch));
// Match oplog entries after "start" and are either supported (1) commands or (2) operations,
// excepting those tagged "fromMigrate".
// Include the resume token, if resuming, so we can verify it was still present in the oplog.
return BSON("$and" << BSON_ARRAY(BSON("ts" << (isResume ? GTE : GT) << startFrom)
<< BSON(OR(opMatch, commandMatch))
<< BSON("fromMigrate" << NE << true)));
}