MATLAB 帮助中心
本页翻译不是最新的。点击此处可查看最新英文版本。
数据存储分区数
n = numpartitions(ds)
n = numpartitions(ds,pool)
n = numpartitions(ds) 返回数据存储 ds 的默认分区数。
ds
示例
n = numpartitions(ds,pool) 返回分区数量以便在 pool 指定的并行池上方并行处理数据存储访问。要对数据存储访问进行并行处理,必须安装 Parallel Computing Toolbox™。
pool
全部折叠
根据示例文件 mapredout.mat(mapreduce 函数的输出文件)创建一个数据存储。
mapredout.mat
mapreduce
ds = datastore('mapredout.mat');
获取默认数量的分区。
n = 1
默认情况下,ds 中仅有一个分区,因为它只包含一个小文件。
划分数据存储并返回与第一部分对应的数据存储。
subds = partition(ds,n,1);
读取 subds 中的数据。
subds
while hasdata(subds) data = read(subds); end
获取多个分区,以基于当前并行池将数据存储访问并行化。您必须安装了 Parallel Computing Toolbox。
获取多个分区,以基于当前并行池将数据存储访问并行化。
n = numpartitions(ds, gcp);
划分数据存储并读取每个部分中的数据。
parfor ii=1:n subds = partition(ds,n,ii); while hasdata(subds) data = read(subds); end end
输入数据存储。可以使用 datastore 函数根据您的数据创建数据存储对象。
datastore
并行池对象。
示例: gcp
gcp
全部展开
backgroundPool
ThreadPool
用法说明和限制:
在基于线程的环境中,您只能对以下数据存储使用 numpartitions:
numpartitions
ImageDatastore 对象
ImageDatastore
使用 combine 或 transform 从 ImageDatastore 对象创建的 CombinedDatastore、SequentialDatastore 或 TransformedDatastore 对象
combine
transform
CombinedDatastore
SequentialDatastore
TransformedDatastore
如果您有 Parallel Computing Toolbox,则可以对其他数据存储使用 numpartitions。为此,请使用基于进程的并行池运行该函数,而不是使用 backgroundPool 或 ThreadPool(使用 ProcessPool 或 ClusterPool)。
ProcessPool
ClusterPool
有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
在 R2015a 中推出
datastore | partition
partition
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处