Main Content

SequentialDatastore

Sequentially read data from multiple underlying datastores

Since R2022b

Description

Use a SequentialDatastore object to sequentially read data from multiple datastores without concatenation.

Creation

You can create a SequentialDatastore object using the combine function. For example, dsnew = combine(ds1,ds2,ReadOrder="sequential") creates a datastore that reads data sequentially from datastores ds1 and ds2.

Properties

expand all

Underlying datastores, specified as a cell array of datastore objects. Resetting the SequentialDatastore object resets all of the underlying datastores.

This property is read-only.

Formats supported for writing, returned as a row vector of strings. This property specifies the possible output formats when using writeall to write output files from the datastore.

Object Functions

combineCombine data from multiple datastores
hasdataDetermine if data is available to read
previewPreview subset of data in datastore
readRead data in datastore
readallRead all data in datastore
writeallWrite datastore to files
resetReset datastore to initial state
transformTransform datastore
numpartitionsNumber of datastore partitions
partitionPartition a datastore
shuffleShuffle all data in datastore
isPartitionableDetermine whether datastore is partitionable
isSubsettableDetermine whether datastore is subsettable
isShuffleableDetermine whether datastore is shuffleable

Examples

collapse all

Create a datastore that reads from two image datastores one after the other.

Create an ImageDatastore ds1 representing a collection of two images. Then, create a second ImageDatastore ds2 by transforming the images of ds1 to grayscale images. Combine ds1 and ds2 to create a SequentialDatastore object.

ds1 = imageDatastore(["peppers.png","street2.jpg"]); 
ds2 = transform(ds1, @(x) {im2gray(x)});
dsseq = combine(ds1,ds2,ReadOrder="sequential");

Read the first three images from the SequentialDatastore object. Each read operation on this SequentialDatastore object returns a single image represented by a 1-by-1 cell array.

img1 = read(dsseq);
img2 = read(dsseq);
img3 = read(dsseq);

Version History

Introduced in R2022b