Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f7c66675
提交
f7c66675
authored
1月 30, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move some common fields and code to AbstractAggregate
上级
2a755298
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
30 行增加
和
49 行删除
+30
-49
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+27
-1
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-18
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+2
-30
没有找到文件。
h2/src/main/org/h2/expression/aggregate/AbstractAggregate.java
浏览文件 @
f7c66675
...
...
@@ -22,6 +22,7 @@ import org.h2.expression.analysis.WindowFrameExclusion;
import
org.h2.expression.analysis.WindowFrameUnits
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
/**
...
...
@@ -34,13 +35,24 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
*/
protected
final
boolean
distinct
;
/**
* The arguments.
*/
protected
final
Expression
[]
args
;
/**
* FILTER condition for aggregate
*/
protected
Expression
filterCondition
;
AbstractAggregate
(
Select
select
,
boolean
distinct
)
{
/**
* The type of the result.
*/
protected
TypeInfo
type
;
AbstractAggregate
(
Select
select
,
Expression
[]
args
,
boolean
distinct
)
{
super
(
select
);
this
.
args
=
args
;
this
.
distinct
=
distinct
;
}
...
...
@@ -59,8 +71,16 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
this
.
filterCondition
=
filterCondition
;
}
@Override
public
TypeInfo
getType
()
{
return
type
;
}
@Override
public
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
for
(
Expression
arg
:
args
)
{
arg
.
mapColumns
(
resolver
,
level
,
innerState
);
}
if
(
filterCondition
!=
null
)
{
filterCondition
.
mapColumns
(
resolver
,
level
,
innerState
);
}
...
...
@@ -69,6 +89,9 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
@Override
public
Expression
optimize
(
Session
session
)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
args
[
i
]
=
args
[
i
].
optimize
(
session
);
}
if
(
filterCondition
!=
null
)
{
filterCondition
=
filterCondition
.
optimize
(
session
);
}
...
...
@@ -77,6 +100,9 @@ public abstract class AbstractAggregate extends DataAnalysisOperation {
@Override
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
for
(
Expression
arg
:
args
)
{
arg
.
setEvaluatable
(
tableFilter
,
b
);
}
if
(
filterCondition
!=
null
)
{
filterCondition
.
setEvaluatable
(
tableFilter
,
b
);
}
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
f7c66675
...
...
@@ -53,10 +53,8 @@ public class Aggregate extends AbstractAggregate {
private
final
AggregateType
aggregateType
;
private
final
Expression
[]
args
;
private
ArrayList
<
SelectOrderBy
>
orderByList
;
private
SortOrder
orderBySort
;
private
TypeInfo
type
;
/**
* Create a new aggregate object.
...
...
@@ -71,12 +69,11 @@ public class Aggregate extends AbstractAggregate {
* if distinct is used
*/
public
Aggregate
(
AggregateType
aggregateType
,
Expression
[]
args
,
Select
select
,
boolean
distinct
)
{
super
(
select
,
distinct
);
super
(
select
,
args
,
distinct
);
if
(
distinct
&&
aggregateType
==
AggregateType
.
COUNT_ALL
)
{
throw
DbException
.
throwInternalError
();
}
this
.
aggregateType
=
aggregateType
;
this
.
args
=
args
;
}
static
{
...
...
@@ -510,16 +507,8 @@ public class Aggregate extends AbstractAggregate {
return
v
.
convertTo
(
type
.
getValueType
());
}
@Override
public
TypeInfo
getType
()
{
return
type
;
}
@Override
public
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
for
(
Expression
arg
:
args
)
{
arg
.
mapColumns
(
resolver
,
level
,
innerState
);
}
if
(
orderByList
!=
null
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
o
.
expression
.
mapColumns
(
resolver
,
level
,
innerState
);
...
...
@@ -531,9 +520,6 @@ public class Aggregate extends AbstractAggregate {
@Override
public
Expression
optimize
(
Session
session
)
{
super
.
optimize
(
session
);
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
args
[
i
]
=
args
[
i
].
optimize
(
session
);
}
if
(
args
.
length
==
1
)
{
type
=
args
[
0
].
getType
();
}
...
...
@@ -627,9 +613,6 @@ public class Aggregate extends AbstractAggregate {
@Override
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
for
(
Expression
arg
:
args
)
{
arg
.
setEvaluatable
(
tableFilter
,
b
);
}
if
(
orderByList
!=
null
)
{
for
(
SelectOrderBy
o
:
orderByList
)
{
o
.
expression
.
setEvaluatable
(
tableFilter
,
b
);
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
f7c66675
...
...
@@ -15,8 +15,6 @@ import org.h2.engine.UserAggregate;
import
org.h2.expression.Expression
;
import
org.h2.expression.ExpressionVisitor
;
import
org.h2.message.DbException
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.TableFilter
;
import
org.h2.value.DataType
;
import
org.h2.value.TypeInfo
;
import
org.h2.value.Value
;
...
...
@@ -30,16 +28,13 @@ import org.h2.value.ValueRow;
public
class
JavaAggregate
extends
AbstractAggregate
{
private
final
UserAggregate
userAggregate
;
private
final
Expression
[]
args
;
private
int
[]
argTypes
;
private
TypeInfo
type
;
private
int
dataType
;
private
Connection
userConnection
;
public
JavaAggregate
(
UserAggregate
userAggregate
,
Expression
[]
args
,
Select
select
,
boolean
distinct
)
{
super
(
select
,
distinct
);
super
(
select
,
args
,
distinct
);
this
.
userAggregate
=
userAggregate
;
this
.
args
=
args
;
}
@Override
...
...
@@ -62,11 +57,6 @@ public class JavaAggregate extends AbstractAggregate {
return
appendTailConditions
(
builder
);
}
@Override
public
TypeInfo
getType
()
{
return
type
;
}
@Override
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
if
(!
super
.
isEverything
(
visitor
))
{
...
...
@@ -92,14 +82,6 @@ public class JavaAggregate extends AbstractAggregate {
return
filterCondition
==
null
||
filterCondition
.
isEverything
(
visitor
);
}
@Override
public
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
for
(
Expression
arg
:
args
)
{
arg
.
mapColumns
(
resolver
,
level
,
innerState
);
}
super
.
mapColumnsAnalysis
(
resolver
,
level
,
innerState
);
}
@Override
public
Expression
optimize
(
Session
session
)
{
super
.
optimize
(
session
);
...
...
@@ -107,9 +89,7 @@ public class JavaAggregate extends AbstractAggregate {
int
len
=
args
.
length
;
argTypes
=
new
int
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Expression
expr
=
args
[
i
];
args
[
i
]
=
expr
.
optimize
(
session
);
int
type
=
expr
.
getType
().
getValueType
();
int
type
=
args
[
i
].
getType
().
getValueType
();
argTypes
[
i
]
=
type
;
}
try
{
...
...
@@ -122,14 +102,6 @@ public class JavaAggregate extends AbstractAggregate {
return
this
;
}
@Override
public
void
setEvaluatable
(
TableFilter
tableFilter
,
boolean
b
)
{
for
(
Expression
e
:
args
)
{
e
.
setEvaluatable
(
tableFilter
,
b
);
}
super
.
setEvaluatable
(
tableFilter
,
b
);
}
private
Aggregate
getInstance
()
{
Aggregate
agg
=
userAggregate
.
getInstance
();
try
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论