net.esper.view.stat.olap
Class CubeDimensionHelper

java.lang.Object
  extended by net.esper.view.stat.olap.CubeDimensionHelper

public final class CubeDimensionHelper
extends Object

Utility methods for dealing with Cube multidimensional tables (OLAP style). Enables iterating within dimensions, obtaining cell count for dimension sizes etc.. Cubes can be 1-dimensional to n-dimensional and these utility methods deal with this variety.


Constructor Summary
CubeDimensionHelper()
           
 
Method Summary
protected static int[] getDimensionSizes(Dimension[] dimensions)
          Compile an array of dimension sizes.
protected static int getOrdinal(int[] dimensionIndizes, int[] dimensionSizes)
          Given index values for each dimension and all dimension sizes this method returns an ordinal value.
protected static int getTotalCells(int[] dimensionSizes)
          Returns the number of cells in a cube that has the given dimension sizes.
protected static void nextIndize(int[] dimensionSizes, int[] dimensionIndizes)
          Increments the index values in the dimensionIndizes array given each dimension's size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CubeDimensionHelper

public CubeDimensionHelper()
Method Detail

getTotalCells

protected static int getTotalCells(int[] dimensionSizes)
Returns the number of cells in a cube that has the given dimension sizes.

Parameters:
dimensionSizes - is an array describing the number of dimensions and size of dimensions (number of members)
Returns:
total number of cells (size)

nextIndize

protected static void nextIndize(int[] dimensionSizes,
                                 int[] dimensionIndizes)
Increments the index values in the dimensionIndizes array given each dimension's size. For example, if dimension sizes are [3, 2, 4] then the indizes follow this order: [0,0,0] [1,0,0] [2,0,0] [0,1,0] ... [1,0,3] [2,0,3] [0,1,3] [1,1,3] [2,1,3] This example shows indize start and end ranges.

Parameters:
dimensionSizes - size of each dimension
dimensionIndizes - index value for each dimension, each value between and dimension size - 1
Throws:
NoSuchElementException - when an attempt is made to position indizes past the max

getDimensionSizes

protected static int[] getDimensionSizes(Dimension[] dimensions)
Compile an array of dimension sizes. The array contains as many elements as there are dimensions. The size of each dimension is returned in each array element. For example, a return value of [2,3,4] denotes a 3 dimensions where the first dimension has 2 members, the second dimension has 3 members, and the 3rd dimension has 4 members.

Parameters:
dimensions - is an array of dimensions
Returns:
integer array with size of each dimension

getOrdinal

protected static int getOrdinal(int[] dimensionIndizes,
                                int[] dimensionSizes)
Given index values for each dimension and all dimension sizes this method returns an ordinal value. For example, for dimensionIndizes [1, 4, 3] and sizes [2, 5, 4] the ordinal is 1 + 4 * 2 + 3 * 10.

Parameters:
dimensionIndizes - index value for each dimension, each value between and dimension size - 1
dimensionSizes - size of each dimension
Returns:
cell ordinal, between 0 and (dimensionSizes[0] + dimensionSizes[1] * dimensionSizes[0] etc.)

© 2007 EsperTech Inc.
All rights reserved.
Visit us at espertech.com