I currently have code like this:

try (var cursor = query().fetchSize(1000).fetchLazy()) { cursor.formatCSV(out); }

Does exactly what I want - lazily fetches (my results are gigantic and would never all fit in memory) and formats as CSV correctly.

However, I now need to preprocess the records in a way that will result in splitting some records into many.

Similar to:

try (var stream = query().fetchSize(1000).stream()) { stream .mapMulti(...) //split the records as needed .forEach(r -> r.formatCSV(out)); }

but this has a number of problems. For one, I'll get the header printed for each row. Also, calling formatCSV() on a record wraps the record in a Result first, which in my case means allocating tens of millions of objects for effectively nothing.

What can I do to make this better?

kaqqao's user avatar

3

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.