protected Result run() { getConnection().getCacheControl(null).flushSchemaCache(); IntegerProperty monLimit = MondrianProperties.instance().ResultLimit; int oldLimit = monLimit.get(); try { monLimit.set(this.resultLimit); Result result = executeQuery(query, con); // Check the number of positions on the last axis, which is // the ROWS axis in a 2 axis query. int numAxes = result.getAxes().length; Axis a = result.getAxes()[numAxes - 1]; final int positionCount = a.getPositions().size(); assertEquals(rowCount, positionCount); return result; } finally { monLimit.set(oldLimit); } }
/** * returns a matrix[rows][columns] of cells * * @param result - a 0, 1, or 2 dimensional Result * @return a matrix containing the result cells * @see #getCellList */ public static Cell[][] getCellMatrix(Result result) { int rows, cols; switch (result.getAxes().length) { case 0: cols = 1; rows = 1; break; case 1: cols = result.getAxes()[0].getPositions().size(); rows = 1; break; case 2: cols = result.getAxes()[0].getPositions().size(); rows = result.getAxes()[1].getPositions().size(); break; default: throw new IllegalArgumentException("result must be 0,1 or 2 dimensional"); } Iterator it = result.getCells().iterator(); Cell[][] matrix = new Cell[rows][cols]; for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++) matrix[row][col] = (Cell) it.next(); return matrix; }
private static int getRowCount(Result result) { return result.getAxes()[result.getAxes().length - 1].getPositions().size(); }