本文整理汇总了C++中NamespaceDetails::replaceUserFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceDetails::replaceUserFlags方法的具体用法?C++ NamespaceDetails::replaceUserFlags怎么用?C++ NamespaceDetails::replaceUserFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceDetails
的用法示例。
在下文中一共展示了NamespaceDetails::replaceUserFlags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _userCreateNS
//.........这里部分代码省略.........
uassert( 10083 , "create collection invalid size spec", size >= 0 );
size += 0xff;
size &= 0xffffffffffffff00LL;
if ( size < Extent::minSize() )
size = Extent::minSize();
}
}
bool newCapped = false;
long long mx = 0;
if( options["capped"].trueValue() ) {
newCapped = true;
BSONElement e = options.getField("max");
if ( e.isNumber() ) {
mx = e.numberLong();
uassert( 16495,
"max in a capped collection has to be < 2^31 or not set",
NamespaceDetails::validMaxCappedDocs(&mx) );
}
}
cc().database()->createCollection( ns, options["capped"].trueValue(), &options );
Collection* collection = cc().database()->getCollection( ns );
verify( collection );
// $nExtents just for debug/testing.
BSONElement e = options.getField( "$nExtents" );
if ( e.type() == Array ) {
// We create one extent per array entry, with size specified
// by the array value.
BSONObjIterator i( e.embeddedObject() );
while( i.more() ) {
BSONElement e = i.next();
int size = int( e.number() );
verify( size <= 0x7fffffff );
// $nExtents is just for testing - always allocate new extents
// rather than reuse existing extents so we have some predictibility
// in the extent size used by our tests
collection->increaseStorageSize( (int)size, false );
}
}
else if ( int( e.number() ) > 0 ) {
// We create '$nExtents' extents, each of size 'size'.
int nExtents = int( e.number() );
verify( size <= 0x7fffffff );
for ( int i = 0; i < nExtents; ++i ) {
verify( size <= 0x7fffffff );
// $nExtents is just for testing - always allocate new extents
// rather than reuse existing extents so we have some predictibility
// in the extent size used by our tests
collection->increaseStorageSize( (int)size, false );
}
}
else {
// This is the non test case, where we don't have a $nExtents spec.
while ( size > 0 ) {
const int max = Extent::maxSize();
const int min = Extent::minSize();
int desiredExtentSize = static_cast<int> (size > max ? max : size);
desiredExtentSize = static_cast<int> (desiredExtentSize < min ? min : desiredExtentSize);
desiredExtentSize &= 0xffffff00;
Extent* e = collection->increaseStorageSize( (int)desiredExtentSize, true );
size -= e->length;
}
}
NamespaceDetails *d = nsdetails(ns);
verify(d);
bool ensure = true;
// respect autoIndexId if set. otherwise, create an _id index for all colls, except for
// capped ones in local w/o autoIndexID (reason for the exception is for the oplog and
// non-replicated capped colls)
if( options.hasField( "autoIndexId" ) ||
(newCapped && nsToDatabase( ns ) == "local" ) ) {
ensure = options.getField( "autoIndexId" ).trueValue();
}
if( ensure ) {
if( deferIdIndex )
*deferIdIndex = true;
else
ensureIdIndexForNewNs( ns );
}
if ( mx > 0 )
d->setMaxCappedDocs( mx );
if ( options["flags"].numberInt() ) {
d->replaceUserFlags( options["flags"].numberInt() );
}
return true;
}