You are here: Home » mst

Master file record format

The master file record is of variable length consisting of three segments: a fixed-length header, a directory and the variable-length data fields. variable length data fields.

Header format

The header consists of the following 7 integers (the fields marked with a * are 31-bit integers):

  • MFN* : Master File Record Number
  • MFRL : Record size (always an odd number)
  • MFBWB* : Previous marker - Block number
  • MFBWP : Previous Pointer - Position
  • BASE : Position of the first data field (record header and directory of the record, expressed in bytes).
  • NVF : Number of fields in the record (i.e. number of entries in the directory)
  • STATUS : Logical indicator of a deleted record (0=active record; 1=record marked for deletion) for deletion).

The MFBWB and MFBWP pointers are initially set to 0 when the record is created. They are subsequently updated each time a record is also modified (see below). modified as well (see below).

Directory format

The directory is a table indicating the contents of the records. There is only one for each field present in the record (i.e. the directory has exactly NVF entries). Each entry in the directory contains three integer elements:

  • TAG Field label
  • POS Position of the first character of the field in the data field segment (the first field has POS=0)
  • LEN Field size in bytes

The total byte size of the directory is 6*NVF; the BASE field of the header is always 18+6*NVF.

Variable length fields

This segment contains the data fields (in the order indicated in the directory). The are arranged one after the other, without any separating characters.

Control record

The first record in the master file is a control record that the system updates automatically. It can never be accessed by the user. It contains the following fields (the fields marked with a * are 31-bit integers):

CTLMFN* : is always 0 NXTMFN* : The MFN to be assigned to the next record created in the database NXTMFB* : The last block number occupied by the master file (the first block is 1) NXTMFP : The location of the next available position in the last block MFTYPE : Is always 0 for the user database (1 for the message database) messages database) RECCNT* MFCXX1* MFCXX2* MFCXX3*

(the last four fields are used for the elaboration of statistics during database backup and recovery operations).

Master File Block Format

The master file records are stored sequentially, one after the other, each taking up MFRL bytes. The file is stored in physical blocks of 512 bytes. A record can start at a value between 0 and 498 (no record starts between 500 and 510) and may extend for two or more blocks. As the master file is created and/or modified, the system creates an index indicating the position of each record. This information is stored in the reference index file .XRF.

Index Reference File

The .XRF file is organised as a table of pointers to the file. The first link corresponds to MFN 1, the second to MFN 2, etc.

Each link consists of two fields:

XRFMFB (21 bits) Block number of master file containing the record XRFMFP (11 bits) Position in the block of the first character of the master file (the first block is position 0)

which are stored in a 31-bit (4-byte) integer variable as shown:

pointer = XRFMFB*2048 + XRFMFP

Each block of the .XRF file is 512 bytes long and contains 127 pointers. The first field field of each block (XRFPOS) is a 31-bit integer variable, where its absolute value is the block number of the XRF. A negative value of XRFPOS indicates the last block.

The deleted records are indicated as follows:

  • XRFMFB<0 logically deleted record (in this case ABS(XRFMFB) is the block correct pointer and XRFMFP is the position of the record, which can still be retrieved)
  • XRFMFP>1 record physically deleted
  • XRFMFB=-1 missing record (all records later than the highest MFN assigned in the database)
  • XRFMFP=0
  • XRFMFB=0
  • XRFMFP=0

Master File Maintenance Techniques

Create new records

The new records are added at the end of the master file, in the position indicated by the NXTMFP/NXTMFP fields of the master file's control record. The MFN to be assigned is also taken from the NXTMFN field of the control record.

After the record has been added, the NXTMFN field is incremented by 1 and the NXTMFB/NXTMFP fields are updated to point to the next available position.

In addition, a new pointer is created in the .XRF file and the XRFMFP field corresponding to the record is incremented by 1024 to indicate that this is a new record to be to be inverted (after the record is inverted, the value 1024 is subtracted from XRFMFP).

Every time a record is updated (i.e. the record is edited using the data collection sheet and you leave the editor with X) the system writes the record back to the master file. The order in which the record is stored depends on its initial state at the time it was read.

There are no records pending to update the inverted file.

This condition is indicated by the following:

In XRF XRFMFP<512 and In MST MFBWB=0 and MFBWP=0

In this case, the record is always overwritten at the end of the master file (as if it were a new record) as indicated by the NXTMFB/NXTMFP fields of the control record.

In the new version of the record, the MFBWB/MFBWP fields point to the old version of the record, whereas in the .XRF file, the pointer points to the new version.

In addition, the value 512 is added to the XRFMFP field to indicate that this is a record pending to be updated in the inverted file. When the reverse file is updated, the old version of the record is used to determine the pointers to be deleted, and the new version to add the new pointers. After the update of the the XRFMFP field is subtracted the value 512 and the MFBWB/MFBWP fields become 0. fields become 0.

There are records pending to update the reverse file.

This condition is indicated by the following:

In XRF XRFMFP>512 and In MST MFBWB>0

In this case, the NXTMFB/NXTMFP fields point to the version of the record in the in the inverted file. If possible, if the record size does not increase, the record is written again at the original position, otherwise it will be written at the end of the master file. At In both cases, the MFBWB/MFBWP fields are not altered.

Delete records

The deletion of records is done as if it were an update, as follows as follows:

In XRF XRFMFB is negative In MST STATUS becomes 1

Reorganisation of the master file

As previously mentioned, updating the master file increases its size and the space occupied by previous versions of the record cannot be reused. Reorganisation makes it possible to recover this lost space by compacting the master file.

During the security phase, a master file backup (.BKP) is created. The structure and format of this file is the same as the master file (.MST), with the exception of the reference index file (.XRF) which is not necessary, since all records are adjacent.) Records marked to be deleted are not saved. As it is the latest version of the record that is saved, the system only allows this operation after the full update of the reverse file.

During the backup recovery phase, the file is sequentially read and the .MST and .XRF files are recreated. At this stage, all the records marked as logically deleted (before the backup) become physically deleted (by changing the fields XRFMFB=-1 and XRFMFP=0). The deleted records are detected by checking the MFN numbering gaps.

The CDS/ISIS reverse file is made up of 6 separate logical files, 5 of which contain the searchable terms from the lexicon (organized in a B*tree index) and the sixth one sixth contains the list of the pointers associated to each term. In order to optimize disk space, there are two separate B*tree, one for terms up to 10 characters (stored in .N01/.L01 files) and another one with the terms longer than 10 characters(1) (stored in the .N02/.L02 files). The .CNT file contains the control fields for both B*tree. In each B*tree, the .N0x file contains the NƒS of the tree and the L0x file contains the LEAFs. The records in the leaves refer to the IFP pointers file.

The relationship between the various files is represented schematically in the following figure.

The physical relationship between these six files, is a pointer, which represents the relative relative address of the record to be referenced. The relative address is the ordinal record number of a record in a file (i.e. the first record is number 1, the second is record number 2, etc.). 2, etc.) The .CNT file points to the .N0x file, the .N0x points to the .L0x, and the .L0x points to the .IFP. Since .IFP is a compressed file, the pointer from .L0x to .IFP has two components: the block number and the position within the block, each expressed by an integer.

mst.txt · Last modified: by CDS DOC