Package mondrian.rolap.agg
Class SparseSegmentDataset
- java.lang.Object
-
- mondrian.rolap.agg.SparseSegmentDataset
-
- All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<CellKey,java.lang.Object>>
,SegmentDataset
class SparseSegmentDataset extends java.lang.Object implements SegmentDataset
ASparseSegmentDataset
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
- Author:
- jhyde
-
-
Constructor Summary
Constructors Constructor Description SparseSegmentDataset()
Creates an empty SparseSegmentDataset.SparseSegmentDataset(java.util.Map<CellKey,java.lang.Object> values)
Creates a SparseSegmentDataset with a given value map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SegmentBody
createSegmentBody(java.util.List<Pair<java.util.SortedSet<java.lang.Comparable>,java.lang.Boolean>> axes)
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 adouble
.int
getInt(CellKey pos)
Returns the value at a given coordinate, as anint
.java.lang.Object
getObject(CellKey pos)
Returns the value at a given coordinate, as anObject
.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.java.util.Iterator<java.util.Map.Entry<CellKey,java.lang.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, java.lang.Object value)
-
-
-
Constructor Detail
-
SparseSegmentDataset
SparseSegmentDataset()
Creates an empty SparseSegmentDataset.
-
SparseSegmentDataset
SparseSegmentDataset(java.util.Map<CellKey,java.lang.Object> values)
Creates a SparseSegmentDataset with a given value map. The map is not copied; a reference to the map is retained inside the dataset, and therefore the contents of the dataset will change if the map is modified.- Parameters:
values
- Value map
-
-
Method Detail
-
getObject
public java.lang.Object getObject(CellKey pos)
Description copied from interface:SegmentDataset
Returns the value at a given coordinate, as anObject
.- Specified by:
getObject
in interfaceSegmentDataset
- 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 interfaceSegmentDataset
- 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 anint
.- Specified by:
getInt
in interfaceSegmentDataset
- 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 adouble
.- Specified by:
getDouble
in interfaceSegmentDataset
- 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 interfaceSegmentDataset
- Parameters:
pos
- Coordinate position- Returns:
- Whether there is a value
-
put
public void put(CellKey key, java.lang.Object value)
-
iterator
public java.util.Iterator<java.util.Map.Entry<CellKey,java.lang.Object>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.util.Map.Entry<CellKey,java.lang.Object>>
-
getBytes
public double getBytes()
Description copied from interface:SegmentDataset
Returns the number of bytes occupied by this dataset.- Specified by:
getBytes
in interfaceSegmentDataset
- Returns:
- number of bytes
-
populateFrom
public void populateFrom(int[] pos, SegmentDataset data, CellKey key)
- Specified by:
populateFrom
in interfaceSegmentDataset
-
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 interfaceSegmentDataset
- Parameters:
pos
- OrdinalrowList
- Row listcolumn
- 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 interfaceSegmentDataset
- Returns:
- A value of SqlStatement.Type
-
createSegmentBody
public SegmentBody createSegmentBody(java.util.List<Pair<java.util.SortedSet<java.lang.Comparable>,java.lang.Boolean>> axes)
Description copied from interface:SegmentDataset
Return an immutable, final and serializable implementation of a SegmentBody in order to cache this dataset.- Specified by:
createSegmentBody
in interfaceSegmentDataset
- Parameters:
axes
- An array with, for each axis, the set of axis values, sorted in natural order, and a flag saying whether the null value is also present. This is supplied by theSegmentLoader
.- Returns:
- A
SegmentBody
.
-
-