Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
487b0e21
提交
487b0e21
authored
14 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Slightly improved API for the multi-dimension tool.
上级
60033163
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
19 行增加
和
5 行删除
+19
-5
MultiDimension.java
h2/src/main/org/h2/tools/MultiDimension.java
+19
-5
没有找到文件。
h2/src/main/org/h2/tools/MultiDimension.java
浏览文件 @
487b0e21
...
@@ -41,7 +41,7 @@ public class MultiDimension implements Comparator<long[]> {
...
@@ -41,7 +41,7 @@ public class MultiDimension implements Comparator<long[]> {
* Convert the multi-dimensional value into a one-dimensional (scalar) value.
* Convert the multi-dimensional value into a one-dimensional (scalar) value.
* This is done by interleaving the bits of the values.
* This is done by interleaving the bits of the values.
* Each values must be bigger or equal to 0. The maximum value
* 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,
*
depends
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.
* for 3: 21 bit, 4: 16 bit, 5: 12 bit, 6: 10 bit, 7: 9 bit, 8: 8 bit.
*
*
* @param values the multi-dimensional value
* @param values the multi-dimensional value
...
@@ -51,11 +51,11 @@ public class MultiDimension implements Comparator<long[]> {
...
@@ -51,11 +51,11 @@ public class MultiDimension implements Comparator<long[]> {
int
dimensions
=
values
.
length
;
int
dimensions
=
values
.
length
;
int
bitsPerValue
=
64
/
dimensions
;
int
bitsPerValue
=
64
/
dimensions
;
// for 2 keys: 0x800000; 3: 0x
// for 2 keys: 0x800000; 3: 0x
long
max
=
1L
<<
bitsPerValue
;
long
max
=
getMaxValue
(
dimensions
)
;
long
x
=
0
;
long
x
=
0
;
for
(
int
i
=
0
;
i
<
dimensions
;
i
++)
{
for
(
int
i
=
0
;
i
<
dimensions
;
i
++)
{
long
k
=
values
[
i
];
long
k
=
values
[
i
];
if
(
k
<
0
||
k
>
max
)
{
if
(
k
<
0
||
k
>
=
max
)
{
throw
new
IllegalArgumentException
(
"value out of range; value="
+
values
[
i
]
+
" min=0 max="
+
max
);
throw
new
IllegalArgumentException
(
"value out of range; value="
+
values
[
i
]
+
" min=0 max="
+
max
);
}
}
for
(
int
b
=
0
;
b
<
bitsPerValue
;
b
++)
{
for
(
int
b
=
0
;
b
<
bitsPerValue
;
b
++)
{
...
@@ -71,6 +71,21 @@ public class MultiDimension implements Comparator<long[]> {
...
@@ -71,6 +71,21 @@ public class MultiDimension implements Comparator<long[]> {
return
x
;
return
x
;
}
}
/**
* Get the maximum value for the given dimension count
* @param dimensions the number of dimensions
*
* @return the maximum value
*/
public
static
long
getMaxValue
(
int
dimensions
)
{
if
(
dimensions
<
2
||
dimensions
>
64
)
{
throw
new
IllegalArgumentException
(
"dimensions: "
+
dimensions
);
}
int
bitsPerValue
=
64
/
dimensions
;
// for 2 keys: 0x800000; 3: 0x
return
1L
<<
bitsPerValue
;
}
/**
/**
* Gets one of the original multi-dimensional values from a scalar value.
* Gets one of the original multi-dimensional values from a scalar value.
*
*
...
@@ -88,7 +103,6 @@ public class MultiDimension implements Comparator<long[]> {
...
@@ -88,7 +103,6 @@ public class MultiDimension implements Comparator<long[]> {
return
value
;
return
value
;
}
}
// public static int get(long z, int d) {
// public static int get(long z, int d) {
// int n = 0;
// int n = 0;
// for (int i = 0; i < 31; i++) {
// for (int i = 0; i < 31; i++) {
...
@@ -149,7 +163,7 @@ public class MultiDimension implements Comparator<long[]> {
...
@@ -149,7 +163,7 @@ public class MultiDimension implements Comparator<long[]> {
* Gets a list of ranges to be searched for a multi-dimensional range query
* 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
* where min <= value <= max. In most cases, the ranges will be larger
* than required in order to combine smaller ranges into one. Usually, about
* than required in order to combine smaller ranges into one. Usually, about
* double as m
uch
points will be included in the resulting range.
* double as m
any
points will be included in the resulting range.
*
*
* @param min the minimum value
* @param min the minimum value
* @param max the maximum value
* @param max the maximum value
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论