Hi Xavier, can you say that you don't miss Pivot4J?

28 views
Skip to first unread message

Pablo S

unread,
Feb 13, 2019, 8:04:18 PM2/13/19
to pivot4j-list

Hope things are well. I'm using the HtmlRenderCallback class to generate OLAP query results and it works very well, including the spanning of complex headers.

What I need now is to add totals to the resulting table. I looked at the code and I don't know where to start. Could you provide any hints on how to approach this?


Thanks 
Pablo

Xavier Cho

unread,
Feb 17, 2019, 11:02:36 AM2/17/19
to pivot4j-list
Hi Pablo,

I do miss this project :) It's just that I'm spending all my spare time in a different open source project and it's been too long since I the last time I looked into the codebase of Pivot4j.

Fortunately though, I believe I remember it just enough to give you some hint on this matter. If I recall correctly, `TableRenderer` is responsible for iterating the OLAP model in a tabular manner, and invokes proper callback methods in a given `TableRenderCallback` (e.g. `HtmlRenderCallback`).

And there's such a concept as 'Aggregator` which can be used to aggregate cell values in a model. You can add one using `AbstractPivotRenderer.setAggregators()` then you'll get a table with an aggregation result.

If the default aggregator implementations or the manner in which they are renderered would not suffice your requirements, you can also write a custom implementation to solve the problem though it'd be a bit more demanding in this case.

Hope this helps!

Cheers,
Xavier

2019년 2월 14일 목요일 오전 10시 4분 18초 UTC+9, Pablo S 님의 말:

Pablo S

unread,
Feb 18, 2019, 7:04:18 AM2/18/19
to pivot4j-list
Hi Xavier,

I recompiled pivot4j with no issues, but when I try to run the HTML Renderer I get the exception below. The lib folder contains java_cup-0.9e.jar, runtime-0.10.0.jar and jflex-1.6.1.jar, so I don't know what is missing:

Caused by: java.lang.NoSuchMethodError: org.pivot4j.mdx.impl.CupParser.unpackFromStrings([Ljava/lang/String;)[[S
at org.pivot4j.mdx.impl.CupParser.<clinit>(CupParser.java:35)
at org.pivot4j.mdx.impl.MdxParserImpl.parse(MdxParserImpl.java:37)
at org.pivot4j.impl.QueryAdapter.parseQuery(QueryAdapter.java:629)
at org.pivot4j.impl.QueryAdapter.initialize(QueryAdapter.java:99)
at org.pivot4j.impl.PivotModelImpl.initialize(PivotModelImpl.java:215)

The code runs an mdx statement:

            PooledOlapDataSource conn = // get connection
            PivotModelImpl model = new PivotModelImpl(conn);
    model.setMdx(mdxString);
            model.initialize();   // <----- fails here
    TableRenderer renderer = new TableRenderer();

How to fix this?

Thanks
Pablo

Xavier Cho

unread,
Feb 18, 2019, 7:09:50 AM2/18/19
to pivot4j-list
Hi again,

If I recall correctly, `CupParser` is generated from a parser definition file when the project is built. And the stacktrace indicates that there might be two conflicting versions of that class somewhere on the classpath.

So, my guess is there may be multiple versions of pivot4j-core*.jar somewhere in your runtime environment.

Hope this helps!

Xavier

2019년 2월 18일 월요일 오후 9시 4분 18초 UTC+9, Pablo S 님의 말:

Pablo S

unread,
Feb 18, 2019, 7:37:46 AM2/18/19
to pivot4j-list

Actually runtime-0.10.0 was in pom.xml but not in EAR/lib. Changing the pom.xml dependency to the latest version java-cup-runtime-11b.jar downloaded the jar to EAR/lib and it worked. 

Thanks!
Pablo
Reply all
Reply to author
Forward
0 new messages