Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5a5f919f
提交
5a5f919f
authored
9月 14, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add AbstractAggregate as a base class
上级
aee4cfaa
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
56 行增加
和
67 行删除
+56
-67
Parser.java
h2/src/main/org/h2/command/Parser.java
+14
-29
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+39
-0
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-23
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+2
-15
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
5a5f919f
...
@@ -170,6 +170,7 @@ import org.h2.expression.UnaryOperation;
...
@@ -170,6 +170,7 @@ import org.h2.expression.UnaryOperation;
import
org.h2.expression.ValueExpression
;
import
org.h2.expression.ValueExpression
;
import
org.h2.expression.Variable
;
import
org.h2.expression.Variable
;
import
org.h2.expression.Wildcard
;
import
org.h2.expression.Wildcard
;
import
org.h2.expression.aggregate.AbstractAggregate
;
import
org.h2.expression.aggregate.Aggregate
;
import
org.h2.expression.aggregate.Aggregate
;
import
org.h2.expression.aggregate.Aggregate.AggregateType
;
import
org.h2.expression.aggregate.Aggregate.AggregateType
;
import
org.h2.expression.aggregate.JavaAggregate
;
import
org.h2.expression.aggregate.JavaAggregate
;
...
@@ -2967,27 +2968,11 @@ public class Parser {
...
@@ -2967,27 +2968,11 @@ public class Parser {
}
}
read
(
CLOSE_PAREN
);
read
(
CLOSE_PAREN
);
if
(
r
!=
null
)
{
if
(
r
!=
null
)
{
r
.
setFilterCondition
(
readFilterCondition
());
readFilterAndOver
(
r
);
Window
over
=
readOver
();
if
(
over
!=
null
)
{
r
.
setOverCondition
(
over
);
currentSelect
.
setWindowQuery
();
}
else
{
currentSelect
.
setGroupQuery
();
}
}
}
return
r
;
return
r
;
}
}
private
Window
readOver
()
{
if
(
readIf
(
"OVER"
))
{
read
(
OPEN_PAREN
);
read
(
CLOSE_PAREN
);
return
new
Window
();
}
return
null
;
}
private
void
setModeAggOrder
(
Aggregate
r
,
Expression
expr
)
{
private
void
setModeAggOrder
(
Aggregate
r
,
Expression
expr
)
{
ArrayList
<
SelectOrderBy
>
orderList
=
new
ArrayList
<>(
1
);
ArrayList
<
SelectOrderBy
>
orderList
=
new
ArrayList
<>(
1
);
SelectOrderBy
order
=
new
SelectOrderBy
();
SelectOrderBy
order
=
new
SelectOrderBy
();
...
@@ -3040,28 +3025,28 @@ public class Parser {
...
@@ -3040,28 +3025,28 @@ public class Parser {
do
{
do
{
params
.
add
(
readExpression
());
params
.
add
(
readExpression
());
}
while
(
readIfMore
(
true
));
}
while
(
readIfMore
(
true
));
Expression
filterCondition
=
readFilterCondition
();
Expression
[]
list
=
params
.
toArray
(
new
Expression
[
0
]);
Expression
[]
list
=
params
.
toArray
(
new
Expression
[
0
]);
JavaAggregate
agg
=
new
JavaAggregate
(
aggregate
,
list
,
currentSelect
,
distinct
,
filterCondition
);
JavaAggregate
agg
=
new
JavaAggregate
(
aggregate
,
list
,
currentSelect
,
distinct
);
Window
over
=
readOver
();
readFilterAndOver
(
agg
);
if
(
over
!=
null
)
{
agg
.
setOverCondition
(
over
);
currentSelect
.
setWindowQuery
();
}
else
{
currentSelect
.
setGroupQuery
();
}
return
agg
;
return
agg
;
}
}
private
Expression
readFilterCondition
(
)
{
private
void
readFilterAndOver
(
AbstractAggregate
aggregate
)
{
if
(
readIf
(
"FILTER"
))
{
if
(
readIf
(
"FILTER"
))
{
read
(
OPEN_PAREN
);
read
(
OPEN_PAREN
);
read
(
WHERE
);
read
(
WHERE
);
Expression
filterCondition
=
readExpression
();
Expression
filterCondition
=
readExpression
();
read
(
CLOSE_PAREN
);
read
(
CLOSE_PAREN
);
return
filterCondition
;
aggregate
.
setFilterCondition
(
filterCondition
);
}
if
(
readIf
(
"OVER"
))
{
read
(
OPEN_PAREN
);
read
(
CLOSE_PAREN
);
aggregate
.
setOverCondition
(
new
Window
());
currentSelect
.
setWindowQuery
();
}
else
{
currentSelect
.
setGroupQuery
();
}
}
return
null
;
}
}
private
AggregateType
getAggregateType
(
String
name
)
{
private
AggregateType
getAggregateType
(
String
name
)
{
...
...
h2/src/main/org/h2/expression/aggregate/AbstractAggregate.java
0 → 100644
浏览文件 @
5a5f919f
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
expression
.
aggregate
;
import
org.h2.expression.Expression
;
/**
* A base class for aggregates.
*/
public
abstract
class
AbstractAggregate
extends
Expression
{
protected
Expression
filterCondition
;
protected
Window
over
;
/**
* Sets the FILTER condition.
*
* @param filterCondition
* FILTER condition
*/
public
void
setFilterCondition
(
Expression
filterCondition
)
{
this
.
filterCondition
=
filterCondition
;
}
/**
* Sets the OVER condition.
*
* @param over
* OVER condition
*/
public
void
setOverCondition
(
Window
over
)
{
this
.
over
=
over
;
}
}
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
5a5f919f
...
@@ -42,7 +42,7 @@ import org.h2.value.ValueString;
...
@@ -42,7 +42,7 @@ import org.h2.value.ValueString;
/**
/**
* Implements the integrated aggregate functions, such as COUNT, MAX, SUM.
* Implements the integrated aggregate functions, such as COUNT, MAX, SUM.
*/
*/
public
class
Aggregate
extends
Expression
{
public
class
Aggregate
extends
AbstractAggregate
{
public
enum
AggregateType
{
public
enum
AggregateType
{
/**
/**
...
@@ -166,10 +166,6 @@ public class Aggregate extends Expression {
...
@@ -166,10 +166,6 @@ public class Aggregate extends Expression {
private
int
displaySize
;
private
int
displaySize
;
private
int
lastGroupRowId
;
private
int
lastGroupRowId
;
private
Expression
filterCondition
;
private
Window
over
;
/**
/**
* Create a new aggregate object.
* Create a new aggregate object.
*
*
...
@@ -257,24 +253,6 @@ public class Aggregate extends Expression {
...
@@ -257,24 +253,6 @@ public class Aggregate extends Expression {
this
.
groupConcatSeparator
=
separator
;
this
.
groupConcatSeparator
=
separator
;
}
}
/**
* Sets the FILTER condition.
*
* @param filterCondition condition
*/
public
void
setFilterCondition
(
Expression
filterCondition
)
{
this
.
filterCondition
=
filterCondition
;
}
/**
* Sets the OVER condition.
*
* @param over OVER condition
*/
public
void
setOverCondition
(
Window
over
)
{
this
.
over
=
over
;
}
private
SortOrder
initOrder
(
Session
session
)
{
private
SortOrder
initOrder
(
Session
session
)
{
int
size
=
orderByList
.
size
();
int
size
=
orderByList
.
size
();
int
[]
index
=
new
int
[
size
];
int
[]
index
=
new
int
[
size
];
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
5a5f919f
...
@@ -28,35 +28,22 @@ import org.h2.value.ValueNull;
...
@@ -28,35 +28,22 @@ import org.h2.value.ValueNull;
/**
/**
* This class wraps a user-defined aggregate.
* This class wraps a user-defined aggregate.
*/
*/
public
class
JavaAggregate
extends
Expression
{
public
class
JavaAggregate
extends
AbstractAggregate
{
private
final
UserAggregate
userAggregate
;
private
final
UserAggregate
userAggregate
;
private
final
Select
select
;
private
final
Select
select
;
private
final
Expression
[]
args
;
private
final
Expression
[]
args
;
private
int
[]
argTypes
;
private
int
[]
argTypes
;
private
final
boolean
distinct
;
private
final
boolean
distinct
;
private
Expression
filterCondition
;
private
Window
over
;
private
int
dataType
;
private
int
dataType
;
private
Connection
userConnection
;
private
Connection
userConnection
;
private
int
lastGroupRowId
;
private
int
lastGroupRowId
;
public
JavaAggregate
(
UserAggregate
userAggregate
,
Expression
[]
args
,
public
JavaAggregate
(
UserAggregate
userAggregate
,
Expression
[]
args
,
Select
select
,
boolean
distinct
)
{
Select
select
,
boolean
distinct
,
Expression
filterCondition
)
{
this
.
userAggregate
=
userAggregate
;
this
.
userAggregate
=
userAggregate
;
this
.
args
=
args
;
this
.
args
=
args
;
this
.
select
=
select
;
this
.
select
=
select
;
this
.
distinct
=
distinct
;
this
.
distinct
=
distinct
;
this
.
filterCondition
=
filterCondition
;
}
/**
* Sets the OVER condition.
*
* @param over OVER condition
*/
public
void
setOverCondition
(
Window
over
)
{
this
.
over
=
over
;
}
}
@Override
@Override
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论