public class MultiDimension
extends java.lang.Object
implements java.util.Comparator<long[]>
| Modifier | Constructor and Description |
|---|---|
protected |
MultiDimension() |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(long[] a,
long[] b) |
int |
deinterleave(int dimensions,
long scalar,
int dim)
Gets one of the original multi-dimensional values from a scalar value.
|
java.lang.String |
generatePreparedQuery(java.lang.String table,
java.lang.String scalarColumn,
java.lang.String[] columns)
Generates an optimized multi-dimensional range query.
|
static MultiDimension |
getInstance()
Get the singleton.
|
int |
getMaxValue(int dimensions)
Get the maximum value for the given dimension count.
|
java.sql.ResultSet |
getResult(java.sql.PreparedStatement prep,
int[] min,
int[] max)
Executes a prepared query that was generated using generatePreparedQuery.
|
long |
interleave(int... values)
Convert the multi-dimensional value into a one-dimensional (scalar)
value.
|
long |
interleave(int x,
int y)
Convert the two-dimensional value into a one-dimensional (scalar) value.
|
int |
normalize(int dimensions,
double value,
double min,
double max)
Normalize a value so that it is between the minimum and maximum for the
given number of dimensions.
|
public static MultiDimension getInstance()
public int normalize(int dimensions,
double value,
double min,
double max)
dimensions - the number of dimensionsvalue - the value (must be in the range min..max)min - the minimum valuemax - the maximum value (must be larger than min)public int getMaxValue(int dimensions)
dimensions - the number of dimensionspublic long interleave(int... values)
values - the multi-dimensional valuepublic long interleave(int x,
int y)
x - the value of the first dimension, normalizedy - the value of the second dimension, normalizedpublic int deinterleave(int dimensions,
long scalar,
int dim)
dimensions - the number of dimensionsscalar - the scalar valuedim - the dimension of the returned value (starting from 0)public java.lang.String generatePreparedQuery(java.lang.String table,
java.lang.String scalarColumn,
java.lang.String[] columns)
table - the table namecolumns - the list of columnsscalarColumn - the column name of the computed scalar columnpublic java.sql.ResultSet getResult(java.sql.PreparedStatement prep,
int[] min,
int[] max)
throws java.sql.SQLException
prep - the prepared statementmin - the lower valuesmax - the upper valuesjava.sql.SQLExceptionpublic int compare(long[] a,
long[] b)
compare in interface java.util.Comparator<long[]>