Data Pipeline Case Studies
Join Labels
Build a compact label string from the first records in a stream.
limit
The selected limit controls how many labels enter the joined output.
separator
The pipeline appends separators only between selected labels.
Join Labels
join_labels.lua
Replay: real traced execution (multi-file project)
local limit = 2
local joined = ""
local count = 0
for _, label in ipairs({"red", "green", "blue"}) do
if count < limit then
if joined ~= "" then
joined = joined .. "|"
end
joined = joined .. label
count = count + 1
end
end
print("limit=" .. limit)
print("count=" .. count)
print("joined=" .. joined)
local limit = 1
local joined = ""
local count = 0
for _, label in ipairs({"red", "green", "blue"}) do
if count < limit then
if joined ~= "" then
joined = joined .. "|"
end
joined = joined .. label
count = count + 1
end
end
print("limit=" .. limit)
print("count=" .. count)
print("joined=" .. joined)
local limit = 3
local joined = ""
local count = 0
for _, label in ipairs({"red", "green", "blue"}) do
if count < limit then
if joined ~= "" then
joined = joined .. "|"
end
joined = joined .. label
count = count + 1
end
end
print("limit=" .. limit)
print("count=" .. count)
print("joined=" .. joined)
limit ← 2, joined ← (empty), count ← 0
1local limit→ 2 = 2 --@limit=1, 32local joined→ (empty) = ""3local count→ 0 = 0_, label in ipairs({"red", "green", "blue"}) do
pass 1 of 35for _1, labelred in ipairs({"red", "green", "blue"}) do6 if count < limit then7 if joined ~= "" thenAll 3 passes — pass 1 is the card above pass _labellimitjoinedcount1 1 red 2 (empty) → red 0 → 1 2 2 green 2 red → red| 1 3 3 blue — — — joined ← red, count ← 1
pass 1 of 25for _, label in ipairs({"red", "green", "blue"}) do6 if count0 < limit2 then7 if joined ~= "" then8 joined = joined .. "|"9 end10 joined→ red = joined .. labelred11 count→ 1 = count + 112 endif count < limit then
pass 2 of 25for _, label in ipairs({"red", "green", "blue"}) do6 if count1 < limit2 then7 if joined ~= "" then8 joined = joined .. "|"joined ← red|
6if count < limit then7 if joinedred ~= "" then8 joined→ red| = joined .. "|"9 endjoined ← red|green, count ← 2
9 end10 joined→ red|green = joined .. labelgreen11 count→ 2 = count + 112endprint("limit=" .. limit)
15print("limit=" .. limit2)16print("count=" .. count2)17print("joined=" .. joinedred|green)outputlimit=2 count=2 joined=red|green
limit ← 1, joined ← (empty), count ← 0
1local limit→ 1 = 12local joined→ (empty) = ""3local count→ 0 = 0_, label in ipairs({"red", "green", "blue"}) do
pass 1 of 35for _1, labelred in ipairs({"red", "green", "blue"}) do6 if count < limit then7 if joined ~= "" thenAll 3 passes — pass 1 is the card above pass _labellimitjoinedcount1 1 red 1 (empty) → red 0 → 1 2 2 green — — — 3 3 blue — — — joined ← red, count ← 1
5for _, label in ipairs({"red", "green", "blue"}) do6 if count0 < limit1 then7 if joined ~= "" then8 joined = joined .. "|"9 end10 joined→ red = joined .. labelred11 count→ 1 = count + 112 endprint("limit=" .. limit)
15print("limit=" .. limit1)16print("count=" .. count1)17print("joined=" .. joinedred)outputlimit=1 count=1 joined=red
limit ← 3, joined ← (empty), count ← 0
1local limit→ 3 = 32local joined→ (empty) = ""3local count→ 0 = 0_, label in ipairs({"red", "green", "blue"}) do
pass 1 of 35for _1, labelred in ipairs({"red", "green", "blue"}) do6 if count < limit then7 if joined ~= "" thenAll 3 passes — pass 1 is the card above pass _labeljoined1 1 red — 2 2 green red → red| 3 3 blue red|green → red|green| joined ← red, count ← 1
pass 1 of 35for _, label in ipairs({"red", "green", "blue"}) do6 if count0 < limit3 then7 if joined ~= "" then8 joined = joined .. "|"9 end10 joined→ red = joined .. labelred11 count→ 1 = count + 112 endAll 3 passes — pass 1 is the card above pass labeljoinedcount1 red (empty) → red 0 → 1 2 — red → red| 1 3 — red|green → red|green| 2 joined ← red|
pass 1 of 26if count < limit then7 if joinedred ~= "" then8 joined→ red| = joined .. "|"9 endjoined ← red|green, count ← 2
9 end10 joined→ red|green = joined .. labelgreen11 count→ 2 = count + 112endjoined ← red|green|
pass 2 of 26if count < limit then7 if joinedred|green ~= "" then8 joined→ red|green| = joined .. "|"9 endjoined ← red|green|blue, count ← 3
9 end10 joined→ red|green|blue = joined .. labelblue11 count→ 3 = count + 112endprint("limit=" .. limit)
15print("limit=" .. limit3)16print("count=" .. count3)17print("joined=" .. joinedred|green|blue)outputlimit=3 count=3 joined=red|green|blue