How to calcualte the number of repeating elements within each group or...
Open Java API for OLAP
Brought to you by:
jhyde,
lucboudreau
Hello all
I am really new to OLAP4J but I was wondering is there a quick away to figure out while looping through the row axis (axis.getPositions().size()) and its members the number of occurrence a member is repeated within.
For example
----------------------------- CA --- FL------ NY
G1 -> V1 -> BBBB.......1.........10........3
G1 -> V1 -> CCCC.......0.........20........4
G1 -> V2 -> AAAA.......5..........5........0
G1 -> V2 -> BBBB......12..........6........0
G1 -> V2 -> CCCC.......1..........0........0
G1 -> V3 -> AAAA.......1..........0........0
G2 -> V1 -> AAAA......10..........0........0
G2 -> V1 -> BBBB.......1..........0........0
G2 -> V1 -> CCCC.......2..........0........0
G2 -> V2 -> AAAA.......7..........0........0
G2 -> V2 -> BBBB.......0..........0........0
If the output above is returned as above (beside having a convoluted set of loops) is there any way I could figure out using OLAP4J API that
1) G1 is repeated 6 times
2) G2 is repeated 5 times
3) V1(G1) 2 times
4) V2(G1) 3 times
4) V3(G1) 1 time
And this goes own for the entire cube result it's sort of like control break or grouping logic.
Thanks in advance for any help
max
You could iterate over the CellSet and use a multiset such as http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/HashMultiset.html to count the number of instances of each member.
However if you just want to print the results nicely formatted, try http://www.olap4j.org/api/org/olap4j/layout/RectangularCellSetFormatter.html or another implementation of CellSetFormatter.
Julian