| java.lang.Object org.h2.tools.MultiDimension
MultiDimension | public class MultiDimension (Code) | | 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 | |
public int | deinterleave(long scalar, int dimensions, int dim) Gets one of the original multi-dimensional values from a scalar value. | public String | generatePreparedQuery(String table, String scalarColumn, String[] columns) Generates an optimized multi-dimensional range query.
The query contains parameters. | public String | generateQuery(String table, String scalarColumn, String[] columns, int[] min, int[] max) Generates an optimized multi-dimensional range query. | public static MultiDimension | getInstance() Get the singleton. | public long[][] | getMortonRanges(int[] min, int[] max) Gets a list of ranges to be searched for a multi-dimensional range query
where min <= value <= max. | public ResultSet | getResult(PreparedStatement prep, int[] min, int[] max) Executes a prepared query that was generated using generatePreparedQuery. | public long | interleave(int[] values) Convert the multi-dimensional value into a one-dimensional (scalar) value.
This is done by interleaving the bits of the values.
Each values must be bigger or equal to 0. |
deinterleave | public int deinterleave(long scalar, int dimensions, int dim)(Code) | | Gets one of the original multi-dimensional values from a scalar value.
Parameters: scalar - the scalar value Parameters: dimensions - the number of dimensions Parameters: dim - the dimension of the returned value (starting from 0) the value |
generatePreparedQuery | public String generatePreparedQuery(String table, String scalarColumn, String[] columns)(Code) | | Generates an optimized multi-dimensional range query.
The query contains parameters. It can only be used with the H2 database.
Parameters: table - the table name Parameters: columns - the list of columns Parameters: scalarColumn - the column name of the computed scalar column the query |
generateQuery | public String generateQuery(String table, String scalarColumn, String[] columns, int[] min, int[] max)(Code) | | Generates an optimized multi-dimensional range query.
This query is database independent, however the performance is
not as good as when using generatePreparedQuery
Parameters: table - the table name Parameters: columns - the list of columns Parameters: min - the lower values Parameters: max - the upper values Parameters: scalarColumn - the column name of the computed scalar column the query |
getMortonRanges | public long[][] getMortonRanges(int[] min, int[] max)(Code) | | Gets a list of ranges to be searched for a multi-dimensional range query
where min <= value <= max. In most cases, the ranges will be larger
than required in order to combine smaller ranges into one. Usually, about
double as much points will be included in the resulting range.
Parameters: min - the minimum value Parameters: max - the maximum value the list of ranges |
getResult | public ResultSet getResult(PreparedStatement prep, int[] min, int[] max) throws SQLException(Code) | | Executes a prepared query that was generated using generatePreparedQuery.
Parameters: prep - the prepared statement Parameters: min - the lower values Parameters: max - the upper values the result set |
interleave | public long interleave(int[] values)(Code) | | Convert the multi-dimensional value into a one-dimensional (scalar) value.
This is done by interleaving the bits of the values.
Each values must be bigger or equal to 0. The maximum value
is dependent on the number of dimensions. For two keys, it is 32 bit,
for 3: 21 bit, 4: 16 bit, 5: 12 bit, 6: 10 bit, 7: 9 bit, 8: 8 bit.
Parameters: values - the multi-dimensional value the scalar value |
|
|