ARCHOS 525 BLUEPRINT · /d/dgm_code-sorting-and-merging
Sorting, Partitioning, External K-Way Merge & Timsort
6 COMPONENTS · 6 FLOWS · UPDATED 2026-11-24
GITHUB README / PR PREVIEW CARD
[](https://archos.sageideas.dev/d/dgm_code-sorting-and-merging) *Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_code-sorting-and-merging)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_code-sorting-and-merging" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Sorting, Partitioning, External K-Way Merge & Timsort — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
client_0["Dataset / Spill Files"]
n1_1["In-RAM Sorter"]
n2a_2[("Partitioner / Spill")]
n2b_3[("K-Way Merge Heap")]
n3_4[("Sorted Output Stream")]
downstream_5["Downstream & OTel"]
client_0 -->|"1. Sort · ON log N"| n1_1
n1_1 -->|"2a. Spill runs · Seq IO"| n2a_2
n1_1 -->|"2b. Merge K · ON log K"| n2b_3
n2a_2 -->|"3a. Write out · Seq IO"| n3_4
n2b_3 -->|"3b. Merge · RAM"| n3_4
n3_4 -.->|"4. Emit / · OTLP/API"| downstream_5COMPONENT STACK (6)
- Dataset / Spill FilesSTATELESSIn-RAM or TB Disk Runs
- In-RAM SorterSTATELESSTimsort / Introsort
- Partitioner / SpillSTATEFULWrites sorted NVMe run files
- K-Way Merge HeapSTATEFULTournament tree / Min-Heap
- Sorted Output StreamSTATEFULStable ordered Parquet/SSTable
- Downstream & OTelSTATELESSConsumers, metrics & SLOs
REQUEST & DATA FLOW (6)
- Dataset / Spill Files → In-RAM Sorter (Sort)[ON log N]
- In-RAM Sorter → Partitioner / Spill (Spill runs)[Seq IO]
- In-RAM Sorter → K-Way Merge Heap (Merge K)[ON log K]
- Partitioner / Spill → Sorted Output Stream (Write out)[Seq IO]
- K-Way Merge Heap → Sorted Output Stream (Merge)[RAM]
- Sorted Output Stream → Downstream & OTel (Emit /)[OTLP/API]