Package org.olap4j

Interface CellSet

All Superinterfaces:
AutoCloseable, OlapWrapper, ResultSet, Wrapper

public interface CellSet extends ResultSet, OlapWrapper
Result of executing an OLAP Statement.

A CellSet consists of a set of (typically two) axes, each populated with a sequence of members, and a collection of cells at the intersection of these axes.

Cell ordinals and coordinates

There are two ways to identify a particular cell: ordinal and coordinates. Suppose that there are p axes, and each axis k (k between 0 and p - 1) has Uk positions. There are U = U0 * ... * Up - 1 cells in total. Then:

  • A cell's ordinal is an integer between 0 and U - 1.
  • A cell's coordinates are a list of p integers, indicating the cell's position on each axis. Each integer is between 0 and Up-1.

The ordinal number of a cell whose tuple ordinals are (S0, S1, ... Sp-1) is

Σi=0p-1 Si . Ei where E0 = 1 and Ei = Πi=0p-1 Uk

Since:
Aug 22, 2006
Author:
jhyde
  • Method Details

    • getStatement

      OlapStatement getStatement() throws SQLException
      Retrieves the OlapStatement object that produced this CellSet object. If the result set was generated some other way, such as by a OlapDatabaseMetaData method, this method may return null.
      Specified by:
      getStatement in interface ResultSet
      Returns:
      the OlapStatment object that produced this CellSet object or null if the cell set was produced some other way
      Throws:
      SQLException - if a database access error occurs or this method is called on a closed cell set
    • getMetaData

      CellSetMetaData getMetaData() throws OlapException
      Retrieves the description of this CellSet's axes and cells.
      Specified by:
      getMetaData in interface ResultSet
      Returns:
      the description of this CellSet's axes and cells
      Throws:
      OlapException - if a database access error occurs
    • getAxes

      List<CellSetAxis> getAxes()
      Retrieves a list of CellSetAxis objects containing the result.

      The list contains axes according to their ordinal: 0 is the columns axis, 1 the rows axis, and so forth.

      Returns:
      list of CellSetAxis objects containing the result
      See Also:
    • getFilterAxis

      CellSetAxis getFilterAxis()
      Retrieves the CellSetAxis representing the filter axis.

      If the query has a WHERE clause, the contains the members returned by that expression. Most query authors write a WHERE clause so that it evaluates to just one member or tuple. The members in this tuple (or the sole member), are referred to as the 'slicer context' of the query. The tuple contains only members of hierarchies explicitly mentioned in the WHERE expression; the slicer context of every hierarchy in the query's cube is implicitly the default member of that hierarchy.

      While not typical, note that a query's WHERE clause may also evaluate to zero or more than one tuples.

      If the query has no WHERE clause, the filter axis has a single position, but the position has no members.

      The filter axis is not included in the getAxes() collection.

      Returns:
      the filter axis
    • getCell

      Cell getCell(List<Integer> coordinates)
      Returns the Cell at a given set of coordinates.
      Parameters:
      coordinates - List of 0-based coordinates of the cell
      Returns:
      Cell
      Throws:
      IndexOutOfBoundsException - if coordinates are outside CellSet bounds
    • getCell

      Cell getCell(int ordinal)
      Returns the Cell at an ordinal.

      Equivalent to

      getCell(ordinalToCoordinates(ordinal))
      Parameters:
      ordinal - 0-based ordinal of the cell
      Returns:
      Cell
      Throws:
      IndexOutOfBoundsException - if ordinal lies outside CellSet bounds
    • getCell

      Cell getCell(Position... positions)
      Returns the Cell at the intersection of a set of axis positions.

      Equivalent to

      
       getCell(
           Arrays.asList(
               positions[0].ordinal(),
               positions[1].ordinal() [, ...]))
       
      Parameters:
      positions - Array of positions
      Returns:
      Cell
      Throws:
      IllegalArgumentException - if positions does not have the same number of members as the cell set has axes
      IndexOutOfBoundsException - if positions lie outside CellSet bounds
    • ordinalToCoordinates

      List<Integer> ordinalToCoordinates(int ordinal)
      Converts a cell ordinal to a list of cell coordinates.
      Parameters:
      ordinal - Cell ordinal
      Returns:
      Cell coordinates
    • coordinatesToOrdinal

      int coordinatesToOrdinal(List<Integer> coordinates)
      Converts a list of cell coordinates to a cell ordinal.
      Parameters:
      coordinates - Cell coordinates
      Returns:
      Cell ordinal