com.ibm.jzos

Class ZFileRecordReader

  • All Implemented Interfaces:
    ZFileConstants


    public class ZFileRecordReader
    extends RecordReader
    implements ZFileConstants
    This ZFile wrapper is no longer the most efficient way to read dataset records. Please see RecordReader.

    In order to provide more efficient dataset record mode read performance, it is often beneficial to read a block, rather than a record, at a time from the underlying dataset. This class wraps an instance of ZFile, re-opens it with RECFM=U, and provides an interface for reading a record at a time. The underlying ZFile must have been opened with the following options:

    • type=record
    • read mode, either text or binary ("r", "rb" or "rt")

    Reading the dataset a block at a time limits the number of calls to the C library fread() function and also reduces the number of JNI calls that need to be made. The z/OS XL C/C++ Programming Guide SC09-4765 (Chapter 34 - I/O Performance considerations) recommends taking this approach to increase performance when possible.

    All record formats are supported, however performance gains will only be realized when the average record lengths are significantly less than the average block size.

    Since:
    2.3.0
    See Also:
    RecordReader
    • Method Detail

      • read

        public int read(byte[] buf)
                 throws ZFileException
        Read a record from the native file into a buffer.

        Specified by:
        read in class RecordReader
        Parameters:
        buf - the byte array into which the bytes will be read
        Returns:
        the number of bytes read, -1 if EOF encountered.
        Throws:
        ZFileException - if the native call fails
      • read

        public int read(byte[] buf,
                        int offset,
                        int len)
                 throws ZFileException
        Read a record from the native file into a buffer.

        Specified by:
        read in class RecordReader
        Parameters:
        buf - the byte array into which the bytes will be read
        offset - the offset, inclusive in buf to start reading bytes
        len - the number of bytes to read
        Returns:
        the number of bytes read, -1 if EOF encountered.
        Throws:
        ZFileException - if the native call fails
      • getBlksize

        public int getBlksize()
        Description copied from class: RecordReader
        Answer the BLKSIZE, which is the maximum block length supported by the dataset.
        Specified by:
        getBlksize in class RecordReader
      • getDsn

        public java.lang.String getDsn()
        Description copied from class: RecordReader
        Answers the native dataset's absolute name, or name(member) if the native dataset is a member of a PDS.
        Specified by:
        getDsn in class RecordReader
        Returns:
        String dataset name
      • getLrecl

        public int getLrecl()
        Description copied from class: RecordReader
        Answer the LRECL, which is the maximum record length for variable length files.
        Specified by:
        getLrecl in class RecordReader
� Copyright IBM Corporation 2005, 2022.