04 - VSAM ESDS and RRDS
-
Upload
api-27095622 -
Category
Documents
-
view
160 -
download
7
Transcript of 04 - VSAM ESDS and RRDS
![Page 1: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/1.jpg)
VSAM ESDS and RRDS
Department of Computer Science
Northern Illinois University
September 2005
Some of the illustrations are from VSAM: Access Method Services and Programming Techniques by James Martin
![Page 2: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/2.jpg)
2
ESDS Structure
• Entry-Sequenced Data Set– cluster consists of data component only– records are stored in the order in which
they are entered into the data set– each record is reference by its relative byte
address (RBA)
![Page 3: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/3.jpg)
3
ESDS Structure
• Entry-Sequenced Data Set– records can be accessed
• sequentially on RBA value• directly by supplying the RBA of desired record
![Page 4: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/4.jpg)
4
ESDS Structure
ESDS
Data ComponentRec
1Rec
2Rec
3Rec
n………….0 100 200
100 byte records:
Record 1 RBA = 0
Record 2 RBA = 100
Record 3 RBA = 200
etc.
![Page 5: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/5.jpg)
5
ESDS Control Interval
• Each CI is filled before records are written into the next control interval in sequence
• Control Areas are filled with CI’s that contain records
![Page 6: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/6.jpg)
6
ESDS Control Interval
ESDS
Cont
Info
Rec
D
Rec
E
Rec
A
Rec
B
Rec
C
Cont
Info
Rec
I
Rec
J
Rec
F
Rec
G
Rec
H
Cont
Info
Rec
N
Rec
O
Rec
K
Rec
L
Rec
M
![Page 7: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/7.jpg)
7
ESDS Control Area
ESDS Control Area
Rec
A
Rec
B
Rec
C
Rec
E
Rec
F
Rec
G
Free
Space
Rec
H
Rec
I
Free
Space
RDF
RDF
RDF
CIDF
RDF
RDF
RDF
CIDF
RDF
RDF
CIDF
CIDF
F S
Rec
J
Rec
D
![Page 8: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/8.jpg)
8
ESDS Processing
• ESDS can be updated using REWRITE either– sequentially on RBA or – directly with given RBA
• ESDS deletion is only logical not physical– space is not reclaimed– VSAM just sets a code denoting logical
deletion
![Page 9: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/9.jpg)
9
ESDS Loading
• Records are loaded in physical sequence
• VSAM fills each control interval with as many records as will fit
• No provision for distributed free space
• No index
![Page 10: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/10.jpg)
10
ESDS Loading
• Any left over space at end of each CI becomes free space
• This free space is NOT usable in subsequent insertions because all records are added at the end of the data set
![Page 11: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/11.jpg)
11
ESDS Retrieval
• For sequential processing VSAM– retrieves the records in the sequence in
which they are stored in the data set– can also be retrieved in descending order
starting with any record whose RBA is known
![Page 12: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/12.jpg)
12
ESDS Retrieval
• For direct processing VSAM– must be given the RBA of the record to be
read
• RBAs can be kept somewhere, maybe in a table, as the ESDS is being loaded– does not allow for efficient processing of
records by key
![Page 13: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/13.jpg)
13
VSAM ESDS and COBOL
• Processing an ESDS is very similar to processing a KSDS sequentially
![Page 14: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/14.jpg)
14
File-Control for ESDS
File-Control.SELECT file-name
ASSIGN to ddname
ORGANIZATION is SEQUENTIAL
ACCESS MODE is SEQUENTIAL
FILE STATUS is data-name-2.
![Page 15: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/15.jpg)
15
Procedure Division in ESDS Processing
• OPEN statement
• READ statement
• WRITE statement
• REWRITE statement
• DELETE statement
• CLOSE statement
![Page 16: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/16.jpg)
16
ESDS OPEN Statement
• OPEN statement
• Must open all files– Loading sequentially
• OPEN OUTPUT esds-file.
– Retrieving sequentially• OPEN INPUT esds-file.
![Page 17: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/17.jpg)
17
ESDS OPEN Statement
• OPEN statement
• Must open all files– Processing dynamically
• OPEN I-O esds-file.
– Only writing at end• OPEN EXTEND esds-file.
![Page 18: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/18.jpg)
18
ESDS READ Statement
• READ statement (sequential)
READ file-name RECORD [INTO area]
[AT END imperative-1]
NOT AT END imperative-2]
[END-READ]
![Page 19: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/19.jpg)
19
ESDS WRITE Statement
• WRITE statement (sequential)– new records cannot be added to an
existing ESDS by inserting a new record between two existing records
– new records are added only at the end– ESDS file must be opened for EXTEND
which automatically positions at end of the file in preparation
![Page 20: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/20.jpg)
20
ESDS WRITE Statement
• WRITE statement (sequential)
WRITE record-name [FROM area]
[END-WRITE]
– Note: INVALID-KEY cannot be specified in ESDS write operation
![Page 21: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/21.jpg)
21
ESDS REWRITE Statement
• REWRITE statement (sequential)– Used to update existing records in an
ESDS in place– the ESDS must be opened for I-O– the record to be rewritten needs to be the
last record read from the file • must read the record prior to rewriting it
![Page 22: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/22.jpg)
22
ESDS REWRITE Statement
• REWRITE statement (sequential)
REWRITE record-name [FROM area]
[END-REWRITE]
![Page 23: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/23.jpg)
23
ESDS DELETE Statement
• DELETE statement (sequential)– ESDS opened as I-O– delete the record read in the last READ
statement– the space in ESDS is only marked as
deleted, space is not reclaimed
![Page 24: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/24.jpg)
24
ESDS DELETE Statement
• DELETE statement (sequential)
DELETE file-record RECORD
[END-DELETE]
![Page 25: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/25.jpg)
25
ESDS CLOSE Statement
• CLOSE statement (sequential)– list the ESDS that is to be closed
![Page 26: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/26.jpg)
26
RRDS Structure
• Relative Record Data Set– used in conjunction with randomizing or
hashing functions– a record can be accessed either
• sequentially in physical order OR• directly by supplying the relative record number
of the slot that contains the desired record
– processing can be combined in a program between physical sequential and direct
![Page 27: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/27.jpg)
27
RRDS Structure
• Relative Record Data Set– consists of a data component only– contains fixed-length records only– each record is
• contained in a fixed-length slot• addressed by the relative record number of the
slot in which it is stored starting with number 0
![Page 28: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/28.jpg)
28
RRDS Structure
RRDS
Data ComponentRec
1Rec35
Recn………….
0 1 2
Fixed-Length records:
Record 1 in Slot 0
Dummy Rec in Slot 1
Record 35 in Slot 2
etc.
![Page 29: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/29.jpg)
29
RRDS Control Interval
• Each CI is filled with fixed-length slots which contain either– an active record OR– a dummy record
• Slots containing dummy records are available for use in the addition of new records to the file
![Page 30: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/30.jpg)
30
RRDS Control Interval
RRDS
Cont
Info
Rec
B
Rec
E
Dummy
Cont
Info
Rec
F
Rec
A
Rec
C
Cont
Info
Rec
G
Rec
D
Rec
H
Dummy Dummy
Dummy Dummy
DummyDummy
![Page 31: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/31.jpg)
31
RRDS Control Area
RRDS Control Area
Rec
A
Rec
B
Rec
E
Rec
F
RDF
RDF
CIDF
RDF
RDF
CIDF
RDF
RDF
CIDF
Dummy
Dummy
Dummy
Dummy
Dummy
Dummy Dummy
Rec
C
![Page 32: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/32.jpg)
32
RRDS Loading
• Records can be loaded either sequentially or directly
• It is more common to load directly
• Records are loaded using WRITE statement that specifies the relative record number of the slot into which the record is to be placed
![Page 33: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/33.jpg)
33
RRDS Loading
• VSAM– locates the desired slot– verifies that the slot does not contain an
active record– write the record into that slot
![Page 34: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/34.jpg)
34
RRDS Loading
• Free space that exists at the end of each control interval cannot be reused
• There may be available space after the load has been completed– these are dummy records into which no
active record has been loaded
• More space is allocated in an RRDS than other types of VSAM data sets
![Page 35: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/35.jpg)
35
RRDS Loading
• When a randomizing routine is used, there is a possibility of synonyms– two key values hashing to the same slot
number
• An application must make provisions for handling synonyms– beyond the scope of this course
![Page 36: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/36.jpg)
36
RRDS Retrieval
• For direct processing VSAM– the same hashing routine is used to
determine the slot number of the record needed
• The program should then check to make sure that the record key is the correct one
![Page 37: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/37.jpg)
37
RRDS Updating
• RRDS records can be updated while processing the file either sequentially or directly
• VSAM performs a deletion by converting the slot into a dummy record
• VSAM performs an update by finding a dummy record an replacing it with a new active record
![Page 38: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/38.jpg)
38
VSAM RRDS and COBOL
• In processing RRDS, an application must be able to – create an appropriate hashing function and – to handle synonyms
![Page 39: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/39.jpg)
39
File-Control for RRDS
File-Control.SELECT file-name
ASSIGN to ddname
ORGANIZATION is RELATIVE
ACCESS MODE is RANDOM
RELATIVE KEY is data-name-1
FILE STATUS is data-name-2.
![Page 40: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/40.jpg)
40
File-Control for RRDS
File-Control.RELATIVE KEY is data-name-1
– relative key • is NOT in record description• is in Working-Storage Section• is where the slot number is placed prior to
directly accessing an RRDS record
![Page 41: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/41.jpg)
41
Procedure Division in RRDS Processing
• OPEN statement
• READ statement
• WRITE statement
• REWRITE statement
• DELETE statement
• CLOSE statement
![Page 42: 04 - VSAM ESDS and RRDS](https://reader033.fdocuments.net/reader033/viewer/2022061115/5464f37bb4af9f94578b4746/html5/thumbnails/42.jpg)
42
Procedure Division in RRDS Processing
• We are not going into the specifics of the RRDS statements in this class.
• Please read the course notes for more information including pseudocode for processing an RRDS.