主要内容

isPartitionable

确定数据存储是否已分配

Description

example

tf = isPartionable(ds)returns logical1(真的) if the datastoredsis partitionable. Otherwise, the result is logical0(false).

  • 变换adatastore.is partitionable if all underlying datastores are partitionable.

  • CombinedDatastoreis partitionable if all underlying datastores have asubsetmethod or are transformations/combinations of datastores that havesubsetmethods.

  • Custom datastore classes are partitionable if they subclass frommatlab.io.datastore.Partitionable.

You can use thepartitionfunction on partitionable datastores to create partitions for parallel processing with Parallel Computing Toolbox™.

Examples

collapse all

Create atabulartextdatastore., and then write an如果别的statement that partitions the datastore only if it is partitionable.

ttds = tabularTextDatastore('outages.csv');ifisPartitionable(ttds) newds = partition(ttds,3,1); disp('Partitioning successful.')elsedisp('Datastore is not partitionable.')end
Partitioning successful.

Now create aCombinedDatastoreobject comprised of two copies ofttds. Use the same如果别的test to partition the datastore.

cds = combine(ttds,ttds);ifisPartitionable(cds) newds = partition(cds,3,1); disp('Partitioning successful.')elsedisp('Datastore is not partitionable.')end
数据存储不是partitionable.

In this case, the combined datastorecdsis not partitionable because the underlyingtabulartextdatastore.objects do not havesubsetmethods.

Create anotherCombinedDatastoreobject, but this time construct it out ofImageDatastoreobjects. In this case the combined datastore is partitionable because the underlyingImageDatastoreobjects havesubsetmethods.

imagefiles = {'Street1.jpg','street2.jpg','peppers.png','corn.tif'}; imds = imageDatastore(imageFiles); cds = combine(imds,imds);ifisPartitionable(cds) newds = partition(cds,3,1); disp('Partitioning successful.')elsedisp('Datastore is not partitionable.')end
Partitioning successful.

Input Arguments

collapse all

Input datastore. You can use these datastores as input:

  • MATLAB®datastores — Datastores created using MATLABdatastore职能。For example, create a datastore for a collection of images usingImageDatastore. For a complete list of datastores, seeSelect Datastore for File Format or Application.

  • Combined and transformed datastores — Datastores created using the结合转变职能。

  • Custom datastores — Datastores created using the custom datastore framework. Any datastore that subclasses frommatlab.io.datastore.supports theisPartitionable功能。看Develop Custom Datastorefor more information.

Extended Capabilities

Introduced in R2020a