3 ms·
Well, the main thing would be to operate in a store-nothing kind of way. There has to be a fixed amount of storage required no matter what the length of the in
by gdp 17y ago
Well, the main thing would be to operate in a store-nothing kind of way. There has to be a fixed amount of storage required no matter what the length of the input is. You'll need to keep aggregate totals and compute over each row, as opposed to storing any data.
The parsing should be simple. Lex and/or Yacc should handle very large files. If not, you can always write something by hand, once again sticking to the store-nothing principle.
I would think about it as a fold operation (http://en.wikipedia.org/wiki/Fold_%28higher-order_function%29 http://en.wikipedia.org/wiki/Fold_%28higher-order_function%2...) over the lines in the file, where the parser state and any aggregate calculated values are stored in the accumulator, and each new line is considered in conjunction with the current state and the previous calculated values.