maxpartitions

Class: matlab.io.datastore.DsFileSet
Package: matlab.io.datastore

Maximum number of partitions

Syntax

N = maxpartitions(fs)

Description

N = maxpartitions(fs) returns the maximum number of partitions for a given DsFileSet object fs.

Input Arguments

expand all

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

Output Arguments

expand all

Number of partitions, returned as an integer. The value of N depends on the FileSplitSize property of the DsFileSet object.

  • If FileSplitSize contains 'file', then maxpartitions sets N equal to the total number of files in fs.

  • If FileSplitSize contains a numeric value, then maxpartitions determines N as the sum of the ceil of the file sizes of each file divided by the FileSplitSize.

Examples

Get Maximum Number of Partitions for the File-Set Object

Create a file-set object and get the number of partitions for different values of the FileSplitSize property.

Create a file-set object for all .mat files in a folder and check the number of files.

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

   40

The FileSplitSize property of the DSFileSet object is set to 'file'. Therefore, maxpartitions returns a value equal to the number of files.

maxpartitions(fs)
ans =

   40

Set the FileSplitSize property to a numeric size (2000 bytes) and compute maxpartitions.

fs = matlab.io.datastore.DsFileSet(folder,...
                                  'FileExtensions','.mat',...
                                  'FileSplitSize',2000);
n = maxpartitions(fs)
n =

       1752

Introduced in R2017b