Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a6c409c9
提交
a6c409c9
authored
9月 19, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not create default window frame if it was not set
上级
b0105180
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
41 行增加
和
18 行删除
+41
-18
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+1
-1
Window.java
h2/src/main/org/h2/expression/aggregate/Window.java
+3
-8
WindowFrame.java
h2/src/main/org/h2/expression/aggregate/WindowFrame.java
+31
-6
WindowFunction.java
h2/src/main/org/h2/expression/aggregate/WindowFunction.java
+6
-3
没有找到文件。
h2/src/main/org/h2/expression/aggregate/AbstractAggregate.java
浏览文件 @
a6c409c9
...
@@ -426,7 +426,7 @@ public abstract class AbstractAggregate extends Expression {
...
@@ -426,7 +426,7 @@ public abstract class AbstractAggregate extends Expression {
protected
void
getOrderedResultLoop
(
Session
session
,
HashMap
<
Integer
,
Value
>
result
,
ArrayList
<
Value
[]>
ordered
,
protected
void
getOrderedResultLoop
(
Session
session
,
HashMap
<
Integer
,
Value
>
result
,
ArrayList
<
Value
[]>
ordered
,
int
rowIdColumn
)
{
int
rowIdColumn
)
{
WindowFrame
frame
=
over
.
getWindowFrame
();
WindowFrame
frame
=
over
.
getWindowFrame
();
if
(
frame
.
isDefault
())
{
if
(
frame
==
null
||
frame
.
isDefault
())
{
Object
aggregateData
=
createAggregateData
();
Object
aggregateData
=
createAggregateData
();
for
(
Value
[]
row
:
ordered
)
{
for
(
Value
[]
row
:
ordered
)
{
updateFromExpressions
(
session
,
aggregateData
,
row
);
updateFromExpressions
(
session
,
aggregateData
,
row
);
...
...
h2/src/main/org/h2/expression/aggregate/Window.java
浏览文件 @
a6c409c9
...
@@ -64,11 +64,6 @@ public final class Window {
...
@@ -64,11 +64,6 @@ public final class Window {
public
Window
(
ArrayList
<
Expression
>
partitionBy
,
ArrayList
<
SelectOrderBy
>
orderBy
,
WindowFrame
frame
)
{
public
Window
(
ArrayList
<
Expression
>
partitionBy
,
ArrayList
<
SelectOrderBy
>
orderBy
,
WindowFrame
frame
)
{
this
.
partitionBy
=
partitionBy
;
this
.
partitionBy
=
partitionBy
;
this
.
orderBy
=
orderBy
;
this
.
orderBy
=
orderBy
;
if
(
frame
==
null
)
{
frame
=
new
WindowFrame
(
WindowFrameUnits
.
RANGE
,
new
WindowFrameBound
(
WindowFrameBoundType
.
UNBOUNDED_PRECEDING
,
null
),
null
,
WindowFrameExclusion
.
EXCLUDE_NO_OTHERS
);
}
this
.
frame
=
frame
;
this
.
frame
=
frame
;
}
}
...
@@ -146,9 +141,9 @@ public final class Window {
...
@@ -146,9 +141,9 @@ public final class Window {
}
}
/**
/**
* Returns window frame.
* Returns window frame
, or null
.
*
*
* @return window frame
* @return window frame
, or null
*/
*/
public
WindowFrame
getWindowFrame
()
{
public
WindowFrame
getWindowFrame
()
{
return
frame
;
return
frame
;
...
@@ -196,7 +191,7 @@ public final class Window {
...
@@ -196,7 +191,7 @@ public final class Window {
}
}
}
}
appendOrderBy
(
builder
,
orderBy
);
appendOrderBy
(
builder
,
orderBy
);
if
(!
frame
.
isDefault
())
{
if
(
frame
!=
null
&&
!
frame
.
isDefault
())
{
builder
.
append
(
' '
).
append
(
frame
.
getSQL
());
builder
.
append
(
' '
).
append
(
frame
.
getSQL
());
}
}
return
builder
.
append
(
')'
).
toString
();
return
builder
.
append
(
')'
).
toString
();
...
...
h2/src/main/org/h2/expression/aggregate/WindowFrame.java
浏览文件 @
a6c409c9
...
@@ -24,7 +24,7 @@ import org.h2.value.Value;
...
@@ -24,7 +24,7 @@ import org.h2.value.Value;
*/
*/
public
final
class
WindowFrame
{
public
final
class
WindowFrame
{
private
abstract
class
Itr
implements
Iterator
<
Value
[]>
{
private
static
abstract
class
Itr
implements
Iterator
<
Value
[]>
{
final
ArrayList
<
Value
[]>
orderedRows
;
final
ArrayList
<
Value
[]>
orderedRows
;
...
@@ -39,7 +39,7 @@ public final class WindowFrame {
...
@@ -39,7 +39,7 @@ public final class WindowFrame {
}
}
private
final
class
PlainItr
extends
Itr
{
private
static
final
class
PlainItr
extends
Itr
{
private
final
int
endIndex
;
private
final
int
endIndex
;
...
@@ -66,7 +66,7 @@ public final class WindowFrame {
...
@@ -66,7 +66,7 @@ public final class WindowFrame {
}
}
private
final
class
PlainReverseItr
extends
Itr
{
private
static
final
class
PlainReverseItr
extends
Itr
{
private
final
int
startIndex
;
private
final
int
startIndex
;
...
@@ -93,7 +93,7 @@ public final class WindowFrame {
...
@@ -93,7 +93,7 @@ public final class WindowFrame {
}
}
private
abstract
class
AbstractBitSetItr
extends
Itr
{
private
static
abstract
class
AbstractBitSetItr
extends
Itr
{
final
BitSet
set
;
final
BitSet
set
;
...
@@ -111,7 +111,7 @@ public final class WindowFrame {
...
@@ -111,7 +111,7 @@ public final class WindowFrame {
}
}
private
final
class
BitSetItr
extends
AbstractBitSetItr
{
private
static
final
class
BitSetItr
extends
AbstractBitSetItr
{
BitSetItr
(
ArrayList
<
Value
[]>
orderedRows
,
BitSet
set
)
{
BitSetItr
(
ArrayList
<
Value
[]>
orderedRows
,
BitSet
set
)
{
super
(
orderedRows
,
set
);
super
(
orderedRows
,
set
);
...
@@ -130,7 +130,7 @@ public final class WindowFrame {
...
@@ -130,7 +130,7 @@ public final class WindowFrame {
}
}
private
final
class
BitSetReverseItr
extends
AbstractBitSetItr
{
private
static
final
class
BitSetReverseItr
extends
AbstractBitSetItr
{
BitSetReverseItr
(
ArrayList
<
Value
[]>
orderedRows
,
BitSet
set
)
{
BitSetReverseItr
(
ArrayList
<
Value
[]>
orderedRows
,
BitSet
set
)
{
super
(
orderedRows
,
set
);
super
(
orderedRows
,
set
);
...
@@ -157,6 +157,31 @@ public final class WindowFrame {
...
@@ -157,6 +157,31 @@ public final class WindowFrame {
private
final
WindowFrameExclusion
exclusion
;
private
final
WindowFrameExclusion
exclusion
;
/**
* Returns iterator for the specified frame, or default iterator if frame is
* null.
*
* @param frame
* window frame, or null
* @param session
* the session
* @param orderedRows
* ordered rows
* @param sortOrder
* sort order
* @param currentRow
* index of the current row
* @param reverse
* whether iterator should iterate in reverse order
*
* @return iterator
*/
public
static
Iterator
<
Value
[]>
iterator
(
WindowFrame
frame
,
Session
session
,
ArrayList
<
Value
[]>
orderedRows
,
SortOrder
sortOrder
,
int
currentRow
,
boolean
reverse
)
{
return
frame
!=
null
?
frame
.
iterator
(
session
,
orderedRows
,
sortOrder
,
currentRow
,
reverse
)
:
reverse
?
new
PlainReverseItr
(
orderedRows
,
0
,
currentRow
)
:
new
PlainItr
(
orderedRows
,
0
,
currentRow
);
}
private
static
int
toGroupStart
(
ArrayList
<
Value
[]>
orderedRows
,
SortOrder
sortOrder
,
int
offset
,
int
minOffset
)
{
private
static
int
toGroupStart
(
ArrayList
<
Value
[]>
orderedRows
,
SortOrder
sortOrder
,
int
offset
,
int
minOffset
)
{
Value
[]
row
=
orderedRows
.
get
(
offset
);
Value
[]
row
=
orderedRows
.
get
(
offset
);
while
(
offset
>
minOffset
&&
sortOrder
.
compare
(
row
,
orderedRows
.
get
(
offset
-
1
))
==
0
)
{
while
(
offset
>
minOffset
&&
sortOrder
.
compare
(
row
,
orderedRows
.
get
(
offset
-
1
))
==
0
)
{
...
...
h2/src/main/org/h2/expression/aggregate/WindowFunction.java
浏览文件 @
a6c409c9
...
@@ -358,10 +358,12 @@ public class WindowFunction extends AbstractAggregate {
...
@@ -358,10 +358,12 @@ public class WindowFunction extends AbstractAggregate {
Value
v
;
Value
v
;
switch
(
type
)
{
switch
(
type
)
{
case
FIRST_VALUE:
case
FIRST_VALUE:
v
=
getNthValue
(
frame
.
iterator
(
session
,
ordered
,
getOverOrderBySort
(),
i
,
false
),
0
,
ignoreNulls
);
v
=
getNthValue
(
WindowFrame
.
iterator
(
frame
,
session
,
ordered
,
getOverOrderBySort
(),
i
,
false
),
0
,
ignoreNulls
);
break
;
break
;
case
LAST_VALUE:
case
LAST_VALUE:
v
=
getNthValue
(
frame
.
iterator
(
session
,
ordered
,
getOverOrderBySort
(),
i
,
true
),
0
,
ignoreNulls
);
v
=
getNthValue
(
WindowFrame
.
iterator
(
frame
,
session
,
ordered
,
getOverOrderBySort
(),
i
,
true
),
0
,
ignoreNulls
);
break
;
break
;
case
NTH_VALUE:
{
case
NTH_VALUE:
{
int
n
=
row
[
1
].
getInt
();
int
n
=
row
[
1
].
getInt
();
...
@@ -369,7 +371,8 @@ public class WindowFunction extends AbstractAggregate {
...
@@ -369,7 +371,8 @@ public class WindowFunction extends AbstractAggregate {
throw
DbException
.
getInvalidValueException
(
"nth row"
,
n
);
throw
DbException
.
getInvalidValueException
(
"nth row"
,
n
);
}
}
n
--;
n
--;
Iterator
<
Value
[]>
iter
=
frame
.
iterator
(
session
,
ordered
,
getOverOrderBySort
(),
i
,
fromLast
);
Iterator
<
Value
[]>
iter
=
WindowFrame
.
iterator
(
frame
,
session
,
ordered
,
getOverOrderBySort
(),
i
,
fromLast
);
v
=
getNthValue
(
iter
,
n
,
ignoreNulls
);
v
=
getNthValue
(
iter
,
n
,
ignoreNulls
);
break
;
break
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论