www.gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/+matlab/+bigdata/+internal/+lazyeval/checkForOperations.m

    function value = checkForOperations(partitionedArray, operations)
% Check for the given operations in the op tree of the partitioned array.

% Copyright 2015 The MathWorks, Inc.

if ~isa(partitionedArray, 'matlab.bigdata.internal.lazyeval.LazyPartitionedArray')
    value = false;
elseif partitionedArray.ValueFuture.IsDone
    value = false;
else
    value = iCheckForUpstreamOperations(partitionedArray.ValueFuture.Promise.Closure, operations);
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Check for the given operations upstream from the provided closure.
function out = iCheckForUpstreamOperations(closure, operations, cache)

if nargin < 3
    % Use a cache for this call to avoid exploring the graph too many times.
    cache = containers.Map('KeyType', 'char', 'ValueType', 'logical');
end

key = closure.Id;

if isKey(cache, key)
    out = cache(key);
    return;
end

out = any(cellfun(@(type)isa(closure.Operation, type), operations));
if ~out
    dependencies = getDirectDependencies(closure);
    for ii = 1:numel(dependencies)
        out = out || iCheckForUpstreamOperations(dependencies(ii), operations, cache);
        if out
            break
        end
    end
end
cache(key) = out; %#ok<NASGU> assigning into handle
end