Main Content

hasPreviousBlock

Determine if blocked file-set has previous block

Since R2020a

Description

tf = hasPreviousBlock(bs) returns logical 1 (true) if any previous blocks are available to process in the BlockedFileSet object specified by bs. Otherwise, it returns logical 0 (false).

example

Examples

collapse all

Check if a blocked file-set has a previous block available to process.

Create a blocked file-set bs for a collection of files.

folder = {'accidents.mat','airlineResults.mat','census.mat','earth.mat'}
folder = 1x4 cell
    {'accidents.mat'}    {'airlineResults.mat'}    {'census.mat'}    {'earth.mat'}

bs = matlab.io.datastore.BlockedFileSet(folder)
bs = 
  BlockedFileSet with properties:

                   NumBlocks: 4
               NumBlocksRead: 0
                   BlockSize: 'file'
                   BlockInfo: BlockInfo for all 4 blocks
    AlternateFileSystemRoots: {}

Get the information for the first block and move the internal pointer forward one block.

blk1 = nextblock(bs)
blk1 = 
  1x1 BlockInfo
                                                        Filename                                                         FileSize    Offset    BlockSize
    _________________________________________________________________________________________________________________    ________    ______    _________

    "/mathworks/devel/bat/filer/batfs2566-0/Bdoc24b.2725827/build/runnable/matlab/toolbox/matlab/demos/accidents.mat"      7343        0         7343   


Get information for the second block and move the internal pointer forward one block.

blk2 = nextblock(bs)
blk2 = 
  1x1 BlockInfo
                                       Filename                                        FileSize     Offset    BlockSize 
    ______________________________________________________________________________    __________    ______    __________

    "/tmp/Bdoc24b_2725827_1770503/tpc95639c5/matlab-ex81791044/airlineResults.mat"    1.5042e+05      0       1.5042e+05


Check to see if a previous block exists. In this case, the result is true because a previous block exists.

tf = hasPreviousBlock(bs)
tf = logical
   1

Input Arguments

collapse all

Blocked file-set, specified as a matlab.io.datastore.BlockedFileSet object. To create a BlockedFileSet object, see matlab.io.datastore.BlockedFileSet.

Example: hasPreviousBlock(bs)

Version History

Introduced in R2020a