Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6ff602ca
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
6ff602ca
编写于
2月 20, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix var data problems in unique function
上级
a7ae8256
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
15 deletion
+10
-15
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+9
-5
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-10
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
6ff602ca
...
@@ -5199,8 +5199,12 @@ static bool unique_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRes
...
@@ -5199,8 +5199,12 @@ static bool unique_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRes
return
true
;
return
true
;
}
}
static
void
do_unique_function
(
SQLFunctionCtx
*
pCtx
,
SUniqueFuncInfo
*
pInfo
,
TSKEY
timestamp
,
char
*
pData
,
char
*
tag
,
int32_t
bytes
){
static
void
do_unique_function
(
SQLFunctionCtx
*
pCtx
,
SUniqueFuncInfo
*
pInfo
,
TSKEY
timestamp
,
char
*
pData
,
char
*
tag
,
int32_t
bytes
,
int16_t
type
){
UniqueUnit
**
unique
=
taosHashGet
(
*
pCtx
->
pUniqueSet
,
pData
,
bytes
);
int32_t
hashKeyBytes
=
bytes
;
if
(
IS_VAR_DATA_TYPE
(
type
)){
hashKeyBytes
=
varDataTLen
(
pData
);
}
UniqueUnit
**
unique
=
taosHashGet
(
*
pCtx
->
pUniqueSet
,
pData
,
hashKeyBytes
);
if
(
unique
==
NULL
)
{
if
(
unique
==
NULL
)
{
size_t
size
=
sizeof
(
UniqueUnit
)
+
bytes
+
pCtx
->
tagInfo
.
tagsLen
;
size_t
size
=
sizeof
(
UniqueUnit
)
+
bytes
+
pCtx
->
tagInfo
.
tagsLen
;
char
*
tmp
=
pInfo
->
res
+
pInfo
->
num
*
size
;
char
*
tmp
=
pInfo
->
res
+
pInfo
->
num
*
size
;
...
@@ -5226,7 +5230,7 @@ static void do_unique_function(SQLFunctionCtx *pCtx, SUniqueFuncInfo *pInfo, TSK
...
@@ -5226,7 +5230,7 @@ static void do_unique_function(SQLFunctionCtx *pCtx, SUniqueFuncInfo *pInfo, TSK
}
}
}
}
taosHashPut
(
*
pCtx
->
pUniqueSet
,
pData
,
b
ytes
,
&
tmp
,
sizeof
(
UniqueUnit
*
));
taosHashPut
(
*
pCtx
->
pUniqueSet
,
pData
,
hashKeyB
ytes
,
&
tmp
,
sizeof
(
UniqueUnit
*
));
pInfo
->
num
++
;
pInfo
->
num
++
;
}
else
if
((
*
unique
)
->
timestamp
>
timestamp
){
}
else
if
((
*
unique
)
->
timestamp
>
timestamp
){
(
*
unique
)
->
timestamp
=
timestamp
;
(
*
unique
)
->
timestamp
=
timestamp
;
...
@@ -5242,7 +5246,7 @@ static void unique_function(SQLFunctionCtx *pCtx) {
...
@@ -5242,7 +5246,7 @@ static void unique_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
ptsList
!=
NULL
)
{
if
(
pCtx
->
ptsList
!=
NULL
)
{
k
=
GET_TS_DATA
(
pCtx
,
i
);
k
=
GET_TS_DATA
(
pCtx
,
i
);
}
}
do_unique_function
(
pCtx
,
pInfo
,
k
,
pData
,
NULL
,
pCtx
->
inputBytes
);
do_unique_function
(
pCtx
,
pInfo
,
k
,
pData
,
NULL
,
pCtx
->
inputBytes
,
pCtx
->
inputType
);
if
(
sizeof
(
SUniqueFuncInfo
)
+
pInfo
->
num
*
(
sizeof
(
UniqueUnit
)
+
pCtx
->
inputBytes
+
pCtx
->
tagInfo
.
tagsLen
)
>=
MAX_UNIQUE_RESULT_SIZE
){
if
(
sizeof
(
SUniqueFuncInfo
)
+
pInfo
->
num
*
(
sizeof
(
UniqueUnit
)
+
pCtx
->
inputBytes
+
pCtx
->
tagInfo
.
tagsLen
)
>=
MAX_UNIQUE_RESULT_SIZE
){
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
-
1
;
// mark out of memory
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
-
1
;
// mark out of memory
...
@@ -5262,7 +5266,7 @@ static void unique_function_merge(SQLFunctionCtx *pCtx) {
...
@@ -5262,7 +5266,7 @@ static void unique_function_merge(SQLFunctionCtx *pCtx) {
TSKEY
timestamp
=
((
UniqueUnit
*
)
tmp
)
->
timestamp
;
TSKEY
timestamp
=
((
UniqueUnit
*
)
tmp
)
->
timestamp
;
char
*
data
=
tmp
+
sizeof
(
UniqueUnit
);
char
*
data
=
tmp
+
sizeof
(
UniqueUnit
);
char
*
tags
=
tmp
+
sizeof
(
UniqueUnit
)
+
pCtx
->
outputBytes
;
char
*
tags
=
tmp
+
sizeof
(
UniqueUnit
)
+
pCtx
->
outputBytes
;
do_unique_function
(
pCtx
,
pOutput
,
timestamp
,
data
,
tags
,
pCtx
->
outputBytes
);
do_unique_function
(
pCtx
,
pOutput
,
timestamp
,
data
,
tags
,
pCtx
->
outputBytes
,
pCtx
->
outputType
);
if
(
sizeof
(
SUniqueFuncInfo
)
+
pOutput
->
num
*
(
sizeof
(
UniqueUnit
)
+
pCtx
->
outputBytes
+
pCtx
->
tagInfo
.
tagsLen
)
>=
MAX_UNIQUE_RESULT_SIZE
){
if
(
sizeof
(
SUniqueFuncInfo
)
+
pOutput
->
num
*
(
sizeof
(
UniqueUnit
)
+
pCtx
->
outputBytes
+
pCtx
->
tagInfo
.
tagsLen
)
>=
MAX_UNIQUE_RESULT_SIZE
){
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
-
1
;
// mark out of memory
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
-
1
;
// mark out of memory
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
6ff602ca
...
@@ -1759,7 +1759,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
...
@@ -1759,7 +1759,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
// todo refactor, only copy one-by-one
// todo refactor, only copy one-by-one
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
const
char
*
p
=
tdGetColDataOfRow
(
src
,
k
);
const
char
*
p
=
tdGetColDataOfRow
(
src
,
k
);
memset
(
dst
,
0
,
bytes
);
memcpy
(
dst
,
p
,
varDataTLen
(
p
));
memcpy
(
dst
,
p
,
varDataTLen
(
p
));
dst
+=
bytes
;
dst
+=
bytes
;
}
}
...
@@ -1772,7 +1771,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
...
@@ -1772,7 +1771,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
char
*
dst
=
pData
;
char
*
dst
=
pData
;
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
memset
(
dst
,
0
,
bytes
);
setVardataNull
(
dst
,
pColInfo
->
info
.
type
);
setVardataNull
(
dst
,
pColInfo
->
info
.
type
);
dst
+=
bytes
;
dst
+=
bytes
;
}
}
...
@@ -1795,7 +1793,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
...
@@ -1795,7 +1793,6 @@ static int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t c
char
*
dst
=
pData
;
char
*
dst
=
pData
;
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
for
(
int32_t
k
=
start
;
k
<
num
+
start
;
++
k
)
{
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
setVardataNull
(
dst
,
pColInfo
->
info
.
type
);
setVardataNull
(
dst
,
pColInfo
->
info
.
type
);
dst
+=
pColInfo
->
info
.
bytes
;
dst
+=
pColInfo
->
info
.
bytes
;
}
}
...
@@ -1863,7 +1860,6 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
...
@@ -1863,7 +1860,6 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
}
else
{
}
else
{
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
}
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
int32_t
colIdOfRow1
;
int32_t
colIdOfRow1
;
if
(
j
>=
numOfColsOfRow1
)
{
if
(
j
>=
numOfColsOfRow1
)
{
...
@@ -1999,7 +1995,6 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
...
@@ -1999,7 +1995,6 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
}
else
{
}
else
{
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
}
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
setVardataNull
(
pData
,
pColInfo
->
info
.
type
);
setVardataNull
(
pData
,
pColInfo
->
info
.
type
);
...
@@ -3155,8 +3150,7 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
...
@@ -3155,8 +3150,7 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
}
}
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
if
(
pTable
->
lastCols
[
j
].
bytes
>
0
)
{
if
(
pTable
->
lastCols
[
j
].
bytes
>
0
)
{
void
*
value
=
pTable
->
lastCols
[
j
].
pData
;
void
*
value
=
pTable
->
lastCols
[
j
].
pData
;
switch
(
pColInfo
->
info
.
type
)
{
switch
(
pColInfo
->
info
.
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
...
@@ -3210,7 +3204,6 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
...
@@ -3210,7 +3204,6 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
n
);
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
n
);
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;;
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;;
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
if
(
pColInfo
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
pColInfo
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
*
(
TSKEY
*
)
pData
=
pTable
->
lastCols
[
j
].
ts
;
*
(
TSKEY
*
)
pData
=
pTable
->
lastCols
[
j
].
ts
;
continue
;
continue
;
...
@@ -3236,7 +3229,6 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
...
@@ -3236,7 +3229,6 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
if
(
priKey
!=
TSKEY_INITIAL_VAL
)
{
if
(
priKey
!=
TSKEY_INITIAL_VAL
)
{
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
priIdx
);
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
priIdx
);
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
*
(
TSKEY
*
)
pData
=
priKey
;
*
(
TSKEY
*
)
pData
=
priKey
;
...
@@ -3247,7 +3239,6 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
...
@@ -3247,7 +3239,6 @@ static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
n
);
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
n
);
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;;
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;;
memset
(
pData
,
0
,
pColInfo
->
info
.
bytes
);
assert
(
pColInfo
->
info
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
assert
(
pColInfo
->
info
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录