Files

22-matching-2stage-MN: Two-Stage M:N Matching

电信业务场景

二级套餐匹配。两段M:N匹配。第一段:基本套餐匹配;第二段:附加套餐匹配。用于叠加套餐的计费处理。

This test verifies two-stage M:N (Cartesian product) matching behavior.

Algorithm

Stage 1: Read FILE-A (file-a.dat) and FILE-B (file-b.dat), write matched records to TEMP-FILE (temp.dat). For each matching key, outputs A_count x B_count records (Cartesian product).

Stage 2: Read TEMP-FILE (temp.dat) and FILE-C (file-c.dat), write matched records to FINAL-OUT (final.dat). For each matching key, outputs temp_count x C_count records (Cartesian product).

Test Data

file-a.dat (4 records)

  • KEY00001: 2 records
  • KEY00002: 2 records

file-b.dat (3 records)

  • KEY00001: 2 records
  • KEY00003: 1 record

file-c.dat (4 records)

  • KEY00001: 2 records
  • KEY00002: 2 records

Expected Results

Stage 1: KEY00001 matches (2x2=4 temp records)

  • KEY00002 has no B match (skipped)
  • KEY00003 has no A match (skipped)
  • Total: 4 records in temp.dat (180 bytes)

Stage 2: 4 temp records (KEY00001) x 2 file-c records (KEY00001) = 8 output records

  • Total: 8 records in final.dat (360 bytes)

Files

  • main-22-matching-2stage-MN.cbl — COBOL program
  • data-gen.sh — Test data generator
  • run.sh — Compile, run, and verify script