vsam_day_1
TRANSCRIPT
-
7/31/2019 VSAM_Day_1
1/36
-
7/31/2019 VSAM_Day_1
2/36
Mainframe ApplicationProgramming
-
7/31/2019 VSAM_Day_1
3/36
Course schedule
UNITVSAM Intro
Access Methods
VSAM Introduction
VSAM Organization
Control Interval
Topics:
-
7/31/2019 VSAM_Day_1
4/36
-
7/31/2019 VSAM_Day_1
5/36
Listed below are some of the traditional access methods thatare available for the Multiple Virtual Storage
(MVS) environment:
Queued Sequential Access Method (QSAM)
Basic Sequential Access Method (BSAM)
Indexed Sequential Access Method (ISAM)
Basic Direct Access Method (BDAM)
Partitioned Data Set Extended (PDS-E)
Access Methods (contd)
-
7/31/2019 VSAM_Day_1
6/36
VSAM Introduction
VSAM stands for Virtual Storage Access Method
Used to access the data sets quickly and effectively.
Used to organize, store, catalog, retrieve and delete data sets.
-
7/31/2019 VSAM_Day_1
7/36
ROLE OF VSAM
VSAM acts as an interface between processing programs
and the operating system.
VSAM groups individual data records into larger units inorder to reduce the number of I/O requests required when
sequentially retrieving records.
These larger units are transferred between the DirectAccess Storage Device (DASD) and virtual storage by
the operating system.
-
7/31/2019 VSAM_Day_1
8/36
How does VSAM retrieve a record
In retrieving a record VSAM goes throughthe following steps:
1. VSAM interprets the processing programs
logical request and determines whatservices are desired.
2. VSAM makes the required Input or Output(I/O) request(s) to the operating system.
3. The operating system performs thephysical I/O operation(s) between thedevice and the storage.
4. VSAM locates and extracts the desireddata before returning it to the processing
program.
Operating System
DASD
VSAM
Processing Program
-
7/31/2019 VSAM_Day_1
9/36
ADVANTAGES OF VSAM
Data can be accessed faster.
Records can be inserted in more efficient manner.
Deletion of records results in them being physically removedfrom the disk.
Records can be accessed sequentially or randomly.
VSAM data sets are device independent.
-
7/31/2019 VSAM_Day_1
10/36
DISADVANTAGES OF VSAM
VSAM data sets require more storage space than
other types of data sets.
VSAM data set require additional free space that
must be embedded in them.
-
7/31/2019 VSAM_Day_1
11/36
DATA SETS IN VSAM
VSAM supports the following data set types:
Entry-Sequenced Data Set (ESDS)
Key-Sequenced Data Set (KSDS)
Relative Record Data Set (RRDS)
Linear Data Set (LDS)
-
7/31/2019 VSAM_Day_1
12/36
Entry-Sequenced Data Set
Records in an ESDS are stored in the order inwhich they are written and are retrieved byaddressed access.
Records are loaded irrespective of their contentsand their byte addresses cannot be changed.
ESDS is also referred to as a sequential VSAMdata set. This is because records in an ESDS are
normally processed sequentially.
ESDS is best suited for applications where mostprocessing is done sequentially.
-
7/31/2019 VSAM_Day_1
13/36
Key-Sequenced Data Set
Records in a KSDS are stored in key sequence and arecontrolled by an index, determine the order in which recordsare stored.
In a KSDS, records can be processed both sequentially andrandomly using their key field values.
The advantages of KSDS are:
Sequential processing is useful for retrieving records inthe sorted form
Random or direct processing of records is useful in on-line applications
-
7/31/2019 VSAM_Day_1
14/36
Relative Record Data Set
Records in an RRDS are loaded into fixed-length or variablelength slots.
These records are representedby the Relative RecordNumbers (RRNs) of their
slots.
A processing program uses RRN to provide random access torecords.
R1 R2 R3
Slots
1 2 3 4
Relative Record Numbers
-
7/31/2019 VSAM_Day_1
15/36
Linear Data Set
LDS is a data set containing only a contiguous string of databytes with no intervening control information.
An LDS is divided into blocks. These blocks can be
sequentially retrieved by a processing program in physicalorder.
A processing program can group several logical recordstogether into a single block
LDS can be kept permanently in store for enhancedperformance.
Continued
Concepts
-
7/31/2019 VSAM_Day_1
16/36
Relative Byte Address
What is a Relative Byte Address?
The Relative Byte Address (RBA) of a record is its displacement
(in bytes) from the beginning of the data set.
VSAM treats data as a contiguous string of bytes. This approach
makes the address of a record device-independent.
A VSAM data set can be moved without affecting the RBAs of
its records.
Continued
-
7/31/2019 VSAM_Day_1
17/36
In addition to data recordsVSAM also stores controlInformation. The presence ofcontrol Information affects theRBAs of subsequent data
records. The example represents a VSAM
data set containing 100-byte,fixed-length records.
The RBA of the first record is 0.
The RBA of the second record is100.
The RBA of the third record is200 and so on.
Relative Byte Address (contd)
Record 1 Record 2 Record3
Relative Byte Addresses
0 100 200 300
-
7/31/2019 VSAM_Day_1
18/36
What is a cluster?
A cluster is the collection of physical data sets thatmake up one logical data set.
The concept of a cluster is more suited for a KSDS.
Cluster
Continued
-
7/31/2019 VSAM_Day_1
19/36
A KSDS cluster has two datasets.
One data set holds the actual
data records.
The other data set containsan index component.
The index component permitsthe direct retrieval of data.
Cluster (contd)
Continued
KSDS.CLUSTER
KSDS.INDEX
KSDS.DATA
-
7/31/2019 VSAM_Day_1
20/36
With an ESDS, an RRDS
and an LDS, the cluster
name and the data set
component name bothrefer to the same data set
and
a cluster consists of only asingle physical data set:
the data component.
Cluster (contd)
Continued
Concepts
A BC
Cluster
Related Data Sets
-
7/31/2019 VSAM_Day_1
21/36
What is a control interval?
o A control interval is the amount of data transferred between the
device and virtual storage.
o When a record is read from or written to a data set, VSAMgroups individual data records into larger units of storage. Theseunits of storage are called control intervals.
o Size of a control interval should be minimum 512 bytes andincreased by multiples of 512 upto a limit of 8 K. Beyond that theincrements should be 2KB up to a maximum of 32KB.
o Control interval size = n * 512 or n * 2048 where n is between1 to 16.
R1 R1 R1UnusedSpace
420
340
220
9 18 00 5
5
-
7/31/2019 VSAM_Day_1
22/36
control interval has 4 components :
Data
Control interval description field
Record description field
Free space
Data
Contains the actual data processed by the program
Control interval description field
Contains the information about the free space within the CI.
field is with 4 bytes long.
Unused Space (No Records)
Control Interval 1 CIDF
Unused Space (1055)980
1055
420220 220340420340
-
7/31/2019 VSAM_Day_1
23/36
Record Description Field:
Contains the information about the records within the data space.
An RDF is a three byte field that is used to define the location and
length of a record or a group of records.
The RDFs immediately precede the CIDF, at the end of the control
interval.
Unused Space (1055)R4432
R3432
R2432
R1432
4324
-
7/31/2019 VSAM_Day_1
24/36
In an ESDS records are stored in the order in which they are writtenand can be read in the same order.
The characteristics of ESDS are summarized below:
Records are stored sequentially.
Records can be of fixed or variable length.
Records are physically grouped into control intervals.
Control intervals contain control information along with data.
ESDS Organization
R4R3R2R1 R8R7R6R5 R4R3R2R1
Control Interval 1 Control Interval 2 Control Interval 3
-
7/31/2019 VSAM_Day_1
25/36
Jcl for ESDS
.
//SAMP003B JOB ,,CLASS=M,
// MSGLEVEL=(1,1),NOTIFY=SAMP003,TIME=(1)//EXEC1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *DEFINE CLUSTER -
( -
NAME(SAMP003.ESDS.CLUSTER) -
TRACKS(2,1) -
CISZ(512) -
RECORDSIZE(80,80) -NONINDEXED -
)
DATA(NAME(SAMP003.ESDS.DATA)
)
/*
-
7/31/2019 VSAM_Day_1
26/36
How is the size of a control interval determined?
The size of a control interval is determined when the data set isdefined.
The size can be defined in either of the following ways:
The size can be defined with the DEFINE CLUSTER commandthat defines the data set.
VSAM selects the size that best utilizes DASD storage.
Control Intervals
Continued
R4R3R2R1 R8R7R6R5 R4R3R2R1
Control Interval 1 Control Interval 2 Control Interval 3
-
7/31/2019 VSAM_Day_1
27/36
Control Intervals (contd)
What is control information?
VSAM uses some information to locate records within acontrol interval. This information is called control
information. Data records are stored at the beginning of the control
interval, while the control information is located at the endof the control interval.
Control Info
R4R3R2R1 R8R7R6R5 R4R3R2R1
Control Interval 1 Control Interval 2 Control Interval 3
-
7/31/2019 VSAM_Day_1
28/36
CIDF (contd)
What does CIDF contain? The CIDF contains the following two values, each two bytes
long:
The first value indicates where the unused space in the
control interval begins, stored as a displacement from thebeginning of the control interval.
The second value indicates the length of the unused space.
Unused Space (No Records) 0
Control Interval 11020
CIDF
-
7/31/2019 VSAM_Day_1
29/36
Record Definition Field
What is a Record Definition Field?
The data records in a control interval are described by a group of
record definition fields (RDFs).
An RDF is a three byte field that is used to define the locationand length of a record or a group of records.
The RDFs immediately precede the CIDF, at the end of the
control interval.
Unused Space (1055)980
Control Interval 1
1055
R3420
R2340
R1220
220340420
CIDFRDF3 RDF2 RDF1
-
7/31/2019 VSAM_Day_1
30/36
Record Definition Field Case 1
Case 1: Consider a case, where no two consecutive records
have the same length and the control interval has unusedspace.
Unused Space (1055)980
Control Interval 1
1055
CIDF
R3420
R2340
R1220
220340420
RDF3 RDF2 RDF1
-
7/31/2019 VSAM_Day_1
31/36
Record Definition Field Case 2
Case 2: Consider a case, where all records in a control interval
are of the same length and the control interval has unused
space.
Unused Space (1055)
Control Interval 1 CIDF
R4432
R3432
R2432
R1432
RDF2 RDF11728
310
4324
-
7/31/2019 VSAM_Day_1
32/36
Record Definition Field Case 3
Case 3: Consider a case, where records are of variable
length, but some consecutive records are of same length.
Unused Space 228
1804
Control Interval 1
228
CIDF
R4380
R3380
R2380
3332R1332
RDF4 RDF3
R5332
332380
RDF2 RDF1
-
7/31/2019 VSAM_Day_1
33/36
How is space wasted in a control interval?
The example shows how a data set, containing records of3000 bytes and 5000 bytes, would be stored if a 5K (5120bytes) control interval is used.
The following inferences can be made from the givenexample:
Only a single record of either size can fit in a controlinterval
For every 3000-byte record, 2113 bytes are unused andfor every 5000-bytes record, 113 bytes are unused
As a result, just for 5 records, 6565 bytes of space iswasted
Managing Control Intervals
Continued
3000 50003000 30005000
5K (5120 bytes) Control Intervals
-
7/31/2019 VSAM_Day_1
34/36
How can you avoid wastage of space?
There are two solutions to prevent space wastage in controlintervals. They are:
Increasing the control interval size
Spanned records
Managing Control Intervals (contd)
Continued
3000 50003000 30005000
5K (5120 bytes) Control Intervals
-
7/31/2019 VSAM_Day_1
35/36
Increasing the Size of Control Intervals
In this case, a 16K control interval might result in a less wasted
space, depending on the proportion and sequence of the 3000-byte and 5000-byte records. However, as VSAM always reads
the CIDF into main storage, this solution is not very efficient.
Managing Control Intervals (contd)
Continued
16K Control Interval
-
7/31/2019 VSAM_Day_1
36/36
Spanned Records The problem of wasted space can be resolved by reducing the
control interval size and directing VSAM to split
records over control intervals. Records which are split betweencontrol intervals are called spanned records.
A spanned record, thus, is a logical record contained in morethan one block.
In the given case, if 3K intervals are used with spanned records,instead of 5K control intervals, the total amount of wastedspace will be reduced to 4234 bytes.
Managing Control Intervals (contd)
3K (3072 bytes) Control Intervals
3000 3062 1038 3000 3000 3062 1938