You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/09/19 16:42:42 UTC

[Bug 53904] New: Generate xlsx File is slow causing by org.apache.poi.openxml4j.opc.PackageRelationshipCollection

https://issues.apache.org/bugzilla/show_bug.cgi?id=53904

          Priority: P2
            Bug ID: 53904
          Assignee: dev@poi.apache.org
           Summary: Generate xlsx File is slow causing by
                    org.apache.poi.openxml4j.opc.PackageRelationshipCollec
                    tion
          Severity: critical
    Classification: Unclassified
                OS: All
          Reporter: superinkfish@gmail.com
          Hardware: All
            Status: NEW
           Version: 3.8
         Component: XSSF
           Product: POI

When I generate a xlsx file which size is 1.7MB, I wait more than 11 minutes to
finish. When I fix the bug, the time is reduce to 5 seconds.
My code(JDK 1.7):
try (BufferedOutputStream out = new
BufferedOutputStream(desFile.getContent().getOutputStream())) {
            this.workbook.write(out);
} catch (IOException ex) {
    log.error(ex.getMessage(), ex);
}

The bug(org.apache.poi.openxml4j.opc.PackageRelationshipCollection):
public PackageRelationship addRelationship(URI targetUri, TargetMode
targetMode, String relationshipType, String id) {
    if (id == null) {
        // Generate a unique ID is id parameter is null.
        int i = 0;
        do {
            id = "rId" + ++i;
        } while (relationshipsByID.get(id) != null);
    }
    ......
}
The variable i will raise form 0 to 1000000 when the method be called  1000000
and the loop will calculate more than 500000 billion times!

I modified the code:
private int currentRelationshipsId = 0;
public PackageRelationship addRelationship(URI targetUri, TargetMode
targetMode,
 String relationshipType, String id) {
    if (id == null) {
        // Generate a unique ID is id parameter is null.
        id = "rId" + ++currentRelationshipsId;
    }
    ......
}

The performance became more faster.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53904] Generate xlsx File is slow causing by org.apache.poi.openxml4j.opc.PackageRelationshipCollection

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53904

Dmitry Smirnov <dm...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |richardjusko@gmail.com

--- Comment #2 from Dmitry Smirnov <dm...@gmail.com> ---
*** Bug 53582 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53904] Generate xlsx File is slow causing by org.apache.poi.openxml4j.opc.PackageRelationshipCollection

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53904

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Your suggested fix would run into problems if relationships were added using
the other overloaded add methods. For example, if you opened an existing file
with two relationships, then went to add a third, your code would fail by
trying to add a second rId1

In r1442148 I've added something that'll hopefully greatly reduce the number of
steps, but will still check for clashes. Could you please test that and see if
it resolves the issue for you?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53904] Generate xlsx File is slow causing by org.apache.poi.openxml4j.opc.PackageRelationshipCollection

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53904

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Dominik Stadler <do...@gmx.at> ---
No response for quite some time on this one, a potential fix was made, so I
don't think we can improve much more here unless you can provide updated
information about your experience with the changes that were applied, therefore
I am closing this to FIXED for now.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org