net.esper.view.stat.olap
Class MultidimCubeImpl<V>

java.lang.Object
  extended by net.esper.view.stat.olap.MultidimCubeImpl<V>
All Implemented Interfaces:
Serializable, MetaDefItem, MultidimCube<V>

public final class MultidimCubeImpl<V>
extends Object
implements MultidimCube<V>, MetaDefItem

Implementation for a multidimensional cube that can be configured with the type of cell to store. This cube implementation grows in each dimension as new dimension members are made known to the cube. If cells are added for dimension members that have not been encountered before, then the new dimension members are added to the known dimension members and the cube is redimensioned, ie. grows. In design of this class, performance is important in the following areas: - Access to cells should be very fast in the normal case. Normal case is that the cell for all dimension members (the particular coordinate) already exists. This class uses a map of dimension member set (coordinates) to fact array ordinal which gets great performance.

See Also:
Serialized Form

Constructor Summary
MultidimCubeImpl(String[] dimensionNames, MultidimCubeCellFactory<V> multidimCubeCellFactory)
          Constructor.
 
Method Summary
 V getCell(MultiKeyUntyped coordinates)
          Get a cell, returns null if the cell does not yet exist.
 V getCellAddMembers(MultiKeyUntyped coordinates)
          Get a cell adding the coordinate members if the cell does not yet exist.
 V[] getCells()
          Returns all cells.
 String[] getDimensionNames()
          Returns array containing name of each dimension including the name of the cell.
 List<Object> getMembers(int dimension)
          Get the members making up a dimension.
 int getNumDimensions()
          Get the number of dimensions of the cube.
 void setMembers(int dimension, Class enumType)
          Set dimension members from the enumeration Class.
 void setMembers(int dimension, List<Object> members)
          Set dimension members from the list of value objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultidimCubeImpl

public MultidimCubeImpl(String[] dimensionNames,
                        MultidimCubeCellFactory<V> multidimCubeCellFactory)
Constructor.

Parameters:
dimensionNames - is the name of each dimension - and dictates the number of dimensions
multidimCubeCellFactory - is the factory for cube cells
Method Detail

getDimensionNames

public String[] getDimensionNames()
Description copied from interface: MultidimCube
Returns array containing name of each dimension including the name of the cell. The array size is getNumDimensions() + 1, with the first element as the cell name.

Specified by:
getDimensionNames in interface MultidimCube<V>
Returns:
dimension names array

getNumDimensions

public final int getNumDimensions()
Description copied from interface: MultidimCube
Get the number of dimensions of the cube. The minimum number of dimensions is 1.

Specified by:
getNumDimensions in interface MultidimCube<V>
Returns:
number of dimensions

setMembers

public final void setMembers(int dimension,
                             Class enumType)
Description copied from interface: MultidimCube
Set dimension members from the enumeration Class.

Specified by:
setMembers in interface MultidimCube<V>
Parameters:
dimension - starts at 0 and has a max of number of dimensions minus 1
enumType - is the class for which the enum constants are obtained, and used as members

setMembers

public final void setMembers(int dimension,
                             List<Object> members)
Description copied from interface: MultidimCube
Set dimension members from the list of value objects.

Specified by:
setMembers in interface MultidimCube<V>
Parameters:
dimension - starts at 0 and has a max of number of dimensions minus 1
members - is a list of objects making up the dimension member values

getMembers

public final List<Object> getMembers(int dimension)
Description copied from interface: MultidimCube
Get the members making up a dimension.

Specified by:
getMembers in interface MultidimCube<V>
Parameters:
dimension - for which to return the members
Returns:
list of member object of the dimension

getCell

public V getCell(MultiKeyUntyped coordinates)
Description copied from interface: MultidimCube
Get a cell, returns null if the cell does not yet exist.

Specified by:
getCell in interface MultidimCube<V>
Parameters:
coordinates - contains member values for each dimension of the cube
Returns:
the cell

getCellAddMembers

public V getCellAddMembers(MultiKeyUntyped coordinates)
Description copied from interface: MultidimCube
Get a cell adding the coordinate members if the cell does not yet exist.

Specified by:
getCellAddMembers in interface MultidimCube<V>
Parameters:
coordinates - contains member values for each dimension of the cube
Returns:
the cell

getCells

public final V[] getCells()
Description copied from interface: MultidimCube
Returns all cells.

Specified by:
getCells in interface MultidimCube<V>
Returns:
cell array