Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f49d2b6a
Unverified
提交
f49d2b6a
authored
9月 20, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
9月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1462 from katzyn/window
Separate aggregate and window code in some places
上级
30649cad
a42ef843
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
504 行增加
和
439 行删除
+504
-439
grammar.html
h2/src/docsrc/html/grammar.html
+5
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+11
-9
SelectGroups.java
h2/src/main/org/h2/command/dml/SelectGroups.java
+28
-15
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+3
-3
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+25
-388
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-8
DataAnalysisOperation.java
...in/org/h2/expression/aggregate/DataAnalysisOperation.java
+419
-0
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+1
-8
WindowFunction.java
h2/src/main/org/h2/expression/aggregate/WindowFunction.java
+6
-4
TransactionStore.java
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
+4
-3
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/docsrc/html/grammar.html
浏览文件 @
f49d2b6a
...
@@ -256,7 +256,12 @@ ${item.example}</p>
...
@@ -256,7 +256,12 @@ ${item.example}</p>
<c:forEach
var=
"item"
items=
"otherGrammar"
>
<c:forEach
var=
"item"
items=
"otherGrammar"
>
<h3
id=
"${item.link}"
class=
"notranslate"
onclick=
"switchBnf(this)"
>
${item.topic}
</h3>
<h3
id=
"${item.link}"
class=
"notranslate"
onclick=
"switchBnf(this)"
>
${item.topic}
</h3>
<!-- railroad-start -->
<!-- railroad-start -->
<pre
name=
"bnf"
style=
"display: none"
>
${item.syntax}
</pre>
<div
name=
"railroad"
>
${item.railroad}
${item.railroad}
</div>
<!-- railroad-end -->
<!-- railroad-end -->
<!-- syntax-start
<!-- syntax-start
<pre>
<pre>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
f49d2b6a
...
@@ -171,6 +171,7 @@ import org.h2.expression.UnaryOperation;
...
@@ -171,6 +171,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.DataAnalysisOperation
;
import
org.h2.expression.aggregate.AbstractAggregate
;
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
;
...
@@ -3053,23 +3054,24 @@ public class Parser {
...
@@ -3053,23 +3054,24 @@ public class Parser {
}
}
private
void
readFilterAndOver
(
AbstractAggregate
aggregate
)
{
private
void
readFilterAndOver
(
AbstractAggregate
aggregate
)
{
boolean
isAggregate
=
aggregate
.
isAggregate
();
if
(
readIf
(
"FILTER"
))
{
if
(
isAggregate
&&
readIf
(
"FILTER"
))
{
read
(
OPEN_PAREN
);
read
(
OPEN_PAREN
);
read
(
WHERE
);
read
(
WHERE
);
Expression
filterCondition
=
readExpression
();
Expression
filterCondition
=
readExpression
();
read
(
CLOSE_PAREN
);
read
(
CLOSE_PAREN
);
aggregate
.
setFilterCondition
(
filterCondition
);
aggregate
.
setFilterCondition
(
filterCondition
);
}
}
Window
over
=
null
;
readOver
(
aggregate
);
}
private
void
readOver
(
DataAnalysisOperation
operation
)
{
if
(
readIf
(
"OVER"
))
{
if
(
readIf
(
"OVER"
))
{
over
=
readWindowNameOrSpecification
();
operation
.
setOverCondition
(
readWindowNameOrSpecification
());
aggregate
.
setOverCondition
(
over
);
currentSelect
.
setWindowQuery
();
currentSelect
.
setWindowQuery
();
}
else
if
(!
isAggregate
)
{
}
else
if
(
operation
.
isAggregate
())
{
throw
getSyntaxError
();
}
else
{
currentSelect
.
setGroupQuery
();
currentSelect
.
setGroupQuery
();
}
else
{
throw
getSyntaxError
();
}
}
}
}
...
@@ -3440,7 +3442,7 @@ public class Parser {
...
@@ -3440,7 +3442,7 @@ public class Parser {
default
:
default
:
// Avoid warning
// Avoid warning
}
}
read
FilterAnd
Over
(
function
);
readOver
(
function
);
return
function
;
return
function
;
}
}
...
...
h2/src/main/org/h2/command/dml/SelectGroups.java
浏览文件 @
f49d2b6a
...
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
...
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
import
org.h2.expression.aggregate.DataAnalysisOperation
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
...
@@ -210,7 +211,7 @@ public abstract class SelectGroups {
...
@@ -210,7 +211,7 @@ public abstract class SelectGroups {
/**
/**
* Maps an expression object to its data.
* Maps an expression object to its data.
*/
*/
private
final
HashMap
<
Express
ion
,
Object
>
windowData
=
new
HashMap
<>();
private
final
HashMap
<
DataAnalysisOperat
ion
,
Object
>
windowData
=
new
HashMap
<>();
/**
/**
* The id of the current group.
* The id of the current group.
...
@@ -251,14 +252,9 @@ public abstract class SelectGroups {
...
@@ -251,14 +252,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 +269,8 @@ public abstract class SelectGroups {
...
@@ -273,15 +269,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 +286,30 @@ public abstract class SelectGroups {
...
@@ -297,6 +286,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
(
DataAnalysisOperation
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
(
DataAnalysisOperation
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
浏览文件 @
f49d2b6a
...
@@ -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
浏览文件 @
f49d2b6a
差异被折叠。
点击展开。
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
f49d2b6a
...
@@ -251,11 +251,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -251,11 +251,6 @@ public class Aggregate extends AbstractAggregate {
return
AGGREGATES
.
get
(
name
);
return
AGGREGATES
.
get
(
name
);
}
}
@Override
public
boolean
isAggregate
()
{
return
true
;
}
/**
/**
* Set the order for ARRAY_AGG() or GROUP_CONCAT() aggregate.
* Set the order for ARRAY_AGG() or GROUP_CONCAT() aggregate.
*
*
...
@@ -312,6 +307,7 @@ public class Aggregate extends AbstractAggregate {
...
@@ -312,6 +307,7 @@ public class Aggregate extends AbstractAggregate {
@Override
@Override
protected
void
updateGroupAggregates
(
Session
session
,
int
stage
)
{
protected
void
updateGroupAggregates
(
Session
session
,
int
stage
)
{
super
.
updateGroupAggregates
(
session
,
stage
);
if
(
on
!=
null
)
{
if
(
on
!=
null
)
{
on
.
updateAggregate
(
session
,
stage
);
on
.
updateAggregate
(
session
,
stage
);
}
}
...
@@ -514,9 +510,6 @@ public class Aggregate extends AbstractAggregate {
...
@@ -514,9 +510,6 @@ public class Aggregate extends AbstractAggregate {
if
(
groupConcatSeparator
!=
null
)
{
if
(
groupConcatSeparator
!=
null
)
{
groupConcatSeparator
=
groupConcatSeparator
.
optimize
(
session
);
groupConcatSeparator
=
groupConcatSeparator
.
optimize
(
session
);
}
}
if
(
filterCondition
!=
null
)
{
filterCondition
=
filterCondition
.
optimize
(
session
);
}
switch
(
type
)
{
switch
(
type
)
{
case
GROUP_CONCAT:
case
GROUP_CONCAT:
dataType
=
Value
.
STRING
;
dataType
=
Value
.
STRING
;
...
...
h2/src/main/org/h2/expression/aggregate/DataAnalysisOperation.java
0 → 100644
浏览文件 @
f49d2b6a
差异被折叠。
点击展开。
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
f49d2b6a
...
@@ -40,11 +40,6 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -40,11 +40,6 @@ public class JavaAggregate extends AbstractAggregate {
this
.
args
=
args
;
this
.
args
=
args
;
}
}
@Override
public
boolean
isAggregate
()
{
return
true
;
}
@Override
@Override
public
int
getCost
()
{
public
int
getCost
()
{
int
cost
=
5
;
int
cost
=
5
;
...
@@ -140,9 +135,6 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -140,9 +135,6 @@ public class JavaAggregate extends AbstractAggregate {
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
throw
DbException
.
convert
(
e
);
}
}
if
(
filterCondition
!=
null
)
{
filterCondition
=
filterCondition
.
optimize
(
session
);
}
return
this
;
return
this
;
}
}
...
@@ -237,6 +229,7 @@ public class JavaAggregate extends AbstractAggregate {
...
@@ -237,6 +229,7 @@ public class JavaAggregate extends AbstractAggregate {
@Override
@Override
protected
void
updateGroupAggregates
(
Session
session
,
int
stage
)
{
protected
void
updateGroupAggregates
(
Session
session
,
int
stage
)
{
super
.
updateGroupAggregates
(
session
,
stage
);
for
(
Expression
expr
:
args
)
{
for
(
Expression
expr
:
args
)
{
expr
.
updateAggregate
(
session
,
stage
);
expr
.
updateAggregate
(
session
,
stage
);
}
}
...
...
h2/src/main/org/h2/expression/aggregate/WindowFunction.java
浏览文件 @
f49d2b6a
...
@@ -10,6 +10,7 @@ import java.util.HashMap;
...
@@ -10,6 +10,7 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.Select
;
import
org.h2.command.dml.SelectGroups
;
import
org.h2.command.dml.SelectOrderBy
;
import
org.h2.command.dml.SelectOrderBy
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Expression
;
...
@@ -24,7 +25,7 @@ import org.h2.value.ValueNull;
...
@@ -24,7 +25,7 @@ import org.h2.value.ValueNull;
/**
/**
* A window function.
* A window function.
*/
*/
public
class
WindowFunction
extends
AbstractAggregate
{
public
class
WindowFunction
extends
DataAnalysisOperation
{
private
final
WindowFunctionType
type
;
private
final
WindowFunctionType
type
;
...
@@ -105,7 +106,7 @@ public class WindowFunction extends AbstractAggregate {
...
@@ -105,7 +106,7 @@ public class WindowFunction extends AbstractAggregate {
* arguments, or null
* arguments, or null
*/
*/
public
WindowFunction
(
WindowFunctionType
type
,
Select
select
,
Expression
[]
args
)
{
public
WindowFunction
(
WindowFunctionType
type
,
Select
select
,
Expression
[]
args
)
{
super
(
select
,
false
);
super
(
select
);
this
.
type
=
type
;
this
.
type
=
type
;
this
.
args
=
args
;
this
.
args
=
args
;
}
}
...
@@ -145,12 +146,13 @@ public class WindowFunction extends AbstractAggregate {
...
@@ -145,12 +146,13 @@ public class WindowFunction extends AbstractAggregate {
}
}
@Override
@Override
protected
void
updateAggregate
(
Session
session
,
Object
aggregateData
)
{
protected
void
updateAggregate
(
Session
session
,
SelectGroups
groupData
,
int
groupRowId
)
{
throw
DbException
.
getUnsupportedException
(
"Window function"
);
updateOrderedAggregate
(
session
,
groupData
,
groupRowId
,
over
.
getOrderBy
()
);
}
}
@Override
@Override
protected
void
updateGroupAggregates
(
Session
session
,
int
stage
)
{
protected
void
updateGroupAggregates
(
Session
session
,
int
stage
)
{
super
.
updateGroupAggregates
(
session
,
stage
);
if
(
args
!=
null
)
{
if
(
args
!=
null
)
{
for
(
Expression
expr
:
args
)
{
for
(
Expression
expr
:
args
)
{
expr
.
updateAggregate
(
session
,
stage
);
expr
.
updateAggregate
(
session
,
stage
);
...
...
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
浏览文件 @
f49d2b6a
...
@@ -449,9 +449,10 @@ public class TransactionStore {
...
@@ -449,9 +449,10 @@ public class TransactionStore {
if
(
map
!=
null
)
{
// might be null if map was removed later
if
(
map
!=
null
)
{
// might be null if map was removed later
Object
key
=
op
[
1
];
Object
key
=
op
[
1
];
commitDecisionMaker
.
setUndoKey
(
undoKey
);
commitDecisionMaker
.
setUndoKey
(
undoKey
);
// although second parameter (value) is not really used
// although second parameter (value) is not really
// by CommitDecisionMaker, MVRTreeMap has weird traversal logic based on it,
// used by CommitDecisionMaker, MVRTreeMap has weird
// and any non-null value will do, to signify update, not removal
// traversal logic based on it, and any non-null
// value will do, to signify update, not removal
map
.
operate
(
key
,
VersionedValue
.
DUMMY
,
commitDecisionMaker
);
map
.
operate
(
key
,
VersionedValue
.
DUMMY
,
commitDecisionMaker
);
}
}
}
}
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
f49d2b6a
...
@@ -796,4 +796,4 @@ interior envelopes multilinestring multipoint packed exterior normalization awkw
...
@@ -796,4 +796,4 @@ interior envelopes multilinestring multipoint packed exterior normalization awkw
xym normalizes coord setz xyzm geometrycollection multipolygon mixup rings polygons rejection finite
xym normalizes coord setz xyzm geometrycollection multipolygon mixup rings polygons rejection finite
pointzm pointz pointm dimensionality redefine forum measures
pointzm pointz pointm dimensionality redefine forum measures
mpg casted pzm mls constrained subtypes complains
mpg casted pzm mls constrained subtypes complains
ranks rno dro rko precede cume reopens preceding unbounded rightly itr lag maximal tiles tile ntile
ranks rno dro rko precede cume reopens preceding unbounded rightly itr lag maximal tiles tile ntile
signify
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论