Search in sources :

Example 1 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class CmdRunner method executeCubeCommand.

public void executeCubeCommand(String cubename, String command, StringBuilder buf) {
    Cube cube = getCube(cubename);
    if (cube == null) {
        buf.append("No cube found with name \"");
        buf.append(cubename);
        buf.append("\"");
    } else {
        if (command.equals("clearCache")) {
            RolapCube rcube = (RolapCube) cube;
            rcube.clearCachedAggregations();
        } else {
            buf.append("For cube \"");
            buf.append(cubename);
            buf.append("\" there is no command \"");
            buf.append(command);
            buf.append("\"");
        }
    }
}
Also used : RolapCube(mondrian.rolap.RolapCube) RolapCube(mondrian.rolap.RolapCube)

Example 2 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class CrossJoinTest method testCrossJoinIterCalc_IterationCancellationOnForward.

// The test to verify that cancellation/timeout is checked
// in CrossJoinFunDef$CrossJoinIterCalc$1$1.forward()
public void testCrossJoinIterCalc_IterationCancellationOnForward() {
    propSaver.set(propSaver.properties.CheckCancelOrTimeoutInterval, 1);
    // Get product members as TupleList
    RolapCube salesCube = (RolapCube) cubeByName(getTestContext().getConnection(), SALES_CUBE);
    SchemaReader salesCubeSchemaReader = salesCube.getSchemaReader(getTestContext().getConnection().getRole()).withLocus();
    TupleList productMembers = productMembersPotScrubbersPotsAndPans(salesCubeSchemaReader);
    // Get genders members as TupleList
    Result genders = executeQuery(SELECT_GENDER_MEMBERS);
    TupleList genderMembers = getGenderMembers(genders);
    // Test execution to track cancellation/timeout calls
    Execution execution = spy(new Execution(genders.getQuery().getStatement(), 0));
    // check no execution of checkCancelOrTimeout has been yet
    verify(execution, times(0)).checkCancelOrTimeout();
    Integer crossJoinIterCalc = crossJoinIterCalcIterate(productMembers, genderMembers, execution);
    // checkCancelOrTimeout should be called once for the left tuple
    // from CrossJoinIterCalc$1$1.forward() since phase
    // interval is 1
    verify(execution, times(productMembers.size())).checkCancelOrTimeout();
    assertEquals(productMembers.size() * genderMembers.size(), crossJoinIterCalc.intValue());
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) ArrayTupleList(mondrian.calc.impl.ArrayTupleList) TupleList(mondrian.calc.TupleList) SchemaReader(mondrian.olap.SchemaReader) Execution(mondrian.server.Execution) RolapCube(mondrian.rolap.RolapCube) Result(mondrian.olap.Result)

Example 3 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class SchemaTest method testMondrian1275.

public void testMondrian1275() throws Exception {
    final TestContext tc = getTestContext().withSchema("<?xml version=\"1.0\"?>\n" + "<Schema name=\"FoodMart\">\n" + "  <Dimension name=\"Store Type\">\n" + "    <Annotations>\n" + "      <Annotation name=\"foo\">bar</Annotation>\n" + "    </Annotations>\n" + "    <Hierarchy hasAll=\"true\" primaryKey=\"store_id\">\n" + "      <Table name=\"store\"/>\n" + "      <Level name=\"Store Type\" column=\"store_type\" uniqueMembers=\"true\"/>\n" + "    </Hierarchy>\n" + "  </Dimension>\n" + "<Cube name=\"Sales\" defaultMeasure=\"Unit Sales\">\n" + "  <Table name=\"sales_fact_1997\">\n" + "    <AggExclude name=\"agg_c_special_sales_fact_1997\" />\n" + "    <AggExclude name=\"agg_lc_100_sales_fact_1997\" />\n" + "    <AggExclude name=\"agg_lc_10_sales_fact_1997\" />\n" + "    <AggExclude name=\"agg_pc_10_sales_fact_1997\" />\n" + "  </Table>\n" + "  <DimensionUsage name=\"Store Type\" source=\"Store Type\" foreignKey=\"store_id\"/>\n" + "  <Measure name=\"Unit Sales\" column=\"unit_sales\" aggregator=\"sum\"\n" + "      formatString=\"Standard\"/>\n" + "</Cube>\n" + "</Schema>\n");
    final RolapConnection rolapConn = tc.getOlap4jConnection().unwrap(RolapConnection.class);
    final SchemaReader schemaReader = rolapConn.getSchemaReader();
    final RolapSchema schema = schemaReader.getSchema();
    for (RolapCube cube : schema.getCubeList()) {
        Dimension dim = cube.getDimensions()[1];
        final Map<String, Annotation> annotations = dim.getAnnotationMap();
        Assert.assertEquals(1, annotations.size());
        Assert.assertEquals("bar", annotations.get("foo").getValue());
    }
}
Also used : RolapConnection(mondrian.rolap.RolapConnection) RolapSchema(mondrian.rolap.RolapSchema) RolapCube(mondrian.rolap.RolapCube)

Example 4 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class DimensionsNumericFunDef method nthHierarchy.

RolapHierarchy nthHierarchy(Evaluator evaluator, int n) {
    RolapCube cube = (RolapCube) evaluator.getCube();
    List<RolapHierarchy> hierarchies = cube.getHierarchies();
    if (n >= hierarchies.size() || n < 0) {
        throw newEvalException(this, "Index '" + n + "' out of bounds");
    }
    return hierarchies.get(n);
}
Also used : RolapCube(mondrian.rolap.RolapCube) RolapHierarchy(mondrian.rolap.RolapHierarchy)

Example 5 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class LastPeriodsFunDef method compileCall.

public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
    // Member defaults to [Time].currentmember
    Exp[] args = call.getArgs();
    final MemberCalc memberCalc;
    if (args.length == 1) {
        final RolapHierarchy timeHierarchy = ((RolapCube) compiler.getEvaluator().getCube()).getTimeHierarchy(getName());
        memberCalc = new HierarchyCurrentMemberFunDef.FixedCalcImpl(call, timeHierarchy);
    } else {
        memberCalc = compiler.compileMember(args[1]);
    }
    // Numeric Expression.
    final IntegerCalc indexValueCalc = compiler.compileInteger(args[0]);
    return new AbstractListCalc(call, new Calc[] { memberCalc, indexValueCalc }) {

        public TupleList evaluateList(Evaluator evaluator) {
            Member member = memberCalc.evaluateMember(evaluator);
            int indexValue = indexValueCalc.evaluateInteger(evaluator);
            return new UnaryTupleList(lastPeriods(member, evaluator, indexValue));
        }
    };
}
Also used : AbstractListCalc(mondrian.calc.impl.AbstractListCalc) RolapCube(mondrian.rolap.RolapCube) RolapHierarchy(mondrian.rolap.RolapHierarchy) UnaryTupleList(mondrian.calc.impl.UnaryTupleList)

Aggregations

RolapCube (mondrian.rolap.RolapCube)15 RolapHierarchy (mondrian.rolap.RolapHierarchy)7 Result (mondrian.olap.Result)3 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)2 RolapConnection (mondrian.rolap.RolapConnection)2 Calc (mondrian.calc.Calc)1 TupleList (mondrian.calc.TupleList)1 AbstractListCalc (mondrian.calc.impl.AbstractListCalc)1 AbstractMemberCalc (mondrian.calc.impl.AbstractMemberCalc)1 ArrayTupleList (mondrian.calc.impl.ArrayTupleList)1 CacheControl (mondrian.olap.CacheControl)1 Hierarchy (mondrian.olap.Hierarchy)1 SchemaReader (mondrian.olap.SchemaReader)1 RolapCubeDimension (mondrian.rolap.RolapCubeDimension)1 RolapSchema (mondrian.rolap.RolapSchema)1 Execution (mondrian.server.Execution)1 Dialect (mondrian.spi.Dialect)1 CellSet (org.olap4j.CellSet)1