Algorithms and Data Structures for External Memory
Algorithms and Data Structures for External Memory
Algorithms and Data Structures for External Memory
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
50 <strong>External</strong> Sorting <strong>and</strong> Related Problems<br />
Output buffers /<br />
Input buffers<br />
Merging buffers /<br />
Partitioning buffers<br />
Prefetch buffers /<br />
Output buffers<br />
1 2 3 4 5<br />
R = 8 runs / S = 8 buckets<br />
D = 6 Disks<br />
1 2 3 4<br />
5<br />
6<br />
7 8<br />
1 2 3 4 5 6<br />
D = 6 Disks<br />
6<br />
Up to 3-D<br />
I/O-buffered<br />
blocks<br />
Disk numbers<br />
Blocks disassembled<br />
via merge<br />
Blocks assembled<br />
via distribution<br />
Stream of blocks are<br />
read in Σ order<br />
Stream of blocks are<br />
written in Σ order<br />
R<br />
Up to m’<br />
prefetched or<br />
queued blocks<br />
D = 6<br />
Disk numbers<br />
Correspondence between<br />
output step in greedy write-once schedule<br />
<strong>and</strong> prefetching step in lazy read-once schedule<br />
Fig. 5.8 Duality between merging with R = 8 runs <strong>and</strong> distribution with S = 8 buckets,<br />
using D = 6 disks. The merge of the R runs proceeds from bottom to top. Blocks are input<br />
from the disks, stored in the prefetch buffers, <strong>and</strong> ultimately read into the merging buffers.<br />
The blocks of the merged run are moved to the output buffers <strong>and</strong> then output to the disks.<br />
The order in which blocks enter the merging buffers determines the sequence Σ, which<br />
can be predetermined by ordering the blocks based upon their smallest key values. The<br />
distribution into S buckets proceeds from top to bottom. Blocks are input from the disks<br />
into input buffers <strong>and</strong> moved to the partitioning buffers. The blocks of the resulting buckets<br />
are written in the order Σ R to the output buffers <strong>and</strong> then output to the appropriate disks.<br />
Internal <strong>Memory</strong>