Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
dffed9ed
提交
dffed9ed
authored
9月 06, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename ST_EXTENT to ENVELOPE
上级
a741e6d5
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
34 行增加
和
34 行删除
+34
-34
help.csv
h2/src/docsrc/help/help.csv
+2
-2
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+10
-10
AggregateData.java
h2/src/main/org/h2/expression/aggregate/AggregateData.java
+2
-2
AggregateDataEnvelope.java
...in/org/h2/expression/aggregate/AggregateDataEnvelope.java
+1
-1
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+2
-2
envelope.sql
...test/org/h2/test/scripts/functions/aggregate/envelope.sql
+17
-17
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
dffed9ed
...
...
@@ -3438,7 +3438,7 @@ MODE() WITHIN GROUP(ORDER BY X)
"
"Functions (Aggregate)","ST_EXTENT","
ST_EXTENT
( value ) [ FILTER ( WHERE expression ) ]
ENVELOPE
( value ) [ FILTER ( WHERE expression ) ]
","
Returns the minimum bounding box that encloses all specified GEOMETRY values.
Only 2D coordinate plane is supported.
...
...
@@ -3446,7 +3446,7 @@ NULL values are ignored in the calculation.
If no rows are selected, the result is NULL.
Aggregates are only allowed in select statements.
","
ST_EXTENT
(X)
ENVELOPE
(X)
"
"Functions (Numeric)","ABS","
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
dffed9ed
...
...
@@ -145,9 +145,9 @@ public class Aggregate extends Expression {
MODE
,
/**
* The aggregate type for
ST_EXTENT
(expression).
* The aggregate type for
ENVELOPE
(expression).
*/
ST_EXTENT
,
ENVELOPE
,
}
private
static
final
HashMap
<
String
,
AggregateType
>
AGGREGATES
=
new
HashMap
<>(
64
);
...
...
@@ -218,7 +218,7 @@ public class Aggregate extends Expression {
addAggregate
(
"MODE"
,
AggregateType
.
MODE
);
// Oracle compatibility
addAggregate
(
"STATS_MODE"
,
AggregateType
.
MODE
);
addAggregate
(
"
ST_EXTENT"
,
AggregateType
.
ST_EXTENT
);
addAggregate
(
"
ENVELOPE"
,
AggregateType
.
ENVELOPE
);
}
private
static
void
addAggregate
(
String
name
,
AggregateType
type
)
{
...
...
@@ -378,8 +378,8 @@ public class Aggregate extends Expression {
}
case
MEDIAN:
return
AggregateDataMedian
.
getResultFromIndex
(
session
,
on
,
dataType
);
case
ST_EXTENT
:
return
((
MVSpatialIndex
)
AggregateData
ST_Extent
.
getGeometryColumnIndex
(
on
)).
getBounds
(
session
);
case
ENVELOPE
:
return
((
MVSpatialIndex
)
AggregateData
Envelope
.
getGeometryColumnIndex
(
on
)).
getBounds
(
session
);
default
:
DbException
.
throwInternalError
(
"type="
+
type
);
}
...
...
@@ -562,7 +562,7 @@ public class Aggregate extends Expression {
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
break
;
case
ST_EXTENT
:
case
ENVELOPE
:
dataType
=
Value
.
GEOMETRY
;
scale
=
0
;
precision
=
displaySize
=
Integer
.
MAX_VALUE
;
...
...
@@ -712,8 +712,8 @@ public class Aggregate extends Expression {
case
MODE:
text
=
"MODE"
;
break
;
case
ST_EXTENT
:
text
=
"
ST_EXTENT
"
;
case
ENVELOPE
:
text
=
"
ENVELOPE
"
;
break
;
default
:
throw
DbException
.
throwInternalError
(
"type="
+
type
);
...
...
@@ -765,8 +765,8 @@ public class Aggregate extends Expression {
return
false
;
}
return
AggregateDataMedian
.
getMedianColumnIndex
(
on
)
!=
null
;
case
ST_EXTENT
:
return
AggregateData
ST_Extent
.
getGeometryColumnIndex
(
on
)
!=
null
;
case
ENVELOPE
:
return
AggregateData
Envelope
.
getGeometryColumnIndex
(
on
)
!=
null
;
default
:
return
false
;
}
...
...
h2/src/main/org/h2/expression/aggregate/AggregateData.java
浏览文件 @
dffed9ed
...
...
@@ -37,8 +37,8 @@ abstract class AggregateData {
return
new
AggregateDataMedian
();
case
MODE:
return
new
AggregateDataMode
();
case
ST_EXTENT
:
return
new
AggregateData
ST_Extent
();
case
ENVELOPE
:
return
new
AggregateData
Envelope
();
default
:
return
new
AggregateDataDefault
(
aggregateType
);
}
...
...
h2/src/main/org/h2/expression/aggregate/AggregateData
ST_Extent
.java
→
h2/src/main/org/h2/expression/aggregate/AggregateData
Envelope
.java
浏览文件 @
dffed9ed
...
...
@@ -23,7 +23,7 @@ import org.locationtech.jts.geom.GeometryFactory;
/**
* Data stored while calculating an aggregate.
*/
class
AggregateData
ST_Extent
extends
AggregateData
{
class
AggregateData
Envelope
extends
AggregateData
{
private
Envelope
envelope
;
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
dffed9ed
...
...
@@ -136,8 +136,8 @@ public class TestScript extends TestDb {
for
(
String
s
:
new
String
[]
{
"help"
})
{
testScript
(
"other/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
"group-concat"
,
"max"
,
"median"
,
"min"
,
"mode"
,
"selectivity"
,
"st
_extent"
,
"st
ddev-pop"
,
for
(
String
s
:
new
String
[]
{
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
"envelope"
,
"group-concat"
,
"max"
,
"median"
,
"min"
,
"mode"
,
"selectivity"
,
"stddev-pop"
,
"stddev-samp"
,
"sum"
,
"var-pop"
,
"var-samp"
,
"array-agg"
})
{
testScript
(
"functions/aggregate/"
+
s
+
".sql"
);
}
...
...
h2/src/test/org/h2/test/scripts/functions/aggregate/
st_extent
.sql
→
h2/src/test/org/h2/test/scripts/functions/aggregate/
envelope
.sql
浏览文件 @
dffed9ed
...
...
@@ -6,21 +6,21 @@
CREATE
TABLE
TEST
(
V
GEOMETRY
);
>
ok
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
null
INSERT
INTO
TEST
VALUES
(
'POINT(1 1)'
);
>
update
count
:
1
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
POINT
(
1
1
)
INSERT
INTO
TEST
VALUES
(
'POINT(1 2)'
),
(
NULL
),
(
'POINT(3 1)'
);
>
update
count
:
3
SELECT
ST_EXTENT
(
V
),
ST_EXTENT
(
V
)
FILTER
(
WHERE
V
<>
'POINT(3 1)'
)
FILTERED1
,
ST_EXTENT
(
V
)
FILTER
(
WHERE
V
<>
'POINT(1 2)'
)
FILTERED2
FROM
TEST
;
>
ST_EXTENT
(
V
)
FILTERED1
FILTERED2
SELECT
ENVELOPE
(
V
),
ENVELOPE
(
V
)
FILTER
(
WHERE
V
<>
'POINT(3 1)'
)
FILTERED1
,
ENVELOPE
(
V
)
FILTER
(
WHERE
V
<>
'POINT(1 2)'
)
FILTERED2
FROM
TEST
;
>
ENVELOPE
(
V
)
FILTERED1
FILTERED2
>
----------------------------------- --------------------- ---------------------
>
POLYGON
((
1
1
,
1
2
,
3
2
,
3
1
,
1
1
))
LINESTRING
(
1
1
,
1
2
)
LINESTRING
(
1
1
,
3
1
)
>
rows
:
1
...
...
@@ -29,41 +29,41 @@ CREATE SPATIAL INDEX IDX ON TEST(V);
>
ok
-- Without index
SELECT
ST_EXTENT
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
SELECT
ENVELOPE
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
>>
POLYGON
((
1
1
,
1
2
,
3
2
,
3
1
,
1
1
))
-- With index
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
POLYGON
((
1
1
,
1
2
,
3
2
,
3
1
,
1
1
))
-- Without index
SELECT
ST_EXTENT
(
V
)
FILTER
(
WHERE
V
<>
'POINT(3 1)'
)
FILTERED
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FILTER
(
WHERE
V
<>
'POINT(3 1)'
)
FILTERED
FROM
TEST
;
>>
LINESTRING
(
1
1
,
1
2
)
-- Without index
SELECT
ST_EXTENT
(
V
)
FROM
TEST
WHERE
V
<>
'POINT(3 1)'
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
WHERE
V
<>
'POINT(3 1)'
;
>>
LINESTRING
(
1
1
,
1
2
)
INSERT
INTO
TEST
VALUES
(
'POINT(-1.0000000001 1)'
);
>
update
count
:
1
-- Without index
SELECT
ST_EXTENT
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
SELECT
ENVELOPE
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
>>
POLYGON
((
-
1
.
0000000001
1
,
-
1
.
0000000001
2
,
3
2
,
3
1
,
-
1
.
0000000001
1
))
-- With index
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
POLYGON
((
-
1
.
0000000001
1
,
-
1
.
0000000001
2
,
3
2
,
3
1
,
-
1
.
0000000001
1
))
TRUNCATE
TABLE
TEST
;
>
ok
-- Without index
SELECT
ST_EXTENT
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
SELECT
ENVELOPE
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
>>
null
-- With index
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
null
SELECT
RAND
(
1000
)
*
0
;
...
...
@@ -73,11 +73,11 @@ INSERT INTO TEST SELECT CAST('POINT(' || CAST(RAND() * 100000 AS INT) || ' ' ||
>
update
count
:
1000
-- Without index
SELECT
ST_EXTENT
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
SELECT
ENVELOPE
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
>>
POLYGON
((
68
78
,
68
99951
,
99903
99951
,
99903
78
,
68
78
))
-- With index
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
POLYGON
((
68
78
,
68
99951
,
99903
99951
,
99903
78
,
68
78
))
TRUNCATE
TABLE
TEST
;
...
...
@@ -91,11 +91,11 @@ INSERT INTO TEST SELECT CAST('POINT(' || (CAST(RAND() * 100000 AS INT) * 0.00000
>
update
count
:
1000
-- Without index
SELECT
ST_EXTENT
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
SELECT
ENVELOPE
(
N
)
FROM
(
SELECT
V
AS
N
FROM
TEST
);
>>
POLYGON
((
1
.
000000068
1
.
000000078
,
1
.
000000068
1
.
000099951
,
1
.
000099903
1
.
000099951
,
1
.
000099903
1
.
000000078
,
1
.
000000068
1
.
000000078
))
-- With index
SELECT
ST_EXTENT
(
V
)
FROM
TEST
;
SELECT
ENVELOPE
(
V
)
FROM
TEST
;
>>
POLYGON
((
1
.
000000068
1
.
000000078
,
1
.
000000068
1
.
000099951
,
1
.
000099903
1
.
000099951
,
1
.
000099903
1
.
000000078
,
1
.
000000068
1
.
000000078
))
DROP
TABLE
TEST
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论