Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 238453

Summary: Code Simplification
Product: z_Archived Reporter: Scott Rosenbaum <scottr>
Component: BIRTAssignee: Xiaoxiao Wu <xwu>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: bluesoldier, lzhu, wenfeng.fwd
Version: 2.3.0Keywords: helpwanted
Target Milestone: 2.5.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard: Obsolete

Description Scott Rosenbaum CLA 2008-06-25 14:17:07 EDT
I had to take a look at the calculation that is used in the Mode calculation in the org.eclipse.birt.data.engine.aggregation.TotalMode class.

You are using a HashMap to store data about the mode values and counts.  Since the HashMap is order independent, you have to use a Counter internal class to keep track of the order that elements are inserted.

Doesn't it make sense to change the implementation to use either a TreeMap or a LinkedHashMap (Java 1.5) so that you don't have to add the step of looking for first inserted item?  

Would this be a good HelpWanted enhancement?

sr
Comment 1 Lin Zhu CLA 2008-06-25 23:18:42 EDT
Scott,

Thanks for the detailed info against the enhancement.

We will make enhancement in 2.3.1.

As this is a plenty trival issue and involves little resources, I think we can do it ourselves;)

Regards,
Lin
Comment 2 Wenfeng Li CLA 2008-06-26 18:08:57 EDT
Add keyword helpwanted for community contribution.
Comment 3 Xiaoxiao Wu CLA 2009-08-20 02:56:26 EDT
For the function “TotalMode”, we did code refactoring to optimize the internal logics. Now we use a single LinkedHashMap to store all the different values with their frequencies.

By using the LinkedHashMap, we can directly find the first one that occurs most frequently.

So mark this bug as FIXED.