Main Content

partition

Class: matlab.io.datastore.DsFileSet
Namespace: matlab.io.datastore

Partition file-set object

Syntax

subfs = partition(fs,n,index)

Description

subfs = partition(fs,n,index) partitions file set fs into the number of parts specified by n and returns the partition corresponding to the index index.

Input Arguments

expand all

Input file-set, specified as a DsFileSet, FileSet, or BlockedFileSet object. To create a DsFileSet object, see matlab.io.datastore.DsFileSet. To create a FileSet object, see matlab.io.datastore.FileSet. To create a BlockedFileSet object, see matlab.io.datastore.BlockedFileSet.

Number of partitions, specified as a positive integer.

Example: 3

Data Types: double

Index, specified as a positive integer.

Example: 1

Data Types: double

Examples

Partition File-Set Object and Get One Partition

Create a file-set object, partition the file-set object, and get the files contained in a specified partition.

Create a file-set object for all .mat files in a folder.

folder = fullfile(matlabroot,'toolbox','matlab','demos');  
fs = matlab.io.datastore.DsFileSet(folder,'FileExtensions','.mat');

Partition the 40 files into five partitions and obtain the first partition. Then, get the file information of all files in the first partition.

subfsA = partition(fs,5,1) % first 8 files
subfsA_fileInfo = resolve(subfsA)

Obtain the second partition and files information for files in this partition.

subfsB = partition(fs,5,2) % next 8 files
subfsB_fileInfo = resolve(subfsB)

Tips

  • Use the NumFiles property of the DsFileSet object to find the number of files in fs and use that number to estimate a reasonable number of partitions for the datastore.

Version History

Introduced in R2017b