Example #1
0
        void run() {

            NamespaceDetails* nsd = nsdetails( _ns );

            // _id_ is at 0, so nIndexes == 1
            IndexCatalog::IndexBuildBlock* a = halfAddIndex("a");
            IndexCatalog::IndexBuildBlock* b = halfAddIndex("b");
            IndexCatalog::IndexBuildBlock* c = halfAddIndex("c");
            IndexCatalog::IndexBuildBlock* d = halfAddIndex("d");
            int offset = nsd->_catalogFindIndexByName( "b_1", true );
            ASSERT_EQUALS(2, offset);

            delete b;

            ASSERT_EQUALS(2, nsd->_catalogFindIndexByName( "c_1", true ) );
            ASSERT_EQUALS(3, nsd->_catalogFindIndexByName( "d_1", true ) );

            offset = nsd->_catalogFindIndexByName( "d_1", true );
            delete d;

            ASSERT_EQUALS(2, nsd->_catalogFindIndexByName( "c_1", true ) );
            ASSERT( nsd->_catalogFindIndexByName( "d_1", true ) < 0 );

            offset = nsd->_catalogFindIndexByName( "a_1", true );
            delete a;

            ASSERT_EQUALS(1, nsd->_catalogFindIndexByName( "c_1", true ));
            delete c;
        }
Example #2
0
        void run() {
            // _id_ is at 0, so nIndexes == 1
            halfAddIndex("a");
            halfAddIndex("b");
            halfAddIndex("c");
            halfAddIndex("d");
            int offset = IndexBuildsInProgress::get(_ns, "b_1");
            ASSERT_EQUALS(2, offset);

            IndexBuildsInProgress::remove(_ns, offset);
            nsdetails(_ns)->indexBuildsInProgress--;

            ASSERT_EQUALS(2, IndexBuildsInProgress::get(_ns, "c_1"));
            ASSERT_EQUALS(3, IndexBuildsInProgress::get(_ns, "d_1"));

            offset = IndexBuildsInProgress::get(_ns, "d_1");
            IndexBuildsInProgress::remove(_ns, offset);
            nsdetails(_ns)->indexBuildsInProgress--;

            ASSERT_EQUALS(2, IndexBuildsInProgress::get(_ns, "c_1"));
            ASSERT_THROWS(IndexBuildsInProgress::get(_ns, "d_1"), MsgAssertionException);

            offset = IndexBuildsInProgress::get(_ns, "a_1");
            IndexBuildsInProgress::remove(_ns, offset);
            nsdetails(_ns)->indexBuildsInProgress--;

            ASSERT_EQUALS(1, IndexBuildsInProgress::get(_ns, "c_1"));
        }