architecture.html
来自「基于mondrian 开源框架进行OLAP多维分析」· HTML 代码 · 共 298 行 · 第 1/2 页
HTML
298 行
<!--########################## API ############################# --><h3>API</h3><p>Mondrian provides an API for client applications to execute queries.</p><p>Since there is no widely universally accepted API for executing OLAP queries, Mondrian's primary API proprietary; however, anyone who has used JDBC should find it familiar. The main difference is the query language: Mondrian uses a language called MDX ('<b>M</b>ulti-<b>D</b>imensional e<b>X</b>pressions') to specify queries, where JDBC would use SQL. MDX is described in more detail <a href="#MDX">below</a>.</p><p>The following Java fragment connects to Mondrian, executes a query, and prints the results:</p><blockquote><p>import mondrian.olap.*;<br />import java.io.PrintWriter;<br /><br />Connection connection = DriverManager.getConnection(<br /> "Provider=mondrian;" +<br /> "Jdbc=jdbc:odbc:MondrianFoodMart;" +<br /> "Catalog=/WEB-INF/FoodMart.xml;",<br /> null,<br /> false);<br />Query query = connection.parseQuery(<br /> "SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} on columns," +<br /> " {[Product].children} on rows " +<br /> "FROM [Sales] " +<br /> "WHERE ([Time].[1997].[Q1], [Store].[CA].[San Francisco])");<br />Result result = connection.execute(query);<br />result.print(new PrintWriter(System.out));</p></blockquote><p>A <a href="api/mondrian/olap/Connection.html">Connection</a>is created via a <a href="api/mondrian/olap/DriverManager.html">DriverManager</a>, in a similar way to JDBC. A<a href="api/mondrian/olap/Query.html">Query</a> is analogous toa JDBC <a href="http://java.sun.com/j2se/1.4/docs/api/java/sql/Statement.html"> Statement</a>,and is created by parsing an MDX string. A<a href="api/mondrian/olap/Result.html">Result</a> is analogousto a JDBC <a href="http://java.sun.com/j2se/1.4/docs/api/java/sql/ResultSet.html">ResultSet</a>;since we are dealing with multi-dimensional data, it consists of axes and cells, rather than rows and columns. Since OLAP isintended for data exploration, you can modify the parse tree contained in a query by operations such as<a href="api/mondrian/olap/Query.html#drillDown(mondrian.olap.Level)">drillDown</a> and <a href="api/mondrian/olap/Query.html#sort(int, int, mondrian.olap.Member[])">sort</a>, then re-execute the query.</p><p>The API also presents the database schema as a set of objects:<a href="api/mondrian/olap/Schema.html">Schema</a>,<a href="api/mondrian/olap/Cube.html">Cube</a>,<a href="api/mondrian/olap/Dimension.html">Dimension</a>,<a href="api/mondrian/olap/Hierarchy.html">Hierarchy</a>,<a href="api/mondrian/olap/Level.html">Level</a>,<a href="api/mondrian/olap/Member.html">Member</a>. For moreinformation about the Mondrian API, see <a href="api/overview-summary.html">the javadoc</a>.</p><p><a href="http://xmla.org/default.asp">XML for Analysis</a> is a standard for accessingOLAP servers via SOAP (Simple Object Access Protocol).This allows non-Java components like Microsoft Excel to runqueries against Mondrian.</p><p>Mondrian included support for the<a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_069_jolap.html">JSR-069</a>('JOLAP') proposed standard, but this support was removed in mondrian-2.3when it became clear that the standard would never be ratified.</p><!--########################## MDX ############################# --><h3>MDX<a name="MDX"> </a></h3><p>MDX is a language for querying multidimensional databases, in the same way that SQL is used to query relational databases. It was originally defined as part of the OLE DB for OLAP specification, and a similar language, mdXML, is part of the XML for Analysis specification.</p><p>Since you can read <a href="http://msdn.microsoft.com/library/en-us/olapdmad/agmdxbasics_04qg.asp">the specification online</a> and there are <a href="faq.html/index.php#Further_reading">some great books on MDX available</a>, I won't describe the full MDX language. Mondrian's extensions to MDX are parameters and modified builtin functions.</p><h1>Parameters</h1><p>A parameter is a named variable embedded in an MDX query. Every parameter has a default value, but you can supply a different value when you run the query.</p><p>Parameters are declared and used by using a special function, <code>Parameter</code>:</p><blockquote><p>Parameter(<name>, <type>, <defaultValue>[, <description>])</p></blockquote><p>The arguments of Parameter are as follows:</p><ul> <li>name is a string constant. It must be unique within the query. </li> <li>type is either NUMERIC, STRING, or the name of a hierarchy.</li> <li>defaultValue is an expression. The expression's type must be consistent with the type parameter; if type was a hierarchy, the expression must be a member of that hierarchy. </li> <li>description is an optional string constant.</li></ul><p>If you want to use a parameter more than once in a query, use the ParamRef function:</p><blockquote><p>ParamRef(<name>)</p></blockquote><p>The name argument must be the name of a parameter declared elsewhere in the query by calling the Parameter function.</p><p>The following query shows the top 10 brands in California, but you could change the Count parameter to show the top 5, or the Region parameter to show sales in Seattle:</p><blockquote><p>SELECT {[Measures].[Unit Sales]} on columns,<br /> TopCount([Product].[Brand].members,<br /> Parameter("Count", NUMERIC, 10, "Number of products to show"),<br /> (Parameter("Region", [Store], [Store].[USA].[CA]),<br /> [Measures].[Unit Sales])) on rows<br />FROM Sales</p></blockquote><p>You can list a query's parameters by calling<a href="api/mondrian/olap/Query.html#getParameters()">Query.getParameters()</a>, and change a parameter's value by calling<a href="api/mondrian/olap/Query.html#setParameter(java.lang.String, java.lang.String)">Query.setParameter(String name, String value)</a>.</p><h1>Builtin Functions</h1><p>The StrToSet() and StrToTuple() functions take an optional parameter not present in thestandard MDX versions of these functions, describing the hierarchy the result will belong to:</p><blockquote><p>StrToSet(<String Expression>[, <Hierarchy>])<br />StrToTuple(<String Expression>[, <Hierarchy>])</p></blockquote><br /><br /><hr noshade size="1"/><p> Author: Julian Hyde; last modified, August 2006.<br/> Version: $Id: //open/mondrian-release/3.0/doc/architecture.html#2 $ (<a href="http://p4web.eigenbase.org/open/mondrian/doc/architecture.html?ac=22">log</a>)<br/> Copyright (C) 2001-2002 Kana Software, Inc.<br/> Copyright (C) 2001-2007 Julian Hyde</p><br /><!-- doc2web end --></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?