Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ee85a66b
提交
ee85a66b
authored
1月 13, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not reevaluate window aggregates in fast methods when frame is not changed
上级
d902164b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
5 行删除
+28
-5
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+12
-5
array-agg.sql
...est/org/h2/test/scripts/functions/aggregate/array-agg.sql
+16
-0
没有找到文件。
h2/src/main/org/h2/expression/aggregate/AbstractAggregate.java
浏览文件 @
ee85a66b
...
...
@@ -123,7 +123,8 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
false
);
iter
.
hasNext
();)
{
updateFromExpressions
(
session
,
aggregateData
,
iter
.
next
());
}
i
=
processGroup
(
session
,
result
,
ordered
,
rowIdColumn
,
i
,
size
,
aggregateData
,
grouped
);
Value
r
=
getAggregatedValue
(
session
,
aggregateData
);
i
=
processGroup
(
session
,
result
,
r
,
ordered
,
rowIdColumn
,
i
,
size
,
aggregateData
,
grouped
);
}
}
...
...
@@ -132,6 +133,7 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
Object
aggregateData
=
createAggregateData
();
int
size
=
ordered
.
size
();
int
lastIncludedRow
=
-
1
;
Value
r
=
null
;
for
(
int
i
=
0
;
i
<
size
;)
{
int
newLast
=
WindowFrame
.
getEndIndex
(
over
,
session
,
ordered
,
getOverOrderBySort
(),
i
);
assert
newLast
>=
lastIncludedRow
;
...
...
@@ -140,8 +142,11 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
updateFromExpressions
(
session
,
aggregateData
,
ordered
.
get
(
j
));
}
lastIncludedRow
=
newLast
;
r
=
getAggregatedValue
(
session
,
aggregateData
);
}
else
if
(
r
==
null
)
{
r
=
getAggregatedValue
(
session
,
aggregateData
);
}
i
=
processGroup
(
session
,
result
,
ordered
,
rowIdColumn
,
i
,
size
,
aggregateData
,
grouped
);
i
=
processGroup
(
session
,
result
,
r
,
ordered
,
rowIdColumn
,
i
,
size
,
aggregateData
,
grouped
);
}
}
...
...
@@ -149,6 +154,7 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
ArrayList
<
Value
[]>
ordered
,
int
rowIdColumn
,
boolean
grouped
)
{
Object
aggregateData
=
createAggregateData
();
int
firstIncludedRow
=
ordered
.
size
();
Value
r
=
null
;
for
(
int
i
=
firstIncludedRow
-
1
;
i
>=
0
;)
{
int
newLast
=
over
.
getWindowFrame
().
getStartIndex
(
session
,
ordered
,
getOverOrderBySort
(),
i
);
assert
newLast
<=
firstIncludedRow
;
...
...
@@ -157,9 +163,11 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
updateFromExpressions
(
session
,
aggregateData
,
ordered
.
get
(
j
));
}
firstIncludedRow
=
newLast
;
r
=
getAggregatedValue
(
session
,
aggregateData
);
}
else
if
(
r
==
null
)
{
r
=
getAggregatedValue
(
session
,
aggregateData
);
}
Value
[]
lastRowInGroup
=
ordered
.
get
(
i
),
currentRowInGroup
=
lastRowInGroup
;
Value
r
=
getAggregatedValue
(
session
,
aggregateData
);
do
{
result
.
put
(
currentRowInGroup
[
rowIdColumn
].
getInt
(),
r
);
}
while
(--
i
>=
0
&&
grouped
...
...
@@ -167,10 +175,9 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
}
}
private
int
processGroup
(
Session
session
,
HashMap
<
Integer
,
Value
>
result
,
ArrayList
<
Value
[]>
ordered
,
private
int
processGroup
(
Session
session
,
HashMap
<
Integer
,
Value
>
result
,
Value
r
,
ArrayList
<
Value
[]>
ordered
,
int
rowIdColumn
,
int
i
,
int
size
,
Object
aggregateData
,
boolean
grouped
)
{
Value
[]
firstRowInGroup
=
ordered
.
get
(
i
),
currentRowInGroup
=
firstRowInGroup
;
Value
r
=
getAggregatedValue
(
session
,
aggregateData
);
do
{
result
.
put
(
currentRowInGroup
[
rowIdColumn
].
getInt
(),
r
);
}
while
(++
i
<
size
&&
grouped
...
...
h2/src/test/org/h2/test/scripts/functions/aggregate/array-agg.sql
浏览文件 @
ee85a66b
...
...
@@ -311,6 +311,22 @@ SELECT *,
>
8
9
[
7
,
8
]
[
9
,
9
]
[
4
,
5
,
6
,
7
,
8
]
[
8
,
8
,
8
,
9
,
9
]
[
9
,
9
,
8
,
8
,
8
]
[
4
,
5
,
6
,
7
,
8
]
[
8
,
8
,
8
,
9
,
9
]
>
rows
:
8
SELECT
*
,
ARRAY_AGG
(
ID
ORDER
BY
ID
)
OVER
(
ORDER
BY
VALUE
RANGE
BETWEEN
1
PRECEDING
AND
UNBOUNDED
FOLLOWING
)
A1
,
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
VALUE
RANGE
BETWEEN
UNBOUNDED
PRECEDING
AND
1
FOLLOWING
)
A2
FROM
TEST
;
>
ID
VALUE
A1
A2
>
-- ----- ------------------------ ------------------------
>
1
1
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
[
1
,
2
]
>
2
1
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
[
1
,
2
]
>
3
5
[
3
,
4
,
5
,
6
,
7
,
8
]
[
1
,
2
,
3
]
>
4
8
[
4
,
5
,
6
,
7
,
8
]
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
>
5
8
[
4
,
5
,
6
,
7
,
8
]
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
>
6
8
[
4
,
5
,
6
,
7
,
8
]
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
>
7
9
[
4
,
5
,
6
,
7
,
8
]
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
>
8
9
[
4
,
5
,
6
,
7
,
8
]
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
>
rows
:
8
SELECT
*
,
ARRAY_AGG
(
ID
)
OVER
(
ORDER
BY
VALUE
ROWS
-
1
PRECEDING
)
FROM
TEST
;
>
exception
INVALID_VALUE_2
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论