diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-05-18 18:01:38 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2015-06-09 16:33:22 -0400 |
commit | 3b731debe162706cbbfabd9578bbb57ab5a7a7d8 (patch) | |
tree | 7b26f5541e5de0060bf75f5563b37cae5a246ee8 /src/mongo/db/exec/text.cpp | |
parent | f50d1d0b7df924926855badd3cd700653f75f0f8 (diff) | |
download | mongo-3b731debe162706cbbfabd9578bbb57ab5a7a7d8.tar.gz |
SERVER-16444 New API for navigating RecordStores
Diffstat (limited to 'src/mongo/db/exec/text.cpp')
-rw-r--r-- | src/mongo/db/exec/text.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mongo/db/exec/text.cpp b/src/mongo/db/exec/text.cpp index b049c17b9ff..5a62fc9937d 100644 --- a/src/mongo/db/exec/text.cpp +++ b/src/mongo/db/exec/text.cpp @@ -133,6 +133,8 @@ namespace mongo { for (size_t i = 0; i < _scanners.size(); ++i) { _scanners.mutableVector()[i]->saveState(); } + + if (_recordCursor) _recordCursor->saveUnpositioned(); } void TextStage::restoreState(OperationContext* opCtx) { @@ -143,6 +145,8 @@ namespace mongo { for (size_t i = 0; i < _scanners.size(); ++i) { _scanners.mutableVector()[i]->restoreState(opCtx); } + + if (_recordCursor) invariant(_recordCursor->restore(opCtx)); } void TextStage::invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type) { @@ -196,6 +200,8 @@ namespace mongo { PlanStage::StageState TextStage::initScans(WorkingSetID* out) { invariant(0 == _scanners.size()); + _recordCursor = _params.index->getCollection()->getCursor(_txn); + _specificStats.parsedTextQuery = _params.query.toBSON(); // Get all the index scans for each term in our query. @@ -304,7 +310,7 @@ namespace mongo { WorkingSetMember* wsm = _ws->get(textRecordData.wsid); try { - if (!WorkingSetCommon::fetchIfUnfetched(_txn, wsm, _params.index->getCollection())) { + if (!WorkingSetCommon::fetchIfUnfetched(_txn, wsm, _recordCursor)) { _scoreIterator++; _ws->free(textRecordData.wsid); _commonStats.needTime++; @@ -338,9 +344,9 @@ namespace mongo { const BSONObj& keyPattern, const BSONObj& key, WorkingSetMember* wsm, - const Collection* collection) + unowned_ptr<RecordCursor> recordCursor) : _txn(txn), - _collection(collection), + _recordCursor(recordCursor), _keyPattern(keyPattern), _key(key), _wsm(wsm) { } @@ -384,14 +390,16 @@ namespace mongo { private: BSONObj getObj() const { - if (!WorkingSetCommon::fetchIfUnfetched(_txn, _wsm, _collection)) + if (!WorkingSetCommon::fetchIfUnfetched(_txn, _wsm, _recordCursor)) throw DocumentDeletedException(); + // Make it owned since we are buffering results. + _wsm->obj.setValue(_wsm->obj.value().getOwned()); return _wsm->obj.value(); } OperationContext* _txn; - const Collection* _collection; + unowned_ptr<RecordCursor> _recordCursor; BSONObj _keyPattern; BSONObj _key; WorkingSetMember* _wsm; @@ -420,7 +428,7 @@ namespace mongo { newKeyData.indexKeyPattern, newKeyData.keyData, wsm, - _params.index->getCollection()); + _recordCursor); shouldKeep = _filter->matches(&tdoc); } catch (const WriteConflictException& wce) { |