0% found this document useful (0 votes)
973 views

Day 2 - S3 S4 - Introduction To Jbase Database1

Uploaded by

alasad parvez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
973 views

Day 2 - S3 S4 - Introduction To Jbase Database1

Uploaded by

alasad parvez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Introduction to jBase Database

Day 2

Session 3&4
Induction Trainings

Introduction to jBase Database


Objectives

At the end of the session you will have


` Adequate knowledge to understand
• File types in jBase

` Adequate knowledge to create


• Non hashed files
• j4 files

` Adequate knowledge to work on


• j4 files

2 Thesys Training Centre

Slide 2
Table Structure In Any RDBMS
Table Structure In Any RDBMS

Table Name : EMPLOYEE

3 Thesys Training Centre

Slide 3
Employee Table When Stored In
jBASE

ƒ The data file contains only data records


ƒ The dict file contains the field names and their attributes
ƒ The dict name will usually be <Data File Name>]D
ƒ The data and the dict file may reside under different directories. VOC links the data and
the dict file together

4 Thesys Training Centre

Slide 4
Slide 4
Supported File Types
ƒ Non Hashed Files
jBASE 4 Sequential files
Non Hashed Files Unix level directories
Used to store programs
Hashed Files
Type = UD

ƒ Hashed Files
Store and retrieve data randomly
Improve performance
Needs to be resized when it
overflows
Type = J4

5 Thesys Training Centre

Slide 5
Creating Non Hashed Files
` Use the CREATE.FILE command to create a non hashed file

` Data file name : TEST.NON.HASHED


` Dict file name : TEST.NON.HASHED]D
` The data as well as the dict file are created as operating system level
directories
` It is equivalent to creating operating system level directories as follows

6 Thesys Training Centre

Slide 6
Non Hashed Files (Cont.)

` Read and write into such files are sequential


` Used to store
• Programs
• Messages that are posted by interfaces

` Can be created under any directory (Use the ‘cd’ command and change to
any directory and issue the CREATE.FILE command, the data and the dict
files will get created under that directory)
` The data and the dict files can be created separately using the following
commands

7 Thesys Training Centre

Slide 7
Hashed Files

` Use the CREATE.FILE command to create a hashed file

` Data file name : TEST.HASHED.FILE


` Dict file name : TEST.HASHED.FILE]D
` The data as well as the dict file are created as operating system
files

8 Thesys Training Centre

Slide 8
Understanding The Parameters For A
Hashed File

` TYPE=J4 – Signifies that the file is a hashed file


` 3,2,2
• 3 – Number of modulo of the dict file
• 2 – Separation of the dict file
• 2 – Secondary buffer size of the dict file

` 4,2,2
• 4 – Number of modulo of the data file
• 2 – Separation of the data file
• 2 – Secondary buffer size of the data file
9 Thesys Training Centre

Slide 9
Hashed Files – Internal Storage
Dict File
Hashed : – Internal Storage
Files
TEST.HASHED.FILE
Modulo 0 Modulo 1 Modulo 2
Size:4096 * 2 Size:4096 * 2 Size:4096 * 2
Modulo is otherwise called a frame or
a bucket.
The size of each modulo by default is
4096 Bytes in j4
Data File :
Separation is otherwise called the
TEST.HASHED.FILE
multiplying factor for modulo
Modulo 0 Modulo 1 Modulo 2 Modulo 3
Size:4096 * 2 Size:4096 * 2 Size:4096 * 2 Size:4096 * 2 Separation enables us to increase the
size of a frame
Default value of separation is 1, of not
specified in the CREATE.FILE
command

10 Thesys Training Centre

Slide 10
Working Of Hashed Files – How Data Is
Written To Hashed Files
Writes a record Writes a record
with ID 1 with ID 2
Result
Frame 0

Hashing algorithm is used to Result


calculate the frame in which the Frame 1
record needs to be stored
based on the ID and the total
number of frames in the file

Frame 0 Frame 1 Frame 2 Frame 3

Record 2 Record 1

Hashed File :
TEST.HASHED.FILE

J4 always stores data evenly across frames


11 Thesys Training Centre

Slide 11
Working Of Hashed Files – How Data Is
Read From Hashed Files
User opens an
existing record
with ID 1

Hashing algorithm calculates the frame J4 reads through the Group1 (Frame 1)
based on the ID and the total number
Result sequentially until it finds record with ID 1 and
Frame 1
of frames in the file then returns the record to the user

Frame 0 Frame 1 Frame 2 Frame 3

Record 2 Record 1

Hashed File : TEST.HASHED.FILE

12 Thesys Training Centre

Slide 12
What Happens When All Frames Are
Full?
Writes a record
with ID 15

Hashing algorithm calculates the Frame in Result


which the record needs to be stored
Frame 0 Frame 0 is full
based on the ID and the total number of
Frames in the file
Record 14 Record 6 Record 8
Frame 90
Record Frame 10
Record 1 Frame 11
Record 2 Frame 73
Record
Record 5 Record 3 Record4 Record 12
Record 15
Record 2 Record 1 Record 13 Frame 4
Frame 0 Frame 1 Frame 2 Frame 3
Hashed File : TEST.HASHED.FILE

When a frame is full and j4 is unable to store data in that frame, a new frame gets created and added to the end of the
existing frames. The record gets stored in the new frame and the main frame holds a pointer to the new frame created.
Whenever j4 calculates the frame number in which the record needs to be stored, it will only take into account the primary
frames (0 – 3 in this case)
When record 15 needs to be fetched, the hashing algorithm will return a value saying that the record is in frame 0. j4 will
then search for the record sequentially in frame 0, if not found, will use the pointer, get to Frame 4 and search sequentially
in Frame 4 until it finds the record.
13 Thesys Training Centre

Slide 13
When A Huge Record Is To Be Written
To The File? What Happens
` What is considered a huge record?
` A record is considered huge when the size of the record exceeds the size
of the ‘Secondary Buffer Size’

` Secondary buffer space calculation


• Size of one frame * Secondary Buffer Size value
• (4096 *2) * 2 = 16384 Bytes

Default size of one frame Separation Secondary Buffer Size Parameter

Only when the size of a record is greater than 16384 bytes,


will a secondary buffer space be created to store the new data

14 Thesys Training Centre

Slide 14
What Happens When A Huge Record Is To
Be Written To The File?
Writes a record
with ID 16

Hashing algorithm calculates the Result


frame in which the record needs to Size of the record
Frame 0
be stored based on the ID and the is 17000 Bytes.
total number of frames in the file
Record 14 Record 6 Record 8
Frame 09
Record Frame 110
Record Frame 211
Record Frame
Record37
Record 5 Record 3 Record 4 Record 12
Record 2 Record 1 Record 13 Record 14
Frame 0 Frame 1 Frame 2 Frame 3 Frame 4
Size = 4096*2
Hashed File : TEST.HASHED.FILE
When the size of a record to be stored is large, then a secondary buffer space is
created
Size of the secondary buffer size : Size of the frame * 2
Record 16 The new record is stored in the secondary buffer space and the original frame
Secondary
holds a pointer to the secondary buffer space
Buffer Space The secondary buffer area/space can be created anywhere in the disk. Not
15
necessary adjacent to the primary frames
Thesys Training Centre

Slide 15
Hashed Files – Points To Remember

` Keep seperation to the minimum


• Higher the separation, higher will be search time within a frame as the read
within a frame is sequential

` How do we decide the best separation


• Follow the thumb rule – Don’t store more than 10 to 20 records in a frame. More
the records in a frame, higher will be the search time

` When ever data gets stored in the secondary buffer space (When the
record is huge) or when data gets split over to other frames other than the
primary, file access will become slow
` J4 always spreads and stores records evenly across all frames

16 Thesys Training Centre

Slide 16
Listing Contents Of Files

` List contents of hashed as well as non hashed files, use the LIST
command

17 Thesys Training Centre

Slide 17
Clearing/Deleting Files

` Clear contents of hashed as well as non hashed files, use the


CLEAR.FILE command

` Delete a hashed or a non hashed file, use the command DELETE.FILE

18 Thesys Training Centre

Slide 18
Clearing/Deleting Files (Cont.)

` Contents of data and dict files can be cleared separately

` Data and dict files can be deleted separately

19 Thesys Training Centre

Slide 19
Workshop

` Create a non hashed file XXX.TRG.NON.HASHED where XXX is your


name
` Create a hashed file XXX.TRG.HASHED where XXX is your name
` List the contents of the hashed and the non hashed files that you just
created
` Clear the contents of the hashed and the non hashed files that you just
created
` Delete the hashed and the non hashed files that you just created

20 Thesys Training Centre

Slide 20
File Maintenance

` You know that file access will become slow when


• Data spills over to frames that are not primary frames
• Data spills over to the secondary buffer space

` How do we prevent performance degradation which arise due to improper


file size?

` Solution : Analyze and resize files periodically. Based on the frequency of


file updates, files need to be analyzed and resized

21 Thesys Training Centre

Slide 21
jstat – Command To Analyse A Hashed
File
` Options

22 Thesys Training Centre

Slide 22
Using jstat To Obtain File Information

Line 1 : Displays the relative path of the file with the actual name of the file. Files
could have truncated names because of file name length restriction imposed by Unix.
Line 2 : Displays the type of the file(J4). The default hash method for all jBASE-
hashed files is 4 that is what is specified in ‘Hash Method’.
Line 3 : Groups : Number of primary frames
Frame Size : Represents the size of 1 frame. Here the size of 1 frame is 4096 bytes.
Therefore the separation would have been 1 when the file was created .
Secondary Buffer Size : Represents the size of the secondary buffer size. The value
is 8192 Bytes which is twice the size of 1 frame. Therefore when the file was created
the secondary buffer size specified would have been 2.
When the file was created or last resized, the valued would have been
Type=J4, Frame = 9, Separation = 1 and Secondary buffer size = 2.
23 Thesys Training Centre

Slide 23
Using jstat To Obtain File Information
(Cont.)
Line 4 :
Record Count : Specifies the total number of records in the file at
present
Record Bytes : Specifies the total number of bytes occupied by the file
at present

Line 5 :
Bytes/Record : Specifies the average size of 1 record
Bytes/Group : Specifies the average size of 1 frame at present

Primary File Space : Total number of frames (Actual frames specified


when the file was created or last resized + frames that got created due
to lack of space in the existing frames)

Secondary File Space : Total number frames that were allocated to


store records that are bigger than the secondary record size

24 Thesys Training Centre

Slide 24
File Maintenance In jBASE
` Resize the file FBNK.ACCOUNT
• Optimum number of records in one frame is 10 to 20
• Number of records per frame = Size of a frame/ Average size of a
record
4096/387 = 11 (Approx) – We are well within the optimum
• If 1 frame can store11 records, how many frames do we need to store
2001 records?
2001/11 = 200 (Approx)
` Resize the file now

jrf –S201 ../mbdemo.data/ac/FBNK.ACCOUNT

` Always keep into account the frequency in which you will be


resizing the file and hence allocate some extra space when
resizing
` Always specify an odd number or a prime number for the
frame. Else j4 will automatically convert the frame number to
25
the nearest possible prime or odd number
Thesys Training Centre

Slide 25
File Maintenance In jBASE

` You can also downsize a file using jrf

jrf –DS<Modulo> <Path and name


of the file>

26 Thesys Training Centre


Analyze The Statistics Of The File
When A Huge Record Is Written
` Assume that the file TEMENOS.HAHSED has just been created and
contains no data

27 Thesys Training Centre

Slide 27
Analyze The Statistics Of The File When A
Huge Record Is Written (Cont.)
` Now, insert a record that is lesser than the size of one frame (Size should
be lesser than 4096 bytes) and view the statistics of the file

` Note that the secondary file space parameters are empty

28 Thesys Training Centre

Slide 28
Workshop

` Obtain the statistics and resize the following files


• FBNK.STMT.ENTRY
• FBNK.CATEG.ENTRY
• F.DE.O.HEADER
• F.DE.ADDRESS
• FBNK.RE.CONSOL.SPEC.ENTRY
• FBNK.ACCOUNT

29 Thesys Training Centre

Slide 29
Resize Files – Automated Tool

` T24 has a built in tool (Enquiry) named EB.BAD.SIZE.FILES which


enables us to
• Analyze files
• Resize badly sized files automatically

` Execute this enquiry at periodic intervals in time to avoid performance


issues which arise due to badly sized files

30 Thesys Training Centre

Slide 30
EB.BAD.SIZE.FILES

` This enquiry on execution


• Populates a file named EB.FILE.STATS with the list of files that have been
analyzed. This file also contains the details of the analysis such as the current
frame, suggested frame etc
• Creates a VOC entry named RESIZE.GLOBUS which contains the ‘jrf’ command
to resize the files. On execution of this VOC entry, the files will get resized.

31 Thesys Training Centre

Slide 31
EB.BAD.SIZE.FILES

` This enquiry should be run from the classic interface of T24

32 Thesys Training Centre

Slide 32
EB.BAD.SIZE.FILES

` Questions prompted by EB.BAD.SIZE.FILES enquiry


• Gather new file size information?
Possible values
FULL – Analyze files that have type as ‘F’ in the VOC entry, prepare a report.
Report is stored in a file named EB.FILE.STATS.
NO – Displays the current contents of the file EB.FILE.STATS. This means that
the enquiry will not analyze the system, but will display previously generated
reports
FAST – Similar to FULL except that in the report, the total number of records in
each file are not updated

• Please enter label for rebuild


A text that appears as part of the report. Useful when this enquiry is run
multiple number of times

• The enquiry can take while to execute based on the number and the
size of the files

33 Thesys Training Centre

Slide 33
EB.FILE.STATS – Contents Of A
Record – F.ABBREVIATION
ID : Name of the file. Voc ID
PathName : Path of the file as in the second line of the VOC
entry
Min Modulo : The suggested modulo of the file based on the
current data. When the file gets resized, this is the new
modulo it will be assigned
Date : Holds the data when the file was analyzed and updated
in EB.FILE.STATS file
Size : Unix file size
Modulo : jBASE modulo
Separation : jBASE separation
OverFlow :Overflow per group - indicates if the file is badly
sized
Records : Number of records in the file (Not populated when
FAST option is chosen at the time when the enquiry is
executed. * will be displayed in this field when the option
FAST is chosen)
Comment : Text that we enter for the question “Please enter
label for rebuild”. Useful when EB.BAD.SIZE.FILES is
executed multiple number of times
Important : Whether the file is considered important. List of
important files are hard coded. Has no significance in resizing
the files
The latest run details will be updated in the first multi value
set. Only the last 10 run details are held .This is to perform a
self clean up of the file.
34 Thesys Training Centre

Slide 34
Understanding Details In EB.FILE.STATS Better
Overflow Calculation :
OVERFLOW = FILESIZE - (FILEMODULO*FILESEP*BLOCK.SIZE)
OVERFLOW = OVERFLOW / (BLOCK.SIZE*FILESEP)
OVERFLOW = INT(OVERFLOW/FILEMODULO)

OVERFLOW = 28672 – (3 * 1 * 4096) 16384


OVERFLOW = 16384/(4096*1) 4
OVERFLOW = INT(4/3) 1

35 Thesys Training Centre

Slide 35
RESIZE.GLOBUS

` The EB.BAD.SIZE.FILES, on execution, also creates a VOC entry named


RESIZE.GLOBUS
` This VOC entry contains the command to resize all badly sized files
provided their overflow is greater than 5
` Execute this VOC entry from the jsh prompt in order to resize the files.

Once the VOC entry is


executed, the names
of files get displayed
one after the other as
they are resized

36 Thesys Training Centre

Slide 36
RESIZE.GLOBUS

Before empty files get


resized, user will be
prompted whether he
wishes to resize empty
files or not

The content of the VOC entry is not cleared after resize. It is overwritten
when EB.BAD.SIZE.FILES is executed next

37 Thesys Training Centre

Slide 37
EB.FILE.STATS

` Once the enquiry is executed, list the contents of the EB.FILE.SATS file.

Choose any record of your choice and view the contents

38 Thesys Training Centre

Slide 38
CREATE.FILE Related Environment
Variables

JEDI_PREFILEOP
JEDI_POSTFILEOP

39 Thesys Training Centre

Slide 39
JEDI_PREFILEOP
` Specify values to this variable so that values specified here are
defaulted when using the CREATE.FILE command
` Value specified in this variable takes more precedence over the value
supplied in command line for the CREATE.FILE command
` Multiple values can be specified for JEDI_PREFILEOP
• Syntax : JEDI_PREFILEOP=“Parameter=Value Parameter=Value”

40 Thesys Training Centre

Slide 40
JEDI_POSTFILEOP

` Specify values to this variable so that values specified here are defaulted
when using the CREATE.FILE command
` Value specified in this variable can be overridden using the CREATE.FILE
command

41 Thesys Training Centre

Slide 41
Additional Information Only -
Characteristics Of J4 Files

42 Thesys Training Centre

Slide 42
Additional Information Only -
Characteristics Of J4 and JR Files
` Backup
• When set, file will be backed up when the jbackup command is executed
• Default value : YES
• Command to change value
Grant : jchmod +B <File Name>
Revoke : jchmod –B <File Name>
` Log
• When set, any DML (Data Manipulation Language) on the file will be recorded
by jBASE Transaction Journaling (Provided jBASE Transaction Journaling is
started)
• Default value : YES
• Command to change value
Grant : jchmod +L <File Name>
Revoke : jchmod –L <File Name>

43 Thesys Training Centre

Slide 43
Additional Information Only - Characteristics Of J4 and
JR Files
` Rollback
• The Rollback flag indicates if a file is subject to transaction boundaries.
• Default value : YES
• If unset, will have an impact on the way jBASE Transaction Journaling journals data
Grant : jchmod +T <File Name>
Revoke : jchmod –T <File Name>

` Network
• Set for files that are NFS mounted so that jBASE can place byte locks on them
• Default value : NO
• Not used by JR files as JR files use jDLS for locking
• Applicable only to J4 files
• Command to change value
Grant : jchmod +N <File Name>

Revoke : jchmod –N <File Name>

44 Thesys Training Centre

Slide 44
Additional Information Only - Characteristics Of
J4 and JR Files

` Secure
• The file is flushed at critical junctures such that any file update will rely only on a
single disk write. This maintains the file structure in the event of system failure.
Set so that file structure never gets corrupt
• Default value : NO
• Applicable only to JR files
• Can affect performance if set
• Command to change value
Grant : jchmod +S <File Name>
Revoke : jchmod –S <File Name>

45 Thesys Training Centre

Slide 45
Summary
` The data file contains only data records
` The dict file contains the field names and their attributes
` Non Hashed Files
• Sequential files
• Unix level directories
• Used to store programs
• Type = UD
CREATE.FILE <FILE.NAME> TYPE=UD

` Hashed Files
• Store and retrieve data randomly
• Improve performance
• Needs to be resized when it overflows
• Type = J4
CREATE.FILE <FILE.NAME> TYPE=J4 MODULO,SEPARATION,SECONDARY BUFFER
MODULO,SEPARATION,SECONDARY BUFFER

46 Thesys Training Centre


Summary

` jstat command is used to obtain the statistics of a file in jBASE


` jrf command is used to resize a file
` T24 has a built in tool (Enquiry) named EB.BAD.SIZE.FILES which
enables us to analyze files and to resize badly sized files automatically

47 Thesys Training Centre

Slide 47
All product names and other company names used herein are for identification purposes only and may be
trademarks or registered trademarks of their respective owners. Errors and omissions excepted,
all specifications are subject to change without notice.

© 2009 Thesys Technologies Incorporated. All rights reserved.

FOR MORE INFORMATION


Visit : www.thesys.co.in
email : [email protected]

You might also like