public class ZFileRecordReader extends java.lang.Object implements ZFileConstants
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:
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.
Example: Read a dataset in record mode using a ZFileRecordReaderZFile zfile = new ZFile("//'HLQ.DATASET.DATA'", "rb,type=record,noseek"); byte[] recordBuf = new byte[zfile.getLrecl()]; ZFileRecordReader reader = ZFileRecordReader.newReader(zfile); int bytesRead; while ((bytesRead = reader.read(recordBuf)) >= 0) { ... } reader.close();
DEFAULT_EBCDIC_CODE_PAGE, DEVICE_DISK, DEVICE_DUMMY, DEVICE_HFS, DEVICE_HIPERSPACE, DEVICE_MEMORY, DEVICE_MSGFILE, DEVICE_OTHER, DEVICE_PRINTER, DEVICE_TAPE, DEVICE_TDQ, DEVICE_TERMINAL, DSORG_CONCAT, DSORG_HFS, DSORG_HIPER, DSORG_MEM, DSORG_PDS_DIR, DSORG_PDS_MEM, DSORG_PDSE, DSORG_PO, DSORG_PS, DSORG_TEMP, DSORG_VSAM, LOCATE_KEY_EQ, LOCATE_KEY_EQ_BWD, LOCATE_KEY_FIRST, LOCATE_KEY_GE, LOCATE_KEY_LAST, LOCATE_RBA_EQ, LOCATE_RBA_EQ_BWD, MODE_FLAG_APPEND, MODE_FLAG_READ, MODE_FLAG_UPDATE, MODE_FLAG_WRITE, OPEN_MODE_BINARY, OPEN_MODE_RECORD, OPEN_MODE_TEXT, RECFM_A, RECFM_B, RECFM_F, RECFM_M, RECFM_S, RECFM_U, RECFM_V, S_IRGRP, S_IROTH, S_IRUSR, S_IRWXG, S_IRWXO, S_IRWXU, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR, SEEK_CUR, SEEK_END, SEEK_SET, VSAM_TYPE_ESDS, VSAM_TYPE_ESDS_PATH, VSAM_TYPE_KSDS, VSAM_TYPE_KSDS_PATH, VSAM_TYPE_NOTVSAM, VSAM_TYPE_RRDS
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the reader and underlying ZFile.
|
static ZFileRecordReader |
newReader(ZFile zFile)
Construct a new ZFileRecordReader on the given ZFile, which must
have been opened in read, record mode.
|
int |
read(byte[] buf)
Read a record from the native file into a buffer.
|
int |
read(byte[] buf,
int offset,
int len)
Read a record from the native file into a buffer.
|
public static ZFileRecordReader newReader(ZFile zFile) throws ZFileException
ZFileException
public int read(byte[] buf) throws ZFileException
buf
- the byte array into which the bytes will be readZFileException
- if the native call failspublic int read(byte[] buf, int offset, int len) throws ZFileException
buf
- the byte array into which the bytes will be readoffset
- the offset, inclusive in buf to start reading byteslen
- the number of bytes to readZFileException
- if the native call failspublic void close() throws ZFileException
ZFileException
- if the native call fails