Пример #1
0
 void BtreeBasedBuilder::addKeysToPhaseOne(NamespaceDetails* d, const char* ns,
                        const IndexDetails& idx,
                        const BSONObj& order,
                        SortPhaseOne* phaseOne,
                        int64_t nrecords,
                        ProgressMeter* progressMeter,
                        bool mayInterrupt, int idxNo) {
     shared_ptr<Cursor> cursor = theDataFileMgr.findAll( ns );
     phaseOne->sortCmp.reset(getComparison(idx.version(), idx.keyPattern()));
     phaseOne->sorter.reset(new BSONObjExternalSorter(phaseOne->sortCmp.get()));
     phaseOne->sorter->hintNumObjects( nrecords );
     auto_ptr<IndexDescriptor> desc(CatalogHack::getDescriptor(d, idxNo));
     auto_ptr<BtreeBasedAccessMethod> iam(CatalogHack::getBtreeBasedIndex(desc.get()));
     while ( cursor->ok() ) {
         RARELY killCurrentOp.checkForInterrupt( !mayInterrupt );
         BSONObj o = cursor->current();
         DiskLoc loc = cursor->currLoc();
         BSONObjSet keys;
         iam->getKeys(o, &keys);
         phaseOne->addKeys(keys, loc, mayInterrupt);
         cursor->advance();
         progressMeter->hit();
         if ( logLevel > 1 && phaseOne->n % 10000 == 0 ) {
             printMemInfo( "\t iterating objects" );
         }
     }
 }
    void BtreeBasedBuilder::addKeysToPhaseOne(Collection* collection,
                                              IndexDescriptor* idx,
                                              const BSONObj& order,
                                              SortPhaseOne* phaseOne,
                                              ProgressMeter* progressMeter,
                                              bool mayInterrupt ) {


        phaseOne->sortCmp.reset(getComparison(idx->version(), idx->keyPattern()));
        phaseOne->sorter.reset(new BSONObjExternalSorter(phaseOne->sortCmp.get()));
        phaseOne->sorter->hintNumObjects( collection->numRecords() );

        BtreeBasedAccessMethod* iam =collection->getIndexCatalog()->getBtreeBasedIndex( idx );

        auto_ptr<Runner> runner(InternalPlanner::collectionScan(collection->ns().ns()));
        BSONObj o;
        DiskLoc loc;
        Runner::RunnerState state;
        while (Runner::RUNNER_ADVANCED == (state = runner->getNext(&o, &loc))) {
            RARELY killCurrentOp.checkForInterrupt( !mayInterrupt );
            BSONObjSet keys;
            iam->getKeys(o, &keys);
            phaseOne->addKeys(keys, loc, mayInterrupt);
            progressMeter->hit();
            if (logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(2))
                && phaseOne->n % 10000 == 0 ) {
                printMemInfo( "\t iterating objects" );
            }
        }

        uassert(17050, "Internal error reading docs from collection", Runner::RUNNER_EOF == state);

    }
Пример #3
0
void InstSwitch::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  Type Ty = getComparison()->getType();
  Str << "switch " << Ty << " ";
  getSrc(0)->dump(Func);
  Str << ", label %" << getLabelDefault()->getName() << " [\n";
  for (SizeT I = 0; I < getNumCases(); ++I) {
    Str << "    " << Ty << " " << getValue(I) << ", label %"
        << getLabel(I)->getName() << "\n";
  }
  Str << "  ]";
}
Пример #4
0
    IndexAccessMethod* BtreeBasedAccessMethod::initiateBulk() {

        if ( _interface->nKeys( _btreeState,
                                _btreeState->head() ) > 0 )
            return NULL;

        auto_ptr<BtreeBulk> bulk( new BtreeBulk( this ) );
        bulk->_phase1.sortCmp.reset( getComparison( _descriptor->version(),
                                                    _descriptor->keyPattern() ) );

        bulk->_phase1.sorter.reset( new BSONObjExternalSorter(bulk->_phase1.sortCmp.get()) );
        bulk->_phase1.sorter->hintNumObjects( _btreeState->collection()->numRecords() );

        return bulk.release();
    }
    BtreeBasedBulkAccessMethod::BtreeBasedBulkAccessMethod(TransactionExperiment* txn,
                                                           BtreeBasedAccessMethod* real,
                                                           BtreeInterface* interface,
                                                           const IndexDescriptor* descriptor,
                                                           int numRecords) {
        _real = real;
        _interface = interface;
        _txn = txn;

        _docsInserted = 0;
        _keysInserted = 0;
        _isMultiKey = false;

        _sortCmp.reset(getComparison(descriptor->version(), descriptor->keyPattern()));
        _sorter.reset(new BSONObjExternalSorter(_sortCmp.get()));
        _sorter->hintNumObjects(numRecords);
    }