Example #1
0
 void run() {
     // It's necessary to index sufficient keys that a RARELY condition will be triggered.
     int32_t nDocs = 130;
     // Add some data to the collection.
     for( int32_t i = 0; i < nDocs; ++i ) {
         _client.insert( _ns, BSON( "a" << i ) );
     }
     IndexDetails& id = addIndexWithInfo();
     // Create a SortPhaseOne.
     SortPhaseOne phaseOne;
     ProgressMeterHolder pm (cc().curop()->setMessage("InterruptAddKeysToPhaseOne",
                                                      "InterruptAddKeysToPhaseOne Progress",
                                                      nDocs,
                                                      nDocs));
     // Register a request to kill the current operation.
     cc().curop()->kill();
     if ( _mayInterrupt ) {
         // Add keys to phaseOne.
         ASSERT_THROWS( BtreeBasedBuilder::addKeysToPhaseOne( nsdetails(_ns), _ns,
                                           id,
                                           BSON( "a" << 1 ),
                                           &phaseOne,
                                           nDocs,
                                           pm.get(),
                                           _mayInterrupt,
                                           nsdetails(_ns)->idxNo(id) ),
                        UserException );
         // Not all keys were added to phaseOne due to the interrupt.
         ASSERT( static_cast<uint64_t>( nDocs ) > phaseOne.n );
     }
     else {
         // Add keys to phaseOne.
         BtreeBasedBuilder::addKeysToPhaseOne( nsdetails(_ns), _ns,
                            id,
                            BSON( "a" << 1 ),
                            &phaseOne,
                            nDocs,
                            pm.get(),
                            _mayInterrupt, nsdetails(_ns)->idxNo(id) );
         // All keys were added to phaseOne despite to the kill request, because
         // mayInterrupt == false.
         ASSERT_EQUALS( static_cast<uint64_t>( nDocs ), phaseOne.n );
     }
 }
Example #2
0
        void run() {
            // Add some data to the collection.
            int32_t nDocs = 130;
            for( int32_t i = 0; i < nDocs; ++i ) {
                _client.insert( _ns, BSON( "a" << i ) );
            }

            IndexDescriptor* id = addIndexWithInfo();
            // Create a SortPhaseOne.
            SortPhaseOne phaseOne;
            ProgressMeterHolder pm (cc().curop()->setMessage("AddKeysToPhaseOne",
                                                             "AddKeysToPhaseOne Progress",
                                                             nDocs,
                                                             nDocs));
            // Add keys to phaseOne.
            BtreeBasedBuilder::addKeysToPhaseOne( collection(),
                                                  id,
                                                  BSON( "a" << 1 ),
                                                  &phaseOne,
                                                  pm.get(), true );
            // Keys for all documents were added to phaseOne.
            ASSERT_EQUALS( static_cast<uint64_t>( nDocs ), phaseOne.n );
        }