lect10
lect10
We know how to create a file, add records to a file and modify the content
of a record. These actions can be performed physically by using the various
basic file operations we have seen (open a file for writing or appending, go-
ing to a position of a file using “seek” and writing the new information there).
Strategies for record deletion and for reusing the unused space :
Note that the space for the record is not released, but the program that ma-
nipulates the file must include logic that checks if record is deleted or not.
After a lot of records have been deleted, a special program is used to squeeze
the file - this is called Storage Compaction.
Date: February 5-6, 2001 CSI 2131 Page: 2
Prof. Lucia Moura Lecture 10
How to use the space of deleted records for storing records that are added
later ?
List head → 4
Edwards Williams *-1 Smith *2 Sethi
0 1 2 3 4 5
If we add a record, it can go to the first available spot in the avail list
(RRN=4).
Use an avail list as before, but take care of the variable-length difficulties.
The records in avail list must store its size as a field. RRN can not be
used, but exact byte offset must be used.
List head → 34
Edwards|M| Wu|F| *-1|10| Smith|M| *16|30|
0 1 2 3 4
10 bytes 5 10 bytes 8 bytes 30 bytes
bytes
Addition of records must find a large enough record in avail list.
Date: February 5-6, 2001 CSI 2131 Page: 3
Prof. Lucia Moura Lecture 10
1. First-Fit Strategy
2. Best-Fit Strategy
3. Worst-Fit Strategy
• Coalescing the holes : if two records in avail list are adjacent, com-
bine them into a larger record.