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("\"");
}
}
}
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());
}
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());
}
}
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);
}
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));
}
};
}
Aggregations