Row store vs column store
An analytics warehouse keeps one table in two layouts, row by row and column by column, and you are sizing the same scan against both. columns describes the table, one entry per column written as "name|width", where width is the bytes a single value of that column occupies, and column names are unique. row_count is how many rows the table holds. projected names the columns the query reads: a name may appear more than once, and a name that is not a column of this table is ignored. A row store has to read whole rows, so it reads row_count times the total width of every column. A column store opens only the files of the projected columns, so it reads row_count times the total width of the distinct projected columns that exist. Return a two element list, the row store bytes first and the column store bytes second.
projection_scan_bytes(columns: list[str], row_count: int, projected: list[str]) → list[int][["event_id|8","user_id|8","country|2","payload|512"],1000,["event_id","country"]]out[530000,10000][["event_id|8","user_id|8","country|2","payload|512"],1000,["event_id","user_id","country","payload"]]out[530000,530000][["event_id|8","user_id|8","country|2","payload|512"],1000,["payload","payload","missing"]]out[530000,512000]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["event_id|8","user_id|8","country|2","payload|512"],1000,["event_id","country"]][530000,10000]not run yetsample[["event_id|8","user_id|8","country|2","payload|512"],1000,["event_id","user_id","country","payload"]][530000,530000]not run yetsample[["event_id|8","user_id|8","country|2","payload|512"],1000,["payload","payload","missing"]][530000,512000]not run yetsample