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

    function count = countReductions(partitionedArray)
%countReductions - Count all reductions necessary to calculate the given value.
%   COUNT = countReductions(PA) counts all reductions for partitioned array PA.

% Copyright 2015-2016 The MathWorks, Inc.

if partitionedArray.ValueFuture.IsDone
    count = 0;
else
    % Run the optimizer first.
    op = matlab.bigdata.internal.Optimizer.default();
    op.optimize(partitionedArray);
    
    % TODO(g1324108): This is simply using the same logic as
    % LazyPartitionedArray to access the Executor. This should in fact
    % be going through the PartitionedArray API.
    closure = partitionedArray.ValueFuture.Promise.Closure;
    executor = matlab.bigdata.internal.executor.PartitionedArrayExecutor.default();
    taskGraph = matlab.bigdata.internal.lazyeval.LazyTaskGraph(closure);
    count = executor.countNumPasses(taskGraph);
end
end