Files
NB-076 94400d50d4 feat: add benchmark-programs — 58 telecom COBOL test programs
作为子目录纳入系统,与核心测试管道协同

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 09:53:21 +08:00

38 lines
1.4 KiB
Markdown

# 20-matching-MN-to-MxN
## 电信业务场景
CDR详细清单M:N→M×N。多个合同×多个通话明细的笛卡尔积组合,输出完整的CDR详细清单(M×N件)。
**M:N matching — Cartesian product output (M x N records per matching key).**
Tests the scenario where both input files may contain duplicate keys and
every combination of matching master and detail records must be output
(the full Cartesian product).
## Test data
| File | Records | Keys |
|-------------|---------|------------------------------------------|
| master.dat | 5 | KEY00001 (x2), KEY00002 (x1), KEY00003 (x2) |
| detail.dat | 7 | KEY00001 (x3), KEY00003 (x2), KEY00004 (x2) |
- **KEY00001:** 2 masters x 3 details = 6 output records
- **KEY00003:** 2 masters x 2 details = 4 output records
- **Total output:** 10 records
- **Unmatched:** KEY00002 (master only), KEY00004 (detail only)
## Algorithm
1. Read both files synchronously (both assumed sorted by key).
2. When keys match: read all master records for that key into a table,
read all detail records for that key into a table, then write M x N
output records covering every combination.
3. Unmatched groups are skipped via the standard key-comparison logic.
## Expected output
- **output.dat:** 10 records x 45 bytes = 450 bytes
- Program displays: `20-matching-MN-to-MxN: PASS`
- Script displays: `20-matching-MN-to-MxN: ALL TESTS PASSED`