Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
795070a2
提交
795070a2
authored
6月 09, 2016
作者:
nicolas-f
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Choose to use spatial index only if the query contain a spatial mask (same cost as hash index)
上级
1888e49a
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
90 行增加
和
8 行删除
+90
-8
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+6
-7
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+84
-1
没有找到文件。
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
795070a2
...
...
@@ -185,19 +185,18 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
* @return Index cost hint
*/
public
static
long
getCostRangeIndex
(
int
[]
masks
,
long
rowCount
,
Column
[]
columns
)
{
rowCount
+=
Constants
.
COST_ROW_OFFSET
;
long
cost
=
rowCount
;
if
(
masks
==
null
)
{
return
cost
;
// Never use spatial tree index without spatial filter
if
(
columns
.
length
==
0
)
{
return
Long
.
MAX_VALUE
;
}
for
(
Column
column
:
columns
)
{
int
index
=
column
.
getColumnId
();
int
mask
=
masks
[
index
];
if
((
mask
&
IndexCondition
.
SPATIAL_INTERSECTS
)
!=
0
)
{
cost
=
3
+
rowCount
/
4
;
if
((
mask
&
IndexCondition
.
SPATIAL_INTERSECTS
)
!=
IndexCondition
.
SPATIAL_INTERSECTS
)
{
return
Long
.
MAX_VALUE
;
}
}
return
10
*
cost
;
return
2
;
}
@Override
...
...
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
795070a2
...
...
@@ -94,6 +94,7 @@ public class TestSpatial extends TestBase {
testNullableGeometryInsert
();
testNullableGeometryUpdate
();
testIndexUpdateNullGeometry
();
testInsertNull
();
}
private
void
testBug1
()
throws
SQLException
{
...
...
@@ -878,7 +879,8 @@ public class TestSpatial extends TestBase {
stat
.
execute
(
"create spatial index spatial on test(the_geom)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"explain select * from test where _ROWID_ = 5"
);
assertTrue
(
rs
.
next
());
assertContains
(
rs
.
getString
(
1
),
"/* PUBLIC.SPATIAL: _ROWID_ = 5 */"
);
assertFalse
(
rs
.
getString
(
1
).
contains
(
"/* PUBLIC.SPATIAL: _ROWID_ = "
+
"5 */"
));
}
finally
{
// Close the database
conn
.
close
();
...
...
@@ -1112,4 +1114,85 @@ public class TestSpatial extends TestBase {
conn
.
close
();
deleteDb
(
"spatial"
);
}
public
void
testInsertNull
()
throws
SQLException
{
deleteDb
(
"spatial"
);
Connection
conn
=
getConnection
(
url
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"\n"
+
"drop table if exists PUBLIC.DUMMY_12;\n"
+
"CREATE TABLE PUBLIC.DUMMY_12 (\n"
+
" \"fid\" serial,\n"
+
" Z_ID INTEGER,\n"
+
" GEOM GEOMETRY,\n"
+
" CONSTRAINT CONSTRAINT_DUMMY_12 PRIMARY KEY (\"fid\")\n"
+
");\n"
+
"CREATE INDEX PRIMARY_KEY_DUMMY_12 ON PUBLIC.DUMMY_12 (\"fid\");\n"
+
"CREATE spatial INDEX PUBLIC_DUMMY_12_SPATIAL_INDEX_ ON PUBLIC.DUMMY_12 (GEOM);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (123,3125163,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (124,3125164,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (125,3125173,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (126,3125174,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (127,3125175,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (128,3125176,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (129,3125177,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (130,3125178,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (131,3125179,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (132,3125180,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (133,3125335,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (134,3125336,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (135,3125165,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (136,3125337,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (137,3125338,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (138,3125339,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (139,3125340,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (140,3125341,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (141,3125342,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (142,3125343,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (143,3125344,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (144,3125345,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (145,3125346,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (146,3125166,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (147,3125347,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (148,3125348,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (149,3125349,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (150,3125350,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (151,3125351,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (152,3125352,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (153,3125353,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (154,3125354,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (155,3125355,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (156,3125356,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (157,3125167,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (158,3125357,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (159,3125358,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (160,3125359,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (161,3125360,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (162,3125361,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (163,3125362,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (164,3125363,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (165,3125364,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (166,3125365,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (167,3125366,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (168,3125168,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (169,3125367,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (170,3125368,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (171,3125369,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (172,3125370,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (173,3125169,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (174,3125170,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (175,3125171,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (176,3125172,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (177,-2,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (178,-1,NULL);\n"
+
"INSERT INTO PUBLIC.DUMMY_12 (\"fid\",Z_ID,GEOM) VALUES (179,"
+
"-1,NULL);"
);
ResultSet
rs
=
stat
.
executeQuery
(
"select * from DUMMY_12"
);
try
{
assertTrue
(
rs
.
next
());
}
finally
{
rs
.
close
();
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论