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
STColumn
*
pCol
=
NULL
;
STSchema
*
pSchema
=
pIter
->
pSchema
;
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
)
{
++
pIter
->
colIdx
;
break
;
}
else
if
(
colId
<
pCol
->
colId
)
{
++
pIter
->
colIdx
;
...
...
@@ -948,7 +947,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
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
))
{
return
tdGetKvRowValOfColEx
(
pIter
,
colId
,
colType
,
&
pIter
->
kvIdx
,
pVal
);
}
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
return
len
;
}
static
FORCE_INLINE
int
tsdbRLockSma
(
SSmaEnv
*
pEnv
)
{
static
FORCE_INLINE
int
32_t
tsdbRLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
...
...
@@ -60,7 +60,7 @@ static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) {
return
0
;
}
static
FORCE_INLINE
int
tsdbWLockSma
(
SSmaEnv
*
pEnv
)
{
static
FORCE_INLINE
int
32_t
tsdbWLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
...
...
@@ -69,7 +69,7 @@ static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) {
return
0
;
}
static
FORCE_INLINE
int
tsdbUnLockSma
(
SSmaEnv
*
pEnv
)
{
static
FORCE_INLINE
int
32_t
tsdbUnLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
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) {
*/
static
int32_t
tsdbInsertTSmaBlocks
(
STSmaWriteH
*
pSmaH
,
void
*
smaKey
,
uint32_t
keyLen
,
void
*
pData
,
uint32_t
dataLen
)
{
SDBFile
*
pDBFile
=
&
pSmaH
->
dFile
;
tsdbDebug
(
"vgId:%d insert sma data blocks into %s: smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
", dataLen %d"
,
REPO_ID
(
pSmaH
->
pTsdb
),
pDBFile
->
path
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
dataLen
);
printf
(
"
\n
vgId:%d insert sma data blocks into %s: smaKey %"
PRIx64
"-%"
PRIx64
", dataLen %"
PRIu32
"
\n
"
,
REPO_ID
(
pSmaH
->
pTsdb
),
pDBFile
->
path
,
*
(
int64_t
*
)
smaKey
,
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
dataLen
);
// TODO: insert sma data blocks into B+Tree(TDB)
if
(
tsdbSaveSmaToDB
(
pDBFile
,
smaKey
,
keyLen
,
pData
,
dataLen
)
!=
0
)
{
...
...
@@ -874,7 +873,6 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
// key: skey + groupId
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
void
*
pSmaKey
=
&
smaKey
;
char
dataBuf
[
512
]
=
{
0
};
void
*
pDataBuf
=
&
dataBuf
;
int32_t
sz
=
taosArrayGetSize
(
pDataBlocks
);
...
...
@@ -887,6 +885,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
for
(
int32_t
j
=
0
;
j
<
rows
;
++
j
)
{
printf
(
"|"
);
TSKEY
skey
=
TSKEY_INITIAL_VAL
;
// the start key of TS window by interval
void
*
pSmaKey
=
&
smaKey
;
int32_t
tlen
=
0
;
for
(
int32_t
k
=
0
;
k
<
colNum
;
++
k
)
{
SColumnInfoData
*
pColInfoData
=
*
(
SColumnInfoData
**
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
k
);
...
...
@@ -894,7 +893,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char
switch
(
pColInfoData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
skey
=
*
(
TSKEY
*
)
var
;
printf
(
" skey = %"
PRIi64
" groupId = %"
PRId64
"|"
,
skey
,
groupId
);
printf
(
"
==>
skey = %"
PRIi64
" groupId = %"
PRId64
"|"
,
skey
,
groupId
);
tsdbEncodeTSmaKey
(
groupId
,
skey
,
&
pSmaKey
);
break
;
case
TSDB_DATA_TYPE_BOOL
:
...
...
@@ -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
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
skey
,
groupId
,
tstrerror
(
terrno
));
...
...
@@ -1313,17 +1312,14 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, char *pData, int64_t indexUid,
int64_t
queryGroupId
=
1
;
tsdbEncodeTSmaKey
(
queryGroupId
,
querySKey
,
(
void
**
)
&
pSmaKey
);
tsdbDebug
(
"vgId:%d get sma data from %s: smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
", keyLen %d"
,
REPO_ID
(
pTsdb
),
tReadH
.
dFile
.
path
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
SMA_KEY_LEN
);
tsdbDebug
(
"vgId:%d get sma data from %s: smaKey %"
PRIx64
"-%"
PRIx64
", keyLen %d"
,
REPO_ID
(
pTsdb
),
tReadH
.
dFile
.
path
,
*
(
int64_t
*
)
smaKey
,
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
SMA_KEY_LEN
);
void
*
result
=
NULL
;
uint32_t
valueSize
=
0
;
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
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
tstrerror
(
terrno
));
tsdbWarn
(
"vgId:%d get sma data failed from smaIndex %"
PRIi64
", smaKey %"
PRIx64
"-%"
PRIx64
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
*
(
int64_t
*
)
smaKey
,
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
tstrerror
(
terrno
));
tsdbCloseDBF
(
&
tReadH
.
dFile
);
return
TSDB_CODE_FAILED
;
}
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
5a6bf4c3
...
...
@@ -59,20 +59,21 @@ TEST(testCase, unionEncodeDecodeTest) {
void
*
buf
=
taosMemoryMalloc
(
1024
);
void
*
pBuf
=
buf
;
void
*
qBuf
=
buf
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU8
(
&
b
uf
,
sut
.
info
);
tlen
+=
taosEncodeFixedI16
(
&
b
uf
,
sut
.
nBSmaCols
);
tlen
+=
taosEncodeFixedU8
(
&
pB
uf
,
sut
.
info
);
tlen
+=
taosEncodeFixedI16
(
&
pB
uf
,
sut
.
nBSmaCols
);
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
};
pBuf
=
taosDecodeFixedU8
(
p
Buf
,
&
dut
.
info
);
pBuf
=
taosDecodeFixedI16
(
p
Buf
,
&
dut
.
nBSmaCols
);
qBuf
=
taosDecodeFixedU8
(
q
Buf
,
&
dut
.
info
);
qBuf
=
taosDecodeFixedI16
(
q
Buf
,
&
dut
.
nBSmaCols
);
if
(
dut
.
nBSmaCols
>
0
)
{
dut
.
pBSmaCols
=
(
col_id_t
*
)
taosMemoryMalloc
(
dut
.
nBSmaCols
*
sizeof
(
col_id_t
));
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
{
dut
.
pBSmaCols
=
NULL
;
...
...
@@ -81,13 +82,17 @@ TEST(testCase, unionEncodeDecodeTest) {
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
);
ASSER
T_EQ
(
sut
.
rollup
,
dut
.
rollup
);
ASSER
T_EQ
(
sut
.
type
,
dut
.
type
);
ASSER
T_EQ
(
sut
.
nBSmaCols
,
dut
.
nBSmaCols
);
EXPEC
T_EQ
(
sut
.
rollup
,
dut
.
rollup
);
EXPEC
T_EQ
(
sut
.
type
,
dut
.
type
);
EXPEC
T_EQ
(
sut
.
nBSmaCols
,
dut
.
nBSmaCols
);
for
(
col_id_t
i
=
0
;
i
<
sut
.
nBSmaCols
;
++
i
)
{
ASSER
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
),
sut
.
pBSmaCols
[
i
]);
EXPEC
T_EQ
(
*
(
col_id_t
*
)(
sut
.
pBSmaCols
+
i
),
dut
.
pBSmaCols
[
i
]);
}
taosMemoryFreeClear
(
buf
);
taosMemoryFreeClear
(
dut
.
pBSmaCols
);
taosMemoryFreeClear
(
sut
.
pBSmaCols
);
}
#if 1
TEST
(
testCase
,
tSma_Meta_Encode_Decode_Test
)
{
...
...
@@ -107,37 +112,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
uint32_t
bufLen
=
tEncodeTSmaWrapper
(
NULL
,
&
tSmaWrapper
);
void
*
buf
=
taosMemoryCalloc
(
1
,
bufLen
);
ASSER
T_NE
(
buf
,
nullptr
);
EXPEC
T_NE
(
buf
,
nullptr
);
STSmaWrapper
*
pSW
=
(
STSmaWrapper
*
)
buf
;
uint32_t
len
=
tEncodeTSmaWrapper
(
&
buf
,
&
tSmaWrapper
);
ASSER
T_EQ
(
len
,
bufLen
);
EXPEC
T_EQ
(
len
,
bufLen
);
// decode
STSmaWrapper
dstTSmaWrapper
=
{
0
};
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
)
{
STSma
*
pSma
=
tSmaWrapper
.
tSma
+
i
;
STSma
*
qSma
=
dstTSmaWrapper
.
tSma
+
i
;
ASSER
T_EQ
(
pSma
->
version
,
qSma
->
version
);
ASSER
T_EQ
(
pSma
->
intervalUnit
,
qSma
->
intervalUnit
);
ASSER
T_EQ
(
pSma
->
slidingUnit
,
qSma
->
slidingUnit
);
ASSER
T_STRCASEEQ
(
pSma
->
indexName
,
qSma
->
indexName
);
ASSER
T_EQ
(
pSma
->
timezoneInt
,
qSma
->
timezoneInt
);
ASSER
T_EQ
(
pSma
->
indexUid
,
qSma
->
indexUid
);
ASSER
T_EQ
(
pSma
->
tableUid
,
qSma
->
tableUid
);
ASSER
T_EQ
(
pSma
->
interval
,
qSma
->
interval
);
ASSER
T_EQ
(
pSma
->
sliding
,
qSma
->
sliding
);
ASSER
T_EQ
(
pSma
->
exprLen
,
qSma
->
exprLen
);
ASSER
T_STRCASEEQ
(
pSma
->
expr
,
qSma
->
expr
);
ASSER
T_EQ
(
pSma
->
tagsFilterLen
,
qSma
->
tagsFilterLen
);
ASSER
T_STRCASEEQ
(
pSma
->
tagsFilter
,
qSma
->
tagsFilter
);
EXPEC
T_EQ
(
pSma
->
version
,
qSma
->
version
);
EXPEC
T_EQ
(
pSma
->
intervalUnit
,
qSma
->
intervalUnit
);
EXPEC
T_EQ
(
pSma
->
slidingUnit
,
qSma
->
slidingUnit
);
EXPEC
T_STRCASEEQ
(
pSma
->
indexName
,
qSma
->
indexName
);
EXPEC
T_EQ
(
pSma
->
timezoneInt
,
qSma
->
timezoneInt
);
EXPEC
T_EQ
(
pSma
->
indexUid
,
qSma
->
indexUid
);
EXPEC
T_EQ
(
pSma
->
tableUid
,
qSma
->
tableUid
);
EXPEC
T_EQ
(
pSma
->
interval
,
qSma
->
interval
);
EXPEC
T_EQ
(
pSma
->
sliding
,
qSma
->
sliding
);
EXPEC
T_EQ
(
pSma
->
exprLen
,
qSma
->
exprLen
);
EXPEC
T_STRCASEEQ
(
pSma
->
expr
,
qSma
->
expr
);
EXPEC
T_EQ
(
pSma
->
tagsFilterLen
,
qSma
->
tagsFilterLen
);
EXPEC
T_STRCASEEQ
(
pSma
->
tagsFilter
,
qSma
->
tagsFilter
);
}
// resource release
...
...
@@ -173,12 +178,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
tSma
.
exprLen
=
strlen
(
expr
);
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
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
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
);
SMeta
*
pMeta
=
NULL
;
...
...
@@ -190,7 +195,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
assert
(
pMeta
!=
NULL
);
// save index 1
ASSER
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
EXPEC
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
pSmaCfg
->
indexUid
=
indexUid2
;
tstrncpy
(
pSmaCfg
->
indexName
,
smaIndexName2
,
TSDB_INDEX_NAME_LEN
);
...
...
@@ -201,7 +206,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
pSmaCfg
->
sliding
=
5
;
// save index 2
ASSER
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
EXPEC
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
// get value by indexName
STSma
*
qSmaCfg
=
NULL
;
...
...
@@ -211,8 +216,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"timezone1 = %"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"expr1 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"tagsFilter1 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
ASSER
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
ASSER
T_EQ
(
qSmaCfg
->
tableUid
,
tSma
.
tableUid
);
EXPEC
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
EXPEC
T_EQ
(
qSmaCfg
->
tableUid
,
tSma
.
tableUid
);
tdDestroyTSma
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
...
...
@@ -222,8 +227,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"timezone2 = %"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"expr2 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"tagsFilter2 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
ASSER
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
ASSER
T_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
EXPEC
T_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
EXPEC
T_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
tdDestroyTSma
(
qSmaCfg
);
taosMemoryFreeClear
(
qSmaCfg
);
...
...
@@ -239,25 +244,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
printf
(
"indexName = %s
\n
"
,
indexName
);
++
indexCnt
;
}
ASSER
T_EQ
(
indexCnt
,
nCntTSma
);
EXPEC
T_EQ
(
indexCnt
,
nCntTSma
);
metaCloseSmaCurosr
(
pSmaCur
);
// get wrapper by table uid
STSmaWrapper
*
pSW
=
metaGetSmaInfoByTable
(
pMeta
,
tbUid
);
assert
(
pSW
!=
NULL
);
ASSER
T_EQ
(
pSW
->
number
,
nCntTSma
);
ASSER
T_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
ASSER
T_EQ
(
pSW
->
tSma
->
timezoneInt
,
timezone
);
ASSER
T_STRCASEEQ
(
pSW
->
tSma
->
expr
,
expr
);
ASSER
T_STRCASEEQ
(
pSW
->
tSma
->
tagsFilter
,
tagsFilter
);
ASSER
T_EQ
(
pSW
->
tSma
->
indexUid
,
indexUid1
);
ASSER
T_EQ
(
pSW
->
tSma
->
tableUid
,
tbUid
);
ASSER
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
ASSER
T_EQ
((
pSW
->
tSma
+
1
)
->
timezoneInt
,
timezone
);
ASSER
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
expr
,
expr
);
ASSER
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
tagsFilter
,
tagsFilter
);
ASSER
T_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
ASSER
T_EQ
((
pSW
->
tSma
+
1
)
->
tableUid
,
tbUid
);
EXPEC
T_EQ
(
pSW
->
number
,
nCntTSma
);
EXPEC
T_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
EXPEC
T_EQ
(
pSW
->
tSma
->
timezoneInt
,
timezone
);
EXPEC
T_STRCASEEQ
(
pSW
->
tSma
->
expr
,
expr
);
EXPEC
T_STRCASEEQ
(
pSW
->
tSma
->
tagsFilter
,
tagsFilter
);
EXPEC
T_EQ
(
pSW
->
tSma
->
indexUid
,
indexUid1
);
EXPEC
T_EQ
(
pSW
->
tSma
->
tableUid
,
tbUid
);
EXPEC
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
EXPEC
T_EQ
((
pSW
->
tSma
+
1
)
->
timezoneInt
,
timezone
);
EXPEC
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
expr
,
expr
);
EXPEC
T_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
tagsFilter
,
tagsFilter
);
EXPEC
T_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
EXPEC
T_EQ
((
pSW
->
tSma
+
1
)
->
tableUid
,
tbUid
);
tdDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
...
...
@@ -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: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i));
}
ASSER
T_EQ
(
taosArrayGetSize
(
pUids
),
1
);
EXPEC
T_EQ
(
taosArrayGetSize
(
pUids
),
1
);
taosArrayDestroy
(
pUids
);
// resource release
...
...
@@ -311,12 +316,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
tSma
.
exprLen
=
strlen
(
expr
);
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
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
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
);
SMeta
*
pMeta
=
NULL
;
...
...
@@ -328,7 +333,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
assert
(
pMeta
!=
NULL
);
// save index 1
ASSER
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
EXPEC
T_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
// step 2: insert data
STsdb
*
pTsdb
=
(
STsdb
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STsdb
));
...
...
@@ -365,7 +370,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
strncpy
(
pDisks
.
dir
,
"/var/lib/taos"
,
TSDB_FILENAME_LEN
);
int32_t
numOfDisks
=
1
;
pTsdb
->
pTfs
=
tfsOpen
(
&
pDisks
,
numOfDisks
);
ASSER
T_NE
(
pTsdb
->
pTfs
,
nullptr
);
EXPEC
T_NE
(
pTsdb
->
pTfs
,
nullptr
);
// generate SSubmitReq msg and update expired window
int16_t
schemaVer
=
0
;
...
...
@@ -375,7 +380,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
uint32_t
msgLen
=
sizeof
(
SSubmitReq
)
+
mockBlkNum
*
sizeof
(
SSubmitBlk
)
+
mockBlkNum
*
mockRowNum
*
mockRowLen
;
SSubmitReq
*
pMsg
=
(
SSubmitReq
*
)
taosMemoryCalloc
(
1
,
msgLen
);
ASSER
T_NE
(
pMsg
,
nullptr
);
EXPEC
T_NE
(
pMsg
,
nullptr
);
pMsg
->
version
=
htobe64
(
schemaVer
);
pMsg
->
numOfBlocks
=
htonl
(
mockBlkNum
);
pMsg
->
length
=
htonl
(
msgLen
);
...
...
@@ -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
const
int32_t
tSmaGroupSize
=
4
;
...
...
@@ -413,7 +418,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
const
int32_t
tSmaNumOfRows
=
2
;
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
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_VARCHAR
,
TSDB_DATA_TYPE_NCHAR
};
...
...
@@ -427,18 +432,18 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
for
(
int32_t
g
=
0
;
g
<
tSmaGroupSize
;
++
g
)
{
SSDataBlock
*
pDataBlock
=
(
SSDataBlock
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
ASSER
T_NE
(
pDataBlock
,
nullptr
);
EXPEC
T_NE
(
pDataBlock
,
nullptr
);
pDataBlock
->
pBlockAgg
=
NULL
;
pDataBlock
->
info
.
numOfCols
=
tSmaNumOfCols
;
pDataBlock
->
info
.
rows
=
tSmaNumOfRows
;
pDataBlock
->
info
.
groupId
=
tSmaGroupId
+
g
;
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
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
));
ASSER
T_NE
(
pColInfoData
,
nullptr
);
EXPEC
T_NE
(
pColInfoData
,
nullptr
);
pColInfoData
->
info
.
type
=
tSmaTypeArray
[
c
];
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
...
...
@@ -481,7 +486,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
memcpy
(
varDataVal
(
pCellData
),
tSmaGroupbyTags
[
g
*
2
+
1
],
varDataLen
(
pCellData
));
break
;
default:
ASSER
T_EQ
(
0
,
1
);
// add definition
EXPEC
T_EQ
(
0
,
1
);
// add definition
break
;
}
}
...
...
@@ -493,7 +498,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
}
// 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
STSmaDataWrapper *pSmaData = NULL;
...
...
@@ -512,7 +517,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
int32_t tableDataLen = sizeof(STSmaTbData);
for (col_id_t c = 0; c < numOfCols; ++c) {
if (bufSize - len - tableDataLen < buffer) {
ASSER
T_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
EXPEC
T_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
pSmaData = (STSmaDataWrapper *)buf;
pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
bufSize = taosTSizeof(buf);
...
...
@@ -539,14 +544,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
}
pSmaData->dataLen = (len - sizeof(STSmaDataWrapper));
ASSER
T_GE(bufSize, pSmaData->dataLen);
EXPEC
T_GE(bufSize, pSmaData->dataLen);
// execute
ASSER
T_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
EXPEC
T_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
#endif
// step 3: query
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
;
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) {
taosMemoryFreeClear
(
pMsg
);
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
);
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
j
);
SColumnInfoData
*
pColInfoData
=
*
(
SColumnInfoData
*
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
j
);
colDataDestroy
(
pColInfoData
);
taosMemoryFreeClear
(
pColInfoData
);
}
taosArrayDestroy
(
pDataBlock
->
pDataBlock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录