isPartitionable - Determine whether datastore is partitionable - MATLAB (original) (raw)
Main Content
Determine whether datastore is partitionable
Since R2020a
Syntax
Description
tf = isPartitionable([ds](#mw%5Fa24d451f-3d99-4c9c-877a-cec0e69e12bf))
returns logical1
(true
) if the datastore ds
is partitionable. Otherwise, the result is logical 0
(false
).
TransformedDatastore
is partitionable if all underlying datastores are partitionable.CombinedDatastore
andSequentialDatastore
are partitionable if all underlying datastores have a subset method or are transformations/combinations of datastores that havesubset
methods.- Custom datastore classes are partitionable if they subclass from
matlab.io.datastore.Partitionable
.
You can use the partition function on partitionable datastores to create partitions for parallel processing with Parallel Computing Toolbox™.
Examples
Test Partitionability of Datastores
Create a TabularTextDatastore
, and then write an if/else
statement that partitions the datastore only if it is partitionable.
ttds = tabularTextDatastore('outages.csv'); if isPartitionable(ttds) newds = partition(ttds,3,1); disp('Partitioning successful.') else disp('Datastore is not partitionable.') end
Now create a CombinedDatastore
object comprised of two copies of ttds
. Use the same if/else
test to partition the datastore.
cds = combine(ttds,ttds); if isPartitionable(cds) newds = partition(cds,3,1); disp('Partitioning successful.') else disp('Datastore is not partitionable.') end
Datastore is not partitionable.
In this case, the combined datastore cds
is not partitionable because the underlying TabularTextDatastore
objects do not have subset
methods.
Create another CombinedDatastore
object, but this time construct it out of ImageDatastore
objects. In this case the combined datastore is partitionable because the underlying ImageDatastore
objects have subset
methods.
imageFiles = {'street1.jpg','street2.jpg','peppers.png','corn.tif'}; imds = imageDatastore(imageFiles); cds = combine(imds,imds); if isPartitionable(cds) newds = partition(cds,3,1); disp('Partitioning successful.') else disp('Datastore is not partitionable.') end
Input Arguments
ds
— Input datastore
datastore
Input datastore. You can use these datastores as input:
- MATLAB® datastores — Datastores created using MATLABdatastore functions. For example, create a datastore for a collection of images using ImageDatastore. For a complete list of datastores, see Select Datastore for File Format or Application.
- Combined, sequential, and transformed datastores — Datastores created using the combine and transform functions.
- Custom datastores — Datastores created using the custom datastore framework. Any datastore that subclasses from
matlab.io.Datastore
supports theisPartitionable
function. See Develop Custom Datastore for more information.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
Usage notes and limitations:
- In a thread-based environment, you can use
isPartitionable
only with the following datastores:ImageDatastore
objectsCombinedDatastore
,SequentialDatastore
, orTransformedDatastore
objects you create fromImageDatastore
objects by usingcombine
ortransform
You can useisPartitionable
with other datastores if you have Parallel Computing Toolbox. To do so, run the function using a process-backed parallel pool instead of usingbackgroundPool
orThreadPool
(use eitherProcessPool
orClusterPool
).
For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2020a