mondrian.rolap.agg
Class Segment

java.lang.Object
  extended by mondrian.rolap.agg.Segment

 class Segment
extends Object

A Segment is a collection of cell values parameterized by a measure, and a set of (column, value) pairs. An example of a segment is

(Unit sales, Gender = 'F', State in {'CA','OR'}, Marital Status = anything)

All segments over the same set of columns belong to an Aggregation, in this case

('Sales' Star, Gender, State, Marital Status)

Note that different measures (in the same Star) occupy the same Aggregation. Aggregations belong to the AggregationManager, a singleton.

Segments are pinned during the evaluation of a single MDX query. The query evaluates the expressions twice. The first pass, it finds which cell values it needs, pins the segments containing the ones which are already present (one pin-count for each cell value used), and builds a cell request for those which are not present. It executes the cell request to bring the required cell values into the cache, again, pinned. Then it evalutes the query a second time, knowing that all cell values are available. Finally, it releases the pins.

A Segment may have a list of excluded Segment.Region objects. These are caused by cache flushing. Usually a segment is a hypercube: it is defined by a set of values on each of its axes. But after a cache flush request, a segment may have a rectangular 'hole', and therefore not be a hypercube anymore.

For example, the segment defined by {CA, OR, WA} * {F, M} is a 2-dimensional hyper-rectangle with 6 cells. After flushing {CA, OR, TX} * {F}, the result is 4 cells:

     F     M
 CA  out   in
 OR  out   in
 WA  in    in
 
defined by the original segment minus the region ({CA, OR} * {F}).

Since:
21 March, 2002
Author:
jhyde
 

Nested Class Summary
(package private) static class Segment.Region
          Definition of a region of values which are not in a segment.
 
Field Summary
(package private)  Aggregation aggregation
           
(package private)  Aggregation.Axis[] axes
           
(package private)  int id
           
(package private)  RolapStar.Measure measure
           
 
Constructor Summary
Segment(Aggregation aggregation, RolapStar.Measure measure, Aggregation.Axis[] axes, List<Segment.Region> excludedRegions)
          Creates a Segment; it's not loaded yet.
 
Method Summary
(package private)  Segment createSubSegment(BitSet[] axisKeepBitSets, int bestColumn, StarColumnPredicate bestPredicate, List<Segment.Region> excludedRegions)
          Creates a Segment which has the same dimensionality as this Segment and a subset of the values.
 int getCellCount()
          Returns the number of cells in this Segment, deducting cells in excluded regions.
(package private)  Object getCellValue(Object[] keys)
          Retrieves the value at the location identified by keys.
(package private)  SegmentDataset getData()
          Returns this Segment's dataset, or null if the data has not yet been loaded.
 List<Segment.Region> getExcludedRegions()
           
(package private)  boolean isFailed()
           
 boolean isReady()
           
 void print(PrintWriter pw)
          Prints the state of this Segment, including constraints and values.
(package private)  void setData(SegmentDataset data, RolapAggregationManager.PinSet pinnedSegments)
          Sets the data, and notifies any threads which are blocked in waitUntilLoaded().
(package private)  void setFailIfStillLoading()
          If this segment is still loading, signals that it failed to load, and notifies any threads which are blocked in waitUntilLoaded().
 String toString()
           
 void waitUntilLoaded()
          Blocks until this segment has finished loading; if this segment has already loaded, returns immediately.
(package private)  boolean wouldContain(Object[] keys)
          Returns whether the given set of key values will be in this segment when it finishes loading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

final int id

aggregation

final Aggregation aggregation

measure

final RolapStar.Measure measure

axes

final Aggregation.Axis[] axes
Constructor Detail

Segment

Segment(Aggregation aggregation,
        RolapStar.Measure measure,
        Aggregation.Axis[] axes,
        List<Segment.Region> excludedRegions)
Creates a Segment; it's not loaded yet.

Parameters:
aggregation - The aggregation this Segment belongs to
measure - Measure whose values this Segment contains
axes - List of axes; each is a constraint plus a list of values
excludedRegions - List of regions which are not in this segment.
Method Detail

setData

void setData(SegmentDataset data,
             RolapAggregationManager.PinSet pinnedSegments)
Sets the data, and notifies any threads which are blocked in waitUntilLoaded().


setFailIfStillLoading

void setFailIfStillLoading()
If this segment is still loading, signals that it failed to load, and notifies any threads which are blocked in waitUntilLoaded().


isReady

public boolean isReady()

isFailed

boolean isFailed()

toString

public String toString()
Overrides:
toString in class Object

getCellValue

Object getCellValue(Object[] keys)
Retrieves the value at the location identified by keys.

Returns


wouldContain

boolean wouldContain(Object[] keys)
Returns whether the given set of key values will be in this segment when it finishes loading.


waitUntilLoaded

public void waitUntilLoaded()
Blocks until this segment has finished loading; if this segment has already loaded, returns immediately.


print

public void print(PrintWriter pw)
Prints the state of this Segment, including constraints and values. Blocks the current thread until the segment is loaded.

Parameters:
pw - Writer

getExcludedRegions

public List<Segment.Region> getExcludedRegions()

getCellCount

public int getCellCount()
Returns the number of cells in this Segment, deducting cells in excluded regions.

This method may return a value which is slightly too low, or occasionally even negative. This occurs when a Segment has more than one excluded region, and those regions overlap. Cells which are in both regions will be counted twice.

Returns:
Number of cells in this Segment

createSubSegment

Segment createSubSegment(BitSet[] axisKeepBitSets,
                         int bestColumn,
                         StarColumnPredicate bestPredicate,
                         List<Segment.Region> excludedRegions)
Creates a Segment which has the same dimensionality as this Segment and a subset of the values.

If bestColumn is not -1, the bestColumnth column's predicate should be replaced by bestPredicate.

Parameters:
axisKeepBitSets - For each axis, a bitmap of the axis values to keep; each axis must have at least one bit set
bestColumn -
bestPredicate -
excludedRegions - List of regions to exclude from segment
Returns:
Segment containing a subset of the values

getData

SegmentDataset getData()
Returns this Segment's dataset, or null if the data has not yet been loaded.


SourceForge.net_Logo