本文整理汇总了C++中NamespaceDetails::indexKeys方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceDetails::indexKeys方法的具体用法?C++ NamespaceDetails::indexKeys怎么用?C++ NamespaceDetails::indexKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceDetails
的用法示例。
在下文中一共展示了NamespaceDetails::indexKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _updateObjects
UpdateResult _updateObjects( const char* ns,
const BSONObj& updateobj,
const BSONObj& patternOrig,
bool upsert,
bool multi,
bool logop ,
OpDebug& debug,
bool fromMigrate,
const QueryPlanSelectionPolicy& planPolicy ) {
TOKULOG(2) << "update: " << ns
<< " update: " << updateobj
<< " query: " << patternOrig
<< " upsert: " << upsert << " multi: " << multi << endl;
debug.updateobj = updateobj;
NamespaceDetails *d = getAndMaybeCreateNS(ns, logop);
auto_ptr<ModSet> mods;
const bool isOperatorUpdate = updateobj.firstElementFieldName()[0] == '$';
bool modsAreIndexed = false;
if ( isOperatorUpdate ) {
if ( d->indexBuildInProgress() ) {
set<string> bgKeys;
d->inProgIdx().keyPattern().getFieldNames(bgKeys);
mods.reset( new ModSet(updateobj, d->indexKeys(), &bgKeys) );
}
else {
mods.reset( new ModSet(updateobj, d->indexKeys()) );
}
modsAreIndexed = mods->isIndexed();
}
int idIdxNo = -1;
if ( planPolicy.permitOptimalIdPlan() && !multi && !modsAreIndexed &&
(idIdxNo = d->findIdIndex()) >= 0 && mayUpdateById(d, patternOrig) ) {
debug.idhack = true;
IndexDetails &idx = d->idx(idIdxNo);
BSONObj pk = idx.getKeyFromQuery(patternOrig);
TOKULOG(3) << "_updateObjects using simple _id query, pattern " << patternOrig << ", pk " << pk << endl;
UpdateResult result = _updateById( pk,
isOperatorUpdate,
mods.get(),
d,
ns,
updateobj,
patternOrig,
logop,
debug,
fromMigrate);
if ( result.existing || ! upsert ) {
return result;
}
else if ( upsert && ! isOperatorUpdate && ! logop) {
debug.upsert = true;
BSONObj objModified = updateobj;
insertAndLog( ns, d, objModified, logop, fromMigrate );
return UpdateResult( 0 , 0 , 1 , updateobj );
}
}
int numModded = 0;
debug.nscanned = 0;
shared_ptr<Cursor> c = getOptimizedCursor( ns, patternOrig, BSONObj(), planPolicy );
if( c->ok() ) {
set<BSONObj> seenObjects;
MatchDetails details;
auto_ptr<ClientCursor> cc;
do {
debug.nscanned++;
if ( mods.get() && mods->hasDynamicArray() ) {
// The Cursor must have a Matcher to record an elemMatchKey. But currently
// a modifier on a dynamic array field may be applied even if there is no
// elemMatchKey, so a matcher cannot be required.
//verify( c->matcher() );
details.requestElemMatchKey();
}
if ( !c->currentMatches( &details ) ) {
c->advance();
continue;
}
BSONObj currPK = c->currPK();
if ( c->getsetdup( currPK ) ) {
c->advance();
continue;
}
BSONObj currentObj = c->current();
BSONObj pattern = patternOrig;
if ( logop ) {
BSONObjBuilder idPattern;
//.........这里部分代码省略.........