|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.tools.MultiDimension
public class MultiDimension
A tool to help an application execute multi-dimensional range queries. The algorithm used is database independent, the only requirement is that the engine supports a range index (for example b-tree).
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Method Detail |
---|
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 dimensions
public long interleave(int... values)
values
- the multi-dimensional value
public long interleave(int x, int y)
x
- the value of the first dimension, normalizedy
- the value of the second dimension, normalized
public 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 column
public 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 values
java.sql.SQLException
public int compare(long[] a, long[] b)
compare
in interface java.util.Comparator<long[]>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |