001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2011-2013 Pentaho and others
008// All Rights Reserved.
009*/
010package mondrian.spi;
011
012import mondrian.rolap.CellKey;
013
014import java.io.Serializable;
015import java.util.*;
016
017/**
018 * SegmentBody is the object which contains the cached data of a
019 * Segment. They are stored inside a {@link mondrian.spi.SegmentCache}
020 * and can be retrieved by a {@link SegmentHeader} key.
021 *
022 * <p>The segment body objects are immutable and fully serializable.
023 *
024 * @author LBoudreau
025 */
026public interface SegmentBody extends Serializable {
027    /**
028     * Converts contents of this segment into a cellkey/value map. Use only
029     * for sparse segments.
030     *
031     * @return Map containing cell values keyed by their coordinates
032     */
033    Map<CellKey, Object> getValueMap();
034
035    /**
036     * Returns an array of values.
037     *
038     * <p>Use only for dense segments.</p>
039     *
040     * @return An array of values
041     */
042    Object getValueArray();
043
044    /**
045     * Returns a bit-set indicating whether values are null. The ordinals in
046     * the bit-set correspond to the indexes in the array returned from
047     * {@link #getValueArray()}.
048     *
049     * <p>Use only for dense segments of native values.</p>
050     *
051     * @return Indicators
052     */
053    BitSet getNullValueIndicators();
054
055    /**
056     * Returns the cached axis value sets to be used as an
057     * initializer for the segment's axis.
058     *
059     * @return An array of SortedSets which was cached previously.
060     */
061    SortedSet<Comparable>[] getAxisValueSets();
062
063    /**
064     * Returns an array of boolean values which identify which
065     * axis of the cached segment contained null values.
066     *
067     * @return An array of boolean values.
068     */
069    boolean[] getNullAxisFlags();
070}
071
072// End SegmentBody.java