Class Segment
- java.lang.Object
-
- mondrian.rolap.agg.Segment
-
- Direct Known Subclasses:
SegmentWithData
public class Segment extends Object
ASegmentis 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 requestfor 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
Segment.ExcludedRegionobjects. 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 indefined by the original segment minus the region ({CA, OR} * {F}).- Since:
- 21 March, 2002
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSegment.ExcludedRegionDefinition of a region of values which are not in a segment.
-
Field Summary
Fields Modifier and Type Field Description protected RolapStar.Column[]columnsThis is set in the load method and is used during the processing of a particular aggregate load.protected List<StarPredicate>compoundPredicateListprotected BitKeyconstrainedColumnsBitKeyprotected List<Segment.ExcludedRegion>excludedRegionsList of regions to ignore when reading this segment.RolapStar.MeasuremeasureStarColumnPredicate[]predicatesAn array of axes, one for each constraining column, containing the values returned for that constraining column.protected RolapStarstar
-
Constructor Summary
Constructors Constructor Description Segment(RolapStar star, BitKey constrainedColumnsBitKey, RolapStar.Column[] columns, RolapStar.Measure measure, StarColumnPredicate[] predicates, List<Segment.ExcludedRegion> excludedRegions, List<StarPredicate> compoundPredicateList)Creates aSegment; it's not loaded yet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddescribeAxes(StringBuilder buf, int i, boolean values)RolapStar.Column[]getColumns()Returns the constrained columns.List<StarPredicate>getCompoundPredicateList()Returns the list of compound predicates.BitKeygetConstrainedColumnsBitKey()Returns the BitKey for ALL columns (Measures and Levels) involved in the query.List<Segment.ExcludedRegion>getExcludedRegions()SegmentHeadergetHeader()RolapStargetStar()Returns the star.protected booleanisExcluded(Object[] keys)Returns whether a cell value is excluded from this segment.booleanmatches(AggregationKey aggregationKey, RolapStar.Measure measure)voidprint(PrintWriter pw)Prints the state of thisSegment, including constraints and values.StringtoString()
-
-
-
Field Detail
-
columns
protected final RolapStar.Column[] columns
This is set in the load method and is used during the processing of a particular aggregate load.
-
measure
public final RolapStar.Measure measure
-
predicates
public final StarColumnPredicate[] predicates
An array of axes, one for each constraining column, containing the values returned for that constraining column.
-
star
protected final RolapStar star
-
constrainedColumnsBitKey
protected final BitKey constrainedColumnsBitKey
-
excludedRegions
protected final List<Segment.ExcludedRegion> excludedRegions
List of regions to ignore when reading this segment. This list is populated when a region is flushed. The cells for these regions may be physically in the segment, because trimming segments can be expensive, but should still be ignored.
-
compoundPredicateList
protected final List<StarPredicate> compoundPredicateList
-
-
Constructor Detail
-
Segment
public Segment(RolapStar star, BitKey constrainedColumnsBitKey, RolapStar.Column[] columns, RolapStar.Measure measure, StarColumnPredicate[] predicates, List<Segment.ExcludedRegion> excludedRegions, List<StarPredicate> compoundPredicateList)
Creates aSegment; it's not loaded yet.- Parameters:
star- Star that this Segment belongs tomeasure- Measure whose values this Segment containspredicates- List of predicates constraining each axisexcludedRegions- List of regions which are not in this segment.
-
-
Method Detail
-
getColumns
public RolapStar.Column[] getColumns()
Returns the constrained columns.
-
getStar
public RolapStar getStar()
Returns the star.
-
getCompoundPredicateList
public List<StarPredicate> getCompoundPredicateList()
Returns the list of compound predicates.
-
getConstrainedColumnsBitKey
public BitKey getConstrainedColumnsBitKey()
Returns the BitKey for ALL columns (Measures and Levels) involved in the query.
-
describeAxes
protected void describeAxes(StringBuilder buf, int i, boolean values)
-
isExcluded
protected final boolean isExcluded(Object[] keys)
Returns whether a cell value is excluded from this segment.
-
print
public void print(PrintWriter pw)
Prints the state of thisSegment, including constraints and values. Blocks the current thread until the segment is loaded.- Parameters:
pw- Writer
-
getExcludedRegions
public List<Segment.ExcludedRegion> getExcludedRegions()
-
matches
public boolean matches(AggregationKey aggregationKey, RolapStar.Measure measure)
-
getHeader
public SegmentHeader getHeader()
-
-