Remove pre-fetch step in measurement exporter#2069
Conversation
|
Apologies for the unrelated Zarr/H5 stuff, this can be removed or I can try to add these in the same PR as desired. |
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
1e200f5 to
2f39521
Compare
9a4975e to
588738d
Compare
Attempts to avoid the pre-fetch step when building by only pre-allocating the measurement tables and not all of the strings. Therefore writing the table will take longer, but without the costly pre-fetch step. In theory writing could be parallelized for some formats also. This should also move file creation closer to writing, which should help avoid the situation possible at the moment where we overwrite a file and then crash before writing a single byte to it without throwing an exception (if createMeasurementTable fails).
588738d to
0caf502
Compare
petebankhead
left a comment
There was a problem hiding this comment.
I think this will be a big improvement and should help with supporting #2057
Made two comments as I think it could be made quite a lot simpler... or, if not, I'd need more comments to understand why not.
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
| exporter.progressMonitor(p -> updateProgress(p, 1.0)) | ||
| .exportMeasurements(new File(pathOut)); | ||
| } catch (IOException e) { | ||
| logger.error("Export failed", e); |
There was a problem hiding this comment.
Previously the error message dialog popped up but was instantly nuked by the progress bar closing
There was a problem hiding this comment.
Ah... that sounds like maybe we need Dialogs.builder to construct the error dialog and set the owner rather than leaving it up to getDefaultOwner (or improve the logic of getDefaultOwner, but that sounds tricky if it doesn't know we'll promptly be closing the progress bar)
|
Okay fair dues, that does indeed make it less convoluted. The progress monitor is now basically unused and has been removed, unless this should be kept? With an iterator it's not clear how to track updates |
|
Fair point... I suppose progress could be per Alternatively, you could count the objects for each image initially when building the table and use that to update the progress in one of 2 ways:
|
petebankhead
left a comment
There was a problem hiding this comment.
I think it's improving in terms of becoming simpler, although in its current state seems to be fundamentally broken... both in terms of columns and rows that are export.
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Outdated
Show resolved
Hide resolved
qupath-gui-fx/src/main/java/qupath/lib/gui/tools/MeasurementExporter.java
Show resolved
Hide resolved
|
Think that's fixed now, also with progress updated once per image data as before. Although now it is when writing data, not when creating the table of strings. |
|
I'll merge this as it certainly improves some important things. I plan to follow up with another PR to handle a few others:
|
|
Neat thanks, I would offer to handle these but I'm sure it's apparent my understanding of the layers here is not comprehensive, to put it politely |
Remove pre-fetch step in measurement export wherein string representations of all columns were fetched. Now we only pre-query the columns and rows of the table by iterating over the image data. Therefore writing the table will take longer, but without the costly pre-fetch step the overall time may be roughly similar. In theory writing could be parallelized for some formats.
This should also move file creation closer to writing, which should help avoid the situation possible at the moment where we overwrite a file and then crash before writing a single byte to it (if createMeasurementTable fails).
Also, make a small optimisation in writer use going by the javadocs for outputstreamwriter