ENCRIBE

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

ENSCRIBE

ENSCRIBE is an utility provide by TANDEM to create data


files.

Features on ENSCRIBE
 Has five file structures.
 Has two formats; 1 & 2.
 Partitioned files; also called as multiple-volume files.
 Relational access among files.
 Optional automatic maintenance of all keys.
 Optional key compression in key sequenced data or index
blocks.
 Optional compression of audit checkpoints records.
 Record locking and file locking facilities.
 Cache buffering.
 Optional sequential block buffering.
Disk File Organization:
A file can be created in two ways.
- using FILE_CREATE_ procedure
- using FUP CREATE command.
You should also specify the file type when u create a
file.
A file can be designated as Temporary or
Permanent.
CONTROL-21 procedure call is used by the
application process to allocate one or more extents as well
as to de-allocate the unused extents.

Unstructured Files:
- a large byte array.
- usually a code file or edit file; not data file.
- data’s in the file is accessed by the relative byte
address(RBA), RBA is an offset from the first byte in the
file which is zero.
File:
A collection of related records, which are physically
organized as a number of extents.

Sector:
The smallest unit of disc I/O or physical addressing. (512
bytes in length)

Extents:
A unit of storage allocation in a file, which is contiguous
space on disc. (2048 byte pages).

Block:
Unit of physical I/O. Contains one or more logical record
plus some control information about the records. It is specified
as no. of bytes. (512, 1024, 2048, 4096).

Key:
A value associated with a record and which is used to
uniquely identify the record in the database or in a file.
Structure Files:
- four type of structure files: Key sequenced, Entry
sequenced, Queue, Relative files.
- Data transfer b/n files and the process is done in terms
of logical records and records keys.
- These files are created using several TANDEM softwares
like DDL, ENFORM and ENABLE.

Partitioned Files:
- max no. of extents in partitioned file is 16 extents.
- a file can reside entirely in one or more volumes.
- up to 16 partitions are allowed with each up to 16
extents.
- entire file is open using FILE_OPEN_ procedure.
- the file system rejects any attempts to open the secondary
partition unless unstructured access is specified.
- can accommodate more locks, can reside in multiple
caches which can result in fewer disk access.
- all partitions has to be either audited or not audited, they
can’t be mixed. MAXEXTENTS and Vol. Name are only things in
which they can differ. Primary & secondary partitions can differ
within same partition.
Access Coordination:
- it specifies which operations are to be performed on a file.
- it specifies read/write, read only or write only access to a
file.
- exclusion mode specifies how much access is granted to
other process.
- exclusion mode are shared, exclusive or protected.
- both access mode and exclusion mode are applied to the
file from the time it is opened to it is closed.
- two locking mode are provided: - File and Record
locking.
- Locking provides concurrent access to a disk file for short
period of time.

Wait & No wait I/O:


- it allows an application process to execute concurrently
with its file operation by means of nowait I/O.
- default is waited I/O; when designated file operations are
performed, application process is suspended until the operation
completes.
- Nowait I/O; application process is not suspended, it
executes concurrently with the file operations.
Operations on Files:
- Creating files:
- programmatic creation disk files is accomplished by
supplying the appropriate parameters to the
FILE_CREATE_ or FILE_CREATELIST_ procedure.
- using FUP commands SET, RESET and SHOW
- FUP ALTER command allows you to change the file
parameters after file is created.

- Describing record formats (DDL):


- DDL provides a uniform method of describing
record formats, regardless of the programming language u
use to access record.

- Loading Files:
- FUP is used to load files into ENSCRIBE software.
- “loading factor”, it determines how much free space
to leave within the block.
- Manipulating Records:
- manipulation of records in a file is done using “Record
Management Functions” like WRITEUPDATE, WRITE, READ,
KEYPOSITION and etc.

Error Numbers:
0 = (CCE) No error.

1-9 > (CCG) Warning.

10-255, < (CCL) Error.


512-32767

300-511 < (CCL) Application defined error.

File Code:
- file code are assigned while creating a file.
- it is used to categorize file according to the kind of information
they contain.
- you can assign an arbitrary numeric file code.
- default file code is “0”, 100 to 999 are reserved for system.
File Creation:
The following are the parameters for creating a file:
 File Code:
 Disk extents size.
 Audit check-point compression.
 Write verification.
 Format of files (whether format 1 or format 2).

Types of File in ENSCRIBE:


 Unstructured Files.
 Key sequenced Files.
 Queue Files.
 Entry sequenced Files.
 Relative file.
Unstructured Files:
- An Unstructured file is a large byte of array on disk that
starts at byte address zero and continues sequentially
upwards as specified by EOF.
- Usually created by EDIT or TEDIT utilities; as well as
using FILE_CREATE_ or by using FUP.
- They are used by application programmers as
intermediate storage of fixed length data records that are
accessed sequentially.
- Access to the data is done using RBA (Relative Byte
Addressing).
- GPC like READ[X], WRITE[X] and READUPDATE[X] are
used for manipulation of these unstructured files.
- Possible Access of Access: - Sequential access, Random
access and Appending at the EOF.
- Important parameter to consider when creating
Unstructured files: Buffer Size and Disc Extent Size.
Example for Unstructured File:
> volume $QNB.SAMPLE
> FUP
--set type U
--set code 1234
--set ext (6250,2500)
--set buffersize 512
--
--show
TYPE U
CODE 1234
EXT (6250 PAGES, 2500 PAGES)
BUFFERSIZE 512
MAXEXTENTS 16
--create FILE1
CREATED - $QNB.SAMPLE.FILE1
Example for creating Partitioned Unstructured File:
> volume $QNB.SAMPLE
> FUP
--set type u
--set code 1234
--set ext (6250, 2500)
--set part (1, $QNB1, 6250, 2500)
--set part (2, $QNB2, 6250, 2500)
--set part (3, $QNB3, 6250, 2500)
--set buffersize 512
--show
TYPE U
CODE 1234
EXT (6250 PAGES, 2500 PAGES)
PART (1, $QNB1, 6250, 2500)
PART (2, $QNB2, 6250, 2500)
PART (3, $QNB3, 6250, 2500)
MAXEXTENTS 16
BUFFERSIZE 512
--create FILE2
CREATED - $QNB.SAMPLE.FILE2
Accessing Unstructured Files
- accessed using “File Pointers”.
- there are three file pointers
Current Record Pointer.
Next Record Pointer.
EOF Pointer.
- both Current and Next Record Pointer points to the first
RBA(zero) when the Unstructured File is opened.
- Current & Next Record Pointer resides in the Access
Control Block (ACB) in the application process
environment.
Key – Sequenced Files
- Key sequenced file consist of variable length records that are
accessed by the values within the designated key fields.
- two types of Keys:
- Primary keys
- Alternate Keys (optional).
- records in KSF are stored based on Primary Key fields in
ascending order.
- maximum size of a KSF is (Block Size – 32).
- types of access for KSF
- Sequential Access.
- Random Access.
- Data’s in KSF are stored internally as B-tree structure
containing Data Block, Index Block and Data Records.

- Data Block: contains Header and one or more data records.


- Index Block: contains an entry for each Data Block; which is
the Key Field of the 1st record in Data Block and Address of that
Data Block.
- Splitting: occurs for BLOCK and INDEX; when the size or
content exceeds the max size of the Block or Index.
Creating KSF:
- using FUP
- using FILE_CREATE_ procedure call.

File Format:
Format 1: A logical record can be up to (Block size - 34 Bytes)
long.
Format 2: A logical record can be up to (Block size – 56 Bytes)
long.

Primary Keys:
- When u specify a primary, u need to give the “OFFSET” and
the LENGTH of the key field.

File Creation:
The following types of KSF files can be created.
- Key sequenced file.
- Key sequenced with alternate keys.
- Key sequenced format 2 with alternate keys.
- Alternate key file.
- Partitioned key sequenced file.
Blocking Factor:
Blocking factor decides how many records will be stored in the
block of block size you specified.
N = (block-size – 32) / (record-size + 2)

Ex: Creating Key-Sequenced File (with alternate keys)


> FUP
--set type K
--set code 1000
--set ext (5000, 2000)
--set format 2
--set rec 150
--set block 2048
--set compress
--set keylen 34
--set altkey (“LO”, keyoff 42, keylen 4)
--set altkey (“VN”, keyoff 46, keylen 8)
--set altfile (o, AFILE)
--CREATE FILE3
CREATED - $QNB.<subvol>.FILE3
CREATED - $QNB.<subvol>.AFILE
Queue Files:
- it is a special type of Key-Sequenced File which can function
as Queue.
- Process can Queue and De-queue the records in queue file.
- it record format is also Variable format.
- Primary key for queue file is 8 byte Timestamp; plus a user
key if desired.

Features of Queue Files:


- Protection against data loss along with TMF.
- Flexible ordering of records, default is FIFO.
- Record level locking.
- Notification when new records are added.
- Access by multiple requester or queuing processes.
- Queue files are shared b/w multiple write process and one
read process.
Restriction on queue files:
- cannot be SQL files.
- cannot define alternate keys or partitions for queue files.
Type of Access for Queue File:
- Random Access.
- Sequential Access.

Queue File Structure:


- physically organised as one or more bitmaps and a B-
tree structure of Index and Data Block.

Primary Key in Queue Files:


- usually a 8 byte TIMESTAMP.
- can contain user defined key.
- Need to specify keylen as 8 while creating a queue file.
If user defined key is needed, specify the keylen which
contains the space for timestamp too.
- Offset should be specified as zero for queue file.
User Key 8 byte Data
(optional) Timestamp
Creating a Queue file with FUP:
> FUP
--set type K
--set code 1001
--set QUEUEFILE
--set ext (20,10)
--set maxextents 64
--set keylen 10
--set rec 100
--set audit
--create QFILE
--
Entry - Sequenced File:
- contains variable length records.
- used for sequential access.
- records added to this file will be appended to the end of
file.
- primary key in ESF is 4 byte records byte address.
- access to this file is only Sequential, but random access
can be made.
- ESF is created using FUP command and using system
procedure calls.
- Maximum no. of records that can be stored in a block is
For Format 1:
N = (block-size – 22) / (record-size + 2)

For Format 2:
N = (block-size – 44) / (record-size + 4)

- Entry sequenced file can contain Alternate Keys.


Creating an Entry Sequenced File:
> FUP
--set type E
--set ext (1000, 500)
--set rec 60
--set block 4096
--show
TYPE E
EXT ( 1000 PAGES, 500 PAGES )
REC 60
BLOCK 4096
--create EFILE
CREATED - $QNB.<subvol>.EFILE
Relative Files:
- it consist of fixed length physical records.
- data’s are accessed by “relative record number”.
- relative file are suited for the application where random access
to fixed length records are required.
- a relative file contains fixed length physical records but the
data can be of variable size data record.
- the position where u want to write a new record is done by
specifying the “record number” to the FILE_SETPOSITION_
procedure call.
- types of access: using primary key which is RBA and using
alternate key.
- three major pointers here are:
Current Record Pointer.
Next Record Pointer
EOF Pointer.
Ex: > FUP
--set type R
--set ext (60,30)
--set rec 112
--set block 4096
--create RFILE.
File Loading:
- Loading into a file is done using FUP command
LOAD and LOADALTFILE.
- LOAD command loads data into existing structured
file without affecting any related alternate-key file.
- when loading into KSF, slack space and the
order(sorted or unsorted) is specified.

Slack space: a percentage of data block and index block


space left for future insertions.

- LOADALTFILE generates alternate key records from


a specified key file.

EX: > FUP


--VOLUME $QNB.<subvol>
--LOAD $TAPE , PARTFILE
File and Record Locking:
- Locks help to maintain Data Inconsistency as well as
concurrent access to data.

Locking Mode:
Normal mode: It is the default locking mode. Any attempt
to lock the file which is locked by different file number, or
any attempt to alter it, is suspended unless the existing
lock is released.
Reject mode: Similar to above, but instead of suspending it
throws an error &#.
Read-through Normal mode: Data can only be read
through but cannot be altered.
Read-through Reject mode: Similar to above statement.
Read Warn Normal Mode and Read Warn Reject Mode:
Through a warning code of 9 when reading that locked
record or file.
File Locking:
File level locking is done using the procedure call
LOCKFILE and UNLOCKFILE.

Record Locking:
Record level locking is done using LOCKREC, READLOCK
and READUPDATELOCK.
Unlocking is done using UNLOCKREC.

Generic Locking:
Using generic locking “sets of records within the key
sequenced file whose key start with the same character
sequence can be locked”.
Done using SETMODE 123 procedure call.

Generally File Lock take precedence to the Record Lock


Locking Limits:
Locking limits are enforced by disc process through
SYSGEN functionality.

Deadlocks:
Occurs when multiple process require multiple records
locks or file lock at the same time.

You might also like