Search in sources :

Example 16 with Axis

use of mondrian.olap.Axis in project pentaho-platform by pentaho.

the class MDXMetaDataTest method testMetadataForNullPositions.

@Test
public void testMetadataForNullPositions() {
    Axis axColumn = mockAxis(null);
    Axis axRow = mockAxis(null);
    Axis[] axes = new Axis[] { axColumn, axRow };
    Result nativeResultSet = mock(Result.class);
    when(nativeResultSet.getAxes()).thenReturn(axes);
    MDXMetaData metadata = new MDXMetaData(nativeResultSet);
    checkEmptyResult(metadata);
}
Also used : Axis(mondrian.olap.Axis) Result(mondrian.olap.Result) Test(org.junit.Test)

Example 17 with Axis

use of mondrian.olap.Axis in project mondrian by pentaho.

the class ModulosTest method testTwo.

public void testTwo() {
    Axis[] axes = new Axis[2];
    TupleList positions = newPositionList(23);
    axes[0] = new RolapAxis(positions);
    positions = newPositionList(13);
    axes[1] = new RolapAxis(positions);
    Modulos modulosMany = Modulos.Generator.createMany(axes);
    Modulos modulos = Modulos.Generator.create(axes);
    int ordinal = 23;
    int[] posMany = modulosMany.getCellPos(ordinal);
    int[] pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 11;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 7;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    pos[0] = 3;
    pos[1] = 2;
    int oMany = modulosMany.getCellOrdinal(pos);
    int o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 2;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 1;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) Axis(mondrian.olap.Axis)

Example 18 with Axis

use of mondrian.olap.Axis in project mondrian by pentaho.

the class ModulosTest method testMany.

public void testMany() {
    Axis[] axes = new Axis[3];
    TupleList positions = newPositionList(4);
    axes[0] = new RolapAxis(positions);
    positions = newPositionList(3);
    axes[1] = new RolapAxis(positions);
    positions = newPositionList(3);
    axes[2] = new RolapAxis(positions);
    Modulos modulos = Modulos.Generator.createMany(axes);
    int ordinal = 23;
    int[] pos = modulos.getCellPos(ordinal);
    assertTrue("Pos length equals 3", pos.length == 3);
    assertTrue("Pos[0] length equals 3", pos[0] == 3);
    assertTrue("Pos[1] length equals 2", pos[1] == 2);
    assertTrue("Pos[2] length equals 1", pos[2] == 1);
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) Axis(mondrian.olap.Axis)

Example 19 with Axis

use of mondrian.olap.Axis in project mondrian by pentaho.

the class ModulosTest method testOne.

public void testOne() {
    Axis[] axes = new Axis[1];
    TupleList positions = newPositionList(53);
    axes[0] = new RolapAxis(positions);
    Modulos modulosMany = Modulos.Generator.createMany(axes);
    Modulos modulos = Modulos.Generator.create(axes);
    int ordinal = 43;
    int[] posMany = modulosMany.getCellPos(ordinal);
    int[] pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 23;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    ordinal = 7;
    posMany = modulosMany.getCellPos(ordinal);
    pos = modulos.getCellPos(ordinal);
    assertTrue("Pos are not equal", Arrays.equals(posMany, pos));
    pos[0] = 23;
    int oMany = modulosMany.getCellOrdinal(pos);
    int o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 11;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
    pos[0] = 7;
    oMany = modulosMany.getCellOrdinal(pos);
    o = modulos.getCellOrdinal(pos);
    assertTrue("Ordinals are not equal", oMany == o);
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) Axis(mondrian.olap.Axis)

Example 20 with Axis

use of mondrian.olap.Axis in project mondrian by pentaho.

the class NonEmptyTest method testNonEmptyUnionQuery.

public void testNonEmptyUnionQuery() {
    Result result = executeQuery("select {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns,\n" + " NON EMPTY Hierarchize(\n" + "   Union(\n" + "     Crossjoin(\n" + "       Crossjoin([Gender].[All Gender].children,\n" + "                 [Marital Status].[All Marital Status].children),\n" + "       Crossjoin([Customers].[All Customers].children,\n" + "                 [Product].[All Products].children) ),\n" + "     Crossjoin({([Gender].[All Gender].[M], [Marital Status].[All Marital Status].[M])},\n" + "       Crossjoin(\n" + "         [Customers].[All Customers].[USA].children,\n" + "         [Product].[All Products].children) ) )) on rows\n" + "from Sales where ([Time].[1997])");
    final Axis rowsAxis = result.getAxes()[1];
    Assert.assertEquals(21, rowsAxis.getPositions().size());
}
Also used : Axis(mondrian.olap.Axis) NonEmptyResult(mondrian.rolap.RolapConnection.NonEmptyResult) Result(mondrian.olap.Result)

Aggregations

Axis (mondrian.olap.Axis)38 Result (mondrian.olap.Result)9 Position (mondrian.olap.Position)8 List (java.util.List)7 Member (mondrian.olap.Member)7 Test (org.junit.Test)7 Cell (mondrian.olap.Cell)6 ArrayList (java.util.ArrayList)5 TupleList (mondrian.calc.TupleList)4 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)4 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Hierarchy (mondrian.olap.Hierarchy)2 RolapAxis (mondrian.rolap.RolapAxis)2 DBCacheEntry (org.pentaho.di.core.DBCacheEntry)2 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)2 RowMeta (org.pentaho.di.core.row.RowMeta)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)2 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)2