RFR: 8088923: IOOBE when adding duplicate categories to the BarChart [v2]
Markus Mack
mmack at openjdk.org
Fri Jun 21 15:22:41 UTC 2024
On Thu, 20 Jun 2024 17:44:41 GMT, Markus Mack <mmack at openjdk.org> wrote:
>> This PR provides the test case given in the JBS issue, and a simple fix for the index calculation when inserting data after previous data with duplicate categories.
>>
>> Also, I've added a comment to `BarChart`s javadoc, clarifying the behavior that was apparently assumed (but broken) previously.
>>
>> The index lookup is skipped for performance reasons if there are no duplicates, corresponding to the previous implementation.
>> Further optimizations would be possible, but probably are not really helpful without more extensive changes. The previous code already loops over all categories to check if they are present, typically nested in a loop adding many data items, thus already scaling quadratically when adding lots of mostly unique data points.
>
> Markus Mack has updated the pull request incrementally with one additional commit since the last revision:
>
> JavaDoc formatting
Turns out this problem is even worse. If there are multiple series, and some data has duplicate categories within one or across multiple series, the insertion index on the category axis could be more or less anywhere.
I've enhanced the fix by choosing an ordering of the categories on the axis according to the concatenation of the data of each series, skipping duplicates. I've added some more unit tests, and checked the manual monkey tester issue discussed above as well.
Note this category ordering on the axis is not necessarily maintained, e.g. removing previously duplicate data items might cause some rather arbitrary ordering again, so it's probably not safe to optimize this much more without much more control over the methods being called.
Performance is still O(n) per item added, however n now is the sum of all categories of all series.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1476#issuecomment-2182954403
More information about the openjfx-dev
mailing list