Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9ba97664
提交
9ba97664
authored
10 年前
作者:
noelgrandin@gmail.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 552: Implement BIT_AND and BIT_OR aggregate functions
上级
25b8313e
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
70 行增加
和
3 行删除
+70
-3
help.csv
h2/src/docsrc/help/help.csv
+20
-0
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+26
-2
AggregateDataDefault.java
h2/src/main/org/h2/expression/AggregateDataDefault.java
+16
-0
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+6
-0
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
9ba97664
...
...
@@ -2466,6 +2466,26 @@ The returned value is of the same data type as the parameter.
AVG(X)
"
"Functions (Aggregate)","BIT_AND","
BIT_AND(expression)
","
The bitwise AND of all non-null values.
If no rows are selected, the result is NULL.
Aggregates are only allowed in select statements.
","
BIT_AND(ID)
"
"Functions (Aggregate)","BIT_OR","
BIT_OR(expression)
","
The bitwise OR of all non-null values.
If no rows are selected, the result is NULL.
Aggregates are only allowed in select statements.
","
BIT_OR(ID)
"
"Functions (Aggregate)","BOOL_AND","
BOOL_AND(boolean)
","
...
...
This diff is collapsed.
Click to expand it.
h2/src/docsrc/html/changelog.html
浏览文件 @
9ba97664
...
...
@@ -22,7 +22,8 @@ Change Log
</li><li>
Script tool: Fix parsing of BLOCKSIZE parameter, original patch by Ken Jorissen
</li><li>
Fix bug in PageStore#commit method - when the ignoreBigLog flag was set,
the logic that cleared the flag could never be reached, resulting in performance degradation.
Reported by Alexander Nesterov.
Reported by Alexander Nesterov.
</li><li>
Issue 552: Implement BIT_AND and BIT_OR aggregate functions
</li></ul>
<h2>
Version 1.4.184 Beta (2014-12-19)
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
9ba97664
...
...
@@ -106,15 +106,25 @@ public class Aggregate extends Expression {
*/
static
final
int
BOOL_AND
=
12
;
/**
* The aggregate type for BOOL_OR(expression).
*/
static
final
int
BIT_OR
=
13
;
/**
* The aggregate type for BOOL_AND(expression).
*/
static
final
int
BIT_AND
=
14
;
/**
* The aggregate type for SELECTIVITY(expression).
*/
static
final
int
SELECTIVITY
=
1
3
;
static
final
int
SELECTIVITY
=
1
5
;
/**
* The aggregate type for HISTOGRAM(expression).
*/
static
final
int
HISTOGRAM
=
1
4
;
static
final
int
HISTOGRAM
=
1
6
;
private
static
final
HashMap
<
String
,
Integer
>
AGGREGATES
=
New
.
hashMap
();
...
...
@@ -170,6 +180,8 @@ public class Aggregate extends Expression {
addAggregate
(
"EVERY"
,
BOOL_AND
);
addAggregate
(
"SELECTIVITY"
,
SELECTIVITY
);
addAggregate
(
"HISTOGRAM"
,
HISTOGRAM
);
addAggregate
(
"BIT_OR"
,
BIT_OR
);
addAggregate
(
"BIT_AND"
,
BIT_AND
);
}
private
static
void
addAggregate
(
String
name
,
int
type
)
{
...
...
@@ -435,6 +447,12 @@ public class Aggregate extends Expression {
displaySize
=
ValueBoolean
.
DISPLAY_SIZE
;
scale
=
0
;
break
;
case
BIT_AND:
case
BIT_OR:
if
(!
DataType
.
supportsAdd
(
dataType
))
{
throw
DbException
.
get
(
ErrorCode
.
SUM_OR_AVG_ON_WRONG_DATATYPE_1
,
getSQL
());
}
break
;
default
:
DbException
.
throwInternalError
(
"type="
+
type
);
}
...
...
@@ -540,6 +558,12 @@ public class Aggregate extends Expression {
case
BOOL_OR:
text
=
"BOOL_OR"
;
break
;
case
BIT_AND:
text
=
"BIT_AND"
;
break
;
case
BIT_OR:
text
=
"BIT_OR"
;
break
;
default
:
throw
DbException
.
throwInternalError
(
"type="
+
type
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/AggregateDataDefault.java
浏览文件 @
9ba97664
...
...
@@ -108,6 +108,20 @@ class AggregateDataDefault extends AggregateData {
v
.
getBoolean
().
booleanValue
());
}
break
;
case
Aggregate
.
BIT_AND
:
if
(
value
==
null
)
{
value
=
v
.
convertTo
(
dataType
);
}
else
{
value
=
ValueLong
.
get
(
value
.
getLong
()
&
v
.
getLong
()).
convertTo
(
dataType
);
}
break
;
case
Aggregate
.
BIT_OR
:
if
(
value
==
null
)
{
value
=
v
.
convertTo
(
dataType
);
}
else
{
value
=
ValueLong
.
get
(
value
.
getLong
()
|
v
.
getLong
()).
convertTo
(
dataType
);
}
break
;
default
:
DbException
.
throwInternalError
(
"type="
+
aggregateType
);
}
...
...
@@ -124,6 +138,8 @@ class AggregateDataDefault extends AggregateData {
case
Aggregate
.
SUM
:
case
Aggregate
.
MIN
:
case
Aggregate
.
MAX
:
case
Aggregate
.
BIT_OR
:
case
Aggregate
.
BIT_AND
:
case
Aggregate
.
BOOL_OR
:
case
Aggregate
.
BOOL_AND
:
v
=
value
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
9ba97664
...
...
@@ -322,6 +322,12 @@ SELECT BOOL_OR(X>4) FROM SYSTEM_RANGE(1,6);
> TRUE;
SELECT BOOL_AND(X>4) FROM SYSTEM_RANGE(1,6);
> FALSE;
SELECT BIT_OR(X) FROM SYSTEM_RANGE(1,6);
> 7;
SELECT BIT_AND(X) FROM SYSTEM_RANGE(1,6);
> 0;
SELECT BIT_AND(X) FROM SYSTEM_RANGE(1,1);
> 1;
CREATE TABLE TEST(ID IDENTITY);
ALTER TABLE TEST ALTER COLUMN ID RESTART WITH ? {1:10};
INSERT INTO TEST VALUES(NULL);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论