Professional Documents
Culture Documents
This
learning unit will help you to work with J4 files
What you see here is a sample Employee table with five rows. The table holds information of
an employee like the employee id, name, address, phone, data of birth etc.
It is not mandatory that the data and the dict file should exist in the same location, it may
reside under different directories. VOC will link the data and dict together.
1. Non Hashed files are sequential files. They are operating system level directories.
They are basically used to store programs and messages that are posted by
interfaces. To create a Non Hashed file from jBASE you will specify Type=UD
2. Hashed files are random files. As they can be randomly accessed, it improves the
performance of the file. These files have to be regularly resized when it overflows. To
create a J4 file in jBASE you will specify Type=J4
1. Use the CREATE.FILE command to create a non hashed file. Consider that you wish to
create a file called TEMENOS.NON.HASHED, use the command CREATE.FILE
TEMENOS.NON.HASHED TYPE=UD. On executing the command a data file
TEMENOS.NON.HASHED and a dict file TEMENOS.NON.HASHED]D will be created.
2. The data as well as the dict files are created as operating system level directories. If you
notice the file description has a value “d” that specifies that is it a directory
3. It is equivalent to creating operating system level directories. If you see this example, it
shows that mkdir command can also be used for creating these files.
1. The data and the dict files can be created separately using the DATA or the DICT
keyword following the CREATE.FILE command
2. The data as well as the dict files are created as operating system files.
4,2,2 are the set of parameters for the data file where
4 – specifies number of modulo of the data file
2 – specifies separation of the data file
2 – specifies secondary buffer size of the data file
If for example (Lets assume the size of one modulo is 4096) the number of modulo specified
is three and the separation specified is two, it means that three frames (bucket) of size 4096
* 2 will be created, where 4096 K is assumed to be the default size of a frame is assumed
and 2 is the separation. The default size of the modulo can change depending on the
underlying operating system.
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.
1. If you remember, a value two was specified as the secondary buffer size for the file
TEMENOS.HASHED
2. Secondary buffer size will be calculated as size of one frame multiplied by the
secondary buffer size.
2.1 4,2,2 means that size of one frame (assume 4096 ) is multiplied by 2 that is
equal to 8192 bytes. The secondary buffer size will be 8192 multiplied by 2, that
is 16384. So when a record is greater that 16384 bytes, it is considered to be a
huge record. Only when the size of a record is greater than 16384 bytes, will a
secondary buffer space be created to store the new data
If no value is specified for the secondary buffer size, it will default to 2. Meaning, the
secondary buffer size by default will be twice the size of a modulo.
The secondary buffer area can be created anywhere in the disk. Not necessary adjacent to
the primary frames
1. Keep separation to the minimum, higher the separation, higher will be search time within
a frame as the read within a frame is sequential
2. 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
3. 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
4. J4 always spreads and stores records evenly across all frames
jstat command allows you to analyse files in jBASE. The syntax for jstat command is jstat {-
DChar} {-fmrsvw} Filename
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 : Specifies the 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
When the file was created or last resized, the valued would have been Type=J4, Frame = 9,
Separation = 1 and Secondary buffer size = 2.
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
1. Additional modulo is allocated for Frame 0 as this modulo did not have space to hold
records
2. The number of records per frame is equal to the size per frame, 4096 divided by the
average size of a record is 387. 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? The answer is 2001/11 = 200 (Approx). Now that you have the
required statistical data about the file, you will resize the file with this
information.
3. jrf command is available for file re-sizing. jrf command followed by –S option is used to
specify the size parameter which is then followed by the number of modulo. jrf –S201
.. ../mbdemo.data/ac/FBNK.ACCOUNT will resize the FBNK.ACCOUNT file to 201
frames. You must specify the physical path of the file.
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 the nearest
possible prime or odd number
1. If you look at the statistics of TRG.TEST file, there are 25 primary frames available.
2. Use the jrf command with –DS option to reduce the number of frames allocated to a file.
You have tried to downsize 25 frames to 3 frames.
Note that secondary buffer space has been allocated and the record which should have
been in frame 3 is stored in the secondary buffer space (Note the + symbol. It denotes that
there is a secondary buffer space allocated for the frame). 3 frames have been allocated in
the secondary buffer space area and they split and store the record. Frame 3 will have the
pointer to the first frame in the secondary file space, the first frame in the secondary file
space will have a pointer to the second frame and so on (Like a link list)
2. Execute this enquiry at periodic intervals in time to avoid performance issues which
arise due to badly sized files
1.3 The enquiry can take while to execute based on the number and the size of 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.
3.OVERFLOW = INT(OVERFLOW/FILEMODULO)
Finally, the resultant is divided with the modulo and converted into an integer value
2. 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.
The content of the VOC entry is not cleared after resize. It is overwritten when
EB.BAD.SIZE.FILES is executed next
1. If you set some value to the environment variable JEDI_PREFILEOP, it gets defaulted
while using the CREATE.FILE command. Let us understand this with an example.
1.1 Set a value “TYPE=JR LOG=NO” to this variable, you can use the command
export JEDI_PREFILEOP = “TYPE=JR LOG=NO” if you are working on UNIX.
2. Now create a file just by giving a command CREATE.FILE followed by a file name. Let
us consider for example CREATE.FILE TRAINING.TEST
2.1 Now check if you have got the values set in the environment variable. Use the
jstat to do this. Can you see the Type set to JR and Log set to NO.
Remember that value specified in this variable takes more precedence over the value
supplied in command line for the CREATE.FILE command.
1. This variable is the same like JEDI_PREFILEOP, If you set some value to the
environment variable JEDI_POSTFILEOP, it gets defaulted while using the
CREATE.FILE command. But you should remember that value specified in this variable
can be overridden using the CREATE.FILE command.
2. Let us understand this with an example.
1.1 Set a value “TYPE=JR LOG=NO” to this variable, you can use the command
export JEDI_POSTFILEOP = “TYPE=JR LOG=NO” if you are working on
UNIX.
3. Now create a file using the CREATE.FILE command followed by a file name, also
specify the file type as J4. Let us consider for example CREATE.FILE TRAINING.TEST
TYPE=J4 1 1
2.1 Now check if you have got the values set in the environment variable. Use the
jstat to do this. If you notice, though you have set JEDI_POSTFILEOP to
TYPE=JR, the file type of the file you created just now is J4, this is because
you have given TYPE=J4 in the CREATE.FILE command. As already said, the
value specified in the CREATE.FILE command takes more precedence when
compared to the variable JEDI_POSTFILEOP
Backup: When set to YES, file will be backed up when the jbackup command is executed,
the default value is YES. You can change this value by issuing the command jchmod +B
<File Name> to grant and jchmod –B <File Name> to revoke backup feature.
Log: When set to YES, any DML (Data Manipulation Language) on the file will be recorded
by jBASE Transaction Journaling, provided jBASE Transaction Journaling is started. Its
default value is YES. You can change this value by issuing jchmod +L <File Name> to
grant and jchmod –L <File Name> to revoke log feature.
Rollback: The Rollback flag indicates if a file is subject to transaction boundaries. Its default
value is YES. If unset, it will have an impact on the way jBASE Transaction Journaling
journals data. To grant Rollback use the command jchmod +T <File Name> and to revoke
use the command jchmod –T <File Name>
Network: It is set for files that are NFS mounted so that jBASE can place byte locks on
them. Its default value is NO. It is not used by JR files as JR files use jDLS for locking.
Applicable only for J4 files. The command to grant this feature is jchmod +N <File Name>
and to revoke the command is jchmod –N <File Name>.
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. Its default value is NO. It is applicable only to JR files. It can
affect performance if set. The command to grant this feature is jchmod +S <File Name>
and to revoke it is jchmod –S <File Name>