当前位置: 首页>>代码示例>>C++>>正文


C++ IndexDescriptor::getOnDisk方法代码示例

本文整理汇总了C++中IndexDescriptor::getOnDisk方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexDescriptor::getOnDisk方法的具体用法?C++ IndexDescriptor::getOnDisk怎么用?C++ IndexDescriptor::getOnDisk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IndexDescriptor的用法示例。


在下文中一共展示了IndexDescriptor::getOnDisk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

 void run() {
     IndexDescriptor* id = addIndexWithInfo();
     // Create a SortPhaseOne.
     SortPhaseOne phaseOne;
     phaseOne.sorter.reset( new BSONObjExternalSorter(_aFirstSort));
     // Add index keys to the phaseOne.
     int32_t nKeys = 130;
     for( int32_t i = 0; i < nKeys; ++i ) {
         phaseOne.sorter->add( BSON( "a" << i ), /* dummy disk loc */ DiskLoc(), false );
     }
     phaseOne.nkeys = phaseOne.n = nKeys;
     phaseOne.sorter->sort( false );
     // Set up remaining arguments.
     set<DiskLoc> dups;
     CurOp* op = cc().curop();
     ProgressMeterHolder pm (op->setMessage("BuildBottomUp",
                                            "BuildBottomUp Progress",
                                            nKeys,
                                            nKeys));
     pm.finished();
     Timer timer;
     // The index's root has not yet been set.
     ASSERT( id->getHead().isNull() );
     // Finish building the index.
     buildBottomUpPhases2And3<V1>( true,
                                   id,
                                   *phaseOne.sorter,
                                   false,
                                   dups,
                                   op,
                                   &phaseOne,
                                   pm,
                                   timer,
                                   true );
     // The index's root is set after the build is complete.
     ASSERT( !id->getHead().isNull() );
     // Create a cursor over the index.
     scoped_ptr<BtreeCursor> cursor(
             BtreeCursor::make( nsdetails( _ns ),
                                id->getOnDisk(),
                                BSON( "" << -1 ),    // startKey below minimum key.
                                BSON( "" << nKeys ), // endKey above maximum key.
                                true,                // endKeyInclusive true.
                                1                    // direction forward.
                                ) );
     // Check that the keys in the index are the expected ones.
     int32_t expectedKey = 0;
     for( ; cursor->ok(); cursor->advance(), ++expectedKey ) {
         ASSERT_EQUALS( expectedKey, cursor->currKey().firstElement().number() );
     }
     ASSERT_EQUALS( nKeys, expectedKey );
 }
开发者ID:Albert-B-P,项目名称:mongo,代码行数:52,代码来源:indexupdatetests.cpp


注:本文中的IndexDescriptor::getOnDisk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。