Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7f5c3510
提交
7f5c3510
authored
12月 16, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return long results from row number and rank functions
上级
59d222f5
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
14 行删除
+14
-14
help.csv
h2/src/docsrc/help/help.csv
+2
-2
WindowFunction.java
h2/src/main/org/h2/expression/analysis/WindowFunction.java
+12
-12
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
7f5c3510
...
@@ -5335,10 +5335,10 @@ SELECT CUME_DIST() OVER (PARTITION BY CATEGORY ORDER BY ID), * FROM TEST;
...
@@ -5335,10 +5335,10 @@ SELECT CUME_DIST() OVER (PARTITION BY CATEGORY ORDER BY ID), * FROM TEST;
"
"
"Functions (Window)","NTILE","
"Functions (Window)","NTILE","
NTILE(
int
) OVER windowNameOrSpecification
NTILE(
long
) OVER windowNameOrSpecification
","
","
Distributes the rows into a specified number of groups.
Distributes the rows into a specified number of groups.
Number of groups should be a positive
integer
value.
Number of groups should be a positive
long
value.
NTILE returns the 1-based number of the group to which the current row belongs.
NTILE returns the 1-based number of the group to which the current row belongs.
First groups will have more rows if number of rows is not divisible by number of groups.
First groups will have more rows if number of rows is not divisible by number of groups.
For example, if 5 rows are distributed into 2 groups this function returns 1 for the first 3 row and 2 for the last 2 rows.
For example, if 5 rows are distributed into 2 groups this function returns 1 for the first 3 row and 2 for the last 2 rows.
...
...
h2/src/main/org/h2/expression/analysis/WindowFunction.java
浏览文件 @
7f5c3510
...
@@ -18,7 +18,7 @@ import org.h2.table.ColumnResolver;
...
@@ -18,7 +18,7 @@ import org.h2.table.ColumnResolver;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableFilter
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueDouble
;
import
org.h2.value.ValueDouble
;
import
org.h2.value.Value
Int
;
import
org.h2.value.Value
Long
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueNull
;
/**
/**
...
@@ -184,7 +184,7 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -184,7 +184,7 @@ public class WindowFunction extends DataAnalysisOperation {
switch
(
type
)
{
switch
(
type
)
{
case
ROW_NUMBER:
case
ROW_NUMBER:
for
(
int
i
=
0
,
size
=
ordered
.
size
();
i
<
size
;)
{
for
(
int
i
=
0
,
size
=
ordered
.
size
();
i
<
size
;)
{
result
.
put
(
ordered
.
get
(
i
)[
rowIdColumn
].
getInt
(),
Value
Int
.
get
(++
i
));
result
.
put
(
ordered
.
get
(
i
)[
rowIdColumn
].
getInt
(),
Value
Long
.
get
(++
i
));
}
}
break
;
break
;
case
RANK:
case
RANK:
...
@@ -231,7 +231,7 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -231,7 +231,7 @@ public class WindowFunction extends DataAnalysisOperation {
int
nm
=
number
-
1
;
int
nm
=
number
-
1
;
v
=
nm
==
0
?
ValueDouble
.
ZERO
:
ValueDouble
.
get
((
double
)
nm
/
(
size
-
1
));
v
=
nm
==
0
?
ValueDouble
.
ZERO
:
ValueDouble
.
get
((
double
)
nm
/
(
size
-
1
));
}
else
{
}
else
{
v
=
Value
Int
.
get
(
number
);
v
=
Value
Long
.
get
(
number
);
}
}
result
.
put
(
row
[
rowIdColumn
].
getInt
(),
v
);
result
.
put
(
row
[
rowIdColumn
].
getInt
(),
v
);
}
}
...
@@ -260,20 +260,20 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -260,20 +260,20 @@ public class WindowFunction extends DataAnalysisOperation {
int
size
=
orderedData
.
size
();
int
size
=
orderedData
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
Value
[]
array
=
orderedData
.
get
(
i
);
Value
[]
array
=
orderedData
.
get
(
i
);
int
buckets
=
array
[
0
].
getInt
();
long
buckets
=
array
[
0
].
getLong
();
if
(
buckets
<=
0
)
{
if
(
buckets
<=
0
)
{
throw
DbException
.
getInvalidValueException
(
"number of tiles"
,
buckets
);
throw
DbException
.
getInvalidValueException
(
"number of tiles"
,
buckets
);
}
}
int
perTile
=
size
/
buckets
;
long
perTile
=
size
/
buckets
;
int
numLarger
=
size
-
perTile
*
buckets
;
long
numLarger
=
size
-
perTile
*
buckets
;
int
largerGroup
=
numLarger
*
(
perTile
+
1
);
long
largerGroup
=
numLarger
*
(
perTile
+
1
);
int
v
;
long
v
;
if
(
i
>=
largerGroup
)
{
if
(
i
>=
largerGroup
)
{
v
=
(
i
-
largerGroup
)
/
perTile
+
numLarger
+
1
;
v
=
(
i
-
largerGroup
)
/
perTile
+
numLarger
+
1
;
}
else
{
}
else
{
v
=
i
/
(
perTile
+
1
)
+
1
;
v
=
i
/
(
perTile
+
1
)
+
1
;
}
}
result
.
put
(
orderedData
.
get
(
i
)[
last
].
getInt
(),
Value
Int
.
get
(
v
));
result
.
put
(
orderedData
.
get
(
i
)[
last
].
getInt
(),
Value
Long
.
get
(
v
));
}
}
}
}
...
@@ -441,7 +441,7 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -441,7 +441,7 @@ public class WindowFunction extends DataAnalysisOperation {
case
RANK:
case
RANK:
case
DENSE_RANK:
case
DENSE_RANK:
case
NTILE:
case
NTILE:
return
Value
.
INT
;
return
Value
.
LONG
;
case
PERCENT_RANK:
case
PERCENT_RANK:
case
CUME_DIST:
case
CUME_DIST:
return
Value
.
DOUBLE
;
return
Value
.
DOUBLE
;
...
@@ -477,7 +477,7 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -477,7 +477,7 @@ public class WindowFunction extends DataAnalysisOperation {
case
RANK:
case
RANK:
case
DENSE_RANK:
case
DENSE_RANK:
case
NTILE:
case
NTILE:
return
Value
Int
.
PRECISION
;
return
Value
Long
.
PRECISION
;
case
PERCENT_RANK:
case
PERCENT_RANK:
case
CUME_DIST:
case
CUME_DIST:
return
ValueDouble
.
PRECISION
;
return
ValueDouble
.
PRECISION
;
...
@@ -499,7 +499,7 @@ public class WindowFunction extends DataAnalysisOperation {
...
@@ -499,7 +499,7 @@ public class WindowFunction extends DataAnalysisOperation {
case
RANK:
case
RANK:
case
DENSE_RANK:
case
DENSE_RANK:
case
NTILE:
case
NTILE:
return
Value
Int
.
DISPLAY_SIZE
;
return
Value
Long
.
DISPLAY_SIZE
;
case
PERCENT_RANK:
case
PERCENT_RANK:
case
CUME_DIST:
case
CUME_DIST:
return
ValueDouble
.
DISPLAY_SIZE
;
return
ValueDouble
.
DISPLAY_SIZE
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论