Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
580b2e58
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
580b2e58
编写于
8月 06, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: set selectivity value for the null group
上级
b2c8d216
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
4 deletion
+39
-4
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+39
-4
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
580b2e58
...
@@ -64,6 +64,9 @@ typedef struct SMinmaxResInfo {
...
@@ -64,6 +64,9 @@ typedef struct SMinmaxResInfo {
bool
assign
;
// assign the first value or not
bool
assign
;
// assign the first value or not
int64_t
v
;
int64_t
v
;
STuplePos
tuplePos
;
STuplePos
tuplePos
;
STuplePos
nullTuplePos
;
bool
nullTupleSaved
;
}
SMinmaxResInfo
;
}
SMinmaxResInfo
;
typedef
struct
STopBotResItem
{
typedef
struct
STopBotResItem
{
...
@@ -75,6 +78,10 @@ typedef struct STopBotResItem {
...
@@ -75,6 +78,10 @@ typedef struct STopBotResItem {
typedef
struct
STopBotRes
{
typedef
struct
STopBotRes
{
int32_t
maxSize
;
int32_t
maxSize
;
int16_t
type
;
int16_t
type
;
STuplePos
nullTuplePos
;
bool
nullTupleSaved
;
STopBotResItem
*
pItems
;
STopBotResItem
*
pItems
;
}
STopBotRes
;
}
STopBotRes
;
...
@@ -221,6 +228,10 @@ typedef struct SSampleInfo {
...
@@ -221,6 +228,10 @@ typedef struct SSampleInfo {
int32_t
numSampled
;
int32_t
numSampled
;
uint8_t
colType
;
uint8_t
colType
;
int16_t
colBytes
;
int16_t
colBytes
;
STuplePos
nullTuplePos
;
bool
nullTupleSaved
;
char
*
data
;
char
*
data
;
STuplePos
*
tuplePos
;
STuplePos
*
tuplePos
;
}
SSampleInfo
;
}
SSampleInfo
;
...
@@ -1134,6 +1145,9 @@ bool minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo)
...
@@ -1134,6 +1145,9 @@ bool minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo)
SMinmaxResInfo
*
buf
=
GET_ROWCELL_INTERBUF
(
pResultInfo
);
SMinmaxResInfo
*
buf
=
GET_ROWCELL_INTERBUF
(
pResultInfo
);
buf
->
assign
=
false
;
buf
->
assign
=
false
;
buf
->
tuplePos
.
pageId
=
-
1
;
buf
->
tuplePos
.
pageId
=
-
1
;
buf
->
nullTupleSaved
=
false
;
buf
->
nullTuplePos
.
pageId
=
-
1
;
return
true
;
return
true
;
}
}
...
@@ -1575,6 +1589,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1575,6 +1589,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
}
}
_min_max_over:
_min_max_over:
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pBuf
->
nullTupleSaved
)
{
doSaveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
&
pBuf
->
nullTuplePos
);
pBuf
->
nullTupleSaved
=
true
;
}
return
numOfElems
;
return
numOfElems
;
}
}
...
@@ -1615,7 +1633,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -1615,7 +1633,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
if
(
pEntryInfo
->
numOfRes
>
0
)
{
if
(
pEntryInfo
->
numOfRes
>
0
)
{
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
}
else
{
}
else
{
set
NullSelectivityValue
(
pCtx
,
pBlock
,
currentRow
);
set
SelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
nullTuplePos
,
currentRow
);
}
}
return
pEntryInfo
->
numOfRes
;
return
pEntryInfo
->
numOfRes
;
...
@@ -3366,6 +3384,8 @@ bool topBotFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
...
@@ -3366,6 +3384,8 @@ bool topBotFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
pRes
->
maxSize
=
pCtx
->
param
[
1
].
param
.
i
;
pRes
->
maxSize
=
pCtx
->
param
[
1
].
param
.
i
;
pRes
->
nullTupleSaved
=
false
;
pRes
->
nullTuplePos
.
pageId
=
-
1
;
return
true
;
return
true
;
}
}
...
@@ -3403,6 +3423,10 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
...
@@ -3403,6 +3423,10 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
true
);
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
true
);
}
}
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pRes
->
nullTupleSaved
)
{
doSaveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
&
pRes
->
nullTuplePos
);
pRes
->
nullTupleSaved
=
true
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -3427,6 +3451,11 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) {
...
@@ -3427,6 +3451,11 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) {
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
false
);
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
false
);
}
}
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pRes
->
nullTupleSaved
)
{
doSaveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
&
pRes
->
nullTuplePos
);
pRes
->
nullTupleSaved
=
true
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -3627,7 +3656,7 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -3627,7 +3656,7 @@ int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t
currentRow
=
pBlock
->
info
.
rows
;
int32_t
currentRow
=
pBlock
->
info
.
rows
;
if
(
pEntryInfo
->
numOfRes
<=
0
)
{
if
(
pEntryInfo
->
numOfRes
<=
0
)
{
colDataAppendNULL
(
pCol
,
currentRow
);
colDataAppendNULL
(
pCol
,
currentRow
);
set
NullSelectivityValue
(
pCtx
,
pBlock
,
currentRow
);
set
SelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
nullTuplePos
,
currentRow
);
return
pEntryInfo
->
numOfRes
;
return
pEntryInfo
->
numOfRes
;
}
}
for
(
int32_t
i
=
0
;
i
<
pEntryInfo
->
numOfRes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pEntryInfo
->
numOfRes
;
++
i
)
{
...
@@ -4902,7 +4931,8 @@ bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo)
...
@@ -4902,7 +4931,8 @@ bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo)
pInfo
->
numSampled
=
0
;
pInfo
->
numSampled
=
0
;
pInfo
->
colType
=
pCtx
->
resDataInfo
.
type
;
pInfo
->
colType
=
pCtx
->
resDataInfo
.
type
;
pInfo
->
colBytes
=
pCtx
->
resDataInfo
.
bytes
;
pInfo
->
colBytes
=
pCtx
->
resDataInfo
.
bytes
;
pInfo
->
nullTuplePos
.
pageId
=
-
1
;
pInfo
->
nullTupleSaved
=
false
;
pInfo
->
data
=
(
char
*
)
pInfo
+
sizeof
(
SSampleInfo
);
pInfo
->
data
=
(
char
*
)
pInfo
+
sizeof
(
SSampleInfo
);
pInfo
->
tuplePos
=
(
STuplePos
*
)((
char
*
)
pInfo
+
sizeof
(
SSampleInfo
)
+
pInfo
->
samples
*
pInfo
->
colBytes
);
pInfo
->
tuplePos
=
(
STuplePos
*
)((
char
*
)
pInfo
+
sizeof
(
SSampleInfo
)
+
pInfo
->
samples
*
pInfo
->
colBytes
);
...
@@ -4948,6 +4978,11 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
...
@@ -4948,6 +4978,11 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
doReservoirSample
(
pCtx
,
pInfo
,
data
,
i
);
doReservoirSample
(
pCtx
,
pInfo
,
data
,
i
);
}
}
if
(
pInfo
->
numSampled
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pInfo
->
nullTupleSaved
)
{
doSaveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
&
pInfo
->
nullTuplePos
);
pInfo
->
nullTupleSaved
=
true
;
}
SET_VAL
(
pResInfo
,
pInfo
->
numSampled
,
pInfo
->
numSampled
);
SET_VAL
(
pResInfo
,
pInfo
->
numSampled
,
pInfo
->
numSampled
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -4964,7 +4999,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -4964,7 +4999,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t
currentRow
=
pBlock
->
info
.
rows
;
int32_t
currentRow
=
pBlock
->
info
.
rows
;
if
(
pInfo
->
numSampled
==
0
)
{
if
(
pInfo
->
numSampled
==
0
)
{
colDataAppendNULL
(
pCol
,
currentRow
);
colDataAppendNULL
(
pCol
,
currentRow
);
set
NullSelectivityValue
(
pCtx
,
pBlock
,
currentRow
);
set
SelectivityValue
(
pCtx
,
pBlock
,
&
pInfo
->
nullTuplePos
,
currentRow
);
return
pInfo
->
numSampled
;
return
pInfo
->
numSampled
;
}
}
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numSampled
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numSampled
;
++
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录