Interface CellKey
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
CellKey.Four,CellKey.Many,CellKey.One,CellKey.Three,CellKey.Two,CellKey.Zero
public interface CellKey extends Serializable
ACellKeyis used as a key in maps which access cells by their position.CellKey is also used within
SparseSegmentDatasetto store values within aggregations.It is important that CellKey is memory-efficient, and that the
Object.hashCode()andObject.equals(java.lang.Object)methods are extremely efficient. There are particular implementations for the most likely cases where the number of axes is 1, 2, 3 and 4 as well as a general implementation.To create a key, call the
CellKey.Generator.newCellKey(int[])method.- Since:
- 10 August, 2001
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCellKey.Fourstatic classCellKey.Generatorstatic classCellKey.Manystatic classCellKey.Onestatic classCellKey.Threestatic classCellKey.Twostatic classCellKey.Zero
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CellKeycopy()Returns a mutable copy of this CellKey.intgetAxis(int axis)Returns theaxisth axis value.intgetOffset(int[] axisMultipliers)Returns the offset of the cell in a raster-scan order.int[]getOrdinals()Returns the axis keys as an array.voidsetAxis(int axis, int value)Sets a given axis.voidsetOrdinals(int[] pos)This method make a copy of the int array parameter.intsize()Returns the number of axes.
-
-
-
Method Detail
-
size
int size()
Returns the number of axes.- Returns:
- number of axes
-
getOrdinals
int[] getOrdinals()
Returns the axis keys as an array.Note: caller should treat the array as immutable. If the contents of the array are modified, behavior is unspecified.
- Returns:
- Array of axis keys
-
setOrdinals
void setOrdinals(int[] pos)
This method make a copy of the int array parameter. Throws a RuntimeException if the int array size is not the size of the CellKey.- Parameters:
pos- Array of axis keys
-
getAxis
int getAxis(int axis)
Returns theaxisth axis value.- Parameters:
axis- Axis ordinal- Returns:
- Value of the
axisth axis - Throws:
ArrayIndexOutOfBoundsException- if axis is out of range
-
setAxis
void setAxis(int axis, int value)Sets a given axis.- Parameters:
axis- Axis ordinalvalue- Value- Throws:
RuntimeException- if axis parameter is larger thansize()
-
copy
CellKey copy()
Returns a mutable copy of this CellKey.- Returns:
- Mutable copy
-
getOffset
int getOffset(int[] axisMultipliers)
Returns the offset of the cell in a raster-scan order.For example, if the axes have lengths {2, 5, 10} then cell (2, 3, 4) has offset
(2 * mulitiplers[0]) + (3 * multipliers[1]) + (4 * multipliers[2])
= (2 * 50) + (3 * 10) + (4 * 1)
= 134The multipliers are the product of the lengths of all later axes, in this case (50, 10, 1).
- Parameters:
axisMultipliers- For each axis, the product of the lengths of later axes- Returns:
- The raster-scan ordinal of this cell
-
-