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


C++ DiskLoc::rec方法代码示例

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


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

示例1: prevExtentFirstLoc

 DiskLoc FindingStartCursor::prevExtentFirstLoc( const DiskLoc& rec ) const {
     Extent *e = rec.rec()->myExtent( rec );
     if ( _qp.nsd()->capLooped() ) {
         while( true ) {
             // Advance e to preceding extent (looping to lastExtent if necessary).
             if ( e->xprev.isNull() ) {
                 e = _qp.nsd()->lastExtent.ext();
             }
             else {
                 e = e->xprev.ext();
             }
             if ( e->myLoc == _qp.nsd()->capExtent ) {
                 // Reached the extent containing the oldest data in the collection.
                 return DiskLoc();
             }
             if ( !e->firstRecord.isNull() ) {
                 // Return the first record of the first non empty extent encountered.
                 return e->firstRecord;
             }
         }
     }
     else {
         while( true ) {
             if ( e->xprev.isNull() ) {
                 // Reached the beginning of the collection.
                 return DiskLoc();
             }
             e = e->xprev.ext();
             if ( !e->firstRecord.isNull() ) {
                 // Return the first record of the first non empty extent encountered.
                 return e->firstRecord;
             }
         }
     }
 }
开发者ID:liubinhit,项目名称:mongo,代码行数:35,代码来源:oplog.cpp

示例2: filterAndScore

    void TextStage::filterAndScore(BSONObj key, DiskLoc loc) {
        // Locate score within possibly compound key: {prefix,term,score,suffix}.
        BSONObjIterator keyIt(key);
        for (unsigned i = 0; i < _params.spec.numExtraBefore(); i++) {
            keyIt.next();
        }

        keyIt.next(); // Skip past 'term'.

        BSONElement scoreElement = keyIt.next();
        double documentTermScore = scoreElement.number();
        double& documentAggregateScore = _scores[loc];
        
        // Handle filtering.
        if (documentAggregateScore < 0) {
            // We have already rejected this document.
            return;
        }
        if (documentAggregateScore == 0 && _filter) {
            // We have not seen this document before and need to apply a filter.
            Record* rec_p = loc.rec();
            BSONObj doc = BSONObj::make(rec_p);

            // TODO: Covered index matching logic here.
            if (!_filter->matchesBSON(doc)) {
                documentAggregateScore = -1;
                return;
            }
        }

        // Aggregate relevance score, term keys.
        documentAggregateScore += documentTermScore;
    }
开发者ID:Convey-Compliance,项目名称:mongo,代码行数:33,代码来源:text.cpp

示例3: _repairExtent

    DiskLoc _repairExtent( Database* db , string ns, bool forward , DiskLoc eLoc ){
        LogIndentLevel lil;
        
        if ( eLoc.getOfs() <= 0 ){
            error() << "invalid extent ofs: " << eLoc.getOfs() << endl;
            return DiskLoc();
        }
        

        MongoDataFile * mdf = db->getFile( eLoc.a() );

        Extent * e = mdf->debug_getExtent( eLoc );
        if ( ! e->isOk() ){
            warning() << "Extent not ok magic: " << e->magic << " going to try to continue" << endl;
        }
        
        log() << "length:" << e->length << endl;
        
        LogIndentLevel lil2;
        
        DiskLoc loc = forward ? e->firstRecord : e->lastRecord;
        while ( ! loc.isNull() ){
            if ( loc.getOfs() <= 0 ){
                error() << "offset is 0 for record which should be impossible" << endl;
                break;
            }
            log() << loc << endl;
            Record* rec = loc.rec();
            log() << loc.obj() << endl;
            loc = forward ? rec->getNext( loc ) : rec->getPrev( loc );
        }
        return forward ? e->xnext : e->xprev;
        
    }
开发者ID:BendustiK,项目名称:mongo,代码行数:34,代码来源:dump.cpp

示例4: prevExtentFirstLoc

 // static
 DiskLoc OplogStart::prevExtentFirstLoc(const NamespaceDetails* nsd, const DiskLoc& rec ) {
     Extent *e = rec.rec()->myExtentLoc( rec ).ext();
     if (nsd->capLooped() ) {
         while( true ) {
             // Advance e to preceding extent (looping to lastExtent if necessary).
             if ( e->xprev.isNull() ) {
                 e = nsd->lastExtent().ext();
             }
             else {
                 e = e->xprev.ext();
             }
             if ( e->myLoc == nsd->capExtent() ) {
                 // Reached the extent containing the oldest data in the collection.
                 return DiskLoc();
             }
             if ( !e->firstRecord.isNull() ) {
                 // Return the first record of the first non empty extent encountered.
                 return e->firstRecord;
             }
         }
     }
     else {
         while( true ) {
             if ( e->xprev.isNull() ) {
                 // Reached the beginning of the collection.
                 return DiskLoc();
             }
             e = e->xprev.ext();
             if ( !e->firstRecord.isNull() ) {
                 // Return the first record of the first non empty extent encountered.
                 return e->firstRecord;
             }
         }
     }
 }
开发者ID:AshishThakur,项目名称:mongo,代码行数:36,代码来源:oplogstart.cpp

示例5: deleteRecord

    void DataFileMgr::deleteRecord(NamespaceDetails* d, const StringData& ns, Record *todelete,
                                   const DiskLoc& dl, bool cappedOK, bool noWarn, bool doLog ) {
        dassert( todelete == dl.rec() );

        if ( d->isCapped() && !cappedOK ) {
            out() << "failing remove on a capped ns " << ns << endl;
            uassert( 10089 ,  "can't remove from a capped collection" , 0 );
            return;
        }

        BSONObj obj = BSONObj::make( todelete );

        Collection* collection = cc().database()->getCollection( ns );
        verify( collection );

        BSONObj toDelete;
        collection->deleteDocument( dl, cappedOK, noWarn, doLog ? &toDelete : NULL );

        if ( ! toDelete.isEmpty() ) {
            // TODO: this is crazy, need to fix logOp
            const char* raw = ns.rawData();
            if ( strlen(raw) == ns.size() ) {
                logOp( "d", raw, toDelete );
            }
            else {
                string temp = ns.toString();
                logOp( "d", temp.c_str(), toDelete );
            }
        }
    }
开发者ID:andeshc,项目名称:mongo,代码行数:30,代码来源:pdfile.cpp

示例6: _recordForYield

    Record* ClientCursor::_recordForYield( ClientCursor::RecordNeeds need ) {
        
        if ( ! ok() )
            return 0;

        if ( need == DontNeed ) {
            return 0;
        }
        else if ( need == MaybeCovered ) {
            // TODO
            return 0;
        }
        else if ( need == WillNeed ) {
            // no-op
        }
        else {
            warning() << "don't understand RecordNeeds: " << (int)need << endl;
            return 0;
        }

        DiskLoc l = currLoc();
        if ( l.isNull() )
            return 0;
        
        Record * rec = l.rec();
        if ( rec->likelyInPhysicalMemory() ) 
            return 0;
        
        return rec;
    }
开发者ID:89snake89,项目名称:mongo,代码行数:30,代码来源:clientcursor.cpp

示例7: insertWithObjMod

 /** @param o the object to insert. can be modified to add _id and thus be an in/out param
  */
 DiskLoc DataFileMgr::insertWithObjMod(const char* ns, BSONObj& o, bool mayInterrupt, bool god) {
     bool addedID = false;
     DiskLoc loc = insert( ns, o.objdata(), o.objsize(), mayInterrupt, god, true, &addedID );
     if( addedID && !loc.isNull() )
         o = BSONObj::make( loc.rec() );
     return loc;
 }
开发者ID:ChrisKozak,项目名称:mongo,代码行数:9,代码来源:pdfile.cpp

示例8: removeRange

    long long Helpers::removeRange( const string& ns , const BSONObj& min , const BSONObj& max , bool yield , bool maxInclusive , RemoveCallback * callback, bool fromMigrate ) {
        BSONObj keya , keyb;
        BSONObj minClean = toKeyFormat( min , keya );
        BSONObj maxClean = toKeyFormat( max , keyb );
        verify( keya == keyb );

        Client::Context ctx(ns);

        shared_ptr<Cursor> c;
        auto_ptr<ClientCursor> cc;
        {
            NamespaceDetails* nsd = nsdetails( ns.c_str() );
            if ( ! nsd )
                return 0;
            
            int ii = nsd->findIndexByKeyPattern( keya );
            verify( ii >= 0 );
            
            IndexDetails& i = nsd->idx( ii );
            
            c.reset( BtreeCursor::make( nsd , ii , i , minClean , maxClean , maxInclusive, 1 ) );
            cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , c , ns ) );
            cc->setDoingDeletes( true );
        }

        long long num = 0;

        while ( cc->ok() ) {

            if ( yield && ! cc->yieldSometimes( ClientCursor::WillNeed) ) {
                // cursor got finished by someone else, so we're done
                cc.release(); // if the collection/db is dropped, cc may be deleted
                break;
            }

            if ( ! cc->ok() )
                break;

            DiskLoc rloc = cc->currLoc();

            if ( callback )
                callback->goingToDelete( cc->current() );

            cc->advance();
            c->prepareToTouchEarlierIterate();

            logOp( "d" , ns.c_str() , rloc.obj()["_id"].wrap() , 0 , 0 , fromMigrate );
            theDataFileMgr.deleteRecord(ns.c_str() , rloc.rec(), rloc);
            num++;

            c->recoverFromTouchingEarlierIterate();

            getDur().commitIfNeeded();


        }

        return num;
    }
开发者ID:Desartstudio,项目名称:mongo-nonx86,代码行数:59,代码来源:dbhelpers.cpp

示例9: extentFirstLoc

 DiskLoc FindingStartCursor::extentFirstLoc( const DiskLoc &rec ) {
     Extent *e = rec.rec()->myExtent( rec );
     if ( !_qp.nsd()->capLooped() || ( e->myLoc != _qp.nsd()->capExtent ) )
         return e->firstRecord;
     // Likely we are on the fresh side of capExtent, so return first fresh record.
     // If we are on the stale side of capExtent, then the collection is small and it
     // doesn't matter if we start the extent scan with capFirstNewRecord.
     return _qp.nsd()->capFirstNewRecord;
 }
开发者ID:Eisforinnovate,项目名称:mongo,代码行数:9,代码来源:oplog.cpp

示例10: addRecordToRecListInExtent

 /** add a record to the end of the linked list chain within this extent. 
     require: you must have already declared write intent for the record header.        
 */
 void addRecordToRecListInExtent(Record *r, DiskLoc loc) {
     dassert( loc.rec() == r );
     Extent *e = r->myExtent(loc);
     if ( e->lastRecord.isNull() ) {
         Extent::FL *fl = getDur().writing(e->fl());
         fl->firstRecord = fl->lastRecord = loc;
         r->prevOfs() = r->nextOfs() = DiskLoc::NullOfs;
     }
     else {
         Record *oldlast = e->lastRecord.rec();
         r->prevOfs() = e->lastRecord.getOfs();
         r->nextOfs() = DiskLoc::NullOfs;
         getDur().writingInt(oldlast->nextOfs()) = loc.getOfs();
         getDur().writingDiskLoc(e->lastRecord) = loc;
     }
 }
开发者ID:ChrisKozak,项目名称:mongo,代码行数:19,代码来源:pdfile.cpp

示例11: removeRange

    long long Helpers::removeRange( const string& ns , const BSONObj& min , const BSONObj& max , bool yield , bool maxInclusive , RemoveCallback * callback ) {
        BSONObj keya , keyb;
        BSONObj minClean = toKeyFormat( min , keya );
        BSONObj maxClean = toKeyFormat( max , keyb );
        assert( keya == keyb );

        Client::Context ctx(ns);
        NamespaceDetails* nsd = nsdetails( ns.c_str() );
        if ( ! nsd )
            return 0;

        int ii = nsd->findIndexByKeyPattern( keya );
        assert( ii >= 0 );

        long long num = 0;

        IndexDetails& i = nsd->idx( ii );

        shared_ptr<Cursor> c( new BtreeCursor( nsd , ii , i , minClean , maxClean , maxInclusive, 1 ) );
        auto_ptr<ClientCursor> cc( new ClientCursor( QueryOption_NoCursorTimeout , c , ns ) );
        cc->setDoingDeletes( true );

        while ( c->ok() ) {
            DiskLoc rloc = c->currLoc();
            BSONObj key = c->currKey();

            if ( callback )
                callback->goingToDelete( c->current() );

            c->advance();
            c->noteLocation();

            logOp( "d" , ns.c_str() , rloc.obj()["_id"].wrap() );
            theDataFileMgr.deleteRecord(ns.c_str() , rloc.rec(), rloc);
            num++;

            c->checkLocation();

            if ( yield && ! cc->yieldSometimes() ) {
                // cursor got finished by someone else, so we're done
                cc.release(); // if the collection/db is dropped, cc may be deleted
                break;
            }
        }

        return num;
    }
开发者ID:BendustiK,项目名称:mongo,代码行数:47,代码来源:dbhelpers.cpp

示例12: matches

    bool CoveredIndexMatcher::matches(const BSONObj &key, const DiskLoc &recLoc , MatchDetails * details ) {
        if ( details )
            details->reset();
        
        if ( !_keyMatcher.matches(key, details ) ){
            return false;
        }
        
        if ( ! _needRecord ){
            return true;
        }

        if ( details )
            details->loadedObject = true;

        return _docMatcher->matches(recLoc.rec() , details );
    }
开发者ID:erickt,项目名称:mongo,代码行数:17,代码来源:matcher_covered.cpp

示例13: fast_oplog_insert

    /* special version of insert for transaction logging -- streamlined a bit.
       assumes ns is capped and no indexes
    */
    Record* DataFileMgr::fast_oplog_insert(NamespaceDetails *d, const char *ns, int len) {
        verify( d );
        RARELY verify( d == nsdetails(ns) );
        DEV verify( d == nsdetails(ns) );

        massert( 16509,
                 str::stream()
                 << "fast_oplog_insert requires a capped collection "
                 << " but " << ns << " is not capped",
                 d->isCapped() );

        //record timing on oplog inserts
        boost::optional<TimerHolder> insertTimer;
        //skip non-oplog collections
        if (NamespaceString::oplog(ns)) {
            insertTimer = boost::in_place(&oplogInsertStats);
            oplogInsertBytesStats.increment(len); //record len of inserted records for oplog
        }

        int lenWHdr = len + Record::HeaderSize;
        DiskLoc loc = d->alloc(ns, lenWHdr);
        verify( !loc.isNull() );

        Record *r = loc.rec();
        verify( r->lengthWithHeaders() >= lenWHdr );

        Extent *e = r->myExtent(loc);
        if ( e->lastRecord.isNull() ) {
            Extent::FL *fl = getDur().writing( e->fl() );
            fl->firstRecord = fl->lastRecord = loc;

            Record::NP *np = getDur().writing(r->np());
            np->nextOfs = np->prevOfs = DiskLoc::NullOfs;
        }
        else {
            Record *oldlast = e->lastRecord.rec();
            Record::NP *np = getDur().writing(r->np());
            np->prevOfs = e->lastRecord.getOfs();
            np->nextOfs = DiskLoc::NullOfs;
            getDur().writingInt( oldlast->nextOfs() ) = loc.getOfs();
            e->lastRecord.writing() = loc;
        }

        d->incrementStats( r->netLength(), 1 );
        return r;
    }
开发者ID:ChrisKozak,项目名称:mongo,代码行数:49,代码来源:pdfile.cpp

示例14: prevLoc

 DiskLoc FindingStartCursor::prevLoc( const DiskLoc &rec ) {
     Extent *e = rec.rec()->myExtent( rec );
     if ( _qp.nsd()->capLooped() ) {
         if ( e->xprev.isNull() )
             e = _qp.nsd()->lastExtent.ext();
         else
             e = e->xprev.ext();
         if ( e->myLoc != _qp.nsd()->capExtent )
             return e->firstRecord;
     }
     else {
         if ( !e->xprev.isNull() ) {
             e = e->xprev.ext();
             return e->firstRecord;
         }
     }
     return DiskLoc(); // reached beginning of collection
 }
开发者ID:rick446,项目名称:mongo,代码行数:18,代码来源:oplog.cpp

示例15: deleteRecord

    void DataFileMgr::deleteRecord(NamespaceDetails* d, const StringData& ns, Record *todelete,
                                   const DiskLoc& dl, bool cappedOK, bool noWarn, bool doLog ) {
        dassert( todelete == dl.rec() );

        if ( d->isCapped() && !cappedOK ) {
            out() << "failing remove on a capped ns " << ns << endl;
            uassert( 10089 ,  "can't remove from a capped collection" , 0 );
            return;
        }

        BSONObj obj = BSONObj::make( todelete );

        BSONObj toDelete;
        if ( doLog ) {
            BSONElement e = obj["_id"];
            if ( e.type() ) {
                toDelete = e.wrap();
            }
        }
        Collection* collection = cc().database()->getCollection( ns );
        verify( collection );

        /* check if any cursors point to us.  if so, advance them. */
        ClientCursor::aboutToDelete(ns, d, dl);

        collection->getIndexCatalog()->unindexRecord( obj, dl, noWarn );

        _deleteRecord(d, ns, todelete, dl);

        collection->infoCache()->notifyOfWriteOp();

        if ( ! toDelete.isEmpty() ) {
            // TODO: this is crazy, need to fix logOp
            const char* raw = ns.rawData();
            if ( strlen(raw) == ns.size() ) {
                logOp( "d", raw, toDelete );
            }
            else {
                string temp = ns.toString();
                logOp( "d", temp.c_str(), toDelete );
            }
        }
    }
开发者ID:ChrisKozak,项目名称:mongo,代码行数:43,代码来源:pdfile.cpp


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