Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a6bf4c3
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看板
未验证
提交
5a6bf4c3
编写于
3月 30, 2022
作者:
C
Cary Xu
提交者:
GitHub
3月 30, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11139 from taosdata/feature/TD-11463-3.0
memory clear
上级
a4a669ed
f70fd313
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
93 addition
and
91 deletion
+93
-91
include/common/trow.h
include/common/trow.h
+3
-3
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+3
-3
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+11
-15
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+76
-70
未找到文件。
include/common/trow.h
浏览文件 @
5a6bf4c3
...
@@ -937,9 +937,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
...
@@ -937,9 +937,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
STColumn
*
pCol
=
NULL
;
STColumn
*
pCol
=
NULL
;
STSchema
*
pSchema
=
pIter
->
pSchema
;
STSchema
*
pSchema
=
pIter
->
pSchema
;
while
(
pIter
->
colIdx
<=
pSchema
->
numOfCols
)
{
while
(
pIter
->
colIdx
<=
pSchema
->
numOfCols
)
{
pCol
=
&
pSchema
->
columns
[
pIter
->
colIdx
];
pCol
=
&
pSchema
->
columns
[
pIter
->
colIdx
];
// 1st column of schema is primary TS key
if
(
colId
==
pCol
->
colId
)
{
if
(
colId
==
pCol
->
colId
)
{
++
pIter
->
colIdx
;
break
;
break
;
}
else
if
(
colId
<
pCol
->
colId
)
{
}
else
if
(
colId
<
pCol
->
colId
)
{
++
pIter
->
colIdx
;
++
pIter
->
colIdx
;
...
@@ -948,7 +947,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
...
@@ -948,7 +947,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
return
false
;
return
false
;
}
}
}
}
return
tdGetTpRowDataOfCol
(
pIter
,
pCol
->
type
,
pCol
->
offset
-
sizeof
(
TSKEY
),
pVal
);
tdGetTpRowDataOfCol
(
pIter
,
pCol
->
type
,
pCol
->
offset
-
sizeof
(
TSKEY
),
pVal
);
++
pIter
->
colIdx
;
}
else
if
(
TD_IS_KV_ROW
(
pIter
->
pRow
))
{
}
else
if
(
TD_IS_KV_ROW
(
pIter
->
pRow
))
{
return
tdGetKvRowValOfColEx
(
pIter
,
colId
,
colType
,
&
pIter
->
kvIdx
,
pVal
);
return
tdGetKvRowValOfColEx
(
pIter
,
colId
,
colType
,
&
pIter
->
kvIdx
,
pVal
);
}
else
{
}
else
{
...
...
source/dnode/vnode/src/inc/tsdbSma.h
浏览文件 @
5a6bf4c3
...
@@ -51,7 +51,7 @@ static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void
...
@@ -51,7 +51,7 @@ static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void
return
len
;
return
len
;
}
}
static
FORCE_INLINE
int
tsdbRLockSma
(
SSmaEnv
*
pEnv
)
{
static
FORCE_INLINE
int
32_t
tsdbRLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pEnv
->
lock
));
int
code
=
taosThreadRwlockRdlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
...
@@ -60,7 +60,7 @@ static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) {
...
@@ -60,7 +60,7 @@ static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) {
return
0
;
return
0
;
}
}
static
FORCE_INLINE
int
tsdbWLockSma
(
SSmaEnv
*
pEnv
)
{
static
FORCE_INLINE
int
32_t
tsdbWLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pEnv
->
lock
));
int
code
=
taosThreadRwlockWrlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
...
@@ -69,7 +69,7 @@ static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) {
...
@@ -69,7 +69,7 @@ static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) {
return
0
;
return
0
;
}
}
static
FORCE_INLINE
int
tsdbUnLockSma
(
SSmaEnv
*
pEnv
)
{
static
FORCE_INLINE
int
32_t
tsdbUnLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pEnv
->
lock
));
int
code
=
taosThreadRwlockUnlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
5a6bf4c3
...
@@ -651,9 +651,8 @@ static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) {
...
@@ -651,9 +651,8 @@ static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) {
*/
*/
static
int32_t
tsdbInsertTSmaBlocks
(
STSmaWriteH
*
pSmaH
,
void
*
smaKey
,
uint32_t
keyLen
,
void
*
pData
,
uint32_t
dataLen
)
{
static
int32_t
tsdbInsertTSmaBlocks
(
STSmaWriteH
*
pSmaH
,
void
*
smaKey
,
uint32_t
keyLen
,
void
*
pData
,
uint32_t
dataLen
)
{
SDBFile
*
pDBFile
=
&
pSmaH
->
dFile
;
SDBFile
*
pDBFile
=
&
pSmaH
->
dFile
;
tsdbDebug
(
"vgId:%d insert sma data blocks into %s: smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
", dataLen %d"
,
printf
(
"
\n
vgId:%d insert sma data blocks into %s: smaKey %"
PRIx64
"-%"
PRIx64
", dataLen %"
PRIu32
"
\n
"
,
REPO_ID
(
pSmaH
->
pTsdb
),
pDBFile
->
path
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
REPO_ID
(
pSmaH
->
pTsdb
),
pDBFile
->
path
,
*
(
int64_t
*
)
smaKey
,
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
dataLen
);
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
dataLen
);
// TODO: insert sma data blocks into B+Tree(TDB)
// TODO: insert sma data blocks into B+Tree(TDB)
if
(
tsdbSaveSmaToDB
(
pDBFile
,
smaKey
,
keyLen
,
pData
,
dataLen
)
!=
0
)
{
if
(
tsdbSaveSmaToDB
(
pDBFile
,
smaKey
,
keyLen
,
pData
,
dataLen
)
!=
0
)
{
...
@@ -874,7 +873,6 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
...
@@ -874,7 +873,6 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
// key: skey + groupId
// key: skey + groupId
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
void
*
pSmaKey
=
&
smaKey
;
char
dataBuf
[
512
]
=
{
0
};
char
dataBuf
[
512
]
=
{
0
};
void
*
pDataBuf
=
&
dataBuf
;
void
*
pDataBuf
=
&
dataBuf
;
int32_t
sz
=
taosArrayGetSize
(
pDataBlocks
);
int32_t
sz
=
taosArrayGetSize
(
pDataBlocks
);
...
@@ -887,6 +885,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
...
@@ -887,6 +885,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
for
(
int32_t
j
=
0
;
j
<
rows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
rows
;
++
j
)
{
printf
(
"|"
);
printf
(
"|"
);
TSKEY
skey
=
TSKEY_INITIAL_VAL
;
// the start key of TS window by interval
TSKEY
skey
=
TSKEY_INITIAL_VAL
;
// the start key of TS window by interval
void
*
pSmaKey
=
&
smaKey
;
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
for
(
int32_t
k
=
0
;
k
<
colNum
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
colNum
;
++
k
)
{
SColumnInfoData
*
pColInfoData
=
*
(
SColumnInfoData
**
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
k
);
SColumnInfoData
*
pColInfoData
=
*
(
SColumnInfoData
**
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
k
);
...
@@ -894,7 +893,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
...
@@ -894,7 +893,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
switch
(
pColInfoData
->
info
.
type
)
{
switch
(
pColInfoData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
skey
=
*
(
TSKEY
*
)
var
;
skey
=
*
(
TSKEY
*
)
var
;
printf
(
" skey = %"
PRIi64
" groupId = %"
PRId64
"|"
,
skey
,
groupId
);
printf
(
"
==>
skey = %"
PRIi64
" groupId = %"
PRId64
"|"
,
skey
,
groupId
);
tsdbEncodeTSmaKey
(
groupId
,
skey
,
&
pSmaKey
);
tsdbEncodeTSmaKey
(
groupId
,
skey
,
&
pSmaKey
);
break
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
...
@@ -976,7 +975,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
...
@@ -976,7 +975,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
}
}
}
}
if
(
tsdbInsertTSmaBlocks
(
&
tSmaH
,
pS
maKey
,
SMA_KEY_LEN
,
pDataBuf
,
tlen
)
!=
0
)
{
if
(
tsdbInsertTSmaBlocks
(
&
tSmaH
,
&
s
maKey
,
SMA_KEY_LEN
,
pDataBuf
,
tlen
)
!=
0
)
{
tsdbWarn
(
"vgId:%d insert tSma data blocks failed for index %"
PRIi64
", skey %"
PRIi64
", groupId %"
PRIi64
tsdbWarn
(
"vgId:%d insert tSma data blocks failed for index %"
PRIi64
", skey %"
PRIi64
", groupId %"
PRIi64
" since %s"
,
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
skey
,
groupId
,
tstrerror
(
terrno
));
REPO_ID
(
pTsdb
),
indexUid
,
skey
,
groupId
,
tstrerror
(
terrno
));
...
@@ -1308,22 +1307,19 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, char *pData, int64_t indexUid,
...
@@ -1308,22 +1307,19 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, char *pData, int64_t indexUid,
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
void
*
pSmaKey
=
&
smaKey
;
void
*
pSmaKey
=
&
smaKey
;
int64_t
queryGroupId
=
1
;
int64_t
queryGroupId
=
1
;
tsdbEncodeTSmaKey
(
queryGroupId
,
querySKey
,
(
void
**
)
&
pSmaKey
);
tsdbEncodeTSmaKey
(
queryGroupId
,
querySKey
,
(
void
**
)
&
pSmaKey
);
tsdbDebug
(
"vgId:%d get sma data from %s: smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
", keyLen %d"
,
REPO_ID
(
pTsdb
),
tsdbDebug
(
"vgId:%d get sma data from %s: smaKey %"
PRIx64
"-%"
PRIx64
", keyLen %d"
,
REPO_ID
(
pTsdb
),
tReadH
.
dFile
.
path
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
tReadH
.
dFile
.
path
,
*
(
int64_t
*
)
smaKey
,
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
SMA_KEY_LEN
);
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
SMA_KEY_LEN
);
void
*
result
=
NULL
;
void
*
result
=
NULL
;
uint32_t
valueSize
=
0
;
uint32_t
valueSize
=
0
;
if
((
result
=
tsdbGetSmaDataByKey
(
&
tReadH
.
dFile
,
smaKey
,
SMA_KEY_LEN
,
&
valueSize
))
==
NULL
)
{
if
((
result
=
tsdbGetSmaDataByKey
(
&
tReadH
.
dFile
,
smaKey
,
SMA_KEY_LEN
,
&
valueSize
))
==
NULL
)
{
tsdbWarn
(
"vgId:%d get sma data failed from smaIndex %"
PRIi64
", smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
tsdbWarn
(
"vgId:%d get sma data failed from smaIndex %"
PRIi64
", smaKey %"
PRIx64
"-%"
PRIx64
" since %s"
,
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
*
(
int64_t
*
)
smaKey
,
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
tstrerror
(
terrno
));
REPO_ID
(
pTsdb
),
indexUid
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
tstrerror
(
terrno
));
tsdbCloseDBF
(
&
tReadH
.
dFile
);
tsdbCloseDBF
(
&
tReadH
.
dFile
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
5a6bf4c3
...
@@ -59,20 +59,21 @@ TEST(testCase, unionEncodeDecodeTest) {
...
@@ -59,20 +59,21 @@ TEST(testCase, unionEncodeDecodeTest) {
void
*
buf
=
taosMemoryMalloc
(
1024
);
void
*
buf
=
taosMemoryMalloc
(
1024
);
void
*
pBuf
=
buf
;
void
*
pBuf
=
buf
;
void
*
qBuf
=
buf
;
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU8
(
&
b
uf
,
sut
.
info
);
tlen
+=
taosEncodeFixedU8
(
&
pB
uf
,
sut
.
info
);
tlen
+=
taosEncodeFixedI16
(
&
b
uf
,
sut
.
nBSmaCols
);
tlen
+=
taosEncodeFixedI16
(
&
pB
uf
,
sut
.
nBSmaCols
);
for
(
col_id_t
i
=
0
;
i
<
sut
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
sut
.
nBSmaCols
;
++
i
)
{
tlen
+=
taosEncodeFixedI16
(
&
b
uf
,
sut
.
pBSmaCols
[
i
]);
tlen
+=
taosEncodeFixedI16
(
&
pB
uf
,
sut
.
pBSmaCols
[
i
]);
}
}
SUnionTest
dut
=
{
0
};
SUnionTest
dut
=
{
0
};
pBuf
=
taosDecodeFixedU8
(
p
Buf
,
&
dut
.
info
);
qBuf
=
taosDecodeFixedU8
(
q
Buf
,
&
dut
.
info
);
pBuf
=
taosDecodeFixedI16
(
p
Buf
,
&
dut
.
nBSmaCols
);
qBuf
=
taosDecodeFixedI16
(
q
Buf
,
&
dut
.
nBSmaCols
);
if
(
dut
.
nBSmaCols
>
0
)
{
if
(
dut
.
nBSmaCols
>
0
)
{
dut
.
pBSmaCols
=
(
col_id_t
*
)
taosMemoryMalloc
(
dut
.
nBSmaCols
*
sizeof
(
col_id_t
));
dut
.
pBSmaCols
=
(
col_id_t
*
)
taosMemoryMalloc
(
dut
.
nBSmaCols
*
sizeof
(
col_id_t
));
for
(
col_id_t
i
=
0
;
i
<
dut
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
dut
.
nBSmaCols
;
++
i
)
{
pBuf
=
taosDecodeFixedI16
(
p
Buf
,
dut
.
pBSmaCols
+
i
);
qBuf
=
taosDecodeFixedI16
(
q
Buf
,
dut
.
pBSmaCols
+
i
);
}
}
}
else
{
}
else
{
dut
.
pBSmaCols
=
NULL
;
dut
.
pBSmaCols
=
NULL
;
...
@@ -81,13 +82,17 @@ TEST(testCase, unionEncodeDecodeTest) {
...
@@ -81,13 +82,17 @@ TEST(testCase, unionEncodeDecodeTest) {
printf
(
"sut.rollup=%"
PRIu8
", type=%"
PRIu8
", info=%"
PRIu8
"
\n
"
,
sut
.
rollup
,
sut
.
type
,
sut
.
info
);
printf
(
"sut.rollup=%"
PRIu8
", type=%"
PRIu8
", info=%"
PRIu8
"
\n
"
,
sut
.
rollup
,
sut
.
type
,
sut
.
info
);
printf
(
"dut.rollup=%"
PRIu8
", type=%"
PRIu8
", info=%"
PRIu8
"
\n
"
,
dut
.
rollup
,
dut
.
type
,
dut
.
info
);
printf
(
"dut.rollup=%"
PRIu8
", type=%"
PRIu8
", info=%"
PRIu8
"
\n
"
,
dut
.
rollup
,
dut
.
type
,
dut
.
info
);
ASSER
T_EQ
(
sut
.
rollup
,
dut
.
rollup
);
EXPEC
T_EQ
(
sut
.
rollup
,
dut
.
rollup
);
ASSER
T_EQ
(
sut
.
type
,
dut
.
type
);
EXPEC
T_EQ
(
sut
.
type
,
dut
.
type
);
ASSER
T_EQ
(
sut
.
nBSmaCols
,
dut
.
nBSmaCols
);
EXPEC
T_EQ
(
sut
.
nBSmaCols
,
dut
.
nBSmaCols
);
for
(
col_id_t
i
=
0
;
i
<
sut
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
sut
.
nBSmaCols
;
++
i
)
{
ASSER
T_EQ
(
*
(
col_id_t
*
)(
sut
.
pBSmaCols
+
i
),
sut
.
pBSmaCols
[
i
]);
EXPEC
T_EQ
(
*
(
col_id_t
*
)(
sut
.
pBSmaCols
+
i
),
sut
.
pBSmaCols
[
i
]);
ASSER
T_EQ
(
*
(
col_id_t
*
)(
sut
.
pBSmaCols
+
i
),
dut
.
pBSmaCols
[
i
]);
EXPEC
T_EQ
(
*
(
col_id_t
*
)(
sut
.
pBSmaCols
+
i
),
dut
.
pBSmaCols
[
i
]);
}
}
taosMemoryFreeClear
(
buf
);
taosMemoryFreeClear
(
dut
.
pBSmaCols
);
taosMemoryFreeClear
(
sut
.
pBSmaCols
);
}
}
#if 1
#if 1
TEST
(
testCase
,
tSma_Meta_Encode_Decode_Test
)
{
TEST
(
testCase
,
tSma_Meta_Encode_Decode_Test
)
{
...
@@ -107,37 +112,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
...
@@ -107,37 +112,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
uint32_t
bufLen
=
tEncodeTSmaWrapper
(
NULL
,
&
tSmaWrapper
);
uint32_t
bufLen
=
tEncodeTSmaWrapper
(
NULL
,
&
tSmaWrapper
);
void
*
buf
=
taosMemoryCalloc
(
1
,
bufLen
);
void
*
buf
=
taosMemoryCalloc
(
1
,
bufLen
);
ASSER
T_NE
(
buf
,
nullptr
);
EXPEC
T_NE
(
buf
,
nullptr
);
STSmaWrapper
*
pSW
=
(
STSmaWrapper
*
)
buf
;
STSmaWrapper
*
pSW
=
(
STSmaWrapper
*
)
buf
;
uint32_t
len
=
tEncodeTSmaWrapper
(
&
buf
,
&
tSmaWrapper
);
uint32_t
len
=
tEncodeTSmaWrapper
(
&
buf
,
&
tSmaWrapper
);
ASSER
T_EQ
(
len
,
bufLen
);
EXPEC
T_EQ
(
len
,
bufLen
);
// decode
// decode
STSmaWrapper
dstTSmaWrapper
=
{
0
};
STSmaWrapper
dstTSmaWrapper
=
{
0
};
void
*
result
=
tDecodeTSmaWrapper
(
pSW
,
&
dstTSmaWrapper
);
void
*
result
=
tDecodeTSmaWrapper
(
pSW
,
&
dstTSmaWrapper
);
ASSER
T_NE
(
result
,
nullptr
);
EXPEC
T_NE
(
result
,
nullptr
);
ASSER
T_EQ
(
tSmaWrapper
.
number
,
dstTSmaWrapper
.
number
);
EXPEC
T_EQ
(
tSmaWrapper
.
number
,
dstTSmaWrapper
.
number
);
for
(
int
i
=
0
;
i
<
tSmaWrapper
.
number
;
++
i
)
{
for
(
int
i
=
0
;
i
<
tSmaWrapper
.
number
;
++
i
)
{
STSma
*
pSma
=
tSmaWrapper
.
tSma
+
i
;
STSma
*
pSma
=
tSmaWrapper
.
tSma
+
i
;
STSma
*
qSma
=
dstTSmaWrapper
.
tSma
+
i
;
STSma
*
qSma
=
dstTSmaWrapper
.
tSma
+
i
;
ASSER
T_EQ
(
pSma
->
version
,
qSma
->
version
);
EXPEC
T_EQ
(
pSma
->
version
,
qSma
->
version
);
ASSER
T_EQ
(
pSma
->
intervalUnit
,
qSma
->
intervalUnit
);
EXPEC
T_EQ
(
pSma
->
intervalUnit
,
qSma
->
intervalUnit
);
ASSER
T_EQ
(
pSma
->
slidingUnit
,
qSma
->
slidingUnit
);
EXPEC
T_EQ
(
pSma
->
slidingUnit
,
qSma
->
slidingUnit
);
ASSER
T_STRCASEEQ
(
pSma
->
indexName
,
qSma
->
indexName
);
EXPEC
T_STRCASEEQ
(
pSma
->
indexName
,
qSma
->
indexName
);
ASSER
T_EQ
(
pSma
->
timezoneInt
,
qSma
->
timezoneInt
);
EXPEC
T_EQ
(
pSma
->
timezoneInt
,
qSma
->
timezoneInt
);
ASSER
T_EQ
(
pSma
->
indexUid
,
qSma
->
indexUid
);
EXPEC
T_EQ
(
pSma
->
indexUid
,
qSma
->
indexUid
);
ASSER
T_EQ
(
pSma
->
tableUid
,
qSma
->
tableUid
);
EXPEC
T_EQ
(
pSma
->
tableUid
,
qSma
->
tableUid
);
ASSER
T_EQ
(
pSma
->
interval
,
qSma
->
interval
);
EXPEC
T_EQ
(
pSma
->
interval
,
qSma
->
interval
);
ASSER
T_EQ
(
pSma
->
sliding
,
qSma
->
sliding
);
EXPEC
T_EQ
(
pSma
->
sliding
,
qSma
->
sliding
);
ASSER
T_EQ
(
pSma
->
exprLen
,
qSma
->
exprLen
);
EXPEC
T_EQ
(
pSma
->
exprLen
,
qSma
->
exprLen
);
ASSER
T_STRCASEEQ
(
pSma
->
expr
,
qSma
->
expr
);
EXPEC
T_STRCASEEQ
(
pSma
->
expr
,
qSma
->
expr
);
ASSER
T_EQ
(
pSma
->
tagsFilterLen
,
qSma
->
tagsFilterLen
);
EXPEC
T_EQ
(
pSma
->
tagsFilterLen
,
qSma
->
tagsFilterLen
);
ASSER
T_STRCASEEQ
(
pSma
->
tagsFilter
,
qSma
->
tagsFilter
);
EXPEC
T_STRCASEEQ
(
pSma
->
tagsFilter
,
qSma
->
tagsFilter
);
}
}
// resource release
// resource release
...
@@ -173,12 +178,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -173,12 +178,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
expr
=
(
char
*
)
taosMemoryCalloc
(
1
,
tSma
.
exprLen
+
1
);
tSma
.
expr
=
(
char
*
)
taosMemoryCalloc
(
1
,
tSma
.
exprLen
+
1
);
ASSER
T_NE
(
tSma
.
expr
,
nullptr
);
EXPEC
T_NE
(
tSma
.
expr
,
nullptr
);
tstrncpy
(
tSma
.
expr
,
expr
,
tSma
.
exprLen
+
1
);
tstrncpy
(
tSma
.
expr
,
expr
,
tSma
.
exprLen
+
1
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
tSma
.
tagsFilter
=
(
char
*
)
taosMemoryCalloc
(
tSma
.
tagsFilterLen
+
1
,
1
);
tSma
.
tagsFilter
=
(
char
*
)
taosMemoryCalloc
(
tSma
.
tagsFilterLen
+
1
,
1
);
ASSER
T_NE
(
tSma
.
tagsFilter
,
nullptr
);
EXPEC
T_NE
(
tSma
.
tagsFilter
,
nullptr
);
tstrncpy
(
tSma
.
tagsFilter
,
tagsFilter
,
tSma
.
tagsFilterLen
+
1
);
tstrncpy
(
tSma
.
tagsFilter
,
tagsFilter
,
tSma
.
tagsFilterLen
+
1
);
SMeta
*
pMeta
=
NULL
;
SMeta
*
pMeta
=
NULL
;
...
@@ -190,7 +195,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -190,7 +195,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
assert
(
pMeta
!=
NULL
);
assert
(
pMeta
!=
NULL
);
// save index 1
// save index 1
ASSER
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
EXPEC
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
pSmaCfg
->
indexUid
=
indexUid2
;
pSmaCfg
->
indexUid
=
indexUid2
;
tstrncpy
(
pSmaCfg
->
indexName
,
smaIndexName2
,
TSDB_INDEX_NAME_LEN
);
tstrncpy
(
pSmaCfg
->
indexName
,
smaIndexName2
,
TSDB_INDEX_NAME_LEN
);
...
@@ -201,7 +206,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -201,7 +206,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
pSmaCfg
->
sliding
=
5
;
pSmaCfg
->
sliding
=
5
;
// save index 2
// save index 2
ASSER
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
EXPEC
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
// get value by indexName
// get value by indexName
STSma
*
qSmaCfg
=
NULL
;
STSma
*
qSmaCfg
=
NULL
;
...
@@ -211,8 +216,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -211,8 +216,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"timezone1 = %"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"timezone1 = %"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"expr1 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"expr1 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"tagsFilter1 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
printf
(
"tagsFilter1 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
ASSER
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
EXPEC
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
ASSER
T_EQ
(
qSmaCfg
->
tableUid
,
tSma
.
tableUid
);
EXPEC
T_EQ
(
qSmaCfg
->
tableUid
,
tSma
.
tableUid
);
tdDestroyTSma
(
qSmaCfg
);
tdDestroyTSma
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
...
@@ -222,8 +227,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -222,8 +227,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"timezone2 = %"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"timezone2 = %"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"expr2 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"expr2 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"tagsFilter2 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
printf
(
"tagsFilter2 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
ASSER
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
EXPEC
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
ASSER
T_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
EXPEC
T_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
tdDestroyTSma
(
qSmaCfg
);
tdDestroyTSma
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
...
@@ -239,25 +244,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -239,25 +244,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"indexName = %s
\n
"
,
indexName
);
printf
(
"indexName = %s
\n
"
,
indexName
);
++
indexCnt
;
++
indexCnt
;
}
}
ASSER
T_EQ
(
indexCnt
,
nCntTSma
);
EXPEC
T_EQ
(
indexCnt
,
nCntTSma
);
metaCloseSmaCurosr
(
pSmaCur
);
metaCloseSmaCurosr
(
pSmaCur
);
// get wrapper by table uid
// get wrapper by table uid
STSmaWrapper
*
pSW
=
metaGetSmaInfoByTable
(
pMeta
,
tbUid
);
STSmaWrapper
*
pSW
=
metaGetSmaInfoByTable
(
pMeta
,
tbUid
);
assert
(
pSW
!=
NULL
);
assert
(
pSW
!=
NULL
);
ASSER
T_EQ
(
pSW
->
number
,
nCntTSma
);
EXPEC
T_EQ
(
pSW
->
number
,
nCntTSma
);
ASSER
T_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
EXPEC
T_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
ASSER
T_EQ
(
pSW
->
tSma
->
timezoneInt
,
timezone
);
EXPEC
T_EQ
(
pSW
->
tSma
->
timezoneInt
,
timezone
);
ASSER
T_STRCASEEQ
(
pSW
->
tSma
->
expr
,
expr
);
EXPEC
T_STRCASEEQ
(
pSW
->
tSma
->
expr
,
expr
);
ASSER
T_STRCASEEQ
(
pSW
->
tSma
->
tagsFilter
,
tagsFilter
);
EXPEC
T_STRCASEEQ
(
pSW
->
tSma
->
tagsFilter
,
tagsFilter
);
ASSER
T_EQ
(
pSW
->
tSma
->
indexUid
,
indexUid1
);
EXPEC
T_EQ
(
pSW
->
tSma
->
indexUid
,
indexUid1
);
ASSER
T_EQ
(
pSW
->
tSma
->
tableUid
,
tbUid
);
EXPEC
T_EQ
(
pSW
->
tSma
->
tableUid
,
tbUid
);
ASSER
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
EXPEC
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
ASSER
T_EQ
((
pSW
->
tSma
+
1
)
->
timezoneInt
,
timezone
);
EXPEC
T_EQ
((
pSW
->
tSma
+
1
)
->
timezoneInt
,
timezone
);
ASSER
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
expr
,
expr
);
EXPEC
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
expr
,
expr
);
ASSER
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
tagsFilter
,
tagsFilter
);
EXPEC
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
tagsFilter
,
tagsFilter
);
ASSER
T_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
EXPEC
T_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
ASSER
T_EQ
((
pSW
->
tSma
+
1
)
->
tableUid
,
tbUid
);
EXPEC
T_EQ
((
pSW
->
tSma
+
1
)
->
tableUid
,
tbUid
);
tdDestroyTSmaWrapper
(
pSW
);
tdDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
taosMemoryFreeClear
(
pSW
);
...
@@ -269,7 +274,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -269,7 +274,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"metaGetSmaTbUids: uid[%"
PRIu32
"] = %"
PRIi64
"
\n
"
,
i
,
*
(
tb_uid_t
*
)
taosArrayGet
(
pUids
,
i
));
printf
(
"metaGetSmaTbUids: uid[%"
PRIu32
"] = %"
PRIi64
"
\n
"
,
i
,
*
(
tb_uid_t
*
)
taosArrayGet
(
pUids
,
i
));
// printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i));
// printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i));
}
}
ASSER
T_EQ
(
taosArrayGetSize
(
pUids
),
1
);
EXPEC
T_EQ
(
taosArrayGetSize
(
pUids
),
1
);
taosArrayDestroy
(
pUids
);
taosArrayDestroy
(
pUids
);
// resource release
// resource release
...
@@ -311,12 +316,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -311,12 +316,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
expr
=
(
char
*
)
taosMemoryCalloc
(
1
,
tSma
.
exprLen
+
1
);
tSma
.
expr
=
(
char
*
)
taosMemoryCalloc
(
1
,
tSma
.
exprLen
+
1
);
ASSER
T_NE
(
tSma
.
expr
,
nullptr
);
EXPEC
T_NE
(
tSma
.
expr
,
nullptr
);
tstrncpy
(
tSma
.
expr
,
expr
,
tSma
.
exprLen
+
1
);
tstrncpy
(
tSma
.
expr
,
expr
,
tSma
.
exprLen
+
1
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
tSma
.
tagsFilter
=
(
char
*
)
taosMemoryCalloc
(
1
,
tSma
.
tagsFilterLen
+
1
);
tSma
.
tagsFilter
=
(
char
*
)
taosMemoryCalloc
(
1
,
tSma
.
tagsFilterLen
+
1
);
ASSER
T_NE
(
tSma
.
tagsFilter
,
nullptr
);
EXPEC
T_NE
(
tSma
.
tagsFilter
,
nullptr
);
tstrncpy
(
tSma
.
tagsFilter
,
tagsFilter
,
tSma
.
tagsFilterLen
+
1
);
tstrncpy
(
tSma
.
tagsFilter
,
tagsFilter
,
tSma
.
tagsFilterLen
+
1
);
SMeta
*
pMeta
=
NULL
;
SMeta
*
pMeta
=
NULL
;
...
@@ -328,7 +333,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -328,7 +333,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
assert
(
pMeta
!=
NULL
);
assert
(
pMeta
!=
NULL
);
// save index 1
// save index 1
ASSER
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
EXPEC
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
// step 2: insert data
// step 2: insert data
STsdb
*
pTsdb
=
(
STsdb
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STsdb
));
STsdb
*
pTsdb
=
(
STsdb
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STsdb
));
...
@@ -365,7 +370,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -365,7 +370,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
strncpy
(
pDisks
.
dir
,
"/var/lib/taos"
,
TSDB_FILENAME_LEN
);
strncpy
(
pDisks
.
dir
,
"/var/lib/taos"
,
TSDB_FILENAME_LEN
);
int32_t
numOfDisks
=
1
;
int32_t
numOfDisks
=
1
;
pTsdb
->
pTfs
=
tfsOpen
(
&
pDisks
,
numOfDisks
);
pTsdb
->
pTfs
=
tfsOpen
(
&
pDisks
,
numOfDisks
);
ASSER
T_NE
(
pTsdb
->
pTfs
,
nullptr
);
EXPEC
T_NE
(
pTsdb
->
pTfs
,
nullptr
);
// generate SSubmitReq msg and update expired window
// generate SSubmitReq msg and update expired window
int16_t
schemaVer
=
0
;
int16_t
schemaVer
=
0
;
...
@@ -375,7 +380,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -375,7 +380,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
uint32_t
msgLen
=
sizeof
(
SSubmitReq
)
+
mockBlkNum
*
sizeof
(
SSubmitBlk
)
+
mockBlkNum
*
mockRowNum
*
mockRowLen
;
uint32_t
msgLen
=
sizeof
(
SSubmitReq
)
+
mockBlkNum
*
sizeof
(
SSubmitBlk
)
+
mockBlkNum
*
mockRowNum
*
mockRowLen
;
SSubmitReq
*
pMsg
=
(
SSubmitReq
*
)
taosMemoryCalloc
(
1
,
msgLen
);
SSubmitReq
*
pMsg
=
(
SSubmitReq
*
)
taosMemoryCalloc
(
1
,
msgLen
);
ASSER
T_NE
(
pMsg
,
nullptr
);
EXPEC
T_NE
(
pMsg
,
nullptr
);
pMsg
->
version
=
htobe64
(
schemaVer
);
pMsg
->
version
=
htobe64
(
schemaVer
);
pMsg
->
numOfBlocks
=
htonl
(
mockBlkNum
);
pMsg
->
numOfBlocks
=
htonl
(
mockBlkNum
);
pMsg
->
length
=
htonl
(
msgLen
);
pMsg
->
length
=
htonl
(
msgLen
);
...
@@ -401,9 +406,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -401,9 +406,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
}
}
}
}
ASSER
T_EQ
(
tdScanAndConvertSubmitMsg
(
pMsg
),
TSDB_CODE_SUCCESS
);
EXPEC
T_EQ
(
tdScanAndConvertSubmitMsg
(
pMsg
),
TSDB_CODE_SUCCESS
);
ASSER
T_EQ
(
tsdbUpdateSmaWindow
(
pTsdb
,
(
const
char
*
)
pMsg
),
0
);
EXPEC
T_EQ
(
tsdbUpdateSmaWindow
(
pTsdb
,
(
const
char
*
)
pMsg
),
0
);
// init
// init
const
int32_t
tSmaGroupSize
=
4
;
const
int32_t
tSmaGroupSize
=
4
;
...
@@ -413,7 +418,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -413,7 +418,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
const
int32_t
tSmaNumOfRows
=
2
;
const
int32_t
tSmaNumOfRows
=
2
;
SArray
*
pDataBlocks
=
taosArrayInit
(
tSmaGroupSize
,
sizeof
(
SSDataBlock
*
));
SArray
*
pDataBlocks
=
taosArrayInit
(
tSmaGroupSize
,
sizeof
(
SSDataBlock
*
));
ASSER
T_NE
(
pDataBlocks
,
nullptr
);
EXPEC
T_NE
(
pDataBlocks
,
nullptr
);
int32_t
tSmaTypeArray
[
tSmaNumOfCols
]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_INT
,
int32_t
tSmaTypeArray
[
tSmaNumOfCols
]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_VARCHAR
,
TSDB_DATA_TYPE_NCHAR
};
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_VARCHAR
,
TSDB_DATA_TYPE_NCHAR
};
...
@@ -427,18 +432,18 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -427,18 +432,18 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
for
(
int32_t
g
=
0
;
g
<
tSmaGroupSize
;
++
g
)
{
for
(
int32_t
g
=
0
;
g
<
tSmaGroupSize
;
++
g
)
{
SSDataBlock
*
pDataBlock
=
(
SSDataBlock
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
SSDataBlock
*
pDataBlock
=
(
SSDataBlock
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
ASSER
T_NE
(
pDataBlock
,
nullptr
);
EXPEC
T_NE
(
pDataBlock
,
nullptr
);
pDataBlock
->
pBlockAgg
=
NULL
;
pDataBlock
->
pBlockAgg
=
NULL
;
pDataBlock
->
info
.
numOfCols
=
tSmaNumOfCols
;
pDataBlock
->
info
.
numOfCols
=
tSmaNumOfCols
;
pDataBlock
->
info
.
rows
=
tSmaNumOfRows
;
pDataBlock
->
info
.
rows
=
tSmaNumOfRows
;
pDataBlock
->
info
.
groupId
=
tSmaGroupId
+
g
;
pDataBlock
->
info
.
groupId
=
tSmaGroupId
+
g
;
pDataBlock
->
pDataBlock
=
taosArrayInit
(
tSmaNumOfCols
,
sizeof
(
SColumnInfoData
*
));
pDataBlock
->
pDataBlock
=
taosArrayInit
(
tSmaNumOfCols
,
sizeof
(
SColumnInfoData
*
));
ASSER
T_NE
(
pDataBlock
->
pDataBlock
,
nullptr
);
EXPEC
T_NE
(
pDataBlock
->
pDataBlock
,
nullptr
);
for
(
int32_t
c
=
0
;
c
<
tSmaNumOfCols
;
++
c
)
{
for
(
int32_t
c
=
0
;
c
<
tSmaNumOfCols
;
++
c
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
));
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
));
ASSER
T_NE
(
pColInfoData
,
nullptr
);
EXPEC
T_NE
(
pColInfoData
,
nullptr
);
pColInfoData
->
info
.
type
=
tSmaTypeArray
[
c
];
pColInfoData
->
info
.
type
=
tSmaTypeArray
[
c
];
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
...
@@ -481,7 +486,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -481,7 +486,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
memcpy
(
varDataVal
(
pCellData
),
tSmaGroupbyTags
[
g
*
2
+
1
],
varDataLen
(
pCellData
));
memcpy
(
varDataVal
(
pCellData
),
tSmaGroupbyTags
[
g
*
2
+
1
],
varDataLen
(
pCellData
));
break
;
break
;
default:
default:
ASSER
T_EQ
(
0
,
1
);
// add definition
EXPEC
T_EQ
(
0
,
1
);
// add definition
break
;
break
;
}
}
}
}
...
@@ -493,7 +498,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -493,7 +498,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
}
}
// execute
// execute
ASSER
T_EQ
(
tsdbInsertTSmaData
(
pTsdb
,
tSma
.
indexUid
,
(
const
char
*
)
pDataBlocks
),
TSDB_CODE_SUCCESS
);
EXPEC
T_EQ
(
tsdbInsertTSmaData
(
pTsdb
,
tSma
.
indexUid
,
(
const
char
*
)
pDataBlocks
),
TSDB_CODE_SUCCESS
);
#if 0
#if 0
STSmaDataWrapper *pSmaData = NULL;
STSmaDataWrapper *pSmaData = NULL;
...
@@ -512,7 +517,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -512,7 +517,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
int32_t tableDataLen = sizeof(STSmaTbData);
int32_t tableDataLen = sizeof(STSmaTbData);
for (col_id_t c = 0; c < numOfCols; ++c) {
for (col_id_t c = 0; c < numOfCols; ++c) {
if (bufSize - len - tableDataLen < buffer) {
if (bufSize - len - tableDataLen < buffer) {
ASSER
T_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
EXPEC
T_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
pSmaData = (STSmaDataWrapper *)buf;
pSmaData = (STSmaDataWrapper *)buf;
pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
bufSize = taosTSizeof(buf);
bufSize = taosTSizeof(buf);
...
@@ -539,14 +544,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -539,14 +544,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
}
}
pSmaData->dataLen = (len - sizeof(STSmaDataWrapper));
pSmaData->dataLen = (len - sizeof(STSmaDataWrapper));
ASSER
T_GE(bufSize, pSmaData->dataLen);
EXPEC
T_GE(bufSize, pSmaData->dataLen);
// execute
// execute
ASSER
T_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
EXPEC
T_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
#endif
#endif
// step 3: query
// step 3: query
uint32_t
checkDataCnt
=
0
;
uint32_t
checkDataCnt
=
0
;
ASSER
T_EQ
(
tsdbGetTSmaData
(
pTsdb
,
NULL
,
indexUid1
,
skey1
,
1
),
TSDB_CODE_SUCCESS
);
EXPEC
T_EQ
(
tsdbGetTSmaData
(
pTsdb
,
NULL
,
indexUid1
,
skey1
,
1
),
TSDB_CODE_SUCCESS
);
++
checkDataCnt
;
++
checkDataCnt
;
printf
(
"%s:%d The sma data check count for insert and query is %"
PRIu32
"
\n
"
,
__FILE__
,
__LINE__
,
checkDataCnt
);
printf
(
"%s:%d The sma data check count for insert and query is %"
PRIu32
"
\n
"
,
__FILE__
,
__LINE__
,
checkDataCnt
);
...
@@ -555,11 +560,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -555,11 +560,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
taosMemoryFreeClear
(
pMsg
);
taosMemoryFreeClear
(
pMsg
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pDataBlocks
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pDataBlocks
);
++
i
)
{
SSDataBlock
*
pDataBlock
=
(
SSDataBlock
*
)
taosArrayGet
(
pDataBlocks
,
i
);
SSDataBlock
*
pDataBlock
=
*
(
SSDataBlock
*
*
)
taosArrayGet
(
pDataBlocks
,
i
);
int32_t
numOfOutput
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
numOfOutput
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
j
);
SColumnInfoData
*
pColInfoData
=
*
(
SColumnInfoData
*
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
j
);
colDataDestroy
(
pColInfoData
);
colDataDestroy
(
pColInfoData
);
taosMemoryFreeClear
(
pColInfoData
);
}
}
taosArrayDestroy
(
pDataBlock
->
pDataBlock
);
taosArrayDestroy
(
pDataBlock
->
pDataBlock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录