Day 2 - S3 S4 - Introduction To Jbase Database1
Day 2 - S3 S4 - Introduction To Jbase Database1
Day 2
Session 3&4
Induction Trainings
Slide 2
Table Structure In Any RDBMS
Table Structure In Any RDBMS
Slide 3
Employee Table When Stored In
jBASE
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
Slide 5
Creating Non Hashed Files
` Use the CREATE.FILE command to create a non hashed file
Slide 6
Non Hashed Files (Cont.)
` 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
Slide 7
Hashed Files
Slide 8
Understanding The Parameters For A
Hashed 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
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
Record 2 Record 1
Hashed File :
TEST.HASHED.FILE
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
Record 2 Record 1
Slide 12
What Happens When All Frames Are
Full?
Writes a record
with ID 15
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’
Slide 14
What Happens When A Huge Record Is To
Be Written To The File?
Writes a record
with ID 16
Slide 15
Hashed Files – Points To Remember
` 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
Slide 16
Listing Contents Of Files
` List contents of hashed as well as non hashed files, use the LIST
command
Slide 17
Clearing/Deleting Files
Slide 18
Clearing/Deleting Files (Cont.)
Slide 19
Workshop
Slide 20
File Maintenance
Slide 21
jstat – Command To Analyse A Hashed
File
` Options
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
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
Slide 25
File Maintenance In jBASE
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
Slide 28
Workshop
Slide 29
Resize Files – Automated Tool
Slide 30
EB.BAD.SIZE.FILES
Slide 31
EB.BAD.SIZE.FILES
Slide 32
EB.BAD.SIZE.FILES
• The enquiry can take while to execute based on the number and the
size of the files
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)
Slide 35
RESIZE.GLOBUS
Slide 36
RESIZE.GLOBUS
The content of the VOC entry is not cleared after resize. It is overwritten
when EB.BAD.SIZE.FILES is executed next
Slide 37
EB.FILE.STATS
` Once the enquiry is executed, list the contents of the EB.FILE.SATS file.
Slide 38
CREATE.FILE Related Environment
Variables
JEDI_PREFILEOP
JEDI_POSTFILEOP
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”
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
Slide 41
Additional Information Only -
Characteristics Of J4 Files
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>
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>
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>
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
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.