Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
22829238
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
22829238
编写于
3月 06, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
put/get sma schema from bdb
上级
1688a9e0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
265 addition
and
6 deletion
+265
-6
include/common/tmsg.h
include/common/tmsg.h
+1
-1
source/dnode/vnode/inc/meta.h
source/dnode/vnode/inc/meta.h
+11
-4
source/dnode/vnode/src/inc/metaDef.h
source/dnode/vnode/src/inc/metaDef.h
+2
-0
source/dnode/vnode/src/meta/metaBDBImpl.c
source/dnode/vnode/src/meta/metaBDBImpl.c
+146
-0
source/dnode/vnode/src/meta/metaIdx.c
source/dnode/vnode/src/meta/metaIdx.c
+17
-0
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+88
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
22829238
...
@@ -1885,7 +1885,7 @@ static FORCE_INLINE void tdDestroyTSma(STSma* pSma, bool releaseSelf) {
...
@@ -1885,7 +1885,7 @@ static FORCE_INLINE void tdDestroyTSma(STSma* pSma, bool releaseSelf) {
}
}
}
}
static
FORCE_INLINE
void
tdDestroyWrapper
(
STSmaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
tdDestroy
TSma
Wrapper
(
STSmaWrapper
*
pSW
)
{
if
(
pSW
&&
pSW
->
tSma
)
{
if
(
pSW
&&
pSW
->
tSma
)
{
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
tdDestroyTSma
(
pSW
->
tSma
+
i
,
false
);
tdDestroyTSma
(
pSW
->
tSma
+
i
,
false
);
...
...
source/dnode/vnode/inc/meta.h
浏览文件 @
22829238
...
@@ -38,8 +38,10 @@ typedef struct SMetaCfg {
...
@@ -38,8 +38,10 @@ typedef struct SMetaCfg {
typedef
struct
SMTbCursor
SMTbCursor
;
typedef
struct
SMTbCursor
SMTbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMSmaCursor
SMSmaCursor
;
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTbReq
STbCfg
;
typedef
STSma
SSmaCfg
;
// SMeta operations
// SMeta operations
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
...
@@ -50,19 +52,24 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
...
@@ -50,19 +52,24 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaCommit
(
SMeta
*
pMeta
);
// For Query
// For Query
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
SSmaCfg
*
metaGetSmaInfoByName
(
SMeta
*
pMeta
,
const
char
*
indexName
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseSmaCurosr
(
SMSmaCursor
*
pSmaCur
);
const
char
*
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
// Options
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsClear
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsClear
(
SMetaCfg
*
pMetaCfg
);
...
...
source/dnode/vnode/src/inc/metaDef.h
浏览文件 @
22829238
...
@@ -33,6 +33,8 @@ int metaOpenDB(SMeta* pMeta);
...
@@ -33,6 +33,8 @@ int metaOpenDB(SMeta* pMeta);
void
metaCloseDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
SSmaCfg
*
pTbCfg
);
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
const
char
*
indexName
);
// SMetaCache
// SMetaCache
int
metaOpenCache
(
SMeta
*
pMeta
);
int
metaOpenCache
(
SMeta
*
pMeta
);
...
...
source/dnode/vnode/src/meta/metaBDBImpl.c
浏览文件 @
22829238
...
@@ -45,6 +45,7 @@ struct SMetaDB {
...
@@ -45,6 +45,7 @@ struct SMetaDB {
DB
*
pStbIdx
;
DB
*
pStbIdx
;
DB
*
pNtbIdx
;
DB
*
pNtbIdx
;
DB
*
pCtbIdx
;
DB
*
pCtbIdx
;
DB
*
pSmaIdx
;
// ENV
// ENV
DB_ENV
*
pEvn
;
DB_ENV
*
pEvn
;
};
};
...
@@ -63,6 +64,7 @@ static int metaNameIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT
...
@@ -63,6 +64,7 @@ static int metaNameIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT
static
int
metaStbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaStbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaSmaIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
...
@@ -128,11 +130,17 @@ int metaOpenDB(SMeta *pMeta) {
...
@@ -128,11 +130,17 @@ int metaOpenDB(SMeta *pMeta) {
return
-
1
;
return
-
1
;
}
}
if
(
metaOpenBDBIdx
(
&
(
pDB
->
pSmaIdx
),
pDB
->
pEvn
,
"sma.index"
,
pDB
->
pSmaDB
,
&
metaSmaIdxCb
,
true
)
<
0
)
{
metaCloseDB
(
pMeta
);
return
-
1
;
}
return
0
;
return
0
;
}
}
void
metaCloseDB
(
SMeta
*
pMeta
)
{
void
metaCloseDB
(
SMeta
*
pMeta
)
{
if
(
pMeta
->
pDB
)
{
if
(
pMeta
->
pDB
)
{
metaCloseBDBIdx
(
pMeta
->
pDB
->
pSmaIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pCtbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pCtbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pNtbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pNtbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pStbIdx
);
metaCloseBDBIdx
(
pMeta
->
pDB
->
pStbIdx
);
...
@@ -218,6 +226,49 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
...
@@ -218,6 +226,49 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
return
0
;
return
0
;
}
}
int
metaSaveSmaToDB
(
SMeta
*
pMeta
,
SSmaCfg
*
pSmaCfg
)
{
char
buf
[
512
]
=
{
0
};
// TODO: may overflow
void
*
pBuf
=
NULL
;
DBT
key1
=
{
0
},
value1
=
{
0
};
{
// save sma info
pBuf
=
buf
;
key1
.
data
=
pSmaCfg
->
indexName
;
key1
.
size
=
strlen
(
key1
.
data
);
tEncodeTSma
(
&
pBuf
,
pSmaCfg
);
value1
.
data
=
buf
;
value1
.
size
=
POINTER_DISTANCE
(
pBuf
,
buf
);
value1
.
app_data
=
pSmaCfg
;
}
metaDBWLock
(
pMeta
->
pDB
);
pMeta
->
pDB
->
pSmaDB
->
put
(
pMeta
->
pDB
->
pSmaDB
,
NULL
,
&
key1
,
&
value1
,
0
);
metaDBULock
(
pMeta
->
pDB
);
return
0
;
}
int
metaRemoveSmaFromDb
(
SMeta
*
pMeta
,
const
char
*
indexName
)
{
// TODO
#if 0
DBT key = {0};
key.data = (void *)indexName;
key.size = strlen(indexName);
metaDBWLock(pMeta->pDB);
// TODO: No guarantee of consistence.
// Use transaction or DB->sync() for some guarantee.
pMeta->pDB->pSmaDB->del(pMeta->pDB->pSmaDB, NULL, &key, 0);
metaDBULock(pMeta->pDB);
#endif
return
0
;
}
/* ------------------------ STATIC METHODS ------------------------ */
/* ------------------------ STATIC METHODS ------------------------ */
static
int
metaEncodeSchema
(
void
**
buf
,
SSchemaWrapper
*
pSW
)
{
static
int
metaEncodeSchema
(
void
**
buf
,
SSchemaWrapper
*
pSW
)
{
int
tlen
=
0
;
int
tlen
=
0
;
...
@@ -433,6 +484,16 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
...
@@ -433,6 +484,16 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
}
}
}
}
static
int
metaSmaIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
SSmaCfg
*
pSmaCfg
=
(
SSmaCfg
*
)(
pValue
->
app_data
);
memset
(
pSKey
,
0
,
sizeof
(
*
pSKey
));
pSKey
->
data
=
&
(
pSmaCfg
->
tableUid
);
pSKey
->
size
=
sizeof
(
pSmaCfg
->
tableUid
);
return
0
;
}
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
)
{
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
)
{
int
tsize
=
0
;
int
tsize
=
0
;
...
@@ -548,6 +609,36 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
...
@@ -548,6 +609,36 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
return
pTbCfg
;
return
pTbCfg
;
}
}
SSmaCfg
*
metaGetSmaInfoByName
(
SMeta
*
pMeta
,
const
char
*
indexName
)
{
SSmaCfg
*
pCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
DBT
value
=
{
0
};
int
ret
;
// Set key/value
key
.
data
=
(
void
*
)
indexName
;
key
.
size
=
strlen
(
indexName
);
// Query
metaDBRLock
(
pDB
);
ret
=
pDB
->
pTbDB
->
get
(
pDB
->
pSmaDB
,
NULL
,
&
key
,
&
value
,
0
);
metaDBULock
(
pDB
);
if
(
ret
!=
0
)
{
return
NULL
;
}
// Decode
pCfg
=
(
SSmaCfg
*
)
malloc
(
sizeof
(
SSmaCfg
));
if
(
pCfg
==
NULL
)
{
return
NULL
;
}
tDecodeTSma
(
value
.
data
,
pCfg
);
return
pCfg
;
}
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
uint32_t
nCols
;
uint32_t
nCols
;
SSchemaWrapper
*
pSW
=
NULL
;
SSchemaWrapper
*
pSW
=
NULL
;
...
@@ -726,6 +817,61 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
...
@@ -726,6 +817,61 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
}
}
}
}
struct
SMSmaCursor
{
DBC
*
pCur
;
tb_uid_t
uid
;
};
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
SMSmaCursor
*
pCur
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
int
ret
;
pCur
=
(
SMSmaCursor
*
)
calloc
(
1
,
sizeof
(
*
pCur
));
if
(
pCur
==
NULL
)
{
return
NULL
;
}
pCur
->
uid
=
uid
;
ret
=
pDB
->
pCtbIdx
->
cursor
(
pDB
->
pSmaIdx
,
NULL
,
&
(
pCur
->
pCur
),
0
);
if
(
ret
!=
0
)
{
free
(
pCur
);
return
NULL
;
}
return
pCur
;
}
void
metaCloseSmaCurosr
(
SMSmaCursor
*
pCur
)
{
if
(
pCur
)
{
if
(
pCur
->
pCur
)
{
pCur
->
pCur
->
close
(
pCur
->
pCur
);
}
free
(
pCur
);
}
}
const
char
*
metaSmaCursorNext
(
SMSmaCursor
*
pCur
)
{
DBT
skey
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pval
=
{
0
};
void
*
pBuf
;
// Set key
skey
.
data
=
&
(
pCur
->
uid
);
skey
.
size
=
sizeof
(
pCur
->
uid
);
if
(
pCur
->
pCur
->
pget
(
pCur
->
pCur
,
&
skey
,
&
pkey
,
&
pval
,
DB_NEXT
)
==
0
)
{
const
char
*
indexName
=
(
const
char
*
)
pkey
.
data
;
assert
(
indexName
!=
NULL
);
return
indexName
;
}
else
{
return
0
;
}
}
static
void
metaDBWLock
(
SMetaDB
*
pDB
)
{
static
void
metaDBWLock
(
SMetaDB
*
pDB
)
{
#if IMPL_WITH_LOCK
#if IMPL_WITH_LOCK
pthread_rwlock_wrlock
(
&
(
pDB
->
rwlock
));
pthread_rwlock_wrlock
(
&
(
pDB
->
rwlock
));
...
...
source/dnode/vnode/src/meta/metaIdx.c
浏览文件 @
22829238
...
@@ -106,3 +106,20 @@ int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) {
...
@@ -106,3 +106,20 @@ int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) {
// TODO
// TODO
return
0
;
return
0
;
}
}
int
metaCreateSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pSmaCfg
)
{
// Validate the tbOptions
// if (metaValidateTbCfg(pMeta, pTbCfg) < 0) {
// // TODO: handle error
// return -1;
// }
// TODO: add atomicity
if
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
)
<
0
)
{
// TODO: handle error
return
-
1
;
}
return
0
;
}
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
22829238
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <tglobal.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#include <metaDef.h>
#include <tmsg.h>
#include <tmsg.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
@@ -94,7 +95,93 @@ TEST(testCase, tSmaEncodeDecodeTest) {
...
@@ -94,7 +95,93 @@ TEST(testCase, tSmaEncodeDecodeTest) {
// resource release
// resource release
tdDestroyTSma
(
&
tSma
,
false
);
tdDestroyTSma
(
&
tSma
,
false
);
tdDestroyWrapper
(
&
dstTSmaWrapper
);
tdDestroyTSmaWrapper
(
&
dstTSmaWrapper
);
}
TEST
(
testCase
,
tSma_DB_Put_Get_Del_Test
)
{
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
smaIndexName2
=
"sma_index_test_2"
;
const
char
*
smaTestDir
=
"./smaTest"
;
const
uint64_t
tbUid
=
1234567890
;
// encode
STSma
tSma
=
{
0
};
tSma
.
version
=
0
;
tSma
.
intervalUnit
=
TD_TIME_UNIT_DAY
;
tSma
.
interval
=
1
;
tSma
.
slidingUnit
=
TD_TIME_UNIT_HOUR
;
tSma
.
sliding
=
0
;
tstrncpy
(
tSma
.
indexName
,
smaIndexName1
,
TSDB_INDEX_NAME_LEN
);
tSma
.
tableUid
=
tbUid
;
tSma
.
numOfColIds
=
2
;
tSma
.
numOfFuncIds
=
5
;
// sum/min/max/avg/last
tSma
.
colIds
=
(
col_id_t
*
)
calloc
(
tSma
.
numOfColIds
,
sizeof
(
col_id_t
));
tSma
.
funcIds
=
(
uint16_t
*
)
calloc
(
tSma
.
numOfFuncIds
,
sizeof
(
uint16_t
));
for
(
int32_t
i
=
0
;
i
<
tSma
.
numOfColIds
;
++
i
)
{
*
(
tSma
.
colIds
+
i
)
=
(
i
+
PRIMARYKEY_TIMESTAMP_COL_ID
);
}
for
(
int32_t
i
=
0
;
i
<
tSma
.
numOfFuncIds
;
++
i
)
{
*
(
tSma
.
funcIds
+
i
)
=
(
i
+
2
);
}
SMeta
*
pMeta
=
NULL
;
SSmaCfg
*
pSmaCfg
=
&
tSma
;
const
SMetaCfg
*
pMetaCfg
=
&
defaultMetaOptions
;
taosRemoveDir
(
smaTestDir
);
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
assert
(
pMeta
!=
NULL
);
// save index 1
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
);
tstrncpy
(
pSmaCfg
->
indexName
,
smaIndexName2
,
TSDB_INDEX_NAME_LEN
);
pSmaCfg
->
version
=
1
;
pSmaCfg
->
intervalUnit
=
TD_TIME_UNIT_HOUR
;
pSmaCfg
->
interval
=
1
;
pSmaCfg
->
slidingUnit
=
TD_TIME_UNIT_MINUTE
;
pSmaCfg
->
sliding
=
5
;
// save index 2
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
);
// get value by indexName
SSmaCfg
*
qSmaCfg
=
NULL
;
qSmaCfg
=
metaGetSmaInfoByName
(
pMeta
,
smaIndexName1
);
assert
(
qSmaCfg
!=
NULL
);
printf
(
"name1 = %s
\n
"
,
qSmaCfg
->
indexName
);
EXPECT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
EXPECT_EQ
(
qSmaCfg
->
tableUid
,
tSma
.
tableUid
);
tdDestroyTSma
(
qSmaCfg
,
true
);
qSmaCfg
=
metaGetSmaInfoByName
(
pMeta
,
smaIndexName2
);
assert
(
qSmaCfg
!=
NULL
);
printf
(
"name2 = %s
\n
"
,
qSmaCfg
->
indexName
);
EXPECT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
EXPECT_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
tdDestroyTSma
(
qSmaCfg
,
true
);
// get value by table uid
SMSmaCursor
*
pSmaCur
=
metaOpenSmaCursor
(
pMeta
,
tbUid
);
assert
(
pSmaCur
!=
NULL
);
uint32_t
indexCnt
=
0
;
while
(
1
)
{
const
char
*
indexName
=
metaSmaCursorNext
(
pSmaCur
);
if
(
indexName
==
NULL
)
{
break
;
}
printf
(
"indexName = %s
\n
"
,
indexName
);
++
indexCnt
;
}
EXPECT_EQ
(
indexCnt
,
2
);
metaCloseSmaCurosr
(
pSmaCur
);
// resource release
metaRemoveSmaFromDb
(
pMeta
,
smaIndexName1
);
metaRemoveSmaFromDb
(
pMeta
,
smaIndexName2
);
tdDestroyTSma
(
&
tSma
,
false
);
metaClose
(
pMeta
);
}
}
#if 0
#if 0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录