Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21b5f723
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
21b5f723
编写于
5月 16, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix tail function NULL value handing.
上级
4be158b3
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
20 addition
and
12 deletion
+20
-12
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+20
-12
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
21b5f723
...
@@ -166,6 +166,7 @@ typedef struct SSampleInfo {
...
@@ -166,6 +166,7 @@ typedef struct SSampleInfo {
typedef
struct
STailItem
{
typedef
struct
STailItem
{
int64_t
timestamp
;
int64_t
timestamp
;
bool
isNull
;
char
data
[];
char
data
[];
}
STailItem
;
}
STailItem
;
...
@@ -3124,7 +3125,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
...
@@ -3124,7 +3125,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
int32_t
startOffset
=
pCtx
->
offset
;
int32_t
startOffset
=
pCtx
->
offset
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_
f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_
s
(
pInputCol
,
i
))
{
//colDataAppendNULL(pOutput, i);
//colDataAppendNULL(pOutput, i);
continue
;
continue
;
}
}
...
@@ -3190,14 +3191,19 @@ bool tailFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) {
...
@@ -3190,14 +3191,19 @@ bool tailFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) {
size_t
unitSize
=
sizeof
(
STailItem
)
+
pInfo
->
colBytes
;
size_t
unitSize
=
sizeof
(
STailItem
)
+
pInfo
->
colBytes
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfPoints
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfPoints
;
++
i
)
{
pInfo
->
pItems
[
i
]
=
(
STailItem
*
)(
pItem
+
i
*
unitSize
);
pInfo
->
pItems
[
i
]
=
(
STailItem
*
)(
pItem
+
i
*
unitSize
);
pInfo
->
pItems
[
i
]
->
isNull
=
false
;
}
}
return
true
;
return
true
;
}
}
static
void
tailAssignResult
(
STailItem
*
pItem
,
char
*
data
,
int32_t
colBytes
,
TSKEY
ts
)
{
static
void
tailAssignResult
(
STailItem
*
pItem
,
char
*
data
,
int32_t
colBytes
,
TSKEY
ts
,
bool
isNull
)
{
pItem
->
timestamp
=
ts
;
pItem
->
timestamp
=
ts
;
if
(
isNull
)
{
pItem
->
isNull
=
true
;
}
else
{
memcpy
(
pItem
->
data
,
data
,
colBytes
);
memcpy
(
pItem
->
data
,
data
,
colBytes
);
}
}
}
static
int32_t
tailCompFn
(
const
void
*
p1
,
const
void
*
p2
,
const
void
*
param
)
{
static
int32_t
tailCompFn
(
const
void
*
p1
,
const
void
*
p2
,
const
void
*
param
)
{
...
@@ -3206,14 +3212,14 @@ static int32_t tailCompFn(const void *p1, const void *p2, const void *param) {
...
@@ -3206,14 +3212,14 @@ static int32_t tailCompFn(const void *p1, const void *p2, const void *param) {
return
compareInt64Val
(
&
d1
->
timestamp
,
&
d2
->
timestamp
);
return
compareInt64Val
(
&
d1
->
timestamp
,
&
d2
->
timestamp
);
}
}
static
void
doTailAdd
(
STailInfo
*
pInfo
,
char
*
data
,
TSKEY
ts
)
{
static
void
doTailAdd
(
STailInfo
*
pInfo
,
char
*
data
,
TSKEY
ts
,
bool
isNull
)
{
STailItem
**
pList
=
pInfo
->
pItems
;
STailItem
**
pList
=
pInfo
->
pItems
;
if
(
pInfo
->
numAdded
<
pInfo
->
numOfPoints
)
{
if
(
pInfo
->
numAdded
<
pInfo
->
numOfPoints
)
{
tailAssignResult
(
pList
[
pInfo
->
numAdded
],
data
,
pInfo
->
colBytes
,
ts
);
tailAssignResult
(
pList
[
pInfo
->
numAdded
],
data
,
pInfo
->
colBytes
,
ts
,
isNull
);
taosheapsort
((
void
*
)
pList
,
sizeof
(
STailItem
**
),
pInfo
->
numAdded
+
1
,
NULL
,
tailCompFn
,
0
);
taosheapsort
((
void
*
)
pList
,
sizeof
(
STailItem
**
),
pInfo
->
numAdded
+
1
,
NULL
,
tailCompFn
,
0
);
pInfo
->
numAdded
++
;
pInfo
->
numAdded
++
;
}
else
if
(
pList
[
0
]
->
timestamp
<
ts
)
{
}
else
if
(
pList
[
0
]
->
timestamp
<
ts
)
{
tailAssignResult
(
pList
[
0
],
data
,
pInfo
->
colBytes
,
ts
);
tailAssignResult
(
pList
[
0
],
data
,
pInfo
->
colBytes
,
ts
,
isNull
);
taosheapadjust
((
void
*
)
pList
,
sizeof
(
STailItem
**
),
0
,
pInfo
->
numOfPoints
-
1
,
NULL
,
tailCompFn
,
NULL
,
0
);
taosheapadjust
((
void
*
)
pList
,
sizeof
(
STailItem
**
),
0
,
pInfo
->
numOfPoints
-
1
,
NULL
,
tailCompFn
,
NULL
,
0
);
}
}
}
}
...
@@ -3231,20 +3237,22 @@ int32_t tailFunction(SqlFunctionCtx* pCtx) {
...
@@ -3231,20 +3237,22 @@ int32_t tailFunction(SqlFunctionCtx* pCtx) {
int32_t
startOffset
=
pCtx
->
offset
;
int32_t
startOffset
=
pCtx
->
offset
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
colDataAppendNULL
(
pOutput
,
i
);
continue
;
}
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
doTailAdd
(
pInfo
,
data
,
tsList
[
i
]);
doTailAdd
(
pInfo
,
data
,
tsList
[
i
]
,
colDataIsNull_s
(
pInputCol
,
i
)
);
}
}
taosqsort
(
pInfo
->
pItems
,
pInfo
->
numOfPoints
,
POINTER_BYTES
,
NULL
,
tailCompFn
);
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfPoints
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfPoints
;
++
i
)
{
int32_t
pos
=
startOffset
+
i
;
int32_t
pos
=
startOffset
+
i
;
STailItem
*
pItem
=
pInfo
->
pItems
[
i
];
STailItem
*
pItem
=
pInfo
->
pItems
[
i
];
if
(
pItem
->
isNull
)
{
colDataAppendNULL
(
pOutput
,
pos
);
}
else
{
colDataAppend
(
pOutput
,
pos
,
pItem
->
data
,
false
);
colDataAppend
(
pOutput
,
pos
,
pItem
->
data
,
false
);
}
}
}
return
pInfo
->
numOfPoints
;
return
pInfo
->
numOfPoints
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录