コード例 #1
0
    RecordId RecordStoreV1RepairIterator::getNext() {
        const DiskLoc retVal = _currRecord;

        const ExtentManager* em = _recordStore->_extentManager;

        while (true) {
            if (_currRecord.isNull()) {

                if (!_advanceToNextValidExtent()) {
                    return retVal.toRecordId();
                }

                _seenInCurrentExtent.clear();

                // Otherwise _advanceToNextValidExtent would have returned false
                //
                invariant(!_currExtent.isNull());

                const Extent* e = em->getExtent(_currExtent, false);
                _currRecord = (FORWARD_SCAN == _stage ? e->firstRecord : e->lastRecord);
            }
            else {
                switch (_stage) {
                case FORWARD_SCAN:
                    _currRecord = _recordStore->getNextRecordInExtent(_txn, _currRecord);
                    break;
                case BACKWARD_SCAN:
                    _currRecord = _recordStore->getPrevRecordInExtent(_txn, _currRecord);
                    break;
                default:
                    invariant(!"This should never be reached.");
                    break;
                }
            }

            if (_currRecord.isNull()) {
                continue;
            }

            // Validate the contents of the record's disk location and deduplicate
            //
            if (!_seenInCurrentExtent.insert(_currRecord).second) {
                error() << "infinite loop in extent, seen: " << _currRecord << " before" << endl;
                _currRecord = DiskLoc();
                continue;
            }

            if (_currRecord.getOfs() <= 0){
                error() << "offset is 0 for record which should be impossible" << endl;
                _currRecord = DiskLoc();
                continue;
            }

            return retVal.toRecordId();
        }
    }
コード例 #2
0
    RecordId SimpleRecordStoreV1Iterator::getNext() {
        DiskLoc ret = _curr;

        // Move to the next thing.
        if (!isEOF()) {
            if (CollectionScanParams::FORWARD == _direction) {
                _curr = _recordStore->getNextRecord( _txn, _curr );
            }
            else {
                _curr = _recordStore->getPrevRecord( _txn, _curr );
            }
        }

        return ret.toRecordId();
    }