Example #1
0
    void BSONObjExternalSorter::add( const BSONObj& o , const DiskLoc & loc ){
        uassert( "sorted already" , ! _sorted );
        
        if ( ! _cur ){
            _cur = new InMemory();
        }
        
        _cur->push_back( pair<BSONObj,DiskLoc>( o.getOwned() , loc ) );

        long size = o.objsize();
        _curSizeSoFar += size + sizeof( DiskLoc );
        
        if ( _curSizeSoFar > _maxFilesize )
            finishMap();

    }
Example #2
0
    void BSONObjExternalSorter::add( const BSONObj& o , const DiskLoc & loc ){
        uassert( "sorted already" , ! _sorted );
        
        if ( ! _map ){
            _map = new multimap<BSONObj,DiskLoc,BSONObjCmp>( _order );
        }
        
        _map->insert( pair<BSONObj,DiskLoc>( o , loc ) );

        long size = o.objsize();
        _mapSizeSoFar += size + sizeof( DiskLoc );
        if ( size > _largestObject )
            _largestObject = size;
        
        if ( _mapSizeSoFar > _maxFilesize )
            finishMap();

    }
Example #3
0
    void BSONObjExternalSorter::sort(){
        uassert( "already sorted" , ! _sorted );

        _sorted = true;

        if ( _map ){
            finishMap();
        }
        
        if ( _map ){
            delete _map;
            _map = 0;
        }
        
        if ( _files.size() == 0 )
            return;
        
    }
Example #4
0
    void BSONObjExternalSorter::add( const BSONObj& o , const DiskLoc & loc ){
        uassert( 10049 ,  "sorted already" , ! _sorted );
        
        if ( ! _cur ){
            _cur = new InMemory( _arraySize );
        }
        
        Data& d = _cur->getNext();
        d.first = o.getOwned();
        d.second = loc;
        
        long size = o.objsize();
        _curSizeSoFar += size + sizeof( DiskLoc ) + sizeof( BSONObj );
        
        if (  _cur->hasSpace() == false ||  _curSizeSoFar > _maxFilesize ){
            finishMap();
            log(1) << "finishing map" << endl;
        }

    }
Example #5
0
    void BSONObjExternalSorter::sort(){
        uassert( 10048 ,  "already sorted" , ! _sorted );
        
        _sorted = true;

        if ( _cur && _files.size() == 0 ){
            _sortInMem();
            log(1) << "\t\t not using file.  size:" << _curSizeSoFar << " _compares:" << _compares << endl;
            return;
        }
        
        if ( _cur ){
            finishMap();
        }
        
        if ( _cur ){
            delete _cur;
            _cur = 0;
        }
        
        if ( _files.size() == 0 )
            return;
        
    }