Presentation 2007-02 (1)

download Presentation 2007-02 (1)

of 83

Transcript of Presentation 2007-02 (1)

  • 8/13/2019 Presentation 2007-02 (1)

    1/83

    1

    An OLAP Solution using

    Mondrian and JPivot

    Sandro Bimonte

    Pascal Wehrle

  • 8/13/2019 Presentation 2007-02 (1)

    2/83

    2

    A tour of OLAP using Mondrian

    Introduction (architecture, functionality)

    Example installation and configuration

    Derived architectures and products Multidimensional expression language

    (MDX)

    How to design a cube in Mondrian Advanced configurations in Mondrian

  • 8/13/2019 Presentation 2007-02 (1)

    3/83

    3

    Introduction

    Architecture & Functionality

  • 8/13/2019 Presentation 2007-02 (1)

    4/83

  • 8/13/2019 Presentation 2007-02 (1)

    5/83

    5

    3 tier architecture

  • 8/13/2019 Presentation 2007-02 (1)

    6/83

    6

    Functionalitypresentation tier

    Web interface in HTML

    Javascript & HTML Forms for interaction

    Managed by Web Component Framework(WCF, included in JPivot) on the server

  • 8/13/2019 Presentation 2007-02 (1)

    7/83

    7

    Functionalityapplication logic tier

    JPivot: Pivot tables and OLAP operations

    Execution of MDX queries by Mondrian

    Hosted by Application Server (JBoss,Tomcat Servlet container etc.)

  • 8/13/2019 Presentation 2007-02 (1)

    8/83

  • 8/13/2019 Presentation 2007-02 (1)

    9/83

    9

    Functionality - Communication

    W e b B ro w s e r

    JPiv o t(Pivo t Ta ble s , OLAP Alg e bra)

    Mondrian

    (Mult idim . Mod e l, OLAP Se rve r)

    DB MS (JDB C)

    (MySQL, Po s tg re SQL,

    MS SQL Se rve r, Ora cle )

    HTMLHTML fo rm s

    Mondria n .o la p .Re s ultMDX que ry

    JDBC Re s ultSe tSQL que ry

  • 8/13/2019 Presentation 2007-02 (1)

    10/83

    10

    FunctionalityFeatures

    Mondrian:

    ROLAP model mapping

    Cache for reuse of query results

    Usage of pre-computed aggregates

    JPivot:

    Pivot table for advanced OLAP operations on

    warehouse data

    Visualization of warehouse data using charts

  • 8/13/2019 Presentation 2007-02 (1)

    11/83

    11

    Example installation and

    configuration

  • 8/13/2019 Presentation 2007-02 (1)

    12/83

    12

    DBMS: PostgreSQL - Installation

    Download from:

    http://www.postgresql.org

    Installed version: 8.1

    Installation type: Local standalone server (run as a service)

    Allow only local connections

    JDBC driver for communication with Java applications

    http://www.postgresql.org/http://www.postgresql.org/http://www.postgresql.org/
  • 8/13/2019 Presentation 2007-02 (1)

    13/83

    13

    DBMS: PostgreSQL - Installation

  • 8/13/2019 Presentation 2007-02 (1)

    14/83

  • 8/13/2019 Presentation 2007-02 (1)

    15/83

    15

    DBMS: PostgreSQL - Configuration

    Easiest way to use

    MondrianFoodMartLoader:

    Get Eclipse IDE, from http://www.eclipse.org

    Add the Web Tools Platform (WTP) plugin

    Download & unzip Mondrian (2.2.2)

    Import the mondrian.war from mondrian-

    2.2.2/lib

    include PostgreSQL JDBC, Apache log4j,

    eigenbase XOM and properties libraries (from

    PostgreSQL install and mondrian-src.zip/lib)

  • 8/13/2019 Presentation 2007-02 (1)

    16/83

    16

    DBMS: PostgreSQL - Configuration

    locate the mondrian-

    2.2.2/demo/FoodMartCreateData.sql file

    Finally, run :

    mondrian.test.loader.MondrianFoodMartLoader-verbose -tables -dataindexes

    -jdbcDrivers=org.postgresql.Driver

    -outputJdbcURL=jdbc:postgresql://localhost/Foodmart

    -outputJdbcUser=foodmart

    -outputJdbcPassword=foodmart

    -inputFile=demo/FoodMartCreateData.sql

  • 8/13/2019 Presentation 2007-02 (1)

    17/83

    17

    Tomcat Servlet/JSP container -

    Installation

    Download from:

    http://tomcat.apache.org

    Installed version: 5.5

    Installation type:

    standard server (run as a service)

    Integrated with Eclipse Web Tools Platform

    (WTP) plugin

    http://tomcat.apache.org/http://tomcat.apache.org/
  • 8/13/2019 Presentation 2007-02 (1)

    18/83

    18

    Tomcat Servlet/JSP container -

    Configuration

    Create a new Eclipse project of type Server

    and follow instructions

    Specify the server type (Apache Tomcat 5.5),

    host (localhost) and runtime configuration:

  • 8/13/2019 Presentation 2007-02 (1)

    19/83

    19

    Mondrian+JPivot - Installation

    Download from:

    http://jpivot.sourceforge.net

    Installed version: 1.6.0

    Installation type:

    Import of deployment package as Eclipse

    project

    Uses Mondrian library included with JPivot

    package

  • 8/13/2019 Presentation 2007-02 (1)

    20/83

    20

    Mondrian+JPivot - Configuration

    Edit WebContent\WEB-INF\queries\mondrian.jsp

    Add JDBC connection parameters to the query

  • 8/13/2019 Presentation 2007-02 (1)

    21/83

    21

    Mondrian+JPivot - Configuration

    Run the JPivot web project on the server

    and enjoy

  • 8/13/2019 Presentation 2007-02 (1)

    22/83

    22

    Derived architectures & products

    Business Intelligence (BI) suites: Pentaho JasperSoft

    Custom solutions: JRubik BIOLAP

    your own project...

  • 8/13/2019 Presentation 2007-02 (1)

    23/83

    23

    Pentaho : Overview

    Open Source BI application suite madefrom free component applications

    Official home of the Mondrian project

    Reporting:Eclipse BIRT (BusinessIntelligence and Reporting Tools)

    Analysis:Mondrian, JPivot

    Data Mining:Weka (University of WaikatoMachine Learning Project)

    Workflow:Enhydra Shark, Enhydra JaWE

  • 8/13/2019 Presentation 2007-02 (1)

    24/83

    24

    Pentaho : Architecture

  • 8/13/2019 Presentation 2007-02 (1)

    25/83

    25

    Pentaho: Analysis

    Another skin for JPivot...

  • 8/13/2019 Presentation 2007-02 (1)

    26/83

    26

    Pentaho: Analysis

    But there's also this (using Apache Batik)...

  • 8/13/2019 Presentation 2007-02 (1)

    27/83

    27

    Pentaho: Analysis ...and this!

  • 8/13/2019 Presentation 2007-02 (1)

    28/83

    28

    JasperSoft

  • 8/13/2019 Presentation 2007-02 (1)

    29/83

    29

    JRubik

    Java client with Swing UI built using JPivot components plugin interface for custom data

    visualization

  • 8/13/2019 Presentation 2007-02 (1)

    30/83

    30

    JRubik

  • 8/13/2019 Presentation 2007-02 (1)

    31/83

    Spatial DW and Spatial OLAP Integration of Spatial data in DW and OLAP

    GeWOLap is OUR web based tree-tier solution: SpatialORACLE, Mondrian andJPivot + MapXtreme Java-

  • 8/13/2019 Presentation 2007-02 (1)

    32/83

    Spatial DW and Spatial OLAP

    It supports Geographical Dimensions andMeasures

  • 8/13/2019 Presentation 2007-02 (1)

    33/83

    33

    Your own application...

    pa cka ge p ro je ct1 ;

    imp ort jav a .io.PrintWrite r;

    im port m ondrian.olap.Conne ct ion;

    im port m ondrian.olap.DriverMan age r ;

    im port m ondrian.olap.Query;

    im port m ondrian.olap.Res ul t ;

    pub lic cla s s im ondria n {

    pub lic s ta t ic vo id m a in (S trin g[] a rg s ) {

    String conne ctString = "Provider= m ondrian ;" +

    "Jdbc= jdbc:m ysql :/ /localhost :3306/foodm art?use r= foodm art&pa ss word= foodm art ;" +

    "Cat alog= file: . \\web ap ps \\m ondrian \\WEB-INF\\que rie s\\FoodMart.xm l;" +

    "JdbcDrive rs= com .m ys ql.jdbc.Drive r";

    Conne ct ion conne ct ion = nul l;

    conne ct ion = Drive rMan age r .ge tConne ct ion(conne ctString, null , fa lse ) ;

    Query que ry = conne ction.pa rse Query("SELECT {[Mea su res ].[Unit Sales ], [Me a su res ].[Store Cost],"+" [Me as ures ].[Store Sales ]} on colum ns , {([Prom otion Media].[All Me dia], [Produ ct].[All Products ])}"+

    "ON rows FROM Sa les WHERE ([Tim e ].[1997 ])");

    Res u lt r e su l t = connec t ion .execu te (query);res ult .print(ne w PrintWriter(Sys te m .out,true ));

    }}

  • 8/13/2019 Presentation 2007-02 (1)

    34/83

    MDX: Basic Notions

  • 8/13/2019 Presentation 2007-02 (1)

    35/83

    First Example

    A First example of a multidimensional

    query: Sum of sales for each year

    SELECT

    {([Measures].[Unit Sales])} ON

    COLUMNS,

    [Time].[Year].Members ON ROWS

    FROM SALES

  • 8/13/2019 Presentation 2007-02 (1)

    36/83

    MDX Grammar (1/3)

    SELECT axis{, axis}

    FROM cube name

    WHERE slicer

    Axes are dimensions and/or Measures

    Slicer represents the selection predicate

  • 8/13/2019 Presentation 2007-02 (1)

    37/83

    MDX Grammar (2/3)

    Terminal are :

    Set{}

    Tuple()

    Cube elements names (cubes,dimensions, levels, members and

    properties)[]

    ON ROWSand ON COLUMNSrepresent the

    configuration of the pivot table

  • 8/13/2019 Presentation 2007-02 (1)

    38/83

    MDX Grammar (3/3)

    Point Operator .

    access to a dimension member

    [Time].[1997]member 1997 of the level Year

    access to a level of a dimension

    [Time].[Year]Year Level

    access to an operation

    [Time].[Year].Membersoperation Members

  • 8/13/2019 Presentation 2007-02 (1)

    39/83

    Set Example

    An expression, which is a set of tuples of

    members, is used to specify an axis

    {([Time].[1997]),

    ([Time].[1998]),

    ([Time].[1998].[9-1998])}

  • 8/13/2019 Presentation 2007-02 (1)

    40/83

    Tuples (1/2)

    Tuples must be coherent

    Each coordinate has to include member belonging to the

    same dimension

    They can belong to different levels

    {([Time].[1997], [Store].[Canada]),

    ([Time].[1998], [Store].[USA]),

    ([Time].[1998].[9-1998], [Store].[Canada])}

  • 8/13/2019 Presentation 2007-02 (1)

    41/83

  • 8/13/2019 Presentation 2007-02 (1)

    42/83

  • 8/13/2019 Presentation 2007-02 (1)

    43/83

    Operations

    Operations having set as output:

    x.Members= set of members of a level or

    dimension

    x.Children= set of children of a member x

    DESCENDANTS(x, l)= set of descendants of amember x at the level l

  • 8/13/2019 Presentation 2007-02 (1)

    44/83

    Descendants example

    SELECT {([Measures].[Store Sales])} On

    COLUMNS,

    DESCENTANTS ([Time].[1998], [Quarter])

    ON ROWS

    FROM [SALES]

  • 8/13/2019 Presentation 2007-02 (1)

    45/83

    SlicerWHEREpermits to selection a part of the cube

    It is specified using members which do not belongto dimensions axes:ON ROWS and ON COLUMNS

    SELECT {([Measures].[Unit Sales])} ON COLUMNS,

    {([Time].[Year].Members)} ON ROWS

    FROM SALES

    WHERE ([Store].[USA].[NY])

    Slice on the state of New York

    It is not possible to have a slice with more than one member of the samedimension

    WHERE ([Store].[USA].[NY], [Store].[USA].[Texas])

    IT IS NOT CORRECT

    C

  • 8/13/2019 Presentation 2007-02 (1)

    46/83

    Calculated Members

    They are used to calculate measures and do comparison

    WITH MEMBERspecify the name and

    AS its associates formula

    WITH MEMBER [Measures].[Store Profit] AS

    [Measures].[Store Sales]- [Measures].[Store Cost]

    SELECT {([Measures].[Unit Sales])} ON COLUMNS,

    {([Time].[Year].Members)} ON ROWS

    FROM SALES

    WHERE ([Store].[USA].[NY])

  • 8/13/2019 Presentation 2007-02 (1)

    47/83

    Operations on Members

    x.CURRENTMEMBERCurrent member ina dimension or a level

    m.PREVMEMBERMember thatpreceds the member m in their

    level

    m.NEXTMEMBERMember that followsthe member m in their level

  • 8/13/2019 Presentation 2007-02 (1)

    48/83

    A Complex Example

    WITH MEMBER [Measures].[Sales Difference] AS

    ([Measures].[Store Sales],[Time].CurrentMember)

    -

    ([Measures].[Store Sales],[Time].PrevMember)

    SELECT {([Measures].[Sales Difference])} ONCOLUMNS,

    {([Time].[Year].Members)} ON ROWSFROM SALES

    WHERE ([Store].[USA].[NY])

  • 8/13/2019 Presentation 2007-02 (1)

    49/83

    Numeric Functions

    SUM (set, expression)

    MAX (set, expression)

    AVG(set, expression)

    MIN(set, expression)

    AVG([Time].Members, [Measures].[StoreProfit])

  • 8/13/2019 Presentation 2007-02 (1)

    50/83

    Example of numeric function

    WITH MEMBER [Store].[USA+Canada] AS

    SUM({[Store].[USA],[Store].[Canada]},[Measures].[

    Store Sales])

    SELECT

    {([[Store].[USA]),([Store].[Canada]),([Store].[USA

    +Canada] )} ON CULUMNS,

    DESCENTANTS ([Time].[1998], [Quarter])

    ON ROWS

    FROM [SALES]

  • 8/13/2019 Presentation 2007-02 (1)

    51/83

    51

    How to design a Cube in

    Mondrian

  • 8/13/2019 Presentation 2007-02 (1)

    52/83

    52

    Outline

    Cube Measure

    Dimension Shared dimensions

    Multiple Hierarchies

    Parent-child hierarchies

    Snowflake schema

    Calculated members

    User-defined functions

    Named Set

  • 8/13/2019 Presentation 2007-02 (1)

    53/83

    53

    Cube

    A cube is a named collection of measures anddimensions

    ...

    The fact table is defined using the element

    You can also use the and constructs to build more complicated SQLstatements

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    54/83

    54

    Measure (1)

    The Sales cube defines two measures, "Unit

    Sales" and "Store Sales".

  • 8/13/2019 Presentation 2007-02 (1)

    55/83

    55

    Measure (2)

    An optional formatStringattribute

    specifies how the value is to be printed

    48.123,45: Two decimals

    datatypeattribute specifies how cell

    values are represented in Mondrian's

    cache, and how they are returned via XML

    for Analysis

    Di i (1)

  • 8/13/2019 Presentation 2007-02 (1)

    56/83

    56

    Dimension (1)

    foreignKey attribute in is the name of a column in thefact table

    The element has primaryKeyattribute

    By default, a Hierarchy has a top level called 'All', with a single

    member called 'All {hierarchyName}'. It is also the default member of the hierarchy

    element has: allMemberName and allLevelNameattributes override the default names of

    the all level and all member

    hasAll="false", the 'all' level is suppressed The default member of that dimension will now be the first member of the first

    level

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    57/83

    57

    Dimension (2)

    uniqueMembersattribute in Level is used to optimize SQLgeneration TRUE if values of a given level column in the dimension table are

    unique across all the other values in that column across the parentlevels

    ordinalColumnand nameColumnattributes of the Leveltag

    ordinalColumnspecifies a column in the Hierarchy table that providesthe order of the members in a given Level

    nameColumnspecifies a column that will be displayed

    [Time].[2005].[Q1].[1] : ordinalColumn1,2,..January: nameColumnJanuary, February

    Shared dimensions

  • 8/13/2019 Presentation 2007-02 (1)

    58/83

    58

    Shared dimensions

    ...

    ...

    Multiple hierarchies

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    59/83

    59

    u t p e e a c es

    Note the common foreignKey: time_Id

    Note the level tag attribut Type{String, Numeric}, say to SQL if use the apices ornot

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    60/83

    60

    Parent-child hierarchies (1)

    CA_LaCot

    e41

    CA_PlaceW

    32

    CA_VU21

    CA10

    full_na

    mebank_idagence_id

    Bank_site

    All

    Bank

    CA

    CA_VU CA_LaCote

    CA_PlaceW

  • 8/13/2019 Presentation 2007-02 (1)

    61/83

    Snowflake schemas

  • 8/13/2019 Presentation 2007-02 (1)

    62/83

    62

    Snowflake schemas

    ...

    ...

    is used to build snowflake dimensions

    "Product" dimension consists of three tables:product, product_class,

    product_type

    The fact table joins to "product" (via the foreign key "product_id")

    "product" is joined to "product_class" (via the foreign key "product_class_id")

    "product_class" is joined to "product_type" (via the foreign key "product_type_id").

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    63/83

    63

    Property

    Define a property for all members of a level

    The role of an Employee:

    SELECT {[Store Sales]} ON COLUMNSFROM Sales

    WHERE [Employees].[Employee].Management.CurrentMember.Properties("management_role") = projetmanager")

    Calculated members

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    64/83

    64

    Calculated members

    WITH MEMBER [Measures].[Profit]AS '[Measures].[Store Sales]-[Measures].[Store Cost]',FORMAT_STRING ='$#,###'SELECT {[Measures].[Store Sales], [Measures].[Profit]} ON COLUMNS,{[Product].Children} ON ROWS

    FROM [Sales]WHERE [Time].[1997]

    [Measures].[Store Sales] - [Measures].[Store Cost]

    is an well-formed MDX formula

    visible="false" user-interfaces hide the member

    User-defined function (1)

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    65/83

    65

    ( )

    import mondrian.olap.*;

    import mondrian.olap.type.*;import mondrian.spi.UserDefinedFunction;

    /*** A simple user-defined function which adds one to its

    argument.*/

    public class PlusOneUdfimplementsUserDefinedFunction{

    // public constructorpublic PlusOneUdf() {

    }

    public String getName() {return "PlusOne";

    }

    public String getDescription() {return "Returns its argument plus one";

    }

    public Syntax getSyntax() {

    return Syntax.Function;}

    public Type getReturnType(Type[] parameterTypes) {

    return new NumericType();}

    public Type[] getParameterTypes() {return new Type[] {new NumericType()};

    }

    public Object execute(Evaluator evaluator, Exp[] arguments) {final Object argValue = arguments[0].evaluateScalar(evaluator);if (argValue instanceof Number) {

    return new Double(((Number) argValue).doubleValue() + 1);

    } else {// Argument might be a RuntimeException indicating that// the cache does not yet have the required cell value. The// function will be called again when the cache is loaded.return null;

    }}

    public String[] getReservedWords() {return null;

    }

    }

    User defined functionspermit to extend MDX language and soMondrian schema language using Java Code

    A user-defined function must have a public constructor and implement

    the mondrian.spi.UserDefinedFunctioninterface

    User defined function (2)

    http://mondrian.sourceforge.net/api/mondrian/spi/UserDefinedFunction.htmlhttp://mondrian.sourceforge.net/api/mondrian/spi/UserDefinedFunction.html
  • 8/13/2019 Presentation 2007-02 (1)

    66/83

    66

    User-defined function (2)

    ...

    WITH MEMBER [Measures].[Unit Sales Plus One]AS 'PlusOne([Measures].[Unit Sales])'

    SELECT{[Measures].[Unit Sales]} ON COLUMNS,{[Gender].MEMBERS} ON ROWS

    FROM [Sales]

    Named sets

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    67/83

    67

    Named sets

    WITH SET [Top Sellers] AS'TopCount([Warehouse].[Warehouse Name].MEMBERS, 5,

    [Measures].[Warehouse Sales])'SELECT

    {[Measures].[Warehouse Sales]} ON COLUMNS,{[Top Sellers]} ON ROWS

    FROM [Warehouse]WHERE [Time].[Year].[1997]

    ...TopCount([Warehouse].[Warehouse

    Name].MEMBERS, 5, [Measures].[Warehouse Sales])

    Advanced configurations in

    http://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.htmlhttp://mondrian.sourceforge.net/schema.html
  • 8/13/2019 Presentation 2007-02 (1)

    68/83

    68

    Advanced configurations inMondrian

    Aggregates and Caching Mondrian and XMLA

  • 8/13/2019 Presentation 2007-02 (1)

    69/83

    69

    Aggregates and Caching

  • 8/13/2019 Presentation 2007-02 (1)

    70/83

    70

    Aggregate Tables

    An aggregate table contains pre-aggregated measuresbuild from the fact table

    It is registered in Mondrian's schema, so that Mondriancan choose to use whether to use the aggregate table

    rather than the fact table, if it is applicable for a particularquery.

    Aggregate Tables : Use Case

  • 8/13/2019 Presentation 2007-02 (1)

    71/83

    71

    Aggregate Tables : Use CaseSTAR SCHEMA

    Select [Measures].value_read, [Measures].fact_count,

    [station].[Region].Members on columns,

    CROSSJOIN({[Pollutant].[Pollutant_family].Members},{[tim

    e].[Year].Members})

    FROM Cube1

  • 8/13/2019 Presentation 2007-02 (1)

    72/83

    72

  • 8/13/2019 Presentation 2007-02 (1)

    73/83

    73

    Aggregate Tables: Schema

  • 8/13/2019 Presentation 2007-02 (1)

    74/83

    74

    In the example Aggregate Table has thedefault name: agg_l_pollutionand thesame columns names than the fact table:value_read, region_code

    This permits to Mondrian to recognizetables as Aggregate Table automatically

    Rules can be set with a file.xml defined in a

    property_agg_l_pollution

    Aggregate Tables: Rules

  • 8/13/2019 Presentation 2007-02 (1)

    75/83

    75

    Aggregate Tables: properties

    If set to true, then Mondrian reads the database schema

    and recognizes aggregate tables. These tables are

    then candidates for use in fulfilling MDX queries. If

    set to false, then aggregate table will not be read

    from the database.

    falseboolean

    mondrian.rolap.

    aggregates

    .Read

    If set to true, then Mondrian uses any aggregate tables

    that have been read. These tables are then

    candidates for use in fulfilling MDX queries. If set to

    false, then no aggregate table related activity takes

    place in Mondrian.

    falseboolean

    mondrian.rolap.

    aggregates

    .Use

    DescriptionDefault ValueTypeProperty

    http://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.htmlhttp://mondrian.sourceforge.net/api/mondrian/olap/MondrianProperties.html
  • 8/13/2019 Presentation 2007-02 (1)

    76/83

  • 8/13/2019 Presentation 2007-02 (1)

    77/83

    77

    Result Cache

    Mondrian caches results

    Speeds up repeated drill down/roll up

    operations

    On by default, needs explicit disable:

  • 8/13/2019 Presentation 2007-02 (1)

    78/83

    78

    Mondrian and XMLA

    XMLA

  • 8/13/2019 Presentation 2007-02 (1)

    79/83

    79

    XMLA

    XML for Analysis (XMLA) is a de facto standard API for OLAP

    XMLA allows client applications to talk to multidimensional datasources.

    XMLA is a specification for a set of XML message interfaces thatuse the Simple Object Access Protocol (SOAP) to define dataaccess interaction between a client application and an analyticaldata provider working over the Internet

    Using a standard API, XMLA permints to access to multidimensionaldata from varied data sources through web services that aresupported by multiple vendors (Microsoft, Mondrian, etc)

    XMLA

  • 8/13/2019 Presentation 2007-02 (1)

    80/83

    80

    XMLA

    Mondrian as XMLA provider

  • 8/13/2019 Presentation 2007-02 (1)

    81/83

    81

    In datasources.xml

    MortaliteEu

    Donnes sur la mortalit en Europe

    http://localhost:8080/jpivot/xmla

    Provider=mondrian; Jdbc=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mortalityEU;JdbcDrivers=com.microsoft.jdbc.sqlserver.SQLServerDriver;

    Catalog=/WEB-INF/schema/MortaliteEU.xml;

    JdbcUser=sa1; JdbcPassword=test

    Mondrian Perforce HEADMDPUnauthenticated

    MortaliteEU SQL Server

    MondrianMortaliteEU.xml

    Jdbc

    Client

    XMLA

    Jpivot

    XLMA Q i JPi t

  • 8/13/2019 Presentation 2007-02 (1)

    82/83

    82

    XLMA Query in JPivot

    select {[Measures].[Ndeaths]} on columns,

    {([Countries], [diseases])}on rows

    from mortalityEU

    where ([temps].[2000])

    Contacts

  • 8/13/2019 Presentation 2007-02 (1)

    83/83

    Contacts

    Sandro Bimonte

    INSA Lyon [email protected]

    http://liris.cnrs.fr/~sbimonte/index.htm

    Pascal Wehrle

    INSA Lyon [email protected]

    mailto:[email protected]://liris.cnrs.fr/~sbimonte/index.htmmailto:[email protected]:[email protected]:[email protected]:[email protected]://liris.cnrs.fr/~sbimonte/index.htmmailto:[email protected]:[email protected]:[email protected]