04 - Vsam Esds And Rrds

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 04 - Vsam Esds And Rrds as PDF for free.

More details

  • Words: 1,505
  • Pages: 42
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

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)

2

ESDS Structure • Entry-Sequenced Data Set – records can be accessed • sequentially on RBA value • directly by supplying the RBA of desired record

3

ESDS Structure

ESDS 100 byte records: Record 1 RBA = 0 Record 2 RBA = 100

Data Component Rec 1

Rec 2

Rec 3

0

100

200

………….

Rec n

Record 3 RBA = 200 etc. 4

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

5

ESDS Control Interval

ESDS Rec

Rec

Rec

Rec

Rec

Cont

A

B

C

D

E

Info

Rec

Rec

Rec

Rec

Rec

Cont

F

G

H

I

J

Info

Rec

Rec

Rec

Rec

Rec

Cont

K

L

M

N

O

Info

6

ESDS Control Area ESDS Control Area Rec

Rec

Rec

Rec

A

B

C

D

Rec

Rec

Rec

E

F

G

Rec

Rec

H

I

R R R C I D D D D F F F F C I D D D D F F F F

Free R R R Space

F S

Rec

Free

J

Space

R R C I D D D F F F C I D F

7

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

8

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

9

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

10

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

11

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

12

VSAM ESDS and COBOL • Processing an ESDS is very similar to processing a KSDS sequentially

13

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.

14

Procedure Division in ESDS Processing • • • • • •

OPEN statement READ statement WRITE statement REWRITE statement DELETE statement CLOSE statement 15

ESDS OPEN Statement • OPEN statement • Must open all files – Loading sequentially • OPEN OUTPUT esds-file.

– Retrieving sequentially • OPEN INPUT esds-file.

16

ESDS OPEN Statement • OPEN statement • Must open all files – Processing dynamically • OPEN I-O esds-file.

– Only writing at end • OPEN EXTEND esds-file.

17

ESDS READ Statement • READ statement (sequential) READ file-name RECORD [INTO area] [AT END imperative-1] NOT AT END imperative-2] [END-READ]

18

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 19

ESDS WRITE Statement • WRITE statement (sequential) WRITE record-name [FROM area] [END-WRITE]

– Note: INVALID-KEY cannot be specified in ESDS write operation 20

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

21

ESDS REWRITE Statement • REWRITE statement (sequential) REWRITE record-name [FROM area] [END-REWRITE]

22

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

23

ESDS DELETE Statement • DELETE statement (sequential) DELETE file-record RECORD [END-DELETE]

24

ESDS CLOSE Statement • CLOSE statement (sequential) – list the ESDS that is to be closed

25

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 26

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

27

RRDS Structure

RRDS

Fixed-Length records: Record 1 in Slot 0 Dummy Rec in Slot 1

Data Component Rec 1 0

Rec 35 1

………….

Rec n

2

Record 35 in Slot 2 etc. 28

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 29

RRDS Control Interval

RRDS Rec

Dummy Dummy

E Dummy

Rec

Dummy Cont

B Rec

Rec

A

C

Dummy Dummy

Dummy

Info Rec

Cont

F

Info

Rec

Rec

Rec

Cont

H

G

D

Info

30

RRDS Control Area RRDS Control Area Rec

Dummy

A Dummy

C I D D D F F F

Dummy R R

C Rec F

Dummy

Rec

Rec E

Dummy

Rec B

R R C I D D D F F F C I D D D F F F

Dummy Dummy R R

31

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 32

RRDS Loading • VSAM – locates the desired slot – verifies that the slot does not contain an active record – write the record into that slot

33

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 34

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 35

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 36

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 37

VSAM RRDS and COBOL • In processing RRDS, an application must be able to – create an appropriate hashing function and – to handle synonyms

38

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. 39

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 40

Procedure Division in RRDS Processing • • • • • •

OPEN statement READ statement WRITE statement REWRITE statement DELETE statement CLOSE statement 41

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.

42

Related Documents

04 - Vsam Esds And Rrds
November 2019 4
Vsam
November 2019 17
03 - Vsam Ksds And Cobol
November 2019 4
Vsam Programs
November 2019 25
Vsam Status Codes
June 2020 5