You are given:
vector<tuple<int timestamp, string code, int value>>
.
Conceptually, the ideal output is an N × M matrix where:
(timestamp, code)
pair has no record, its cell value is
-1
.
Across the entire stream (or equivalently within each batch, with batches emitted in order), records are produced in non-decreasing timestamp order, and for the same timestamp, in lexicographic code order.
Implement a stream transformer that consumes the above input stream and produces an output stream of:
pair<int timestamp, vector<int> row>
where:
timestamp
is a timestamp present in the overall input (or in a given list of timestamps, if provided).
row
has length
M
.
row[i]
is the value for the
i
-th code (in lexicographic order) at that
timestamp
, or
-1
if missing.
Your transformer should emit exactly one output row per timestamp (once all records for that timestamp have been consumed).
(timestamp, code)
can appear (and if so, whether to take last-write-wins, sum, or treat as invalid).
If codes are ["A","B","C"] and the stream contains:
Then output rows: