Contenuto principale

hasNextBlock

Determine if blocked file-set has another block

Description

tf = hasNextBlock(bs) returns logical 1 (true) if another block is 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 another block available to process and read the data iteratively.

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

folder = {'accidents.mat','airlineResults.mat','census.mat','earth.mat'}
folder = 1×4 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: Show BlockInfo for all 4 blocks
    AlternateFileSystemRoots: {}

Use the hasNextBlock and nextblock functions to read block information one block at a time while blocks remain in the set.

while hasNextBlock(bs)
   file = nextblock(bs)
end
file = 
  1×1 BlockInfo
                Filename                FileSize     Offset    BlockSize 
    _______________________________    __________    ______    __________

    "C:\...\folder1\accidents.mat"        7343          0         7343   

file = 
  1×1 BlockInfo
                  Filename                  FileSize     Offset    BlockSize 
    ___________________________________    __________    ______    __________

    "C:\...\folder1\airlineResults.mat"    1.5042e+05      0       1.5042e+05

file = 
  1×1 BlockInfo
              Filename              FileSize     Offset    BlockSize 
    ___________________________    __________    ______    __________

    "C:\...\folder1\census.mat"        353         0          353   

file = 
  1×1 BlockInfo
              Filename              FileSize     Offset    BlockSize 
    ___________________________    __________    ______    __________

    "C:\...\folder1\earth.mat"        32522        0         32522  

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: hasNextBlock(bs)

Version History

Introduced in R2020a