Пример #1
0
StatusWith<ClusterQueryResult> RouterStageMock::next() {
    if (_resultsQueue.empty()) {
        return {ClusterQueryResult()};
    }

    auto out = _resultsQueue.front();
    _resultsQueue.pop();
    return out;
}
StatusWith<ClusterQueryResult> RouterStageAggregationMerge::next() {
    // Pipeline::getNext will return a boost::optional<Document> or boost::none if EOF.
    if (auto result = _mergePipeline->getNext()) {
        return {result->toBson()};
    }

    // If we reach this point, we have hit EOF.
    _mergePipeline.get_deleter().dismissDisposal();
    _mergePipeline->dispose(getOpCtx());

    return {ClusterQueryResult()};
}
Пример #3
0
StatusWith<ClusterQueryResult> RouterStageLimit::next(RouterExecStage::ExecContext execContext) {
    if (_returnedSoFar >= _limit) {
        return {ClusterQueryResult()};
    }

    auto childResult = getChildStage()->next(execContext);
    if (!childResult.isOK()) {
        return childResult;
    }

    if (!childResult.getValue().isEOF()) {
        ++_returnedSoFar;
    }
    return childResult;
}
Пример #4
0
StatusWith<ClusterQueryResult> AsyncResultsMerger::nextReady() {
    stdx::lock_guard<stdx::mutex> lk(_mutex);
    dassert(ready_inlock());
    if (_lifecycleState != kAlive) {
        return Status(ErrorCodes::IllegalOperation, "AsyncResultsMerger killed");
    }

    if (!_status.isOK()) {
        return _status;
    }

    if (_eofNext) {
        _eofNext = false;
        return {ClusterQueryResult()};
    }

    const bool hasSort = !_params->sort.isEmpty();
    return hasSort ? nextReadySorted() : nextReadyUnsorted();
}
StatusWith<ClusterQueryResult> ClusterClientCursorMock::next(
    RouterExecStage::ExecContext execContext) {
    invariant(!_killed);

    if (_resultsQueue.empty()) {
        _exhausted = true;
        return {ClusterQueryResult()};
    }

    auto out = _resultsQueue.front();
    _resultsQueue.pop();

    if (!out.isOK()) {
        return out.getStatus();
    }

    ++_numReturnedSoFar;
    return out.getValue();
}
Пример #6
0
void RouterStageMock::queueEOF() {
    _resultsQueue.push({ClusterQueryResult()});
}