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) 2002-2005 Julian Hyde
008// Copyright (C) 2005-2013 Pentaho and others
009// All Rights Reserved.
010//
011// jhyde, 21 March, 2002
012*/
013package mondrian.rolap.agg;
014
015import mondrian.rolap.CellKey;
016
017import java.util.BitSet;
018
019/**
020 * Implementation of {@link DenseSegmentDataset} that stores
021 * values of type {@code double}.
022 *
023 * @author jhyde
024 */
025abstract class DenseNativeSegmentDataset extends DenseSegmentDataset {
026    protected final BitSet nullValues;
027
028    /**
029     * Creates a DenseNativeSegmentDataset.
030     *
031     * @param axes Segment axes, containing actual column values
032     * @param nullValues A bit-set indicating whether values are null. Each
033     *                   position in the bit-set corresponds to an offset in the
034     *                   value array. If position is null, the corresponding
035     *                   entry in the value array will also be 0.
036     */
037    DenseNativeSegmentDataset(
038        SegmentAxis[] axes,
039        BitSet nullValues)
040    {
041        super(axes);
042        this.nullValues = nullValues;
043    }
044
045    public boolean isNull(CellKey key) {
046        int offset = key.getOffset(axisMultipliers);
047        return isNull(offset);
048    }
049
050    /**
051     * Returns whether the value at the given offset is null.
052     *
053     * <p>The native value at this offset will also be 0. You only need to
054     * call this method if the {@link #getInt getXxx} method has returned 0.
055     *
056     * @param offset Cell offset
057     * @return Whether the cell at this offset is null
058     */
059    protected final boolean isNull(int offset) {
060        return nullValues.get(offset);
061    }
062}
063
064// End DenseNativeSegmentDataset.java