Partly Review of Mondrian Olap Engine

Mondrian Olap Engine Partly Review

 

1. Consisted of 4 layers

n  Presentation layer

    Take charge of the end-user interaction in various presentation forms. The logic model is multidimensional 'grammar' of dimensions, measures and cells.

n  Calculation layer

    Validates and executes MDX queries. Query transformer.

n  Aggregation layer

       Manage aggregation in the cache.

n  Storage layer

       Usually is an RDBMS.

 

2. Aggregation strategy

General idea is to delegate unto the database what the database has. Thus the side-effect is loading data processing is easier, and the system is suited to do Olap on dataset changing in real time.

n  Fact data is stored in the RDBMS

n  Read aggregated data into the cache by submitting group by queries

n  Use materialized views as many as possible

 

3. APIs

n  The Usage is similar to JDBC interfaces (see the following example)

n  Use MDX, in place of SQL

n  Presents the database schema as a set of objects: Schema, Cube, Dimension, Hierarchy, Level, Member

n  Now suppot XML/A

Example:

/*

establish a connection with Mondrian , submit an MDX query and retrieve the multi-dimension dataset from Mondrian . 

*/

import mondrian.olap.*;

import java.io.PrintWriter;

 

Connection connection = DriverManager.getConnection(

    "Provider= mondrian ;" +

    "Jdbc=jdbc:odbc:MondrianFoodMart;" +

    "Catalog=/WEB-INF/FoodMart.xml;",

    null,

    false);

Query query = connection.parseQuery(

    "SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} on columns," +

    "  {[Product].children} on rows " +

    "FROM [Sales] " +

    "WHERE ([Time].[1997].[Q1], [Store].[CA].[ San Francisco ])");

Result result = connection.execute(query);

result.print(new PrintWriter(System.out));

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4. MDX extensions

Mondrian extends Mdx in two aspects.

n  Support parameters

This is done through the functions Parameter():

       Parameter(<name>, <type>, <defaultValue>[, <description>])

For example:

/*

the top 10 brands in California

*/

SELECT {[Measures].[Unit Sales]} on columns,

  TopCount([Product].[Brand].members,

 Parameter("Count", NUMERIC, 10, "Number of products to show"),

 ( Parameter("Region", [Store], [Store].[ USA ].[CA]), [Measures].[Unit Sales])

          ) on rows

FROM Sales

          

n  Extend Build in functions StrToSet and StrToTuple

Add a optional parameter <hierarchy> to the functions, thus user can get the result of the given hierarchy.

       StrToSet(<String Expression>[, <Hierarchy>])

       StrToTuple(<String Expression>[, <Hierarchy>])

 

5. Schema

Mondrian use xml files to define its schema, including Logical model, Physical model and the mapping between them.

n  Logical Model: the structure of multi-dimensional database cubes, including dimensions, hierarchies, levels, and members.

n  Physical Model: the source of the data

Example:

/*

foodmart, Sales cube defination

*/

<Schema>

  <Cube name="Sales">

    <Table name="sales_fact_1997"/>

    <Dimension name="Gender" foreignKey="customer_id">

      <Hierarchy hasAll="true" allMemberName="All Genders" primaryKey="customer_id">

        <Table name="customer"/>

        <Level name="Gender" column="gender" uniqueMembers="true"/>

      </Hierarchy>

    </Dimension>

    <Dimension name="Time" foreignKey="time_id">

      <Hierarchy hasAll="false" primaryKey="time_id">

        <Table name="time_by_day"/>

        <Level name="Year" column="the_year" type="Numeric"

            uniqueMembers="true"/>

        <Level name="Quarter" column="quarter"

            uniqueMembers="false"/>

        <Level name="Month" column="month_of_year" type="Numeric"

            uniqueMembers="false"/>

      </Hierarchy>

    </Dimension>

    <Measure name="Unit Sales" column="unit_sales"

        aggregator="sum" formatString="#,###"/>

    <Measure name="Store Sales" column="store_sales"

        aggregator="sum" formatString="#,###.##"/>

  </Cube> 

</Schema>

 

Attention: You can write custom member readers to extend the datasource.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值