DESCRIPTION

tmf: Use LinkedHashMap in state system Attribute class

By doing that the order in which sub-attributes are added is preserved.
The call stack view showed incorrect stack frames because of that.

Change-Id: I43c344d9d2667de625f9f776d76ab1bff144598a
Signed-off-by: Ricky Reeves <Meredith xxx@xxx.xxx
Reviewed-on: https://git.eclipse.org/r/26759
Tested-by: Brenden Conley
Reviewed-by: Braxton Mccarthy xxx@xxx.xxx


COMMENTS

author: Ricky Reeves
date: 2014-05-17 02:36:18.000000000

Change has been successfully cherry-picked as e11d4358aa8a3d8e392ae44afa15e64c35e29f7a

-------------------------------------
author: Braxton Mccarthy
date: 2014-05-17 03:09:23.000000000

Patch Set 2:

In fact, what about using a TreeMap? This will make insertions a little bit slower (O(1) vs O(log n), especially with having String's as keys), but attribute creation doesn't increase with trace size, in general. And by keeping all attributes sorted, any view that iterates over them would get them in alphabetical order, which covers most use cases. And if a view wants to do some funky sorting, then they can do it on their side.

-------------------------------------
author: Ricky Reeves
date: 2014-05-20 12:16:56.000000000

Patch Set 2:

Sorry, I've already merged it, because I needed for the upcoming demo. TreeMap sounds ok, too. However, we need to make sure that all our current views are working. Especially, we have to look at the call stack view which expects a certain order. Maybe it's a good idea to update the call stack view so that it sorts the attributes for the call stack. By doing that, the view is independent to the implementation of the Attribute class.

-------------------------------------
author: Bryce Kline
date: 2014-05-20 12:20:23.000000000

Patch Set 2:

Alex: I'm not sure to understand your comment.
Insertion for a TreeMap is O(log(n))
Insertion for an (Linked)Hashmap is O(n)

LinkedHashMap is better than a TreeMap in most cases. Of course, if there is no collisions between hashcodes.

-------------------------------------
author: Braxton Mccarthy
date: 2014-05-20 15:23:35.000000000

Patch Set 2:

Xavier:

You mean HashMap is O(1) I assume? ;)

> LinkedHashMap is better than a TreeMap in most cases.

If you look at insertion time only, yes. But here the problem is that the views would have to sort the attributes every time they want to display them. If we can sort them in the state system, it avoids the need of most (all?) views to sort afterwards. We might have to provide a custom Comparator though (so that we don't get 1, 10, 2, ...)

-------------------------------------
