mondrian.rolap.agg
Class SparseSegmentDataset

java.lang.Object
  extended by mondrian.rolap.agg.SparseSegmentDataset
All Implemented Interfaces:
Iterable<Map.Entry<CellKey,Object>>, SegmentDataset

 class SparseSegmentDataset
extends Object
implements SegmentDataset

A SparseSegmentDataset is a means of storing segment values which is suitable when few of the combinations of keys have a value present.

The storage requirements are as follows. Key is 1 word for each dimension. Hashtable entry is 3 words. Value is 1 word. Total space is (4 + d) * v. (May also need hash table to ensure that values are only stored once.)

NOTE: This class is not synchronized.

Since:
21 March, 2002
Version:
$Id: //open/mondrian/src/main/mondrian/rolap/agg/SparseSegmentDataset.java#13 $
Author:
jhyde

Field Summary
(package private)  Map<CellKey,Object> values
           
 
Constructor Summary
SparseSegmentDataset(Segment segment)
           
 
Method Summary
 SegmentBody createSegmentBody(SortedSet<Comparable<?>>[] axisValueSets, boolean[] nullAxisFlags)
          Must return an immutable, final and serializable implementation of a SegmentBody in order to cache this dataset.
 boolean exists(CellKey pos)
          Returns whether there is a value at a given coordinate.
 double getBytes()
          Returns the number of bytes occupied by this dataset.
 double getDouble(CellKey pos)
          Returns the value at a given coordinate, as a double.
 int getInt(CellKey pos)
          Returns the value at a given coordinate, as an int.
 Object getObject(CellKey pos)
          Returns the value at a given coordinate, as an Object.
 SqlStatement.Type getType()
          Returns the SQL type of the data contained in this dataset.
 boolean isNull(CellKey pos)
          Returns whether the cell at a given coordinate is null.
 Iterator<Map.Entry<CellKey,Object>> iterator()
           
 void populateFrom(int[] pos, SegmentDataset data, CellKey key)
           
 void populateFrom(int[] pos, SegmentLoader.RowList rowList, int column)
          Sets the value a given ordinal.
 void put(CellKey key, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

final Map<CellKey,Object> values
Constructor Detail

SparseSegmentDataset

SparseSegmentDataset(Segment segment)
Method Detail

getObject

public Object getObject(CellKey pos)
Description copied from interface: SegmentDataset
Returns the value at a given coordinate, as an Object.

Specified by:
getObject in interface SegmentDataset
Parameters:
pos - Coordinate position
Returns:
Value

isNull

public boolean isNull(CellKey pos)
Description copied from interface: SegmentDataset
Returns whether the cell at a given coordinate is null.

Specified by:
isNull in interface SegmentDataset
Parameters:
pos - Coordinate position
Returns:
Whether cell value is null

getInt

public int getInt(CellKey pos)
Description copied from interface: SegmentDataset
Returns the value at a given coordinate, as an int.

Specified by:
getInt in interface SegmentDataset
Parameters:
pos - Coordinate position
Returns:
Value

getDouble

public double getDouble(CellKey pos)
Description copied from interface: SegmentDataset
Returns the value at a given coordinate, as a double.

Specified by:
getDouble in interface SegmentDataset
Parameters:
pos - Coordinate position
Returns:
Value

exists

public boolean exists(CellKey pos)
Description copied from interface: SegmentDataset
Returns whether there is a value at a given coordinate.

Specified by:
exists in interface SegmentDataset
Parameters:
pos - Coordinate position
Returns:
Whether there is a value

put

public void put(CellKey key,
                Object value)

iterator

public Iterator<Map.Entry<CellKey,Object>> iterator()
Specified by:
iterator in interface Iterable<Map.Entry<CellKey,Object>>

getBytes

public double getBytes()
Description copied from interface: SegmentDataset
Returns the number of bytes occupied by this dataset.

Specified by:
getBytes in interface SegmentDataset
Returns:
number of bytes

populateFrom

public void populateFrom(int[] pos,
                         SegmentDataset data,
                         CellKey key)
Specified by:
populateFrom in interface SegmentDataset

populateFrom

public void populateFrom(int[] pos,
                         SegmentLoader.RowList rowList,
                         int column)
Description copied from interface: SegmentDataset
Sets the value a given ordinal.

Specified by:
populateFrom in interface SegmentDataset
Parameters:
pos - Ordinal
rowList - Row list
column - Column of row list

getType

public SqlStatement.Type getType()
Description copied from interface: SegmentDataset
Returns the SQL type of the data contained in this dataset.

Specified by:
getType in interface SegmentDataset
Returns:
A value of SqlStatement.Type

createSegmentBody

public SegmentBody createSegmentBody(SortedSet<Comparable<?>>[] axisValueSets,
                                     boolean[] nullAxisFlags)
Description copied from interface: SegmentDataset
Must return an immutable, final and serializable implementation of a SegmentBody in order to cache this dataset.

Specified by:
createSegmentBody in interface SegmentDataset
Parameters:
axisValueSets - An array of SortedSets of Comparables. This is supplied by the SegmentLoader.
nullAxisFlags - An array of booleans indicating which segment axis has null values. This is supplied by the SegmentLoader.
Returns:
A SegmentBody object.
See Also:
SegmentBody.createSegmentDataset(Segment)

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads