Monash University · FACULTY OF INFORMATION TECHNOLOGY

FIT5202 · Data Processing for Big Data

- one subject, every graph, every model, every mark
Information Technology14 Chapters8-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 4 of 11 · FIT5202

Parallel Sort & Parallel Group-By

Week 4 closes the Volume theme of Monash FIT5202 with parallel external sorting and parallel aggregation. It builds from serial external sort-merge (counting passes with a limited buffer) to the five parallel sort algorithms — merge-all, binary-merge, the two redistribution variants and partitioned sort — and the three parallel group-by methods (traditional, two-phase, and redistribution). Counting external-sort passes and choosing a group-by method are recurring calculation and reasoning items in the exam.

In this chapter

What this chapter covers

  • 01Serial external sort-merge: Pass 0 sort phase, then (B−1)-way merge passes with a B-page buffer
  • 02Counting passes: #runs = ⌈file pages / buffer pages⌉, then repeatedly merge (B−1) at a time
  • 03Parallel Merge-All Sort (local sort + one final K-way merge — the merge is a bottleneck)
  • 04Parallel Binary-Merge Sort (pairwise pipelined merge)
  • 05Parallel Redistribution Binary-Merge and Redistribution Merge-All (redistribute to spread the merge)
  • 06Parallel Partitioned Sort (range-redistribute, then independent local sort — no merge needed; skew risk)
  • 07Parallel Group-By: traditional (local then global), two-phase, and redistribution methods
  • 08Cost and skew considerations across sort and aggregation
Worked example · free

Counting passes in an external sort-merge

Q [4 marks]. An external sort-merge must sort a file of 150 data pages using a memory buffer of 8 pages. How many passes (including the initial sort pass) are needed, and how many sorted runs remain after each pass? (4 marks)
  • +1Pass 0 (sort phase): read the file in chunks of 8 pages, sort each chunk in memory, write it back. Number of runs = ⌈150 / 8⌉ = ⌈18.75⌉ = 19 sorted runs (the last run is 150 − 18×8 = 6 pages).
  • +1Merge fan-in: with B = 8 buffer pages, reserve 1 for output, leaving B − 1 = 7 input buffers, so each merge pass is a 7-way merge.
  • +1Pass 1: 7-way merge the 19 runs → ⌈19 / 7⌉ = 3 runs.
  • +1Pass 2: 7-way merge the 3 runs → ⌈3 / 7⌉ = 1 sorted file. Total = Pass 0 (sort) + Pass 1 + Pass 2 = 3 passes.
3 passes in total. Runs go 19 (after the Pass-0 sort) → 3 (after Pass 1) → 1 (after Pass 2). The (B−1) = 7-way merge fan-in is what makes the run count fall so quickly.
Sia tip — Two moving parts: the Pass-0 run count is ⌈file/buffer⌉, and every later pass divides the run count by (B−1), rounding up. Forgetting to reserve one buffer page for output (using B-way instead of (B−1)-way) is the usual slip.
Glossary

Key terms

External sort-merge
A sort for data that does not fit in memory: Pass 0 sorts buffer-sized runs, then repeated (B−1)-way merges combine runs until one sorted file remains.
(B−1)-way merge
With a B-page buffer, one page is the output buffer and B−1 are input buffers, so each merge pass combines up to B−1 runs at once.
Parallel Merge-All Sort
Each processor sorts locally, then a single processor performs one final K-way merge of all runs. Simple, but the final merge overloads one processor and the network.
Parallel Partitioned Sort
Range-redistribute records so each processor owns a value range, then each sorts independently. No merge is needed, but partitioning can introduce skew.
Two-phase group-by
Phase 1: each processor aggregates its local records by the group-by attribute. Phase 2: redistribute the partial results by that attribute and do a final aggregation per processor.
Redistribution group-by
Redistribute the RAW records to processors by the group-by attribute first, then each processor aggregates locally in one step. Moves more data than the two-phase method.
FAQ

Parallel Sort & Parallel Group-By FAQ

How do I count external-sort passes quickly?

Start with the Pass-0 run count ⌈file pages / buffer pages⌉. Then repeatedly divide by the merge fan-in (B−1), rounding up, counting one pass each time until you reach a single run. Add the Pass-0 sort as one pass. Reserving a buffer page for output is the detail people forget.

What makes the redistribution sort algorithms better than merge-all?

Parallel Merge-All Sort funnels every run into one final K-way merge, so one processor and the network become the bottleneck. The redistribution variants spread the merging work across the whole pool of processors, giving genuine parallelism in the merge phase — at the cost of a redistribution step and possible skew.

When should I use the two-phase group-by instead of redistribution?

Use two-phase when local aggregation shrinks the data a lot (for example many records per group): you aggregate locally first, so only small partial results are shuffled. Use redistribution when groups are few or aggregation does not reduce much, so shuffling raw records is acceptable. The choice is again a network-cost trade-off.

Can AI help me with parallel sort and group-by?

Yes. Sia can count external-sort passes with you, compare the five parallel sort algorithms, and explain when two-phase beats redistribution for a group-by — step by step, checking your reasoning. It does not complete your graded work, and Monash academic-integrity rules apply.

Study strategy

Exam move

Make external-sort pass-counting automatic: ⌈file/buffer⌉ runs, then divide by (B−1) each pass, remembering to reserve one output buffer. Learn the five parallel sort algorithms as two families — without redistribution (merge-all, binary-merge) and with redistribution (the two redistribution variants and partitioned sort) — and be ready to say why redistribution spreads the merge. For group-by, be able to justify two-phase versus redistribution by data movement. Keep the Week-4 quiz warm on Moodle; it closes the Volume block that Test-style questions revisit.

Working through Parallel Sort & Parallel Group-By in FIT5202? Sia is AskSia’s AI Information Technology tutor — ask any FIT5202 Parallel Sort & Parallel Group-By question and get a clear, step-by-step explanation grounded in how FIT5202 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 47 of your Monash University subjects - and 1,000+ Bibles across every Australian university.
Sia - your FIT5202 tutor, unlimited, worked the way the exam marks it
The full 8-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$25/ month
30-day money-back · cancel in one tap · how it works
Unlock the full FIT5202 Bible + 47 Monash University subjects解锁完整 FIT5202 Bible + Monash University 47 门科目
$25/mo