Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3814c595
提交
3814c595
authored
9月 20, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split group and window methods in SelectGroups
上级
d432403d
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
27 行删除
+39
-27
SelectGroups.java
h2/src/main/org/h2/command/dml/SelectGroups.java
+26
-14
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+3
-3
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+10
-10
没有找到文件。
h2/src/main/org/h2/command/dml/SelectGroups.java
浏览文件 @
3814c595
...
@@ -251,14 +251,9 @@ public abstract class SelectGroups {
...
@@ -251,14 +251,9 @@ public abstract class SelectGroups {
*
*
* @param expr
* @param expr
* expression
* expression
* @param window
* true if expression is a window expression
* @return expression data or null
* @return expression data or null
*/
*/
public
Object
getCurrentGroupExprData
(
Expression
expr
,
boolean
window
)
{
public
final
Object
getCurrentGroupExprData
(
Expression
expr
)
{
if
(
window
)
{
return
windowData
.
get
(
expr
);
}
Integer
index
=
exprToIndexInGroupByData
.
get
(
expr
);
Integer
index
=
exprToIndexInGroupByData
.
get
(
expr
);
if
(
index
==
null
)
{
if
(
index
==
null
)
{
return
null
;
return
null
;
...
@@ -273,15 +268,8 @@ public abstract class SelectGroups {
...
@@ -273,15 +268,8 @@ public abstract class SelectGroups {
* expression
* expression
* @param object
* @param object
* expression data to set
* expression data to set
* @param window
* true if expression is a window expression
*/
*/
public
void
setCurrentGroupExprData
(
Expression
expr
,
Object
obj
,
boolean
window
)
{
public
final
void
setCurrentGroupExprData
(
Expression
expr
,
Object
obj
)
{
if
(
window
)
{
Object
old
=
windowData
.
put
(
expr
,
obj
);
assert
old
==
null
;
return
;
}
Integer
index
=
exprToIndexInGroupByData
.
get
(
expr
);
Integer
index
=
exprToIndexInGroupByData
.
get
(
expr
);
if
(
index
!=
null
)
{
if
(
index
!=
null
)
{
assert
currentGroupByExprData
[
index
]
==
null
;
assert
currentGroupByExprData
[
index
]
==
null
;
...
@@ -297,6 +285,30 @@ public abstract class SelectGroups {
...
@@ -297,6 +285,30 @@ public abstract class SelectGroups {
currentGroupByExprData
[
index
]
=
obj
;
currentGroupByExprData
[
index
]
=
obj
;
}
}
/**
* Get the window data for the specified expression.
*
* @param expr
* expression
* @return expression data or null
*/
public
final
Object
getWindowExprData
(
Expression
expr
)
{
return
windowData
.
get
(
expr
);
}
/**
* Set the window data for the specified expression.
*
* @param expr
* expression
* @param object
* expression data to set
*/
public
final
void
setWindowExprData
(
Expression
expr
,
Object
obj
)
{
Object
old
=
windowData
.
put
(
expr
,
obj
);
assert
old
==
null
;
}
abstract
void
updateCurrentGroupExprData
();
abstract
void
updateCurrentGroupExprData
();
/**
/**
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
3814c595
...
@@ -164,9 +164,9 @@ public class ExpressionColumn extends Expression {
...
@@ -164,9 +164,9 @@ public class ExpressionColumn extends Expression {
// this is a different level (the enclosing query)
// this is a different level (the enclosing query)
return
;
return
;
}
}
Value
v
=
(
Value
)
groupData
.
getCurrentGroupExprData
(
this
,
false
);
Value
v
=
(
Value
)
groupData
.
getCurrentGroupExprData
(
this
);
if
(
v
==
null
)
{
if
(
v
==
null
)
{
groupData
.
setCurrentGroupExprData
(
this
,
now
,
false
);
groupData
.
setCurrentGroupExprData
(
this
,
now
);
}
else
{
}
else
{
if
(!
database
.
areEqual
(
now
,
v
))
{
if
(!
database
.
areEqual
(
now
,
v
))
{
throw
DbException
.
get
(
ErrorCode
.
MUST_GROUP_BY_COLUMN_1
,
getSQL
());
throw
DbException
.
get
(
ErrorCode
.
MUST_GROUP_BY_COLUMN_1
,
getSQL
());
...
@@ -180,7 +180,7 @@ public class ExpressionColumn extends Expression {
...
@@ -180,7 +180,7 @@ public class ExpressionColumn extends Expression {
if
(
select
!=
null
)
{
if
(
select
!=
null
)
{
SelectGroups
groupData
=
select
.
getGroupDataIfCurrent
(
false
);
SelectGroups
groupData
=
select
.
getGroupDataIfCurrent
(
false
);
if
(
groupData
!=
null
)
{
if
(
groupData
!=
null
)
{
Value
v
=
(
Value
)
groupData
.
getCurrentGroupExprData
(
this
,
false
);
Value
v
=
(
Value
)
groupData
.
getCurrentGroupExprData
(
this
);
if
(
v
!=
null
)
{
if
(
v
!=
null
)
{
return
v
;
return
v
;
}
}
...
...
h2/src/main/org/h2/expression/aggregate/AbstractAggregate.java
浏览文件 @
3814c595
...
@@ -252,13 +252,13 @@ public abstract class AbstractAggregate extends Expression {
...
@@ -252,13 +252,13 @@ public abstract class AbstractAggregate extends Expression {
ValueArray
key
=
over
.
getCurrentKey
(
session
);
ValueArray
key
=
over
.
getCurrentKey
(
session
);
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
ValueHashMap
<
Object
>
map
=
(
ValueHashMap
<
Object
>)
groupData
.
get
CurrentGroupExprData
(
this
,
true
);
ValueHashMap
<
Object
>
map
=
(
ValueHashMap
<
Object
>)
groupData
.
get
WindowExprData
(
this
);
if
(
map
==
null
)
{
if
(
map
==
null
)
{
if
(
ifExists
)
{
if
(
ifExists
)
{
return
null
;
return
null
;
}
}
map
=
new
ValueHashMap
<>();
map
=
new
ValueHashMap
<>();
groupData
.
set
CurrentGroupExprData
(
this
,
map
,
true
);
groupData
.
set
WindowExprData
(
this
,
map
);
}
}
PartitionData
partition
=
(
PartitionData
)
map
.
get
(
key
);
PartitionData
partition
=
(
PartitionData
)
map
.
get
(
key
);
if
(
partition
==
null
)
{
if
(
partition
==
null
)
{
...
@@ -271,25 +271,25 @@ public abstract class AbstractAggregate extends Expression {
...
@@ -271,25 +271,25 @@ public abstract class AbstractAggregate extends Expression {
data
=
partition
.
getData
();
data
=
partition
.
getData
();
}
}
}
else
{
}
else
{
PartitionData
partition
=
(
PartitionData
)
groupData
.
get
CurrentGroupExprData
(
this
,
true
);
PartitionData
partition
=
(
PartitionData
)
groupData
.
get
WindowExprData
(
this
);
if
(
partition
==
null
)
{
if
(
partition
==
null
)
{
if
(
ifExists
)
{
if
(
ifExists
)
{
return
null
;
return
null
;
}
}
data
=
forOrderBy
?
new
ArrayList
<>()
:
createAggregateData
();
data
=
forOrderBy
?
new
ArrayList
<>()
:
createAggregateData
();
groupData
.
set
CurrentGroupExprData
(
this
,
new
PartitionData
(
data
),
true
);
groupData
.
set
WindowExprData
(
this
,
new
PartitionData
(
data
)
);
}
else
{
}
else
{
data
=
partition
.
getData
();
data
=
partition
.
getData
();
}
}
}
}
}
else
{
}
else
{
data
=
groupData
.
getCurrentGroupExprData
(
this
,
false
);
data
=
groupData
.
getCurrentGroupExprData
(
this
);
if
(
data
==
null
)
{
if
(
data
==
null
)
{
if
(
ifExists
)
{
if
(
ifExists
)
{
return
null
;
return
null
;
}
}
data
=
forOrderBy
?
new
ArrayList
<>()
:
createAggregateData
();
data
=
forOrderBy
?
new
ArrayList
<>()
:
createAggregateData
();
groupData
.
setCurrentGroupExprData
(
this
,
data
,
false
);
groupData
.
setCurrentGroupExprData
(
this
,
data
);
}
}
}
}
return
data
;
return
data
;
...
@@ -338,10 +338,10 @@ public abstract class AbstractAggregate extends Expression {
...
@@ -338,10 +338,10 @@ public abstract class AbstractAggregate extends Expression {
ValueArray
key
=
over
.
getCurrentKey
(
session
);
ValueArray
key
=
over
.
getCurrentKey
(
session
);
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
ValueHashMap
<
Object
>
map
=
(
ValueHashMap
<
Object
>)
groupData
.
get
CurrentGroupExprData
(
this
,
true
);
ValueHashMap
<
Object
>
map
=
(
ValueHashMap
<
Object
>)
groupData
.
get
WindowExprData
(
this
);
if
(
map
==
null
)
{
if
(
map
==
null
)
{
map
=
new
ValueHashMap
<>();
map
=
new
ValueHashMap
<>();
groupData
.
set
CurrentGroupExprData
(
this
,
map
,
true
);
groupData
.
set
WindowExprData
(
this
,
map
);
}
}
partition
=
(
PartitionData
)
map
.
get
(
key
);
partition
=
(
PartitionData
)
map
.
get
(
key
);
if
(
partition
==
null
)
{
if
(
partition
==
null
)
{
...
@@ -352,11 +352,11 @@ public abstract class AbstractAggregate extends Expression {
...
@@ -352,11 +352,11 @@ public abstract class AbstractAggregate extends Expression {
data
=
partition
.
getData
();
data
=
partition
.
getData
();
}
}
}
else
{
}
else
{
partition
=
(
PartitionData
)
groupData
.
get
CurrentGroupExprData
(
this
,
true
);
partition
=
(
PartitionData
)
groupData
.
get
WindowExprData
(
this
);
if
(
partition
==
null
)
{
if
(
partition
==
null
)
{
data
=
forOrderBy
?
new
ArrayList
<>()
:
createAggregateData
();
data
=
forOrderBy
?
new
ArrayList
<>()
:
createAggregateData
();
partition
=
new
PartitionData
(
data
);
partition
=
new
PartitionData
(
data
);
groupData
.
set
CurrentGroupExprData
(
this
,
partition
,
true
);
groupData
.
set
WindowExprData
(
this
,
partition
);
}
else
{
}
else
{
data
=
partition
.
getData
();
data
=
partition
.
getData
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论