[Mondrian] Improving concurrency on Segment.getCellValue()

Julian Hyde jhyde at pentaho.com
Tue Dec 2 06:05:17 EST 2008


Another part of the life cycle you don't mention is Aggregation member
List<Segment> segmentRefs, which is implemented using a
CopyOnWriteArrayList. This ensures that looking up a Segment that matches a
particular cell value can be done without taking locks.

Whatever solution you choose, it needs to work under JDK 1.4 using
mondrian's current strategy based on retroweaver. The fact that
CopyOnWriteArrayList is being used already is a good sign, but you will need
to test that it works on JDK 1.4.

The locking primitives you describe seem to do the job required, and of
course multi-threaded testing will prove that.

My biggest concern is that the code will be another factor more difficult to
understand after your change. You will at the very least need to document
the locking strategy that you implement at an appropriate point in the class
documentation. Approach #2 is attractive because it reflects the locking
protocol in the class structure (first ascertain the state, then get the

In that sense, approach #2 is 'simpler' than #1. When you say that #1 is
simpler, I think you mean that it is less work to get there.

I am not going to mandate approach #2. As you say, it makes sense to do
option #1 first, and you should do that. I would like you to leave deliver
clear, maintainable code, and you should seriously consider option #2 if it
leads to clearer code.


More information about the Mondrian mailing list