public class MultiDimension extends Object implements 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.
|
String |
generatePreparedQuery(String table,
String scalarColumn,
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.
|
ResultSet |
getResult(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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
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 String generatePreparedQuery(String table, String scalarColumn, String[] columns)
table
- the table namecolumns
- the list of columnsscalarColumn
- the column name of the computed scalar columnpublic ResultSet getResult(PreparedStatement prep, int[] min, int[] max) throws SQLException
prep
- the prepared statementmin
- the lower valuesmax
- the upper valuesSQLException
public int compare(long[] a, long[] b)
compare
in interface Comparator<long[]>
Copyright © 2020 JBoss by Red Hat. All rights reserved.