Jump to content
  • Deserializing JasperPrint objects from .jrprint files should allow use of JRVirtualizer functionality


    es_dev
    Assigned User lucianc
    CategoryFeature request
    PriorityNormal
    ReproducibilityAlways
    ResolutionFixed
    SeverityMinor
    StatusClosed

    For very large reports, Jasper supports the REPORT_VIRTUALIZER report parameter to allow for better management of memory, including caching report pages to disk with JRFileVirtualizer. This allows reports to be run and exported to different formats with a very small memory footprint compared to the size of the report.

     

    Report output may also be saved with JRSaver.saveObject() in the form of a serlialized instance of JasperPrint, typically with the .jrprint extension. Under normal circumstances, this allows flexibility in output rendering by delaying the choice of export format until the exported output is required. For instance, a report output might be serialized into a .jrprint file and retained in a database, and later exported to CSV or PDF, depending on user preference.

     

    However, the JRLoader.loadObject() method (as called by the various JRExporter classes) deserializes the JasperPrint object naively, and does not allow for the "re-virtualization" of the object to preserve memory. Therefore, after the JasperPrint object has been serialized and released for garbage collection, it may be impossible to reload or export the report to another format.

     

    Feature request: provide an option both within the JRLoader.loadObject() methods, and the JRExportParameter map, to allow for virtualization of reports being deserialized from .jrprint files.



    User Feedback

    Recommended Comments

    Using a virtualizer on JasperPrint object deserialization can be done by calling JRVirtualizationHelper.setThreadVirtualizer, see http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRVirtualizationHelper.html#setThreadVirtualizer(net.sf.jasperreports.engine.JRVirtualizer).

     

    Keeping this open to consider the requests to make this functionality more visible by adding a JRLoader argument and/or an export parameter.

     

    Regards,

    Lucian

    Link to comment
    Share on other sites

    Lucian, you have just made my morning. This worked like a charm, and is going to let me include a feature in my product that I thought might have to be scrapped.

     

    Any effort to make the feature more visible in the future would be appreciated.

    Link to comment
    Share on other sites

    these methods with signature loadJasperPrint* are not available in latest version 4.5, could u please confirm?

     

    lucian could u please give a sample code to add virtualizer technique while exporting large reports to xls.

     

     

    Regards,

    chinnu

    Link to comment
    Share on other sites

    Right, the changes did make it into JasperReports 4.5.0. I'm correcting the bug version.

     

    Virtualizers apply to reports at fill time, and do not have any direct effect when exporting the reports. So just fill the reports using a virtualizer, and then export the report to Excel. Note though that the Excel exporters use a lot of memory on their own, so even if the report is virtualized you might end up exhausting the memory at export time.

     

    Regards,

    Lucian

    Link to comment
    Share on other sites

    Lucian

    Is there any way to de-virtualize the JRPrint ?

    I need to throttle the JRPrint size that could be loaded into memory, so the idea is to create virtualized JRPrint (with swap file virtualizer), check it's size and if it's less than threshold - devirualize it into memory and pass to web tier (for later exporting by page) , otherwise - full export and send by email in background thread.

    May be I'm missing something and there is another approach to accomplish this.

     

    Thanks

    Alexander

     

     

    Link to comment
    Share on other sites


×
×
  • Create New...