Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 15
Blocking Tape Records
12 Communicating With Magnetic Tape
Blocking Tape Records
A record is a collection of related information as seen by the application; for example, a
data structure containing an account number, name, and balance. Records can be
fixed or variable length.
A record block contains the data that is written to or read from tape in one read or write
operation. Record blocks within a tape file are typically the same length. A record
block, however, can be larger than a record as recognized by the application.
The relationship between the record and the record block written to tape depends on
whether the record length is fixed or unspecified. If you are using an unspecified
record length, each record block typically contains one record and is padded with blank
space. The size of the record block determines the maximum size of the record.
Figure 12-1 shows this concept.
If your application uses fixed-length records, then for efficiency, you can block multiple
records into one record block that is read from or written to tape in one operation. The
record-block size must be an exact multiple of the record size. Figure 12-2 shows this
concept.
Blocking records is more efficient than having equal-sized physical and records for the
fo
llowing reasons:
Each physical read or write operation has an overhead associated with it. Blocking
reduces the number of physical read and write operations, therefore reducing the
overhead.
Record blocks are separated from each other on tape by an interrecord gap.
Blocking reduces the number of interrecord gaps that are needed and therefore
uses less magnetic tape to store the same information.
When the application performs a read operation, however, it receives a record block of
data and must therefore deblock the record block to extract the record that it wants to
read.
Figure 12-1. Physical Tape Records Containing Records of Unspecified Length
VST060.VSD