Mercurial > hg > svcore
diff data/fileio/CSVFileWriter.cpp @ 1452:6e9615bde1f9 streaming-csv-writer
For sparse models, write whole model to CSV in one go
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 17 Apr 2018 10:37:50 +0100 |
parents | a12fd0456f0c |
children | c546429d4c2f |
line wrap: on
line diff
--- a/data/fileio/CSVFileWriter.cpp Tue Apr 17 10:37:15 2018 +0100 +++ b/data/fileio/CSVFileWriter.cpp Tue Apr 17 10:37:50 2018 +0100 @@ -67,11 +67,11 @@ }; MultiSelection selections; selections.addSelection(all); - writeSelection(&selections); + writeSelection(selections); } void -CSVFileWriter::writeSelection(MultiSelection *selection) +CSVFileWriter::writeSelection(MultiSelection selection) { try { TempWriteFile temp(m_path); @@ -85,13 +85,24 @@ QTextStream out(&file); + sv_frame_t blockSize = 65536; + + if (m_model->isSparse()) { + // Write the whole in one go, as re-seeking for each block + // may be very costly otherwise + sv_frame_t startFrame, endFrame; + selection.getExtents(startFrame, endFrame); + blockSize = endFrame - startFrame; + } + bool completed = CSVStreamWriter::writeInChunks( out, *m_model, - *selection, + selection, m_reporter, m_delimiter, - m_options + m_options, + blockSize ); file.close();