Skip to content

Commit

Permalink
Major progress on XMLA driver. All tests pass for XMLA driver (runnin…
Browse files Browse the repository at this point in the history
…g against mondrian in-process, but nevertheless sending and receiving SOAP requests) and still pass for mondrian driver.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@52 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Dec 13, 2007
1 parent 5abb015 commit 179dd06
Show file tree
Hide file tree
Showing 81 changed files with 7,029 additions and 637 deletions.
22 changes: 16 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ ${jar-jdk14.file}"/>
<pathelement location="${testlib.dir}/junit.jar"/>
<pathelement location="${testlib.dir}/servlet.jar"/>

<!-- To use the checked in mondrian.jar, make sure the <pathelement>
element following this comment is uncommented; to develop code against
'live' mondrian source code, uncomment <pathelement> elements 2 and 3
following this comment. Between releases, we don't keep mondrian.jar
up to date, so probably the latter option is the only one which will
work. One day the mondrian driver will be part of the mondrian source
code and all mondrian dependencies will go away. -->
<!--
<pathelement location="${lib.dir}/mondrian.jar"/>
<!-- To develop code against 'live' mondrian source code, remove the
previous line and uncomment the next two.
-->
<pathelement location="${mondrian.dir}/classes"/>
<pathelement location="${mondrian.dir}/testclasses"/>
-->
Expand All @@ -74,6 +81,7 @@ ${jar-jdk14.file}"/>
<pathelement location="${lib.dir}/commons-vfs.jar"/>
<pathelement location="${lib.dir}/commons-logging.jar"/>
<pathelement location="${lib.dir}/commons-math-1.0.jar"/>
<pathelement location="${lib.dir}/xercesImpl.jar"/>
</path>

<path id="project.test.classpath">
Expand Down Expand Up @@ -253,6 +261,7 @@ lib/commons-vfs.jar,
lib/commons-logging.jar,
lib/commons-math-1.0.jar,
lib/javacup.jar,
lib/xercesImpl.jar,
lib/log4j-1.2.9.jar,
lib/asm-2.2.3.jar,
lib/asm-commons-2.2.3.jar,
Expand Down Expand Up @@ -372,7 +381,7 @@ META-INF/**"/>
classpathref="project.test.classpath"
destdir="${javadoc.dir}"
packagenames="org.olap4j.*"
excludepackagenames="org.olap4j.driver.*,org.olap4j.mdx.parser.impl.*,org.olap4j.sample.*"
excludepackagenames="org.olap4j.driver.*,org.olap4j.impl.*,org.olap4j.mdx.parser.impl.*,org.olap4j.sample.*"
overview="${src.dir}/overview.html"
footer="&lt;a href=&quot;http://sourceforge.net/projects/olap4j&quot;&gt;&lt;img src=&quot;http://sourceforge.net/sflogo.php?group_id=35302&#38;type=1&quot; width=&quot;88&quot; height=&quot;31&quot; border=&quot;0&quot; alt=&quot;SourceForge.net_Logo&quot;&gt;&lt;/a&gt;"
author="true"
Expand Down Expand Up @@ -441,7 +450,7 @@ META-INF/**"/>
classpathref="project.test.classpath"
destdir="${javadoc.dir}"
packagenames="org.olap4j.*"
excludepackagenames="org.olap4j.driver.*,org.olap4j.mdx.parser.impl.*,org.olap4j.sample.*"
excludepackagenames="org.olap4j.driver.*,org.olap4j.impl.*,org.olap4j.mdx.parser.impl.*,org.olap4j.sample.*"
overview="${src.dir}/overview.html"
footer="&lt;a href=&quot;http://sourceforge.net/projects/olap4j&quot;&gt;&lt;img src=&quot;http://sourceforge.net/sflogo.php?group_id=35302&#38;type=1&quot; width=&quot;88&quot; height=&quot;31&quot; border=&quot;0&quot; alt=&quot;SourceForge.net_Logo&quot;&gt;&lt;/a&gt;"
author="true"
Expand Down Expand Up @@ -499,8 +508,8 @@ META-INF/**"/>
</javadoc>
</target>

<target name="test" depends="prepare, compile.tests">
<junit printsummary="yes" fork="no" failureproperty="junit.failure"
<target name="test" depends="prepare, compile, compile.tests">
<junit printsummary="yes" fork="yes" failureproperty="junit.failure"
tempdir="${testlog.dir}">
<formatter type="plain"/>
<formatter type="xml"/>
Expand All @@ -510,6 +519,7 @@ META-INF/**"/>
</fileset>
</batchtest>
<classpath refid="project.test.classpath"/>
<jvmarg value="-Xmx256m"/>
</junit>
</target>

Expand Down
32 changes: 30 additions & 2 deletions doc/tasks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Javadoc

Code
----


* add method(s) to Cube to look up a member and its relatives by unique name
* fix 4 TODOs in ParserTest

Testing
Expand All @@ -51,7 +52,34 @@ Not in scope for olap4j 0.9

* convert parser to javacc
* XMLA driver


XMLA driver tasks
-----------------

* Member cache as part of cube (weak hash map)
** Use member cache for XmlaOlap4jHierarchy.getDefaultMember (store member in hierarchy, so Hierarchy.getDefaultMember never throws OlapException)
** Use member cache for XmlaOlap4jHierarchy.getRootMembers
** Consider using member cache for XmlaOlap4jLevel.getMembers
** Use member cache for XmlaOlap4jMember.getParentMember (lookup parent member before creating member, and store pointer rather than name of parent member)

* On creating XmlaOlap4jDimension, lookup and store default hierarchy; obsolete defaultHierarchyUniqueName field

* Create enum Measure.DataType (possibly related to Property.Datatype), and change method 'int Measure.dataType()' to 'Datatype Measure.getDatatype()'

* Reduce memory usage by converting some of XmlaOlap4jMember's fields into properties (e.g. ordinal, cardinality)

* Add test for Member.getAncestorMembers

* Remove dependency on xerces; use JDK XML parser.

Changes since 0.9
-----------------

* Various methods now throw OlapException

* Rename 'enum Property.Scope' to 'Property.TypeFlag', and method
'Scope Property.getScope()' becomes 'Set<TypeFlag> Property.getType()'.

General guidelines
------------------

Expand Down
Binary file added lib/xercesImpl.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions src/mondrian/olap4j/EmptyResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* methods for querying object types where those object types never have
* any instances for this particular driver.</p>
*
* <p>This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
* it is instantiated using {@link Factory#newEmptyResultSet}.</p>
*
* @author jhyde
* @version $Id$
* @since May 24, 2007
Expand Down
1 change: 0 additions & 1 deletion src/mondrian/olap4j/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
package mondrian.olap4j;

import mondrian.olap.Result;
import mondrian.olap.Query;

import java.util.Properties;
Expand Down
17 changes: 13 additions & 4 deletions src/mondrian/olap4j/FactoryJdbc3Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,23 @@ public EmptyResultSetJdbc3(
}
}

private class MondrianOlap4jConnectionJdbc3 extends MondrianOlap4jConnection {
public MondrianOlap4jConnectionJdbc3(String url, Properties info) throws SQLException {
private class MondrianOlap4jConnectionJdbc3
extends MondrianOlap4jConnection
{
public MondrianOlap4jConnectionJdbc3(
String url,
Properties info) throws SQLException
{
super(FactoryJdbc3Impl.this, url, info);
}
}

private static class MondrianOlap4jDatabaseMetaDataJdbc3 extends MondrianOlap4jDatabaseMetaData {
public MondrianOlap4jDatabaseMetaDataJdbc3(MondrianOlap4jConnection olap4jConnection) {
private static class MondrianOlap4jDatabaseMetaDataJdbc3
extends MondrianOlap4jDatabaseMetaData
{
public MondrianOlap4jDatabaseMetaDataJdbc3(
MondrianOlap4jConnection olap4jConnection)
{
super(olap4jConnection);
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/mondrian/olap4j/FactoryJdbc4Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ public Struct createStruct(
}
}

private static class MondrianOlap4jCellSetJdbc4 extends MondrianOlap4jCellSet {
private static class MondrianOlap4jCellSetJdbc4
extends MondrianOlap4jCellSet
{
public MondrianOlap4jCellSetJdbc4(
MondrianOlap4jStatement olap4jStatement,
Query query)
Expand Down Expand Up @@ -741,7 +743,8 @@ public void setNClob(
}

private static class MondrianOlap4jDatabaseMetaDataJdbc4
extends MondrianOlap4jDatabaseMetaData {
extends MondrianOlap4jDatabaseMetaData
{
public MondrianOlap4jDatabaseMetaDataJdbc4(
MondrianOlap4jConnection olap4jConnection)
{
Expand Down Expand Up @@ -779,15 +782,17 @@ public ResultSet getClientInfoProperties() throws SQLException {
public ResultSet getFunctions(
String catalog,
String schemaPattern,
String functionNamePattern) throws SQLException {
String functionNamePattern) throws SQLException
{
throw new UnsupportedOperationException();
}

public ResultSet getFunctionColumns(
String catalog,
String schemaPattern,
String functionNamePattern,
String columnNamePattern) throws SQLException {
String columnNamePattern) throws SQLException
{
throw new UnsupportedOperationException();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/mondrian/olap4j/MondrianOlap4jCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.olap4j.metadata.Schema;
import org.olap4j.OlapException;
import org.olap4j.OlapDatabaseMetaData;
import org.olap4j.impl.*;

/**
* Implementation of {@link Catalog}
Expand All @@ -40,7 +41,7 @@ public NamedList<Schema> getSchemas() throws OlapException {
olap4jDatabaseMetaData.olap4jConnection.connection.getSchema();
list.add(
olap4jDatabaseMetaData.olap4jConnection.toOlap4j(schema));
return (NamedList) list;
return Olap4jUtil.cast(list);
}

public String getName() {
Expand Down
48 changes: 43 additions & 5 deletions src/mondrian/olap4j/MondrianOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* Implementation of {@link CellSet}
* for the Mondrian OLAP engine.
*
* <p>This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
* it is instantiated using {@link Factory#newCellSet}.</p>
*
* @author jhyde
* @version $Id$
* @since May 24, 2007
Expand Down Expand Up @@ -113,6 +116,11 @@ public Cell getCell(List<Integer> coordinates) {
}

public Cell getCell(int ordinal) {
final int[] pos = ordinalToCoordinateArray(ordinal);
return getCellInternal(pos);
}

private int[] ordinalToCoordinateArray(int ordinal) {
Axis[] axes = result.getAxes();
final int[] pos = new int[axes.length];
int modulo = 1;
Expand All @@ -127,7 +135,7 @@ public Cell getCell(int ordinal) {
+ ") lies outside CellSet bounds ("
+ getBoundsAsString() + ")");
}
return getCellInternal(pos);
return pos;
}

public Cell getCell(Position... positions) {
Expand All @@ -148,6 +156,10 @@ private Cell getCellInternal(int[] pos) {
"Cell coordinates (" + getCoordsAsString(pos)
+ ") fall outside CellSet bounds ("
+ getCoordsAsString(pos) + ")");
} else if (e.getMessage().indexOf("coordinates should have dimension") >= 0) {
throw new IllegalArgumentException(
"Cell coordinates should have dimension "
+ axisList.size() + ")");
} else {
throw e;
}
Expand All @@ -156,7 +168,7 @@ private Cell getCellInternal(int[] pos) {
}

private String getBoundsAsString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
Axis[] axes = result.getAxes();
for (int i = 0; i < axes.length; i++) {
if (i > 0) {
Expand All @@ -168,7 +180,7 @@ private String getBoundsAsString() {
}

private static String getCoordsAsString(int[] pos) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (int i = 0; i < pos.length; i++) {
int po = pos[i];
if (i > 0) {
Expand All @@ -180,11 +192,37 @@ private static String getCoordsAsString(int[] pos) {
}

public List<Integer> ordinalToCoordinates(int ordinal) {
throw new UnsupportedOperationException();
final int[] ints = ordinalToCoordinateArray(ordinal);
final List<Integer> list = new ArrayList<Integer>(ints.length);
for (int i : ints) {
list.add(i);
}
return list;
}

public int coordinatesToOrdinal(List<Integer> coordinates) {
throw new UnsupportedOperationException();
List<CellSetAxis> axes = getAxes();
if (coordinates.size() != axes.size()) {
throw new IllegalArgumentException(
"Coordinates have different dimension " + coordinates.size()
+ " than axes " + axes.size());
}
int modulo = 1;
int ordinal = 0;
int k = 0;
for (CellSetAxis axis : axes) {
final Integer coordinate = coordinates.get(k++);
if (coordinate < 0 || coordinate >= axis.getPositionCount()) {
throw new IndexOutOfBoundsException(
"Coordinate " + coordinate
+ " of axis " + k
+ " is out of range ("
+ getBoundsAsString() + ")");
}
ordinal += coordinate * modulo;
modulo *= axis.getPositionCount();
}
return ordinal;
}

public boolean next() throws SQLException {
Expand Down
10 changes: 2 additions & 8 deletions src/mondrian/olap4j/MondrianOlap4jCellSetAxisMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import org.olap4j.CellSetAxisMetaData;
import org.olap4j.Axis;
import org.olap4j.metadata.*;
import org.olap4j.metadata.Hierarchy;
import org.olap4j.metadata.Property;
import mondrian.olap.*;
Expand All @@ -30,12 +29,7 @@
class MondrianOlap4jCellSetAxisMetaData implements CellSetAxisMetaData {
private final QueryAxis queryAxis;
private final MondrianOlap4jConnection olap4jConnection;
private final NamedList<Property> propertyList =
new ArrayNamedListImpl<Property>() {
protected String getName(Property property) {
return property.getName();
}
};
private final List<Property> propertyList = new ArrayList<Property>();

MondrianOlap4jCellSetAxisMetaData(
MondrianOlap4jConnection olap4jConnection,
Expand Down Expand Up @@ -93,7 +87,7 @@ public List<Hierarchy> getHierarchies() {
return hierarchyList;
}

public NamedList<Property> getProperties() {
public List<Property> getProperties() {
return propertyList;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/mondrian/olap4j/MondrianOlap4jCellSetMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import mondrian.olap.Query;
import mondrian.olap.QueryAxis;
import org.olap4j.*;
import org.olap4j.impl.ArrayNamedListImpl;
import org.olap4j.metadata.*;

import java.sql.SQLException;
Expand Down
Loading

0 comments on commit 179dd06

Please sign in to comment.