Closed jferard closed 7 years ago
The currrent design doesn't fit to threading.
The process is quite strict: the data is written at the very end of the process. All the objects (tables, rows, cells, styles) are first created by the user, then transcripted to XML format and written to the file.
The aim is to make the process more flexible, allowing to flush data at any time, but to keep the current behavior in the case of a single flush at the end.
Here's a possible kind of "producer-consumer" design:
flush(boolean endOfTable)
method that flushes the rows to the bus. If endOfTable
is true, then the end of the table XML is written.flush()
method that flushes all the document to the bus.OdsFileWriter
, which has access to the output stream and to the document.Note 1: all the files of the ods archive, except content.xml
, must be written before content.xml
. That means that the styles have to be inserted manually in the document.
Note 2: this would free some memory, if the rows are set to null in the document when sent to the bus.
This is the most hard feature to implement for 0.3.0, so this issue will be the first in the next iteration. I think now that the point is not speed but memory: a flush method would allow to free memory fast, e.g. after each table is complete.
The flush should be a method from OdsFileWriter:
OdsFileWriter.flushRows
to flush current rowsOdsFileWriter.flushTables
to flush current tables.Here are a few steps:
The current implementation is very tedious:
The goal is:
This seems to be a too big step for one iteration. Let"s split it in two:
OdsFileWriter
that reproduces the OdsDocument
output;I keep this issue open, but set to milestone 3.1, and open a new issue for the first step.
The current implementation of the flush
method misses the point: the first thread should handle the whole text/xml production (including escape of xml chars), the second thread the writing of the text/xml into the output stream. The communication using one or several CharBuffer
seems a good solution.
Let's split this issue into two new issues:
CharBuffer
as communication "channel".See #69
Reminder:
content.xml
to be defined before they are used (that means that astyle-name
attribute mut refer to a style previously defined);Now, under some assumptions, it is possible to split FastODS work into two threads:
HeavyTableRow
s and put it on a bus;These assumptions are:
I think there is only one way to discover if it will really speed up the file creation: try!