Uploaded image for project: 'ODF Toolkit'
  1. ODF Toolkit
  2. ODFTOOLKIT-215

Performance problem in CellRange constructor when Table.getRowCount() is large

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • simple-0.5
    • None
    • performance
    • None
    • Operating System: Windows
      Platform: PC
    • 328

    Description

      Created an attachment (id=536)
      Test data for the example code

      Given a spreadsheet document which has for example the text alignment or similar formatting set for a whole column (in OpenOffice by selecting the column and then changing the formatting), then reading any cell ranges from that Table using org.odftoolkit.simple.table.Table#getCellRangeByName or org.odftoolkit.simple.table.Table#getCellRangeByPosition becomes unusable in performance.

      This is because in the constructor of org.odftoolkit.simple.table.CellRange there is the method call maOwnerTable.getCellCoverInfos(0, 0, maOwnerTable.getColumnCount() - 1, maOwnerTable.getRowCount() - 1) and in this situation maOwnerTable.getRowCount() will return 1048576 (and for formatted rows maOwnerTable.getColumnCount() will return 1024). As a result that method call will take many minutes or hours.

      The performance of creating a CellRange should be relative to the size of the range or a constant time operation - not relative to the maximum size of the spreadsheet.

      Here is some code to reproduce the issue. I've attached the test.ods file used in the code. On my 3 GHz Core 2 CPU that code takes over an hour to execute - and I haven't even waited until the end.

      import org.odftoolkit.simple.SpreadsheetDocument;
      import org.odftoolkit.simple.table.*;

      public class PerformanceProblem {
      public static void main(String[] args) throws Exception

      { SpreadsheetDocument document = SpreadsheetDocument.loadDocument("test.ods"); Table table = document.getTableByName("Sheet1"); long start = System.currentTimeMillis(); CellRange values = table.getCellRangeByPosition(0, 0, 2, 2); long end = System.currentTimeMillis(); System.out.println("Calling getCellRangeByPosition took " + (end - start) + " ms"); }

      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              orfjackal@odftoolkit.org orfjackal
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: