コード例 #1
0
 void IndexCatalogEntry::setMultikey() {
     if ( isMultikey() )
         return;
     NamespaceDetails* nsd = _collection->detailsWritable();
     int idxNo = _indexNo();
     if ( nsd->setIndexIsMultikey( idxNo, true ) ) {
         LOG(1) << _collection->ns().ns() << ": clearing plan cache - index "
                << _descriptor->keyPattern() << " set to multi key.";
         _collection->infoCache()->clearQueryCache();
     }
     _isMultikey = true;
 }
コード例 #2
0
ファイル: namespacetests.cpp プロジェクト: vigneshncc/mongo
            void run() {
                create();
                NamespaceDetails *nsd = collection()->detailsWritable();

                DurTransaction txn;
                // Set 2 & 54 as multikey
                nsd->setIndexIsMultikey(&txn, 2, true);
                nsd->setIndexIsMultikey(&txn, 54, true);
                ASSERT(nsd->isMultikey(2));
                ASSERT(nsd->isMultikey(54));

                // Flip 2 & 47
                nsd->setIndexIsMultikey(&txn, 2, false);
                nsd->setIndexIsMultikey(&txn, 47, true);
                ASSERT(!nsd->isMultikey(2));
                ASSERT(nsd->isMultikey(47));

                // Reset entries that are already true
                nsd->setIndexIsMultikey(&txn, 54, true);
                nsd->setIndexIsMultikey(&txn, 47, true);
                ASSERT(nsd->isMultikey(54));
                ASSERT(nsd->isMultikey(47));

                // Two non-multi-key
                nsd->setIndexIsMultikey(&txn, 2, false);
                nsd->setIndexIsMultikey(&txn, 43, false);
                ASSERT(!nsd->isMultikey(2));
                ASSERT(nsd->isMultikey(54));
                ASSERT(nsd->isMultikey(47));
                ASSERT(!nsd->isMultikey(43));
            }
コード例 #3
0
ファイル: index.cpp プロジェクト: Ry4an/mongo
 void getIndexChanges(vector<IndexChanges>& v, NamespaceDetails& d, BSONObj newObj, BSONObj oldObj, bool &changedId) {
     int z = d.nIndexesBeingBuilt();
     v.resize(z);
     for( int i = 0; i < z; i++ ) {
         IndexDetails& idx = d.idx(i);
         BSONObj idxKey = idx.info.obj().getObjectField("key"); // eg { ts : 1 }
         IndexChanges& ch = v[i];
         idx.getKeysFromObject(oldObj, ch.oldkeys);
         idx.getKeysFromObject(newObj, ch.newkeys);
         if( ch.newkeys.size() > 1 )
             d.setIndexIsMultikey(i);
         setDifference(ch.oldkeys, ch.newkeys, ch.removed);
         setDifference(ch.newkeys, ch.oldkeys, ch.added);
         if ( ch.removed.size() > 0 && ch.added.size() > 0 && idx.isIdIndex() ) {
             changedId = true;
         }
     }
 }