poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 58740] [PATCH] Fix O(n^2) behavior when generating XLSX files with large number of styles
Date Wed, 16 Dec 2015 14:15:18 GMT

--- Comment #2 from Archie Cobbs <archie@dellroad.org> ---
(In reply to Javen O'Neal from comment #1)
> Out of curiosity, how many styles are you creating that cause the reported
> several minutes/10 seconds times?

I have one column where the background color is set according to the
data value as a visual aid. Lots of values lead to lots of colors and
therefore styles. Even limiting to couple thousand colors leads to this

> 1) higher memory consumption

Yes but insignificantly. A small constant number of bytes per style.

> 2) extra processing power updating multiple data structures

Huh?!? You're missing the whole point.

If you have non-trivial number of styles, there will be MUCH less
processing power utilized because we eliminate the stupid O(n^2) behavior.

For a trivial number of styles, the overhead is minimal - linear time in
the number of styles, which by definition, is small.

> 3) potential for the data structures to get out of sync, especially
> considering projects that subclass POI.

Wrong - the fields are all private. It's not possible for a subclass
to get things out of sync.

> My recommendation is use a single data structure that is a container for
> cell styles, that combines the features that you need that will give fast
> by-index and by-style lookup. If such a data structure isn't available
> off-the-shelf, you may want to write your own. Most trivially, this is just
> a class that contains an ArrayList and a HashMap for inverted array lookups,

That's a possible refinement and I considered it. My goal was to address
the immediate problem.

You are letting the perfect be the enemy of the good. I've provided a
reasonable patch to address what is truly stupid behavior. My recommendation
is to use this patch to "put out the fire" so to speak, and we can refine it
later at a lower priority.

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

View raw message