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-2012 Pentaho and others 009// All Rights Reserved. 010// 011// jhyde, 21 March, 2002 012*/ 013package mondrian.rolap.agg; 014 015import mondrian.rolap.CellKey; 016import mondrian.rolap.SqlStatement; 017import mondrian.spi.SegmentBody; 018import mondrian.util.Pair; 019 020import java.util.*; 021 022/** 023 * A <code>SegmentDataset</code> holds the values in a segment. 024 * 025 * @author jhyde 026 * @since 21 March, 2002 027 */ 028public interface SegmentDataset extends Iterable<Map.Entry<CellKey, Object>> { 029 /** 030 * Returns the value at a given coordinate, as an {@link Object}. 031 * 032 * @param pos Coordinate position 033 * @return Value 034 */ 035 Object getObject(CellKey pos); 036 037 /** 038 * Returns the value at a given coordinate, as an {@code int}. 039 * 040 * @param pos Coordinate position 041 * @return Value 042 */ 043 int getInt(CellKey pos); 044 045 /** 046 * Returns the value at a given coordinate, as a {@code double}. 047 * 048 * @param pos Coordinate position 049 * @return Value 050 */ 051 double getDouble(CellKey pos); 052 053 /** 054 * Returns whether the cell at a given coordinate is null. 055 * 056 * @param pos Coordinate position 057 * @return Whether cell value is null 058 */ 059 boolean isNull(CellKey pos); 060 061 /** 062 * Returns whether there is a value at a given coordinate. 063 * 064 * @param pos Coordinate position 065 * @return Whether there is a value 066 */ 067 boolean exists(CellKey pos); 068 069 /** 070 * Returns the number of bytes occupied by this dataset. 071 * 072 * @return number of bytes 073 */ 074 double getBytes(); 075 076 void populateFrom(int[] pos, SegmentDataset data, CellKey key); 077 078 /** 079 * Sets the value a given ordinal. 080 * 081 * @param pos Ordinal 082 * @param rowList Row list 083 * @param column Column of row list 084 */ 085 void populateFrom( 086 int[] pos, SegmentLoader.RowList rowList, int column); 087 088 /** 089 * Returns the SQL type of the data contained in this dataset. 090 * @return A value of SqlStatement.Type 091 */ 092 SqlStatement.Type getType(); 093 094 /** 095 * Return an immutable, final and serializable implementation 096 * of a SegmentBody in order to cache this dataset. 097 * 098 * @param axes An array with, for each axis, the set of axis values, sorted 099 * in natural order, and a flag saying whether the null value is also 100 * present. 101 * This is supplied by the {@link SegmentLoader}. 102 * 103 * @return A {@link SegmentBody}. 104 */ 105 SegmentBody createSegmentBody( 106 List<Pair<SortedSet<Comparable>, Boolean>> axes); 107} 108 109// End SegmentDataset.java