bool DocumentSourceCommandFutures::eof() {
        /* if we haven't even started yet, do so */
        if (!pCurrent.get())
            getNextDocument();

        return (pCurrent.get() == NULL);
    }
bool
LidSpaceCompactionJob::scanDocuments(const LidUsageStats &stats)
{
    if (_scanItr->valid()) {
        DocumentMetaData document = getNextDocument(stats);
        if (document.valid()) {
            IFrozenBucketHandler::ExclusiveBucketGuard::UP bucketGuard = _frozenHandler.acquireExclusiveBucket(document.bucketId);
            if ( ! bucketGuard ) {
                // the job is blocked until the bucket for this document is thawed
                setBlocked(BlockedReason::FROZEN_BUCKET);
                _retryFrozenDocument = true;
                return true;
            } else {
                MoveOperation::UP op = _handler.createMoveOperation(document, stats.getLowestFreeLid());
                search::IDestructorCallback::SP context = _moveOpsLimiter->beginOperation();
                _opStorer.storeOperation(*op, context);
                _handler.handleMove(*op, std::move(context));
                if (isBlocked(BlockedReason::OUTSTANDING_OPS)) {
                    return true;
                }
            }
        }
    }
    if (!_scanItr->valid()){
        if (shouldRestartScanDocuments(_handler.getLidStatus())) {
            _scanItr = _handler.getIterator();
        } else {
            _scanItr = IDocumentScanIterator::UP();
            _shouldCompactLidSpace = true;
        }
    }
    return false; // more work to do (scan documents or compact lid space)
}
    bool DocumentSourceCommandFutures::advance() {
        if (eof())
            return false;

        /* advance */
        getNextDocument();

        return (pCurrent.get() != NULL);
    }
    bool DocumentSourceCommandFutures::advance() {
        DocumentSource::advance(); // check for interrupts

        if (eof())
            return false;

        /* advance */
        getNextDocument();

        return (pCurrent.get() != NULL);
    }