A variable RRDS (VRRDS) is a Relative Record Data Set in which records can have different lengths. You define it with NUMBERED and RECORDSIZE(average maximum) where the average and maximum are not the same—for example RECORDSIZE(50 200). Unlike a fixed RRDS, there are no fixed-size slots on disk; instead, an INDEX component maps each relative record number (RRN) to the physical location of the record. You still access records by RRN (direct addressing), but the system uses the index to find each record. This page explains what VRRDS is, how it differs from fixed RRDS, how to define it with DEFINE CLUSTER (including the INDEX component and VOLUMES), and when to choose VRRDS over fixed RRDS or other VSAM types.
In a fixed RRDS every record has the same length and the file is divided into fixed slots. In a variable RRDS records can vary in length within a range you specify (e.g. 50 to 200 bytes). So one record might be 80 bytes and the next 120 bytes. Because lengths vary, the system cannot compute "slot N" as a simple offset. Instead, VRRDS uses an index component—similar in concept to a KSDS index—that maps each RRN to the location of that record. When you set the RRN and issue READ, the access method looks up the RRN in the index and uses the stored pointer to read the record. So you still get direct access by RRN, but the mechanism is index-based rather than slot-offset-based.
In a fixed RRDS the position of record (slot) N can be calculated: N × record-length (plus control information). In a variable RRDS record lengths differ, so there is no fixed slot size. The only way to find "record with RRN 5" is to maintain a mapping: RRN 5 → location. That mapping is the index. The index is ordered by RRN and holds, for each RRN, the information needed to locate the record in the data component. So VRRDS has both a data component (where variable-length records are stored) and an index component (which maps RRN to record). When you insert, delete, or replace records, the index is updated to reflect the new locations or the removal of the RRN.
For VRRDS you specify RECORDSIZE(average maximum) with two different values. The average is used for space estimation and possibly for buffer sizing; the maximum is the largest record length allowed. For example RECORDSIZE(80 120) means records can be from 1 to 120 bytes (or whatever the minimum is for your system), with an average of 80. Every record you write must not exceed the maximum. If you use the same value for both (e.g. RECORDSIZE(80 80)), you have a fixed RRDS, not a VRRDS, and you do not define an index.
You create a VRRDS with DEFINE CLUSTER by specifying NUMBERED, RECORDSIZE(avg max) with avg and max different, and both DATA and INDEX components. Allocate space for both components. On many systems VOLUMES should be specified at the cluster level so that both the data and index components receive volume allocation; if VOLUMES is only on DATA, the define may fail because the index has no volume. The following example shows the structure.
| Parameter | Description |
|---|---|
| NUMBERED | Specifies RRDS (required for both fixed and variable RRDS). |
| RECORDSIZE(avg max) | For VRRDS, average and maximum differ (e.g. 50 200). Records can be any length from min up to max. |
| INDEX component | Required for VRRDS. Maps RRN to record location; no fixed slots. |
| DATA and INDEX | Both components must be defined; each can have its own space allocation. |
| VOLUMES | Often specified at cluster level so both DATA and INDEX get volume allocation. |
1234567891011DEFINE CLUSTER ( - NAME(USERID.MY.VRRDS) - NUMBERED - RECORDSIZE(80 200) - CYLINDERS(5 2) - VOLUMES(volser) - REUSE) - DATA (NAME(USERID.MY.VRRDS.DATA) - CYLINDERS(4 1)) - INDEX (NAME(USERID.MY.VRRDS.INDEX) - CYLINDERS(1 1))
NUMBERED makes it an RRDS. RECORDSIZE(80 200) allows variable-length records with average 80 and maximum 200 bytes. VOLUMES at the cluster level applies to both components. DATA and INDEX each have their own space (CYLINDERS). REUSE, if supported for VRRDS on your system, allows a deleted RRN to be reused for a new record. The index will map each RRN to the corresponding record in the data component.
Fixed RRDS has same-length records and no index; RRN is the slot number and the slot position is computed. Variable RRDS has variable-length records and an index; RRN is the logical record number and the index maps it to the record. Fixed RRDS is simpler and uses less metadata (no index); VRRDS is more flexible for varying record sizes but requires index maintenance and more space for the index. Choose fixed RRDS when all records are the same length; choose VRRDS when record lengths vary.
| Aspect | Fixed RRDS | Variable RRDS (VRRDS) |
|---|---|---|
| Record length | All records same length | Records can vary within min–max range |
| RECORDSIZE | RECORDSIZE(n n) | RECORDSIZE(avg max), avg < max |
| Index | No index | INDEX component required |
| RRN mapping | RRN = slot position (computed) | Index maps RRN to record |
You can READ by RRN (the index finds the record), WRITE at an RRN (insert or assign that RRN; the index is updated), REWRITE after READ (update in place; record length can change within the max), and DELETE at an RRN (remove the record and free the RRN; with REUSE the RRN can be reused). Sequential access reads records in RRN order (1, 2, 3, …); the index is used to traverse in RRN order. Direct access is by RRN as in fixed RRDS, but each access goes through the index to locate the record.
The RRN in VRRDS is still the relative record number: 1 for the first record, 2 for the second, and so on. The difference is that in fixed RRDS the RRN is tied to a fixed slot, while in VRRDS the RRN is a logical number maintained by the index. When you delete a record in VRRDS, that RRN can be reused for a new record if the cluster has REUSE. So the RRN space can be recycled. The index keeps the mapping from RRN to current record location; when you insert a new record at a reused RRN, the index is updated to point to the new record.
Use VRRDS when you need RRN-based (position-based) access but your records have different lengths. For example, a table where each "row" is identified by row number (RRN) but the row content length varies. Use fixed RRDS when all records are the same length—it is simpler and has no index overhead. Use KSDS when you need key-based access rather than position-based. Use ESDS when you need append-only with stable RBA addresses.
Imagine a row of cubbyholes where each cubbyhole can be a different size. You still number them 1, 2, 3, 4, 5. But because they're different sizes, you need a list (the index) that says "number 1 is here, number 2 is there." When you ask for the thing in cubbyhole 3, you check the list to find where 3 is, then go there. That list is the index. Fixed RRDS is when every cubbyhole is the same size so you don't need the list—you just count over. Variable RRDS is when they're different sizes so you need the list.
1. What distinguishes VRRDS from fixed RRDS in RECORDSIZE?
2. Why does VRRDS require an INDEX component?
3. In VRRDS, how is a record found when you READ by RRN?