TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)

486 Chapter10
Internal Structures and Techniques
Internal Techniques
before the record is added, the assigned record address is the primary address. If the bit is
a one before the record is added, it indicates that an entry already exists. If this existing
entry is a primary entry, a search is done to find a free location, secondary address, for the
new entry. However, if the existing entry is a secondary entry, this secondary entry is
relocated to another free secondary address, and the new entry is added at this location. If
the data set is enabled for dynamic expansion, the search for a free secondary address is
done in the original as well as expansion area. For the original (primary, hashing, or
initial) area, a secondary address is identified by a serial search of the bit maps of blocks
for a zero indicating an unused record. For the expanded area, a secondary address is
identified using the pointer to a delete chain and end-of-file pointer, as in detail data sets.
Space Allocation for Detail Data Sets
Space allocation for each detail data set is controlled by a free space counter, an end-of-file
pointer and a pointer to a delete chain. The end-of-file pointer contains the record
address of the highest-numbered entry which has existed so far in the data set. The delete
chain pointer contains the record address of the entry which was most recently deleted.
When each detail data set is first created, the end-of-file pointer and delete chain pointer
are both zero.
When a new entry is added to a detail data set, TurboIMAGE/XL assigns to it the record
address referenced by the delete chain pointer, unless the pointer is zero or HWMPUT has
been enabled either using DBCONTROL or using DBUTIL. If the delete chain pointer is zero or
if the HWMPUT flag is enabled, the end-of-file pointer is incremented and then used as the
assigned record address. The free space counter is decremented in either case. When a new
entry is to be added to a detail data set and the free space counter is zero, at run-time, the
data set is expanded according to the capacity expansion parameter specified for this data
set (if any). The capacity expansion parameters can be set using DBSCHEMA for new
databases or by using DBCHANGE Plus or other third-party utilities for existing databases.
When an existing entry is deleted, its media record is zeroed, the first word is replaced
with the current delete chain pointer, and the block is written to disk. The delete chain
pointer is set to the address of the newly deleted entry and the free space counter is
incremented.
The delete chain is, in effect, a "last-in–first-out" linked list of reusable media record space.
Reusable space is allocated in preference to the unused space represented by record
addresses beyond the end-of-file pointer except when HWMPUT is enabled.
Addition and deletion of data entries also requires data chain maintenance and turning on
or turning off the corresponding bit of the appropriate bit map. Both of these are necessary
for retrieval integrity but neither play a role in space allocation for detail data sets.