How to extend OLAP Operators on Mondrian Server (Java)

I think there are many works over Java-based server Mondrian, in which MDX-based OLAP operators have been created to apply multidimensional analysis over data (Ex.: LMDQL, GeoMDQL, both are PhD thesis from Federal University of Pernambuco, Brazil).

I’m going to explain this topic through the four OLAP operator that I have implemented for Forensic LMDQL (which is a OLAP language for financial fraud detection over financial (XBRL) documents). When I was implementing these financial forensic operators, I needed to look for about this topic on web and I could not find enough sources about that…That’s why I am posting it.

  • UDF – UserDefinedFunction 

Mondrian Server provides a so-called UserDefinedFunction interface to extend new OLAP operators. Then, the developer have to import the package “mondrian.spi.UserDefinedFunction” in the class imports, after that, it has to implement this interface.  The following figure illustrates the implementation of EmpiricalRule operator:

EmpiricalRule Operator - Forensic LMDQL

EmpiricalRule Operator – Forensic LMDQL

Then, you have to implement the methods of the Mondrian UDF interface, as such: execute, getDescription, getName, getParameterTypes, getReservedWords, getReturnType, getSyntax.

UDFmethods

UDF interface methods

  • Mondrian Data Type

Mondrian server provides many data types for development of the operator, in which the data can be handled and processed. You have to import the package “modrian.olap.type.*”. These types can be a cube, dimension, member, hierarchy, serialized number set…etc.

Mondrian Data Types

Mondrian Data Types

Essentially, these types are going to be used in the getParameterTypes, getReturnType and execute methods.

  • getParameterTypes()

In this method, it is defined what parameters the operator is going receive, and also its types. Then, this method is directly linked to execute() method. In the following figure you can see getParameterType() method defines that the operator receives fours parameters, all of them can be a set of MemberType.

getParameterTypes

Mondrian UDF method: getParameterTypes()

  • getReturnType()

In this method it is defined the data type that the operator will return. The data types available are the same of the previous method (getParameterType()).

Mondrian UDF method: getReturnType()

Mondrian UDF method: getReturnType()

  • execute()

Definitely this method is the core of the OLAP operator, where the data is going to be processed. Its parameters are defined in the getParameterType() method (how it was explained in the previous topic). In the following figure you can notice that the declaration of execute() parameter is just a array of Argument. Then, every data set (received by MDX query) is put in a List<> (java type), which is declared as Member (Mondrian type). After that, you can manipulate all data and also process them, such as this specific operator have to.

Mondrian UDF method: execute()

Mondrian UDF method: execute()

Basically, those are the topics you have to know for building MDX-based OLAP operator over Mondrian Server. I hope this post can be very useful.

Finally, the following link is a good presentation about how you can build an OLAP Solution using Mondrian and JPivot (by Sandro Bimonte and Pascal Wehrle).

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.