本文整理汇总了C++中NamespaceDetails::setUserFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceDetails::setUserFlag方法的具体用法?C++ NamespaceDetails::setUserFlag怎么用?C++ NamespaceDetails::setUserFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceDetails
的用法示例。
在下文中一共展示了NamespaceDetails::setUserFlag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: postBuildHook
// static
void IndexLegacy::postBuildHook(Collection* collection, const BSONObj& keyPattern) {
// If it's an FTS index, we want to set the power of 2 flag.
string pluginName = collection->getIndexCatalog()->getAccessMethodName(keyPattern);
if (IndexNames::TEXT == pluginName) {
NamespaceDetails* nsd = collection->details();
if (nsd->setUserFlag(NamespaceDetails::Flag_UsePowerOf2Sizes)) {
nsd->syncUserFlags(collection->ns().ns());
}
}
}
示例2: doTTLForDB
void doTTLForDB( const string& dbName ) {
//check isMaster before becoming god
bool isMaster = isMasterNs( dbName.c_str() );
Client::GodScope god;
vector<BSONObj> indexes;
{
auto_ptr<DBClientCursor> cursor =
db.query( dbName + ".system.indexes" ,
BSON( secondsExpireField << BSON( "$exists" << true ) ) ,
0 , /* default nToReturn */
0 , /* default nToSkip */
0 , /* default fieldsToReturn */
QueryOption_SlaveOk ); /* perform on secondaries too */
if ( cursor.get() ) {
while ( cursor->more() ) {
indexes.push_back( cursor->next().getOwned() );
}
}
}
for ( unsigned i=0; i<indexes.size(); i++ ) {
BSONObj idx = indexes[i];
BSONObj key = idx["key"].Obj();
if ( key.nFields() != 1 ) {
error() << "key for ttl index can only have 1 field" << endl;
continue;
}
BSONObj query;
{
BSONObjBuilder b;
b.appendDate( "$lt" , curTimeMillis64() - ( 1000 * idx[secondsExpireField].numberLong() ) );
query = BSON( key.firstElement().fieldName() << b.obj() );
}
LOG(1) << "TTL: " << key << " \t " << query << endl;
long long n = 0;
{
string ns = idx["ns"].String();
Client::WriteContext ctx( ns );
NamespaceDetails* nsd = nsdetails( ns );
if ( ! nsd ) {
// collection was dropped
continue;
}
if ( nsd->setUserFlag( NamespaceDetails::Flag_UsePowerOf2Sizes ) ) {
nsd->syncUserFlags( ns );
}
// only do deletes if on master
if ( ! isMaster ) {
continue;
}
n = deleteObjects( ns.c_str() , query , false , true );
ttlDeletedDocuments.increment( n );
}
LOG(1) << "\tTTL deleted: " << n << endl;
}
}