use of mondrian.olap.Member in project mondrian by pentaho.
the class RolapAxisTest method toString.
protected String toString(List<Member> position) {
StringBuffer buf = new StringBuffer(100);
buf.append('{');
boolean firstTimeInner = true;
for (Member m : position) {
if (!firstTimeInner) {
buf.append(',');
}
buf.append(m);
firstTimeInner = false;
}
buf.append('}');
return buf.toString();
}
use of mondrian.olap.Member in project mondrian by pentaho.
the class ExistingFunDef method compileCall.
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final IterCalc setArg = compiler.compileIter(call.getArg(0));
final Type myType = call.getArg(0).getType();
return new AbstractListCalc(call, new Calc[] { setArg }) {
public boolean dependsOn(Hierarchy hierarchy) {
return myType.usesHierarchy(hierarchy, false);
}
public TupleList evaluateList(Evaluator evaluator) {
TupleIterable setTuples = setArg.evaluateIterable(evaluator);
TupleList result = TupleCollections.createList(setTuples.getArity());
List<Member> contextMembers = Arrays.asList(evaluator.getMembers());
List<Hierarchy> argDims = null;
List<Hierarchy> contextDims = getHierarchies(contextMembers);
for (List<Member> tuple : setTuples) {
if (argDims == null) {
argDims = getHierarchies(tuple);
}
if (existsInTuple(tuple, contextMembers, argDims, contextDims, evaluator)) {
result.add(tuple);
}
}
return result;
}
};
}
use of mondrian.olap.Member in project mondrian by pentaho.
the class UnionFunDefTest method testMondrian2250.
/**
* Test for MONDRIAN-2250 issue.
* Tests that the result is independent on the hashCode.
* For this purpose MemberForTest with rewritten hashCode is used.
*
* Tuples are gotten from customer attachments.
*/
public void testMondrian2250() {
Member[] dates = new Member[4];
for (int i = 25; i < 29; i++) {
dates[i - 25] = new MemberForTest("[Consumption Date.Calendar].[2014-07-" + i + "]");
}
List<Member> list = Arrays.asList(dates);
UnaryTupleList unaryTupleList = new UnaryTupleList(list);
Member consumptionMethod = new MemberForTest("[Consumption Method].[PVR]");
Member measuresAverageTimeshift = new MemberForTest("[Measures].[Average Timeshift]");
String[] hours = { "00", "14", "15", "16", "23" };
Member[] times = new Member[5];
for (int i = 0; i < hours.length; i++) {
times[i] = new MemberForTest("[Consumption Time.Time].[" + hours[i] + ":00]");
}
int arity = 3;
ArrayTupleList arrayTupleList = new ArrayTupleList(arity);
for (Member time : times) {
List<Member> currentList = new ArrayList(3);
currentList.add(consumptionMethod);
currentList.add(measuresAverageTimeshift);
currentList.add(time);
arrayTupleList.add(currentList);
}
CrossJoinFunDef crossJoinFunDef = new CrossJoinFunDef(new CrossJoinTest.NullFunDef());
Exp[] expMock = new Exp[1];
expMock[0] = mock(Exp.class);
ResolvedFunCall resolvedFunCall = new ResolvedFunCall(mock(FunDef.class), expMock, mock(SetType.class));
Calc[] calcs = new Calc[1];
calcs[0] = Mockito.mock(Calc.class);
CrossJoinFunDef.ImmutableListCalc immutableListCalc = crossJoinFunDef.new ImmutableListCalc(resolvedFunCall, calcs);
TupleList listForUnion1 = immutableListCalc.makeList(unaryTupleList, arrayTupleList);
List<Member> list2 = Arrays.asList(dates);
UnaryTupleList unaryTupleList2 = new UnaryTupleList(list2);
Member measuresTotalViewingTime = new MemberForTest("[Measures].[Total Viewing Time]");
ArrayTupleList arrayTupleList2 = new ArrayTupleList(arity);
for (Member time : times) {
List<Member> currentList = new ArrayList(3);
currentList.add(consumptionMethod);
currentList.add(measuresTotalViewingTime);
currentList.add(time);
arrayTupleList2.add(currentList);
}
TupleList listForUnion2 = immutableListCalc.makeList(unaryTupleList2, arrayTupleList2);
UnionFunDef unionFunDefMock = Mockito.mock(UnionFunDef.class);
doCallRealMethod().when(unionFunDefMock).union(any(TupleList.class), any(TupleList.class), anyBoolean());
TupleList tupleList = unionFunDefMock.union(listForUnion1, listForUnion2, false);
System.out.println(tupleList);
assertEquals(40, tupleList.size());
}
use of mondrian.olap.Member in project mondrian by pentaho.
the class BatchTestCase method getMeasure.
protected RolapStar.Measure getMeasure(String cube, String measureName) {
final Connection connection = getFoodMartConnection();
final boolean fail = true;
Cube salesCube = connection.getSchema().lookupCube(cube, fail);
Member measure = salesCube.getSchemaReader(null).getMemberByUniqueName(Util.parseIdentifier(measureName), fail);
return RolapStar.getStarMeasure(measure);
}
use of mondrian.olap.Member in project pentaho-kettle by pentaho.
the class MondrianHelper method outputFlattenedRecurse.
private static void outputFlattenedRecurse(Result result, List<List<Object>> rows, List<Object> rowValues, int[] coords, int axisOrdinal) {
final Axis[] axes = result.getAxes();
if (axisOrdinal == axes.length) {
final Cell cell = result.getCell(coords);
// Output the raw (unformatted) value of the cell.
// NOTE: We could output other properties of the cell here, such as its
// formatted value, too.
rowValues.add(cell.getValue());
// Add a copy of the completed row to the list of rows.
rows.add(new ArrayList<>(rowValues));
} else {
final Axis axis = axes[axisOrdinal];
int k = -1;
int saveLength = rowValues.size();
for (Position position : axis.getPositions()) {
coords[axisOrdinal] = ++k;
for (Member member : position) {
rowValues.add(member.getUniqueName());
}
outputFlattenedRecurse(result, rows, rowValues, coords, axisOrdinal + 1);
while (rowValues.size() > saveLength) {
rowValues.remove(rowValues.size() - 1);
}
}
}
}
Aggregations