Skip to content

Commit

Permalink
Rename OlapResultSet to CellSet, OlapResultSetMetaData to CellSetMeta…
Browse files Browse the repository at this point in the history
…Data, OlapResultAxis to CellSetAxis, ResultCell to Cell, ResultSetPosition to Position; add implementation of olap4j against mondrian, and a unit test

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@17 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed May 25, 2007
1 parent b456d38 commit 5d7b66c
Show file tree
Hide file tree
Showing 48 changed files with 5,352 additions and 157 deletions.
90 changes: 61 additions & 29 deletions doc/olap4j_fs.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,17 @@ <h2><a name="Contents">Contents</a></h2>
<li><a href="#OlapStatement">The OlapStatement interface</a></li>
<li><a href="#PreparedOlapStatement">The PreparedOlapStatement interface</a></li>
<li><a href="#OlapParameterMetaData">The OlapParameterMetaData interface</a></li>
<li><a href="#OlapResultSet">The OlapResultSet interface</a></li>
<li><a href="#ResultAxis">The ResultAxis interface</a></li>
<li><a href="#The_ResultPosition_interface">The ResultPosition interface</a></li>
<li><a href="#ResultCell">The ResultCell interface</a></li>
<li><a href="#CellSet">The CellSet interface</a></li>
<li><a href="#CellSetAxis">The CellSetAxis interface</a></li>
<li><a href="#The_Position_interface">The Position interface</a></li>
<li><a href="#Cell">The Cell interface</a></li>
<li><a href="#The_CellSetMetaData_interface">The CellSetMetaData
interface</a></li>
<li><a href="#The_OlapDatabaseMetaData_interface">The
OlapDatabaseMetaData interface</a></li>
<li><a href="#The_CellSetAxis_interface">The CellSetAxis interface</a></li>
<li><a href="#The_CellSetAxisMetaData_interface">The CellSetAxisMetaData
interface</a></li>
</ol>
</li>
<li><a href="#MDX_query_model">MDX query model</a></li>
Expand Down Expand Up @@ -195,6 +202,7 @@ <h2><a name="Contents">Contents</a></h2>
<li><a href="#Open_issues">Appendix C. Open issues</a></li>
<li><a href="#Miscellaneous">Appendix D. Miscellaneous</a></li>
<li><a href="#References">Appendix E. References</a></li>
<li><a href="#Change_log">Appendix F. Change log</a></li>
</ol>
<h2>1. <a name="Introduction">Introduction</a></h2>

Expand Down Expand Up @@ -422,8 +430,8 @@ <h4>2.1.4 <a name="The_OlapException_class">The OlapException class</a></h4>
driver chooses, throw instead an OlapException.<br>
<br>
OlapException provides some additional information to help an OLAP client
identify the location of the error. The <code>context</code> is the ResultCell
or ResultPosition object where the error occurred. The <code>region</code> is an
identify the location of the error. The <code>context</code> is the Cell
or Position object where the error occurred. The <code>region</code> is an
object representing the textual region in the MDX statement.</p>
<p>Methods:</p>
<ul>
Expand Down Expand Up @@ -481,7 +489,7 @@ <h3>2.2. <a name="Connections">Connections</a></h3>
<div class="code">
import org.olap4j.*;<br><br>Class.forName(&quot;olap4j.impl.xmla.Driver&quot;);<br>OlapConnection connection = (OlapConnection)<br>&nbsp;&nbsp;&nbsp; DriverManager.createConnection(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;jdbc:olap4jxmla:Server=http://localhost/xmla/msxisapi.dll;&quot;
+<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Catalog=FoodMart&quot;);<br>OlapStatement statement = connection.createOlapStatement();<br>
<br>OlapResultSet result =<br>&nbsp;&nbsp;&nbsp; statement.execute(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;SELECT {[Measures].[Unit Sales]} ON
<br>CellSet result =<br>&nbsp;&nbsp;&nbsp; statement.execute(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;SELECT {[Measures].[Unit Sales]} ON
COLUMNS,\n&quot; +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&nbsp; {[Product].Members} ON
ROWS\n&quot; +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;FROM [Sales]&quot;);</div>

Expand Down Expand Up @@ -537,7 +545,7 @@ <h4>2.2.2. <a name="Connection_pooling">Connection pooling</a></h4>
that any statements or prepared statements created from that connection also
work with the connection pool. </p>
<p>The problem does not just affect connections: some connection pools also wrap
<code>Statement</code>, <code>PreparedStatement</code>, <code>ResultSet</code>
<code>Statement</code>, <code>PreparedStatement</code>, <code>CellSet</code>
and
<a class="javadoc" href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/DatabaseMetaData.html">
DatabaseMetaData</a> objects, so there are <code>convert()</code>
Expand Down Expand Up @@ -585,13 +593,13 @@ <h4>2.3.3. <a name="OlapParameterMetaData">The OlapParameterMetaData interface</
<li><code>getOlapType(int param)</code></li>
</ul>

<h4>2.3.4. <a name="OlapResultSet">The OlapResultSet interface</a></h4>
<p><a class="javadoc" href="api/org/olap4j/OlapResultSet.html">OlapResultSet</a> (extends
<h4>2.3.4. <a name="CellSet">The CellSet interface</a></h4>
<p><a class="javadoc" href="api/org/olap4j/CellSet.html">CellSet</a> (extends
<a class="javadoc" href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html">
java.sql.ResultSet</a>) is the result of executing an <a class="javadoc" href="api/org/olap4j/OlapStatement.html">OlapStatement</a>
or <a class="javadoc" href="api/org/olap4j/PreparedOlapStatement.html">PreparedOlapStatement</a>.</p>
<p>It extends ResultSet, but since most of these methods are concerned with rows
and columns, few of ResultSet's methods are applicable. The following methods
and columns, only a few of the base class's methods are applicable. The following methods
are applicable:</p>
<ul>
<li><a class="javadoc" href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html#clearWarnings%28%29">clearWarnings()</a></li>
Expand All @@ -603,32 +611,37 @@ <h4>2.3.4. <a name="OlapResultSet">The OlapResultSet interface</a></h4>
</ul>
<p>Additional methods to retrieve the axes of the multidimensional result:</p>
<ul>
<li>List&lt;ResultAxis&gt; getAxes()</li>
<li>ResultSet getCell(List&lt;Integer&gt; coordinates)</li>
<li>List&lt;CellSetAxis&gt; getAxes()</li>
<li>CellSetAxis getFilterAxis()</li>
<li>Cell getCell(List&lt;Integer&gt; coordinates)</li>
</ul>

<h4>2.3.5. <a name="ResultAxis">The ResultAxis interface</a></h4>
<p>A <a class="javadoc" href="api/org/olap4j/ResultAxis.html">ResultAxis</a> is
<p>An OlapStatement can have no more than one CellSet open. Closing an
OlapStatement, or preparing or executing a new query, implicitly closes any
previous CellSet.</p>

<h4>2.3.5. <a name="CellSetAxis">The CellSetAxis interface</a></h4>
<p>A <a class="javadoc" href="api/org/olap4j/CellSetAxis.html">CellSetAxis</a> is
a ...</p>
<p>[tbd]</p>
<p>[access positions by index (i.e. a list) and by scrolling (i.e. an iterator)]</p>
<h4>2.3.6. <a name="The_ResultPosition_interface">The ResultPosition interface</a></h4>
<p><a class="javadoc" href="api/org/olap4j/ResultPosition.html">ResultPosition</a>
is a position on a <a class="javadoc" href="api/org/olap4j/ResultAxis.html">
ResultAxis</a>.</p>
<h4>2.3.6. <a name="The_Position_interface">The Position interface</a></h4>
<p><a class="javadoc" href="api/org/olap4j/Position.html">Position</a>
is a position on a <a class="javadoc" href="api/org/olap4j/CellSetAxis.html">
CellSetAxis</a>.</p>
<p>Methods:</p>
<ul>
<li>List&lt;Member&gt; getMembers()</li>
<li>int getOrdinal()</li>
</ul>

<h4>2.3.7. <a name="ResultCell">The ResultCell interface</a></h4>
<p>A <a class="javadoc" href="api/org/olap4j/ResultCell.html">ResultCell</a> is
a cell returned from an <a class="javadoc" href="api/org/olap4j/OlapResultSet.html">
OlapResultSet</a>.</p>
<h4>2.3.7. <a name="Cell">The Cell interface</a></h4>
<p>A <a class="javadoc" href="api/org/olap4j/Cell.html">Cell</a> is
a cell returned from an <a class="javadoc" href="api/org/olap4j/CellSet.html">
CellSet</a>.</p>
<p>Methods:</p>
<ul>
<li>getResultSet()</li>
<li>getCellSet()</li>
<li>getOrdinal()</li>
<li>getCoordinateList()</li>
<li>getPropertyValue(Property)</li>
Expand All @@ -641,6 +654,20 @@ <h4>2.3.7. <a name="ResultCell">The ResultCell interface</a></h4>
<li>getFormattedValue()</li>
</ul>

<h4>2.3.8. <a name="The_CellSetMetaData_interface">The CellSetMetaData interface</a></h4>

<p>Extends ResultSetMetaData</p>

<h4>2.3.9. <a name="The_OlapDatabaseMetaData_interface">The OlapDatabaseMetaData
interface</a></h4>

<p>Extends DatabaseMetaData</p>

<h4>2.3.10. <a name="The_CellSetAxis_interface">The CellSetAxis interface</a></h4>

<h4>2.3.11. <a name="The_CellSetAxisMetaData_interface">The CellSetAxisMetaData
interface</a></h4>

<h3>2.4. <a name="MDX_query_model">MDX query model</a></h3>

<p>The MDX query model represents a parsed MDX statement. </p>
Expand Down Expand Up @@ -691,9 +718,9 @@ <h3>2.4. <a name="MDX_query_model">MDX query model</a></h3>
}<br>
<br>
// Execute the statement.<br>
ResultSet rset;<br>
CellSet cset;<br>
try {<br>
    rset = stmt.execute();<br>
    cset = stmt.execute();<br>
} catch (OlapException e) {<br>
    System.out.println("Execution failed: " + e);<br>
}</div>
Expand Down Expand Up @@ -3299,7 +3326,6 @@ <h3>D.1. To be specified</h3>
is to support an object model (hence easy programming model) without increasing
memory. No specific change to the specification, but decided to add memory
efficiency as a design goal.]</p>
<p>[Is an OlapResultSet still accessible when its OlapStatement is closed?]</p>
<h3>D.2. Design notes</h3>

<p><a name="JDK">JDK</a>. We are targeting JDK 1.5, and running retroweaver for
Expand All @@ -3317,11 +3343,11 @@ <h4>Accessing cells</h4>
<p>It would be possible to access cells in a result set (a) by ordinal; (b) by
coordinates; (c) by the 'etchasketch' model determined by the position of the
iterator along each axis, as used by JOLAP. We decided to support (a) and (b)
but not (c). There are methods on ResultSet to convert from ordinal to
but not (c). There are methods on CellSet to convert from ordinal to
coordinates and vice versa.</p>
<p>If there is a huge number of cells, the client has limited memory, and
bandwidth to the server is limited, random access to cells is costly. Michael
suggested that we add a method <code>List&lt;ResultCell&gt; getCells(int startOrdinal, int
suggested that we add a method <code>List&lt;Cell&gt; getCells(int startOrdinal, int
endOrdinal)</code>, which matches XML/A behavior, but we declined to add it to the spec
for now. John drew the analogy of a modern file system, implementing a serial
access interface (streams) on top of random-access primitives. For now, we
Expand All @@ -3332,6 +3358,12 @@ <h2>Appendix E. <a name="References">References</a></h2>

<p>1. <a name="XMLA">XMLA</a>: <a class="l" href="http://www.xmla.org/spec/1.1/xmla1.1.doc">XML for
Analysis Specification, version 1.1</a>.</p>
<h2>Appendix F. <a name="Change_log">Change log</a></h2>
<ul>
<li>Rename OlapResultSet to CellSet, OlapResultSetMetaData to
CellSetMetaData, OlapResultAxis to CellSetAxis, ResultCell to Cell,
ResultSetPosition to Position.</li>
</ul>

<hr noshade="noshade">

Expand Down
53 changes: 53 additions & 0 deletions src/mondrian/olap4j/AbstractNamedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
// $Id: $
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2007-2007 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap4j;

import org.olap4j.metadata.NamedList;

import java.util.AbstractList;

/**
* Partial implementation of {@link org.olap4j.metadata.NamedList}.
*
* <p>Derived class must implement {@link #get(int)} and {@link #size()}, as
* per {@link java.util.AbstractList}.
*
* @see mondrian.olap4j.NamedListImpl
*
* @author jhyde
* @version $Id: $
* @since May 25, 2007
*/
abstract class AbstractNamedList<T extends Named>
extends AbstractList<T>
implements NamedList<T>
{
public T get(String name) {
for (T t : this) {
if (t.getName().equals(name)) {
return t;
}
}
return null;
}

public int indexOfName(String name) {
for (int i = 0; i < size(); ++i) {
T t = get(i);
if (t.getName().equals(name)) {
return i;
}
}
return -1;
}

}

// End AbstractNamedList.java
Loading

0 comments on commit 5d7b66c

Please sign in to comment.