• Aucun résultat trouvé

IBM System/3 Disk Concepts and Planning Guide

N/A
N/A
Protected

Academic year: 2022

Partager "IBM System/3 Disk Concepts and Planning Guide"

Copied!
108
0
0

Texte intégral

(1)
(2)
(3)

IBM System/3

Disk Concepts and Planning Guide

(4)

Fourth Edition (December 1975)

r h i s i s a r e p r i n r of Gc21'7s71-2, incorporating technicar newsretter GN2r -5293 d a r e d 1 7 A p r i t 1975.

I n f o r m a t i o n c o n c e r n i n g inquiry and duar programming for the Moder 10 Disk Sys- tem has been removed from this manuar and can now be found in the tBM system/3

Disk system contror Programming Raference Manuar, GC21-75i2; inforrnation concerning inquiry for Model 6 can now be found in the lgM system/3 Modet 6 operation contror Languqe and Disk lJtirity programs Reference Manual. GC21- 7 5 1 6 ; i n f o r m a t i o n c o n c e r n i n g in q u i r y and rollout/rollin for Moder 15 can be founo in the /EMSystemlS Moder r5 system contor prognmming Raference Manuar, G C 2 1 - 5 0 7 7 .

C h a n g e s a r e p e r i o d i c a l l y m a d e to the information herein; before using this publica_

tion in connection with the operation of rgM systems, refer to the ratest rBM System/3 Bibliography, GC2o€O8O, for the edirions that are applicable and c u r r e n t .

Requests for copies of rBM pubtications shourd be made to your rBM representative o r t o t h e I B M b r a n c h office serving your locality.

A Reader',s comment Form is at the back of this publication. lf the form has been removed, comments may be addressed to IBM corporation. pubrications, Depart- ment 245, Rochester, Minnesota 55901.

@ C o p y r i g h t I n t e r n a t i o n a l Business M a c h i n e s C o r p o r a t i o n 1g7 1, 1972, 1974

(5)

P R E F A C E

T h i s m a n u a l d i s c u s s e s t h e d i s k c o n c e p t s a n d p l a n n i n g i n f o r m a t i o n y o u n e e d t o k n o w to d e s i g n c o m p u t e r a p p l i c a t i o n s f o r t h e I B M S y s t e m / 3 M o d e l 6 , M o d e l 1 0 D i s k S y s t e m , a r r d M o d e l 1 5 . T h e b o o k is in t e n d e d f o r p r o g r a m m e r s w h o d e s i g n a p p l i c a t i o n s f o r t h e i r c o m p a n y .

The System/3 Model 8 is supported by System/3 Model 10 Disk System control p r o g r a m m i n g a n d p r o g r a m p r o d u c t s . T h e fa c i l i t i e s d e s c r i b e d i n t h i s p u b l i c a t i o n f o r the Model 10 are also applicable to the Model 8, although the Model 8 is not referred to.

I t s h o u l d b e n o t e d t h a t n o t a l l d e v i c e s a n d fe a t u r e s t h a t a r e a v a i l a b l e o n t h e M o d e l 1 0 a r e a v a i l a b l e o n t h e M o d e l 8 . T h e r e f o r e , M o d e l 8 u s e r s s h o u l d b e f a m i l i a r w i t h the contents ot IBM System/3 Model 8 lntroduction,GC2l-5114.

T h i s m a n u a l a p p l i e s t o t h e s e p r o g r a m p r o d u c t s : o System/3 Model l0 Disk RPG ll (5702-RGl ) o System/3 Model6 RPG ll (5703-RGl) . System/3 Model l5 RPG ll (5704-RGl)

. System/3 Model l0 Subsef ANS COBOL (5702-CBl) . System/s Model l5 ANS COBOL (5704-CBl) . System/3 Model l0 Disk FORTRAN lV (5702-F0l) o System/3 Mooel l5 FORTRAN lV (5704-F0l) . system/3 Modet6 Disk F}RTRAN tv (5703-F0l)

Differences between these RPG ll, COBOL, and FORTRAN programs are noted when applicable, and references are made to related publications.

The chapters of this manual should be read in a specific sequence, as described in How to Use This Publication which follows.

You should be familiar with the IBM System/3 Disk System lntroduction,

GC21-7510, the l8M System/3 ModelS lntroduction, GC21-5114, the l8M System/3 Mod el 6 I ntroduction, G A21 -9122, or the I B M System /3 Model 1 5 I ntroduction, GC21-5094, depending on the system you have.

After completing this manual, you should be able to write basic programs with the aid of various reference manuals. For additional information on processing disk files using RPG ll, see the l8M System/3 RPG ll Disk File Procesing Pro- grammer's G u ide, GC21 -7566.

(6)

HOW TO USE THIS PUBLICATION

This publication has eight chapters and two appendixes;

o Chapters 1 through 5 discuss the basic characteristics of the IBM 5444 Disk Storage D r i v e a n d th e I B M 5 4 4 5 D i s k Storage. a n d d e s c r i b e t h e f o l l o w i n g b a s i c f i l e o r g a n i z a t i o n s

Sequential files I n d e x e d f i l e s D i r e c t f i l e s

Record address files

o Chapters 6 through 8 discuss the considerations for selecting a particular file organiza- tion, how to plan the files to be created, and how to store programs and procedures on disk. lnformation in these chapters is basically the same for the 5444 andS44E, but specific differences are noted.

o Appendix 4 describes the calculations necessary to determine how much d i s k s p a c e a f i l e w i l l r e q u i r e .

' Appendix I describes some performance factors to consider when using in- dexed files.

Chapters 1 through 5 of this manual are for users who need a basic knowledge of how to use disk files. Chapters 6 through I can be read after the reader thoroughly understands the basic concepts discussed in chapters 1 through 5. Appendix A should be read for information about how to calculate file space. Appendix B will help those who plan to use indexed files.

(7)

CONTENTS

C I I A P T E R 1 . D I S K S T O R A G E I B M 5 4 4 4 D i s k S t o r a g e D r i v e I B M 5 4 4 5 D i s k S t o r a g e .

S t o r a g e C h a r a c t e r i s t i c s ( 5 4 4 4 and 5445) . C o m p a r a t i v e A c c e s s T i m e s ( 5 4 4 4 a n d 5 4 4 5 ) C I { A P T E R 2 , S E O U E N T I A L F I L E S

C r e a t i n g a S e q u e n t i a l F i l e P r o c e s s i n g a S e q u e n t i a l F i l e M a i n t a i n i n g a S e q u e n t i a l F i l e

C H A P T E R 3 . I N D E X E D F I L E S C r e a t i n g a n I n d e x e d F i l e P r o c e s s i n g a n I n d e x e d F i l e . M a i n t a i n i n g a n l n d e x e d F i l e C H A P T E R 4 . D I R E C T F I L E S

R e l a t i v e R e c o r d N u m b e r S p i l l f e c h n i q u e C r e a t i n g a D i r e c t F i l e P r o c e s s i n g a D i r e c t F r l e . M a i n t a i n i n g a D i r e c t F i l e M a n i p u l a t i n g D i r e c t F i l e D a t a A c c e s s i n g a F i l e C o n s e c u t i v e l y

L o a d i n g a n d R e t r i e v i n g R e c o r d s in t h e S a m e P r o g r a m C o n r r e c t i n g S t r i n g s o f R e l a t e d R e c o r d s

M e s s a g e O u e u i n g in a S y s t e m / 3 D i r e c t F i l e U s i n E a D i r e c t F i l e f o r L a r g e A r r a y s C H A P T E R 5 . R E C O R D A D D R E S S F I L E S .

F i l e s C o n t a i n i n g R e l a t i v e R e c o r d N u m b e r s ( A D D R O U T F i l e s )

F i l e s C o n t a i n i n g R e c o r d K e y L i m i t s

C H A P T E R 6 . C H O O S I N G A F I L E O R G A N I Z A T I O N U s e o f t h e F i l e

V o l a t i l i t y o f t h e F i l e A c t i v i t v o f t h e F i l e S i z e o f r h e F i l e

C H A P T E R 7 . P L A N N I N G D I S K F I L E S . 4 1

D e s i g n i n g a R e c o r d 4 1

D o c u m e n t i n g R e c o r d L a y o u t 4 4

D e t e r m i n i n g S i z e a n d L o c a t i o n o { a D i s k F i l e I S p l i t C y l i n d e r C a p a b i l i t y (5 4 4 5 ) 5 3

D a t a F i l e S e c u r i t y 5 4

C H A P T E R 8 . S T O R I N G P R O G R A M S A N D

P R O C E D U R E S O N D I S K 5 5

A d v a n t a g e s o f S t o r i n g P r o g r a m s a n d P r o c e d u r e s o n 1

1 5

o

b

9 I 1 0

l z

t c

1 6 2 1 2 1 2 3 2 4 25 2 6 2 6 2 6 2a 29

?n

30

? 1

? ? J 5

36

3 l

D is k

L o c a t i o n o f L r b r a r i e s o n D i s k S o u r c e L i b r a r i e s .

O b j e c t L i b r a r i e s

S t o r i n g P r o g r a m s a n d P r o c e d u r e s i n t o L i b r a r i e s , A P P E N D I X A . C A L C U L A T I N G D I S K F I L E S I Z E

D e t e r m i n i n g N u m b e r o f R e c o r d s i n a F i l e C a l c u l a t i n g R e c o r d S p a c e

D e t e r m i n i n g H o w M a n y T r a c k s a r e N e e d e d - 5 4 4 4 . D e t e r m i n i n g H o w M a n y T r a c k s a r e N e e d e d - 5 4 4 5 C a f c u l a t i n g In d e x S p a c e - 5 4 4 4

C a l c u l a t i n g In d e x S p a c e - 5 4 4 5 F i l e S i z e

C a l c u l a t i n g D i s k F i l e S i z e s - S u m m a r y

A P P E N D I X B . P E R F O R M A N C E C O N S I D E R A T I O N S F O R P R O C E S S I N G I N D E X E O F I L E S .

I n d e x e s

T y p e o f P r o c e s s i n g

H i g h e s t A d d e d K e y S a v e A r e a ( 5 4 4 5 O n l y I M o d e l 6 a n d 1 O ( 5 4 4 5 O n l y )

P r e - S o r t e d In p u t K e y S o r t / K e y M e r g e W o r k F i l e F o r K e y S o r t M o d e l 1 5 ( 5 4 4 4 a n d 5 4 4 5 ) K e y le n g t h

D i s t r i b u t i o n o f A d d e d R e c o r d s

I N D E X F i l e D e s c r i p t r o n E n t r y ( M o d e l 1 5 R P G l l l I NDEX

. 5 5 . 5 6 . 5 7 . 5 8 . 6 1 . 6 3 . 6 3 . 6 4 . 6 4 . 6 4 . 6 5 . 6 7 . 6 8

a a

. 7 6

. t b 7 Q

. 8 6 . 4 7 . 8 8 . 8 8 . 8 8 . 8 9 . 9 0

o l o 1

92

i l l

(8)
(9)

T h e I B M S y s t e m / 3 M o d e l 6 , M o d e l 1 0 D i s k S y s t e m , a n d M o d e l 1 5 c a n u s e t h e I B M 5444 Disk Storage Drive to store information such as nraster, customer, and inventory f i l e s a s w e l l a s p r o g r a m s u s e d o n t h e s y s t e m . IB M 5 4 4 5 D i s k S t o r a g e , o n t h e o t h e r h a n d , . c a n b e a t t a c h e d t o t h e I B M s y s t e m / 3 M o d e l 1 0 D i s k s y s t e m a n d th e I B M s y s t e m / 3 M o d e l 1 5 t o p r o v i d e a d d i t i o n a l s t o r a g e c a p a c i t y ; n o l i b r a r i e s c a n r e s i d e o n t h e 5 4 4 5 .

The major advantages of storing information on disk instead of on cards are:

Large storage capacity. A5444 disk can hold as muclr data as 25,600 96- c o l u m n c a r d s . A l s o , a d i s k p a c k is m o r e c o n v e n i e n t t o h a n d l e t h a n la r g e n u m - bers of cards.

Faster processing rate. A card f ile must be processed in its entirety. even if all the c a r d s a r e n o t n e e d e d . A d i s k fi l e , o n t h e o t h e r h a n d , c a n b e p r o c e s s e d r a n d o m l y ; t h a t is, only the records needed are accessed and processed.

IBM 5444 Disk Storage Drive

The IBM 5444 Disk storage Drive consists of one drive, two disks, ano an access m e c h a n i s m ( F i g u r e 1 ) . T h e lo w e r d i s k is m o u n t e d p e r m a n e n t l y o n t h e d r i v e . The upper disk is removable and can be replaced with other disks. Each disk, w h e t h e r f i x e d o r r e m o v a b l e . i s c a l l e d a v o l u m e .

The access mechanism contains four read/write heads, one for each surface of the two disks. This mechanism moves back and forth across the disk surfaces to posi- tion the heads to read or write data. When the access m€'chanism is in any one position, all four heads are positioned in the same relative location on the four disk surfaces.

Figure 1. IBM 5444 Disk Storage Drive

C H A P T E R 1 . DISK STORAGE

Read/Write Heads (4)

Disk Storage 1

(10)

Each surface of each 5444 disk provides the user with 100 or 200 tracks, depend- i n g o n w h i c h m o d e l o f t h e d i s k s t o r a g e d r i v e y o u h a v e . T r a c k s a r e d i v i d e d i n t o 24 equal parts called sectors; each sector of a track has its own unique address.

Each sector can contain 256 characters (bytes) of data.

Corresponding tracks fronr both surfaces of one disk form a cylinder. These two corresponding tracks can be accessed in a single position of the read/write heads.

2 O 4 c o n c e n t r i c c y l i n d e r s , 1 f o r e a c h set of corresponding tracks on a disk

C y l i n d e r 0 , T o p o f D i s k 1

C y l i n d e r 0 , B o t t o m o f D i s k 1

F o r t h i s e x a m p l e . c y l i n d e r s a r e n u m b e r e d 0 t h r o u g h 2 0 3 , b e g i n n i n g w i t h t h e outer cylinder. IBM cus,tomer engineers use cylinder 203 for diagnostic functions, so this cylinder is not av;ailable for permanent storage. Tracks in cylinders

1 , 2 , a n d 3 a r e u s e d b y l l 3 M p r o g r a m m i n g a s a l t e r n a t e ' t r a c k s w h e n e v e r t r a c k s i n c y l i n d e r s 1 through 2O2are found to be defective; therefore, if IBM programming is being used, cyfinders 1 ,2 and 3 are reserved for use as alternate tracks. Cylinder 0 is used by I B M - s u p p l i e d p r o g r a m m i n g s u p p o r t .

Although there are actu4lly 1O4 or 2O4 tracks per surface depending on which m o d e l y o u h a v e , o n l y 1 ( 1 0 o r 2 0 0 a r e a v a i l a b l e t o t h e u s e r . I n t h i s m a n u a l a n d elsewhere, capacity is re ferred to as either 100 or 200 tracks per surface or 200 or 400 per disk pacl<.

1 S e c t o r ( 2 5 6 characters)

(11)

The IBM 5444 Disk Storage Drive is available in these configurations:

C o n f ig u r a t i o n

N u m b e r o { D r i v s s

N u m b e r o f Disks

N u m b e r o f C y l i n d e r s

Storage Capacity 1

J

4

1 1

2

3 4

100/disk ' 200/disk 200/disk 200/disk

2,457,600 bytes 4,915,200 bytes 7,372,800 bytes 9,830,400 bytes

* M o d e l s 6 a n d 1 0 o n l Y

IBM 5445 Disk Storage

IBM 5445 Disk Storage has one or two drives for the Model 10 Disk System or from one t o f o u r d r i v e s f o r t h e M o d e l 1 5 . E a c h d r i v e u s e s a d i s k p a c k t h a t c o n t a i n s 1 1 d i s k s . T h e upper surface of the top disk and the lower surface of the bottom disk are unused. There are, therefore, 20 usable surfaces. The disk pack is removable.

The access mechanism contains 20 read/write heads for the usable disk surfaces.

This mechanism moves back and forth across the disk surfaces to position the heads to read or write data. When the access mechanism is in any one position, all 20 heads are positioned in the same relative location on the 20 disk surfaces ( F i g u r e 2 ) .

Each surface of each 5445 disk contains 200 tracks. Tracks are divided into 20 sectors; each sector has a unique address, and contains 256 characters (bytes) of data.

D i s k

Figure 2. IBM 5445 Disk Storage

Disk Storage 3

(12)

A 5 4 4 5 c y l i n d e r c o n s i s t s o f a l l t h e t r a c k s o n a d i s k p a c k in o n e v e r t i c a l p l a n e ( F i g u r e 3 ) . S i n c e 2 0 d i s k s u r f a c e s c a n b e a c c e s s e d , a c y l i n d e r i s m a d e u o o f 2 0 t r a c k s . T h e s a m e c y l i n d e r a d d r e s s i s u s e d f o r a l l c o r r e s p o n d i n g t r a c k s i n t h e c y l i n d e r .

l - . ' a r , i n d e r s - | ,

- t n n |

oo

I

I

I

I

T r a c k s i n a C y l i n d e r

I I

I

I

I

1 9

{

C y l i n d e r s 3 - 5 F i g u r e 3 . C y l i n d e r Concept on the IBM 5445

| -

\\:- \ r

(13)

Storage Gharacteristics (5444 and 544b)

Figure 4 shows the relative storage characteristics of the IBM 5444 and IBM 5445 Disk Storage drives.

Comparative Access Times 15444 and il45)

Figure 5 illustrates the access times available on the IBM 5444 Disk Storage Drive (normal and high speed) and the IBM 5445 Disk Storage drive. For more information, see the IBM System/3 Model l0 Components Reference Manual, (GA21-9103) ,the IBM System/3 Model 6 Components Reference Manual, GA34-0001, or the l9M System/3 Model l5 ComponenB Reference Manual (GA21-91 93).

' Models 6 and 10 only

Figure 5. Comparative Access Timee (5444 and 5,4451 Bytes per sector

Sectors per track Bytes per track Tracks per cylinder

Bytes per cylinder Cylinders per disk pack Bytes per disk pack Tracks per disk pack Sectors per disk pack

Maximum number of disk files stored per disk pack

5444 256 24 6144

2 't2,288 r 00/200 1,228,8001 2,457,600

200/400 4800/9600

il45 256

20 51 20 20 1 0 2 , 4 0 0

200 20,480,000

4000 80,000 50

8

50

4 0 ( M o d e l 1 0 ) ; 8 0 ( M o d e l 1 5 ) 2 ( M o d e l 1 0 ) ; 4 ( M o d e l 1 5 1 Maximum number of usable disk surfaces

Maximum number of disk drives

Figure 4. Charsctoristics of the IBM 54F,4 and 5445 Disk Storage Drives

5444 (normal) t 5444 (hiqh speedl 54t15

1 00 cyl 200 cyl

100 cyl

200 cyl

Minimum access time

39 msec 39 msec 28 rnsec 28 msec 25 msec

Average aocess time 153 msec

269 msec

86 msec

126 msec

60 msec

Maximum access time

395 msec 750 msec

1 65 nsec

255 msec 130 msec

Data transfer rate

199,000 bytes/sec 199,000 bytes/sec 312,000 bytes/sec

Rotational speed

15OO RPM

15OO RPM

24OO RPM

Average rotational delay

20 msec 20 msec 12.5 msec

Dirk Storage 5

(14)

C H A P T E R 2 . S E O U E N T I A L F I L E S

A d i s k f i l e c a n b e o r g a n i z e d a n d p r o c e s s e d l i k e a c a r d fi l e . S u c h a d i s k fi l e i s called a sequential file. The sequence of the file can be determined by control fields, such as an employee number or a customer number, or the records may be in no particular sequence. Consecutive processing means that the records are processed one after another in the physical order in which they occur.

An example of a sequential file is an employee master f ile arranged in employee number order and containing information about each employee. When this file is used for processing, such as payroll checks, the records are processed consecutively.

The lowestemployee number is processed firstand so on until the last record, the highest employee number, is processed.

A s e q u e n t i a l f i l e m a y s p a n m u l t i p l e d i s k v o l u m e s . ( A v o l u m e r e f e r s t o o n e d i s k p a c k . A m u l t i v o l u m e f i l e i s a f i l e t h a t is c o n t a i n e d o n m o r e th a n o n e d i s k p a c k . ) A multivolume file, however, affects the processing of your file. For information on processing considerations when using multivolume sequential f iles, see the discussion on multivolume files in Chapter 6.

Creating a Sequential File

You create a file when you write the records onto a disk for the first time. The records in a sequential file are placed on the disk consecutively; that is, they are written on the disk in the order in which they are read. All tracks in one cylinder a r e fi l l e d fi r s t , th e n a l l t r a c k s i n t h e n e x t c y l i n d e r , a n d s o o n u n t i l th e w h o l e fi l e i s p l a c e d o n t h e d i s k .

Figure 6 shows an example of this process using a5444. In this example, each record is 128 positions (bytes) long. Since each track can contain 6144 bytes of data,48 records can be written on each track; 96 records can be written on each cylinder. The numbers on the tracks in Figure 6 correspond to the number and position of each record.

Processing a Sequential File

Sequential files can be processed consecutively or randomly by relative record number. Normally the file is processed consecutively because a sequential file is usually used when all the records in the file are to be processed.

Sometimes, however, you may want to process only certain records in the file.

Consecutive processing can be time-consuming in this case, because allthe records must be processed or at least read. lt would be faster to process the records ran- domly by a number related to the position of the records in the file. This number is called a relative record number. lf your sequential file is in order by control fields and there are no missing or duplicate records, the contents of the control fields can be used as relative record numbers. For more information on this type of processing, see Random Processing by Relative Record Number in Chapter 4.

(15)

T o p T r a c k s

n d C y l i n d e r

B o t t o m T r a c k s

F i r s t C y l i n d e r

= 124 F i g u r e 6 . W r i t i n g R e c o r d s on a Disk

Maintaining a Sequential File

Once you create a file. you must maintain it. File maintenance means performing those functions that keep a file current for daily processing needs. Four file main- tenance functions affect or apply to sequential files:

Adding records

Tagging records for deletion Updating records

Reorganizing a file

Adding Records

Records can be added to a file after the file has been created. When records are added to a sequential file, they are written at the end of the file. Thus, the file is extended by the added records.

Sometimes, however, the new records must be merged between the records al- ready in the file. This may be necessary in order to keep the file in a particular order when the control fields of the new records are not higher in sequence than those already in the file. In order to put the new records in the proper sequence, you must sort the file to create a new file containing the added records. Another technique would be to merge the new records into the proper place in the original file during a copy to a new file.

Note: Adding records to a sequential file is not supported by COBOL. A FORTRAN program must read all existing records first, and then begin writing.

1 .

2 . 3.

4.

S e q u e n t i a l F i l e s 7

(16)

Tagging Records for Deletion

when a record becomes inactive, you wiil no ronger want to process it with the other records. A record cannot be physically removed from the file during regular processing; therefore, it is necessary to identify or tag the record so it can be by- passed.

one way to tag such a record is to put a code, calred a derete code, in a particular location in the record. when the fire is processed, your program can check for the derete code; if the code is present, the program can bypass that record.

Updating Records

when you update records in a fire, you can add or change some data on the record.

For exampre, in an inventory fire you might want to add the quantity of items re- ceived to the previous quantity on hand. The record to be updated is read into storage, changed, and written back on the disk in its original rocation.

Reorganizing a File

when several records in a fire have been tagged for deretion, you shourd physicaily remove them from the file. This will free disk space. You can remove the inactive records by copying the records to be retained onto another disk area.

(17)

I n s o m e d a t a p r o c e s s i n g a p p l i c a t i o n s y o u m a y n o t w a n t t o p r o c e s s y o u r f i l e c o n - s e c u t i v e l y . C o n s e c u t i v e p r o c e s s i n g i s t i m e - c o n s u m i n g i f y o u o n l y w a n t t o p r o c e s s certain records in the file. lt is faster to skip the records not needed in a job and p r o c e s s o n l y t h e r e q u i r e d o n e s . A n i n d e x e d fi l e a l l o w s th i s t y p e o f p r o c e s s i n g . /Vote.' This chapter and any other discussions of indexed files in this manual do n o t a p p l y t o F O R T R A N ; i n d e x e d fi l e s a r e n o t s u p p o r t e d b y F O R T R A N .

An indexed file is organized into two parts: an index and the data records. The i n d e x c o n t a i n s a n e n t r y f o r e a c h r e c o r d in t h e f i l e . Y o u c a n g o t o t h e i n d e x , f i n d the location of the record, go to that location, and {ind the record you want.

Under certain conditions up to three types of indexes may be used. These index types a r e g i v e n s p e c i f i c n a m e s in t h i s m a n u a l to e l i m i n a t e c o n f u s i o n . T h e f i r s t , a n d m o s t u s e d , index is referred to as the file index. In some cases when using the 5445, the system may generate an index (on disk) known as the drsk track index. Still another type of in- dex, used to improve performance, isthecore index. For more information on these three indexes, see Appendix B.

E a c h e n t r y i n t h e f i l e i n d e x d e s c r i b e s a r e c o r d in t h e f i l e . T h e r e i s a n e n t r y i n t h e f i l e i n d e x f o r e a c h r e c o r d in t h e f i l e . F o r e x a m p l e , if a f i l e i n d e x h a s 2 0 0 0 e n t r i e s , t h e f i l e contains 2000 records. The first part of the entry contains the record's key field.

E a c h e n t r y ( k e y ) i n t h e k e y f i e l d c o n t a i n s d a t a t h a t u n i q u e l y i d e n t i f i e s t h e r e c o r d . F o r example, the customer number may be the key field for a customer master record. The second part of the f ile index entry contains the drsk address of the record. The disk address represents the location on the disk where the record is stored. The file index is arranged in ascending sequence according to the key field in each record.

A n i n d e x e d f i l e c a n b e a m u l t i v o l u m e f i l e . W h e n p r o c e s s i n g a n i n d e x e d f i l e . h o w e v e r , y o u m u s t c o n s i d e r t h e e f f e c t t h a t m u l t i v o l u m e fi l e s w i l l h a v e o n f i l e p r o c e s s i n g . F o r i n f o r m a t i o n o n p r o c e s s i n g c o n s i d e r a t i c l n s w h e n u s i n g m u l t i v o l u m e in d e x e d f i l e s . s e e t h e d i s c u s s i o n o n m u l t i v o l u m e f i l e s in C h a p t e r 6 .

Creating an lndexed File

When you create an indexed file for RPG ll, the records in the file can be in an

ordered or an unordered sequence; when creating an indexed file for COBOL, however, the records must be in ascending sequence, as determined by their keys.

An ordered sequence means the records are arranged in order according to some major control field used as the key field. An unordered sequence means the records are in no particular order.

An inventory file loaded according to frequency of use is an example of an unordered file. The most active items are at the beginning of the file. When the file is used to write customer orders, most of the records needed are located in a small area of the file rather than scattered throughout the entire file. This reduces the total time it takes to process the records because the access mechanism does not have to move back and forth across the whole disk to access the required records.

CHAPTER 3. I N D E X E D F I L E S

l n d e x e d F i l e s I

(18)

W h e n a n i n d e x e d fi l e i s c r e a t e d , th e f i l e i n d e x i s created as the records are written on disk.

l f t h e f i l e i s a n o r d e r e d fi l e , t h e f i l e i n d e x i s i n t h e correct sequence w h e n t h e r e c o r d s a r e w r i t t e n . l f t h e f i l e i s a n u n o r d e r e d fi l e , t h e system automatically sorts the file index into ascending sequence after all the records in the file have been loaded. (The time

r e q u i r e d f o r s o r t c a n b e r e d u c e d if t h e s p e c i a l w o r k f i l e $ l N D E X 4 4 o r $ l N D E X 4 5 i s a v a i l a b l e . )

The file index area precedes the area where records are placed on a disk. For example, s u p p o s e t h e f i l e i n d e x f o r a c e r t a i n fi l e r e q u i r e s f i v e t r a c k s . T h e ' f i l e i n d e x e n t r i e s w o u l d b e w r i t t e n o n t h e f i r s t f i v e t r a c k s o f t h e f i l e . R e c o r d s w o u l d be written beginning i n t h e f i r s t s e c t o r o f t h e s i x t h t r a c k . B o t h t h e f i l e i n d e x area and the record area must s t a r t a t t h e b e g i n n i n g o f a t r a c k .

T o p Track o f F i r s t C y l i n d e r

Bottom Track o f T h i r d C y l i n d e r

For indexed files on the 5445, another type of index is created when the file index uses m o r e th a n 1 5 t r a c k s . T h i s a d d i t i o n a l i n d e x . w h i c h p r e c e d e s t h e f i l e i n d e x . i s k n o w n a s the drbk track index. Each entry in the disk track index refers to one track of the file index. The disk track index will be used by the system only if its use will improve per- formance. See Appendix B for more information on this subject.

Processing an Indexed File

Indexed files are not limited to consecutive processing; they can be processed several ways because the file index provides several ways to find records.

Sequential Processing by Key

When an indexed file is processed sequentially by key, the records are processed in the order of the key fields. This method is used to process all records in a file, regardless o f t h e i r o r d e r .

1 0

(19)

To illustrate this processing method, note the similari ties and differences between F i l e A a n d F i l e B i n F i g u r e 7 . B o t h f i l e s c o n t a i n t h e s r a m e r e c o r d s , a n d b o t h f i l e indexes are in order according to the key field. The dlifference between the two files is the order of the records. The records in File A, are in order according to k e y f i e l d ; t h e r e c o r d s i n F i l e B a r e u n o r d e r e d . A l l r e c ; o r d s i n e i t h e r fi l e c a n b e processed in order if you specify the processing as secluential by key.

F i l e A

F i l e l n d e x

10 I 20 | 3ol 40 I 50 | 60 | 70

Fiila B

F i g u r e 7 . E x a m p l e o f a n O r d e r e d a n d a n U n o r d e r e d F i l e

Sequential Processing Within Limits

A n o t h e r w a y t o s e q u e n t i a l l y p r o c e s s a n i n d e x e d fi l e i s s e q u e n t i a l l y w i t h i n l i m i t s , a m e t h o d in which records are processed in groups.

/ V o t e ; C O B O L s u p p o r t s s t a r t i n g k e y ( l o w e r l i m i t ) p r o c e s s i n g o n l y . U p p e r l i m i t p r o c e s s i n g , i f d e s i r e d , m u s t b e p r o v i d e d i n y o u r C O B O L s o u r c e p r o g r a m . T h e l i m i t s f o r a n R P G l l object program can be supplied by a limits iecord or the lower limit can be set in your pro'

g r a m . F o r m u l t i v o l u m e fi l e s , th i s t y p e o f p r o c e s s i n g l a p p l i e s o n l y t o M o d e l 1 5 .

A s a n e x a m p l e o f s e q u e n t i a l p r o c e s s i n g w i t h i n l i m i t s , s u p p o s e t h a t a w h o l e s a l e c o m p a n y prepares monthly statements of each customer's charges. Each customer is assigned a 5 - d i g i t n u m b e r ; th e f i r s t d i g i t r e p r e s e n t s t h e r e g i o n th e c u s t o m e r is i n a n d t h e r e m a i n i n g four digits represent the customer's number. The company's customers are divided into four regions. allowing monthly statements to btr sent each week to the customers i n o n e o f t h e r e g i o n s . R e g i o n 1 c u s t o m e r s ( 1 0 0 0 0 - 1 1 1 9 9 9 ) a r e b i l l e d t h e f i r s t w e e k of the month. region 2 customers (20000-29999) the second week, and so on. The statements, therefore. are processed sequentially within limits'

F o r i n f o r m a t i o n o n p r o c e s s i n g a n i n d e x e d fi l e s e q u e n t i a l l y w i t h i n l i m i t s , s e e Chapter 5 in this manual'

Records

Records F i l e I n d e x

t 0

n

30 40 50 60

x

l n d e x e d F i l e s 1 I

(20)

Random Processing

Indexed files can arso be processed randomry. This type of processing, cailed random by key, permtts processing of one particular record without regard to i t s r e l a t i o n to o t h e r r e c o r d s .

when you process a fire randomry by key, you specify the key of the record you w a n t . T h e k e y i s f o u n r J in the file index; the disk address (adjacent to the key) i s then used to rocate the record so the record can be transferred to storage for processi ng.

Processing an Indexed File Ocnsecutively

I n d e x e d fi l e s c a n b e p r o c e s s e d ( r e a d ) c o n s e c u t i v e l y b y d e f i n i n g th e i n d e x e d fi l e as a s e q u e n t i a l i n p u t f i l e i r n th e F i l e D e s c r i p t i o n specifications. when an indexed file is processed consecutivery, the f ire index is bypassed and data records are pro_

c e s s e d c o n s e c u t i v e r y f r o m t h e b e g i n n i n g o f t h e f i r e t o t h e e n d , a s if i t w a s a se- q u e n t i a l fi l e . N o t e that indexed fires can not be created, added to, or updated consecutively.

A n e x a m p l e o f u s i n g c o n s e c u t i v e p r o c e s s i n g o f a n i n d e x e d f i l e i s r e a d i n g re c o r d s f r o m a n i n d e x e d fi r e w h e n the fire index is unusabre f o r s o m e r e a s o n .

M a i n t a i n i n g a n I n d e x e d File

A f t e r t h e f i l e i s c r e a t e d , yo u c a n use these fire maintenance functions to keep the f i l e c u r r e n t f o r d a i l y p r o c e s s i n g n e e d s :

Adding records

Tagging records for deletion Updating records

R e o r g a n i z i n g a f i l , e

Adding Records

When a record is added to an indexed file, it is written at the end of the records a l r e a d y in t h e f i l e . R e c o , r d s c a n b e a d d e d e i t h e r s e q u e n t i a l l y b y k e y o r r a n d o m l y by key. When records are added randomly by key (the records to be added need not be in any particurar sequence) or sequentiaily by key, the system checks to ensure that the record is not a duplicate of a record already in the file; if the record i s n o t a d u p l i c a t e . it w i l l b e added to the fire.

The file index entry for the added record is written at the end of tne current entries in the index area. After all the records are added, the keys of the added records and the keys of the original records are sorted or merged, so that the keys cf all records i n t h e f i l e a r e i n a s c e n d i n g s e q u e n c e i n t h e f i r e i n d e x . a s f o i l o w s :

2.

3.

4 .

1 2

(21)

F i l e I n d e x E n t r y

( k e y f i e l d and disk address) Before Additions

D u r i n g A d d i t i o n s

After Additions

lf many records are to be added to the file, the time required for the index sort/merge can be decreased by allocating a special work file. This requires no special RPG ll coding but does require that the llFlLE statement be included in the OCL statements, and that the special file name $lNDEX44 or $lNDEX45 be specified. See the IBM System/3 Model 10 Disk System Control Programming Reference Manual lGC21-75121 , the I8M System/3 Model 6 Operation Control Language and Disk Utility Programs Reference Manual (GC21-7516), or the IBM System/3 Model 15 System Control Program- ming Reference Manual (GC21-5077), for more information concerning these require-

ments.

Tagging Records for Deletion

Inactive records in an indexed file must be handled like inactive records in a sequential file. Since the record is not removed from the file during regular processing, you must identify or tag the record so it can be bypassed. To do this. put a code called a delete code in a particular location in the record; a delete code cannot be put in the key field.

When the file is processed, your program can check for the delete code; if the code is present, the program can bypass that record.

K e y F i e l d s

1 M 2 D3 J D5 D2 6 D1

1 Bl 2 D3 3 o5 4 D6 5 D2 6 D2

I n d e x e d F i l e s 1 3

(22)

Updating Records

When you update records in a file. the records to be updated are read into storage, c h a n g e d , a n d w r i t t e n b a c k o n t h e d i s k i n t h e i r o r i g i n a l lo c a t i o n s . R e c o r d s in an indexed f i l e c a n b e u p d a t e o :

l . S e q u e n t i a l l y b y k e y R a n d o m l y b y k e y S e q u e n t i a l l y w i t h i n li m i t s

f t / o t e . ' C O B O L s u p p o r t s s t a r t i n g k e y ( l o w e r li m i t ) p r o c e s s i n g o n l y ; u p p e r

l i m i t p r o c e s s i n g , i f d e s i r e d , m u s t b e p r o v i d e d in y o u r c o B o L s o u r c e p r o g r a m . T h e l i m i t s f o r a n R P G l l o b j e c t p r o g r a m c a n b e s u p p l i e d b y a l i m i t s f i l e , or the lower limit c a n b e s e t i n y o u r p r o g r a m .

R e c o r d s a r e u s u a l l y u p d a t e d s e q u e n t i a l l y b y k e y w h e n y o u w a n t t o u p d a t e a l l t h e records in the file. Each record is updated in order.

T o u p d a t e y o u r f i l e r a n d o m l y b y k e y , y o u s p e c i f y th e k e y y o u w a n t . This key is then found in the file index so the desired record can be located and moved into storage for updating.

F o r a d i s c u s s i o n o n u p d a t i n g a n i n d e x e d fi l e s e q u e n t i a l l y w i t h i n l i m i t s , s e e C h a p t e r 5 i n t h i s m a n u a l .

Reorganizing a File

I t m a y b e n e c e s s a r y a t t i m e s t o r e o r g a n i z e y o u r i n d e x e d fi l e i n o r d e r r o t n c r e a s e p r o - c e s s i n g e f f i c i e n c y a n d f r e e d i s k s p a c e . T h i s c a n b e d o n e b y p h y s i c a l l y m e r g i n g added

records in sequence with the records originally created, and by removing records tagged f o r d e l e t i o n .

F o r e x a m p l e , s u p p o s e a n i n d e x e d fi l e w a s c r e a t e d w i t h t h e r e c o r d s in a s c e n d i n g k e y field order. Since that time, several records were added to the file. These records w e r e a d d e d a t t h e e n d o f t h e f i l e , b u t t h e f i l e i n d e x i s i n s e q u e n t i a l o r d e r b y k e y f i e l d . W h e n t h e f i l e i s p r o c e s s e d s e q u e n t i a l l y b y k e y , t t t e d i s k a c c e s s a r m m u s t m o v e b a c k a n d forth between the sequenced records (those originally created) and the added records.

T h i s s i t u a t i o n o f t e n i n c r e a s e s p r o c e s s i n g t i m e f o r a p a r t i c u l a r j o b . D u r i n g r e o r g a n i z a t i o n , the added records can be placed in sequence.

As records are added to a file, the space reserved for the file becomes filled. Reorganizing is a means of freeing space since inactive records, those with a delete code, can be physi- c a l l y r e m o v e d .

A f i l e i s r e o r g a n i z e d b y c o p y i n g t h e o l d f i l e i n t o a n e w d i s k a r e a . D u r i n g t h e c o p y , deleted records can be removed from the file. Records previously added to the o l d f i l e w i l l b e c o p i e d in t o t h e n e w f i l e i n s e q u e n c e w i t h t h e o r i g i n a l re c o r d s . T h e s p a c e p r e v i o u s l y o c c u p i e d b y t h e o l d f i l e c a n t h e n b e u s e d to c o n t a i n n e w d a t a .

2.

3.

(23)

A direct file is a file on disk in which records are assigned specific record positions.

Direct file organization enables you to directly access any record in the file without examining other records or searching an index. Thus, in some processing situations, direct file organization has advantages over sequential and indexed organizations.

Figure 8 shows direct file organization. Records are assigned specific locations, independent of the order they are put into the file. All records put into the file have record locations, although not all locations contain records. The specific location in the file assigned to a record is determined from a control field in the record. Re- cords can be scattered throughout the file, depending on the distribution of the con- trol fields. The unused record locations contain blanks.

Direct files may span multiple disk volumes. when a direct file is processed, however, all volumes containing portions of the file must be mounted on the disk drives, since every record in the file must be accessible (in other words, the entire file must be online). Therefore, multivolume direct files ons444 disk drives are limited to two v o l u m e s w i t h a s i n g l e d i s k d r i v e (o n e f i x e d v o l u m e a n d o n e re m o v a b l e v o l u m e ) a n d four volumes with dual disk drives (two fixed volumes and two removable volumes).

M u l t i v o l u m e d i r e c t f i l e s o n 5 4 4 5 d i s k d r i v e s a r e li m i t e d t o t w o v o l u m e s f o r t h e M o d e l 1 0 o r f o u r v o l u m e s f o r t h e M o d e l 1 5 . F o r m o r e i n f o r m a t i o n o n p r o c e s s i n g c o n s i d e r a t i o n s w h e n u s i n g m u l t i v o l u m e d i r e c t f i l e s , s e e t h e d i s c u s s i o n o n m u l t i v o l u m e f i l e s i n C h a p t e r 6 .

Control F i e l d

Unused Record L o c a t i o n s ( b l a n k s ) F i g u r e 8 . D i r e c t F i l e O r g a n i z a t i o n

C H A P T E R 4 . D I R E C T F I L E S

i ' i

O i r e c t F i l e s 1 5

(24)

Relative Record Number

ln a direct file, a record is written and retrieved directly by specifying the location o f t h e r e c o r d in r e l a t i o n to t h e b e g i n n i n g of the file. This relative position is called t h e r e l a t i v e r e c o r d n u m b e r . T h e r e l a t i v e re c o r d n u m b e r is not a disk address, b u t i s a positive, whole number that is converted by disk system management to the disk address of the record to be accessed.

Deriving the Relative Record Number

A r e l a t i v e r e c o r d n u m b e r i s s i m i l a r to t h e k e y of an indexed file or the control infor- m a t i o n i n a s e q u e n t i a l f i l e ; i t i s d e p e n d e n t u p o n a s p e c i f i c fi e l d ( c o n t r o l field) in the r e c o r d . T h e c o n t r o r f i e r d c a n e i t h e r b e u s e d directry (without change) as a rerative record number or it can be mathematically converted to provide an acceptable re- lative record number.

Direct Method

An easy way to derive relative record numbers is to have them correspond directly to the control fields in the records. Because the control information need not be c o n v e r t e d i n t o a r e l a t i v e r e c o r d n u m b e r . m a n i p u l a t i o n a n d p r o g r a m m i n g a r e kept t o a m i n i m u m . F o r e x a m p l e . in F i g u r e g , the record with a 1 in the control f ield becomes relative record number one; the record with a 5 becomes relative record number five, and so forth. This method is practical where control numbers can be assigned on a sequential basis. such as employee numbers for payroll records, student numbers in a school. and customer numbers for customer files.

S u p p o s e a s m a l l c o l l e g e h a s a n e n r o l l m e n t o f 5 . 0 0 0 s t u d e n t s . A master student file is m a i n t a i n e d w h i c h i n c l u d e s c u r r e n t l y e n r o l l e d s t u d e n t s a n d g r a d u a t e s f o r t h e l a s t tw o years. The master file contains approximately 7,000 records. Each student is assigned a 6 - d i g i t fi l e n u m b e r a s f o l l o w s :

7\e3e7 i

Expected '7ear I

of graduation I

A u n i q u e i d e n t i f i c a t i o n n u m b e r f r o m 1 - 9 9 9 9

T h e i d e n t i f y i n g n u m b e r s a r e a s s i g n e d o n a s e q u e n t i a l b a s i s ; n u m b e r s re t i r e d fr o m t h e m a s t e r fi l e a r e a v a i l a b l e f o r r e a s s i g n m e n t .

A direct file with 10,000 record locations is used for the stuclent master file, satisfying a need for fast access to each student's record. Since the identifying numbers range between 1 and 9999 and there are no duplicates, the relative record n u m b e r is t a k e n d i r e c t l y f r o m t h e s t u d e n t fi l e n u m b e r . Figure 9 shows relative record numbers taken from the student file number being used to update student addresses.

' t 6

(25)

Student Addres F i l e

Control F i e l d

R E I I T J O H N H R R z

1 5 ' 6 r r a ' 9 t 0 r r 2 : r : r .

G L E N C O E r M I N N

a 2

l

B

2 l

a

I N N

! ! 5 . 5 t 5 6 t t

I H N S O N r J M A I N g T

3 l l r 3 ! ! G r ' , a J r . o L A K E T O

E L M S T U T L L V I O

R C E R I J A C Q U E S B I R O N C I T Y T M I N N

R B E R T F 3 1 6 E , u I N N

Diroct Student M a s t e r F i l e

i:*H)-'

8006 8007 8008

F i g u r e 9 . R e l a t i v e R e c o r d Numbers Corresponding Directly to a Control Field

Conversion Method

Conversion refers to any technique for obtaining a desirable range of relative record numbers from the control fields of the records. The conversion method must be used when the values in the control fields cannot be used directly as relative record numbers. For example, employee numbers in a factory range from 0001 to 1500, but only 450 numbers are in use since numbers belonging to employees who have retired or terminated have not been reused. A file large enough for 1500 records i s n o t n e e d e d ; t h e r e f o r e , a t e c h n i q u e m u s t b e f o u n d fo r c o n v e r t i n g t h e e m p l o y e e numbers to approximately a 1 through 500 range (which would provide 50 locations f o r f i l e e x p a n s i o n ) .

f+t

tril

D i r e c t F i l e s 1 7

(26)

when the conversion method is used, every possible control field in the f ile must convert to a relative record number in the allotted range (in this case, I through b00), and the resulting relative record numbers should be distributed evenly across the af lotted range so that there are few synonym records. synonym records are rwo or more records whose control fields yield the same relative record number, but contain different data (see the next section, synonym Recordsl. your program must allow for synonyms if they are generated.

A way to convert the range of employee numbers from 1500 to b00 is to divide the employee number by 3 and drop the remainder (thus 3 becomes 1; 6 becomes 2;

1500 becomes 500). However, there is a possibility of having synonym records. For example, if the numbers 6, 7, and 8 are present, all three become relative record number 2 .

Another technique that may produce fewer synonyms is to divide the employee number by 2 and drop the remainder. This compresses 1500 numbers to 7s0. There are 300 unused locations in this case, rather than 50.

A third method would be to divide the employee number by 499 (500 - 1). and use the remainder + 1 as the relative record nUmber,

lf there is no sequence to numbers in a control field (such as part numbers), a conversion technique that produces random numbers can be used. The resulting numbers should be distributed evenly within the selected range (depending upon the number of record locations needed), and should be suitable as relative record numbers (positive, whole numbers). one such technique is squaring the number in the control field and selecting certain digits from the resulting number as the relative record number. The calculation must be performed every time the program must seek a record, For example, suppose you have part numbers that consist of six d i g i t s . w i t h c e r t a i n d i g i t s h a v i n g a s p e c i a l m e a n i n g . N o t w o p a r t n u m b e r s a r e a l i k e . The part number is squared and, of the resulting digits, only four are used as the relative record number for the parts inventory file.

Part number = 4681 52 4€81 52 x 4681 52 = 21 91166-t6ls1 04

Relative record number = 6629

Since four digits are selected. random numbers from 1 to gggg could be developed.

Therefore, a file containing 10,000 record locations should be provided for the parts inventory.

Even the technique used in the example above is likely to produce synonym records, since the selected four digits of the square of two different part numbers can be

identical. lf a conversion technique produces too many synonyms, it may be necessary to f ind a different technique.

1 8

(27)

Synonym Records

Two or more records whose control f ields yield the same relative record number are called synonym records. Synonyms have the same relative record numbers, but con- tain different data. Since only one synonym record can be stored in the record location for its relative record number. a different method must be found to store and retrieve the other synonym records.

Chain Technique

O n e w a y t o h a n d l e s y n o n y m s i s to c h a i n (l i n k ) th e m to g e t h e r s o th a t a l l c a n b e f o u n d b y locating the first. The first record is stored in the record location indicated by its relative record number. That location is called the home location; the record placed there is called the home record. The first synonym (second record) is stored in the first unoccu- pied record location in the file (a location for which no relative record number had been d e v e l o p e d ) . T h e r e l a t i v e r e c o r d n u m b e r o f t h e s e c o n d l o c a t i o n i s th e n s t o r e d i n t h e h o m e r e c o r d ; t h a t i s , th e f i r s t s y n o n y m i s li n k e d to t h e h o m e re c o r d . T h e s e c o n d s y n o n y m , i f present. would be stored in the next unoccupied record location and would be linked to t h e f i r s t s y n o n y m , a n d s o fo r t h . I n F i g u r e 1 0 , a l l r e c o r d s t h a t a r e s y n o n y m s a r e lo a d e d into the file after records that can be stored in their home location have been loaded.

L o a d i n g t h e r e c o r d s i n t h i s m a n n e r s i m p l i f i e s t h e p r o g r a m m i n g b e c a u s e t h e c o d i n g f o r l o a d i n g s y n o n y m r e c o r d s c a n b e d o n e i n a s e p a r a t e p r o g r a m . T h e c h a i n t e c h n i q u e i s useful when a file is created, but tends to be of less value as records are added to or de- l e t e d f r o m a f i l e .

U n o c c u p i e d L o c a t i o n s

l \

S y n o n y m I , A d d e d

S y n o n y m B, Added

Record I contains location o f s y n o n y m 8 r .

S y n o n y m I , c o n t a i n s lo c a t i o n o f s y n o n y m I , Home

Location

A B 3

8 1

I

l u

D

B z

G H

I

1 2 3 4 5 6 7 8 I 1 0

F i g u r e 1 0 . S t o r i n g S y n o n y m R e c o r d s i n a D i r e c t F i l e

D i r e c t F i l e s 1 9

(28)

l f a n e w r e c o r d is a d d e d to t h e f i l e , but its home location is already occupied by a s y n o n y m , f o r a d i f f e r e n t r e c o r d lo c a t i o n , the new record must be treated as a syno- n y m f o r i t s h o m e l o c a t i o n . F i g u r e 1 1 shows the file that resulted from the addition o f s y n o n y m s in F i g u r e 1 0 . T h e h o m e l o c a t i o n fo r r e c o r d c is occupied by a synonym f o r r e c o r d B , s o r e c o r d c i s p l a c e d in the first unoccupied location. Since record B1 i s a l r e a d y li n k e d t o r e c o r d B 2 , r e c o r d c must be linked through 82 to its home loca- t r o n .

Record C is relative record number 3, but location 3 is already occupied. Therefore, record C must be placed in the first avail- a b l e l o c a t i o n .

Figure 11. Storing a Record When lts Home Location ls Occupied

W h e n y o u p r o c e s s a d i r e c t f i l e c o n t a i n i n g s y n o n y m s , y o u m u s t v e r i f y e v e r y r e c o r d r e t r i e v e d . F o r e x a m p l e , w h e n y o u r e t r i e v e re l a t i v e record 3 from the file in Figure 11.

y o u g e t r e c o r d 8 1 , w h i c h i s a synonym for relative record2, which is not the rer:ord you w a n t . H o w e v e r , if y o u c h e c k t h e r e c o r d r e t r i e v e d , y o u f i n d t h a t i t i s a s y n o n y m r . Y o u c a n n o w c h a i n th e r e l a t i v e re c o r d lo c a t i o n , if a n y , i n d i c a t e d b y the first record:rnd re- t r i e v e th e s e c o n d re c o r d . Y o u c a n c o n t i n u e th i s p r o c e s s u n t i l y o u f i n d t h e r e c o r d y o u w a n t o r u n t i l t h e c h a i n o f s y n o n y m s e n d s . I n t h i s c a s e , y o u c o u l d e v e n t u a l l v h a v e a n e r r o r c o n d i t i o n b e c a u s e t h e r e q u e s t e d r e c o r d is n o t i n t h e f i l e .

A s i m i l a r m e t h o d f o r h a n d l i n g s y n o n y m s is t o s e t a s i d e a p o r t i o n of the f ile for synonym records' Suppose, for example, a f ile for 8500 records is set up to provide relative record n u m b e r s b e t w e e n 0 a n d 9 9 9 9 . B y a c t u a l l y s e t t i n g a s i d e e n o u g h area for 1 1,000 records, a n y s y n o n y m s d e v e l o p e d c a n b e s t o r e d in r e c o r d lo c a t i o n s f r o m 1 0 , 0 0 0 t o 1 0 , 9 9 9 .

Relative record numbers G9999 S y n o n y m

records

9999 10,000 10,999

1 0

\

A

I

B 1 3 I

I

B t 5 D

I

p l A

- 2 l "

I

c

G H J

D i r e c t F i l e

20

(29)

The relative record number of a synonym is stored in the home location, and a c h a i n o f s y n o n y m s i s b u i l t a s in t h e p r e v i o u s m e t h o d .

)

A

B

I

110000 ,1111;1..r.1.i1i1111ifi+.'+fl " i.ro-'[$ ]Hfl Bl

D l

10,000 10,001

-

Synonyrrs Processing by this method is faster when records must be added to a file because

a home location is kept free for every relative record number; only one seek operation is required for records without synonyms. However, this method wastes more file space, because 11,000 locations are used for 8500 records.

Spill Technique

A n o t h e r m e t h o d o f h a n d l i n g s y n o n y m r e c o r d s , t h e s p i l l t e c h n i q u e . u s e s t h e h o m e l o c a t i o n a s a s t a r t i n g p o i n t . W h e n t h e f i l e i s f i r s t l o a d e d , a c o u n t e r i s s e t t o i n d i c a t e t h e m a x i m u m n u m b e r o f r e a d s w h i c h w o u l d b e n e c e s s a r y f o r l o c a t i n g a g i v e n s y n o n y m r e c o r d . ( F o r e x a m p l e , t h e c o u n t e r w o u l d b e s e t t o 3 i f t h e m a x i m u m number of synonyms for a given home address were 3.) To retrieve a record from t h e f i l e , y o u w o u l d f i r s t n e e d to d e t e r m i n e th e h o m e r e c o r d lo c a t i o n a n d r e a d th e record from that address. lf it isn't the record you want. you read the record in the n e x t l o c a t i o n in t h e f i l e . T h i s o r o c e s s c o n t i n u e s u n t i l t h e c o r r e c t r e c o r d i s s e l e c t e d f r o m t h e f i l e . l f t h e m a x i m u m n u m b e r o f r e a d s (3 i n t h e e x a m p l e , a b o v e ) is r e a c h e d . a record-not-found condition exists.

When a record is to be added to a file, you first check the location at the home a d d r e s s . lf t h i s l o c a t i o n in d i c a t e s t h a t t h e h o m e r e c o r d h a s a s y n o n y m , y o u i n c r e - m e l t t h e r e l a t i v e r e c o r d n u m b e r b y o n e . a n d c o n t i n u e to c h e c k f o r s y n o n y m s , u n t i l a n a v a i l a b l e s p a c e i s f o u n d . A t t h a t p o i n t y o u w o u l d a d d t h e n e w r e c o r d t o t h e file. lf the number of times you incremented the relative record number exceeds t h e c o u n t y o u s e t u p f o r t h e m a x i m u m n u m b e r o f r e a d s , t h e c o u n t w o u l d b e i n c r e - m e n t e d b y o n e ( i n t h e e x a m p l e , th e c o u n t w o u l d b e s e t t o 4 ) .

O t h e r m e t h o d s fo r h a n d l i n g s y n o n y m s c a n b e d e v i s e d . W h a t e v e r t h e m e t h o d u s e d , plan on extra accesses for synonym records and extra coding in order to verify the recoros.

C r e a t i n g a D i r e c t F i l e

T o c r e a t e a d i r e c t f i l e , y o u m u s t d e f i n e a d i s k f i l e a s : a c h a i n e d o u t p u t f i l e ( f o r R P G l l ) ; a r a n d o m o u t p u t f i l e ( f o r C O B O L ) ; o r , a d i r e c t a c c e s s f i l e ( f o r F O R T R A N ) . I n t h i s w a y , t h e f i l e i s u n i q u e l y id e n t i f i e d to d i s k s y s t e m m a n a g e m e n t a s a d i r e c t f i l e . D i s k s y s t e m m a n a g e m e n t t h e n a l l o c a t e s d i s k s p a c e f o r t h e f i l e , a n d t h e e n t i r e f i l e s p a c e i s e r a s e d t o b l a n k s . T h i s a c t i o n , in e f f e c t , c r e a t e s d u m m y r e c o r d s w h o s e length is determined by the creating program- Once the file has been cleared, one o r m o r e s u b s e q u e n t j o b s c a n b e r u n t o r e a d r e c o r d lo c a t i o n s w h i l e l o a d i n g th e f i l e . The method you use to write data records on the file depends on whether or not y o u m u s t c h e c k fo r s y n o n y m s a m o n g th o s e r e c o r d s .

D i r e c t F i l e s 2 1

(30)

whether or not you must check for synonyms. relative record numbers are used in your program to make the corresponding record locations available for loading. Re- cords are loaded into the file in an update mode by f irst chaining the record to a given record location according to its relative record number, and then by ourput- ting the new record into that record space. The relative record number is the sequence number of that record within the file. The data used as a relative record number can come from a field in the input record, or it can be created in your pro- gram.

Creating a Direst File Without Synonyms

lf you do not have synonyms, you can load records into a direct file in a single pass. In this case, record locations are not inspected before they are filled with data. lf a synonym is encountered, it is written over the previous record and the previous record is lost.

Creating a Direct File With Synonyms

lf you have synonyms, you can create a direct file by using more tnan one pass to load records into the file. The exact method you use depends on your scheme for handling synonym records (see Synonym Recordsl.

(31)

Processing a Direct File

Direct f iles can be processed in three ways:

1 . Consecutively

R a n d o m l y b y r e l a t i v e r e c o r d n u m b e r

Randomly by ADDROUT file (see Chapter 5. Record Address Filesl

Consecutive Processin g

D i r e c t fi l e s a r e o f t e n u s e d w h e r e th e a c t i v i t y o f a f i l e i s l o w a n d d i r e c t i n q u i r y o f t h e f i l e i s n e c e s s a r y . H o w e v e r , w h e n t h e a c t i v i t y o n a d i r e c t f i l e i s h i g h f o r c e r t a i n jobs, such as writing a report where the entire file is listed, you may want to process t h e f i l e c o n s e c u t i v e l v .

C o n s e c u t i v e p r o c e s s i n g o f d i r e c t f i l e s i s s i m i l a r to c o n s e c u t i v e p r o c e s s i n g o f s e q u e n t i a l f i l e s . R e c o r d lo c a t i o n s a r e p r o c e s s e d o n e a f t e r a n o t h e r u n t i l e n d o f j o b r e q u i r e m e n t s a r e m e t . T h e d i r e c t f i l e h a s n o n e x t a v a i l a b l e r e c o r d ( E O F ) p o i n t e r i n t h e l a b e l . A s a r e - s u l t , c o n s e c u t i v e p r o c e s s i n g w i l l a c c e s s t h e e n t i r e f i l e s p a c e b e f o r e th e l a s t r e c o r d ( L R ) c o n d i t i o n o c c u r s . R e m e m b e r t h a t a d i r e c t f i l e i s c l e a r e d t o b l a n k s w h e n i t i s c r e a t e d , a n d r e c o r d lo c a t i o n s n o t f i l l e d r e m a i n b l a n k . T h u s , i n c o n s e c u t i v e p r o c e s s i n g , b l a n k r e c o r d lo c a t i o n s w i l l b e r e a d a l o n g w i t h t h o s e c o n t a i n i n g d a t a . Y o u r p r o g r a m s h o u l d c h e c k f o r b l a n k r e c o r d lo c a t i o n s a n d b y p a s s t h e m s o t h a t o n l y v a l i d r e c o r d s a r e p r o c e s s e d . W h e n r e t r i e v i n g a n d u p d a t i n g a d i r e c t f i l e c o n s e c u t i v e l y , y o u a l s o m a y w a n t t o c h e c k e a c h r e c o r d fo r s y n o n y m s a n d t h e n h a n d l e th e s y n o n y m s d i f f e r e n t l y f r o m o t h e r r e c o r d s . However, since consecutive processing does not depend on relative record numbers, a d i r e c t f i l e c a n b e p r o c e s s e d c o n s e c u t i v e l y w i t h o u t r e g a r d { o r s y n o n y m s .

Random Processing by Relative Record Number

R e m e m b e r t h a t r a n d o m p r o c e s s i n g o f i n d e x e d fi l e s i s a c c o m p l i s h e d b y u s i n g th e c o n t r o l f i e l d v a l u e ( r e c o r d k e y ) t o s e a r c h a n i n d e x . l f a m a t c h i s f o u n d , t h e r e c o r d a t t h e d i s k l o c a t i o n c o n t a i n e d in t h e i n d e x e n t r y c a n b e a c c e s s e d . T h e c o n t r o l f i e l d v a l u e , th e r e f o r e , i s n o t r e l a t e d to t h e a c t u a l lo c a t i o n o f t h e r e c o r d o n d i s k . W h e n p r o c e s s i n g r a n d o m l y b y r e l a t i v e r e c o r d n u m b e r , h o w e v e r , t h e r e l a t i v e r e c o r d n u m b e r i s u s e d b y d i s k s y s t e m m a n - a g e m e n t t o c a l c u l a t e t h e d i s k l o c a t i o n o f t h e r e c o r d . N o i n d e x a r e a a n d i n d e x s e a r c h a r e r e q u i r e d , s i n c e th e c o n t r o l f i e l d v a l u e is d i r e c t l y r e l a t e d to t h e r e c o r d lo c a t i o n . T h e r e f o r e , random processing by relative record number can be faster than random processing by key o f a n i n d e x e d fi l e . l f a l a r g e n u m b e r o f s y n o n y m s e x i s t i n t h e f i l e , h o w e v e r , re t r i e v i n g a r e c o r d b y l o c a t i o n m a y r e q u i r e m o r e e x t e n s i v e p r o g r a m m i n g , a n d a n i n c r e a s e i n t h e average number of seeks per record due to synonyn"!s.

R e c o r d s c a n b e p r o c e s s e d e i t h e r i n a n o r d e r e d o r a n u n o r d e r e d m a n n e r . P r o c e s s i n g o f r e c o r d s in o r d e r a c c o r d i n g t o r e l a t i v e r e c c l r d n u m b e r i s u s u a l l y fa s t e r th a n u n o r d e r e d p r o c e s s i n g s i n c e le s s n r o v e m e n t o f t h e d i s k a c c e s s m e c h a n i s m i s r e q u i r e d . F i g u r e 1 2 s h o w s th e s t e p s in v o l v e d in r a n d o m p r o c e s s i n g o f a d i s k f i l e b y r e l a t i v e r e c o r d n u m b e r . l n t h e f i g u r e , r e l a t i v e r e c o r d n u m b e r s a r e o b t a i n e d fo r c o n t r o l f i e l d s in t h e i n p u t r e c o r d s ; h o w e v e r , t h e y c o u l d a l s o b e g e n e r a t e d b y y o u r p r o g r a m . R a n d o m r e t r i e v a l i n c l u d e s s t e p s o n e , t w o , a n d t h r e e in t h e f i g u r e ; r a n d o m u p d a t e in c l u d e s a l l f i v e steps.

2 .

D i r e c t F i l e s 2 3

(32)

o

R e c o r d i s t h e i n p u t

read from f i l e

I I I

It

€) n.rr,il record number from the input r€cord clntrol field ir used to chain to the disk fite.

\ \ - -

R e l a t i v e

Oisk File R e c o r d N u m b e r t . F

2 3 4 5

Figure 12. Random Processing by Relative Record Number

Maintaining a Direct File

Three file maintenance functions can be used to are created:

1. Adding records

2. Tagging records for deletion 3. Updating records

@ *",r, information is inserted in the record if update is indicated.

keep direct files current after they

Updated disk is written.

r->g 8 e ro

'9

I I

Références

Documents relatifs

The AC power cord connector and fuse are found at the bottom right of the back panel on all drive models.. To change the voltage selection, flip the small circuit board and

With the newly created copy of the original CP/M source diskette in the floppy drive, simultaneously

4.2.3.4 Read Sector (011) - This function is used to locate a desired track and sector and transfer the contents of the data field to the jLCPU controller sector buffer..

• Core image library, system source statement library, small private relocatable library (on the operational pack) and private relocatable library.. Job control is

Note that the actual update of the directories and the system status report are delayed until completion of the execution of PRO GB, when /&amp; is read. From a

SYMBOLIC ADDRESSING OF INPUT/OUTPUT DEVICES The DPS programs use symbolic addresses to refer to input/output (I/O) devices. These symbolic I/O device addresses

The control card deck is divided by END cards into logical files, each of which initiates one function of the Core and Tape Dump program. Control infor- mation entered

These replacement pages remain in effect for subsequent versions and modifications unless specifically altered... See Column 7 under Field Descrip- tian Specifications tor