A meta-item, that describes each record in the file, is a
tuple (key; pointer; len), where key is the primary key of
the record, pointer points to the record in the file, len is the
length of the (variable-length) record. Each record has the
corresponding meta-item and these meta-items are stored
in the meta-item file. Assume that we have B buffer pages,
where B − 1 pages are used to buffer the records and the
remaining buffer page is the output buffer for the metaitems.
The record file will be scanned to construct metaitems.
After the meta-items are created, the unclustered
sorting is to sort the meta-items instead of records. The
sorting process of the meta-items is similar to that of records
in the clustered sorting. Because the size of one meta-item
is less than that of one record, a lot of page reads and page
writes can be saved during the merging process of runs. Note
that for the sake of simplicity, instead of (key; pointer; len),
the type of (key; pointer) is adopted for the rest of the paper.
After the meta-item is sorted, we will rearrange the records
in the record file by scanning the sorted meta-items that
point to the records in the record file. According to the
record order in the sorted meta-items, the records in the
record file are read and written out to the sorted record file.
During the record rearrangement, B buffer pages will be
used to buffer the records and replacement will be needed
while B buffer pages are full