Class Segment

java.lang.Object
mondrian.rolap.agg.Segment
Direct Known Subclasses:
SegmentWithData

public 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 Segment.ExcludedRegion 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
  • Field Details

    • 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 Details

  • Method Details

    • 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)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 this Segment, 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()