Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8b1dc0fd
提交
8b1dc0fd
authored
7 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check all possible indexes for MEDIAN aggregate
上级
4f73254a
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
41 行增加
和
19 行删除
+41
-19
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+41
-19
没有找到文件。
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
8b1dc0fd
...
@@ -650,6 +650,46 @@ public class Aggregate extends Expression {
...
@@ -650,6 +650,46 @@ public class Aggregate extends Expression {
return
null
;
return
null
;
}
}
private
Index
getMedianColumnIndex
()
{
if
(
on
instanceof
ExpressionColumn
)
{
ExpressionColumn
col
=
(
ExpressionColumn
)
on
;
Column
column
=
col
.
getColumn
();
TableFilter
filter
=
col
.
getTableFilter
();
if
(
filter
!=
null
)
{
Table
table
=
filter
.
getTable
();
ArrayList
<
Index
>
indexes
=
table
.
getIndexes
();
Index
result
=
null
;
if
(
indexes
!=
null
)
{
for
(
int
i
=
1
,
size
=
indexes
.
size
();
i
<
size
;
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(!
index
.
canFindNext
())
{
continue
;
}
if
(!
index
.
isFirstColumn
(
column
))
{
continue
;
}
IndexColumn
ic
=
index
.
getIndexColumns
()[
0
];
if
(
column
.
isNullable
())
{
int
sortType
=
ic
.
sortType
;
// Nulls last is not supported
if
((
sortType
&
SortOrder
.
NULLS_LAST
)
!=
0
)
continue
;
// Descending without nulls first is not supported
if
((
sortType
&
SortOrder
.
DESCENDING
)
!=
0
&&
(
sortType
&
SortOrder
.
NULLS_FIRST
)
==
0
)
{
continue
;
}
}
if
(
result
==
null
||
result
.
getColumns
().
length
>
index
.
getColumns
().
length
)
{
result
=
index
;
}
}
}
return
result
;
}
}
return
null
;
}
@Override
@Override
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
if
(
visitor
.
getType
()
==
ExpressionVisitor
.
OPTIMIZABLE_MIN_MAX_COUNT_ALL
)
{
if
(
visitor
.
getType
()
==
ExpressionVisitor
.
OPTIMIZABLE_MIN_MAX_COUNT_ALL
)
{
...
@@ -669,25 +709,7 @@ public class Aggregate extends Expression {
...
@@ -669,25 +709,7 @@ public class Aggregate extends Expression {
if
(
distinct
)
{
if
(
distinct
)
{
return
false
;
return
false
;
}
}
index
=
getMinMaxColumnIndex
();
return
getMedianColumnIndex
()
!=
null
;
if
(
index
==
null
)
{
return
false
;
}
IndexColumn
ic
=
index
.
getIndexColumns
()[
0
];
if
(!
ic
.
column
.
isNullable
())
{
return
true
;
}
int
sortType
=
ic
.
sortType
;
// Nulls last is not supported
if
((
sortType
&
SortOrder
.
NULLS_LAST
)
!=
0
)
return
false
;
// Ascending is supported
if
((
sortType
&
SortOrder
.
DESCENDING
)
==
0
)
return
true
;
// Descending with nulls first is also supported
if
((
sortType
&
SortOrder
.
NULLS_FIRST
)
!=
0
)
return
true
;
return
false
;
default
:
default
:
return
false
;
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论