Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d4123972
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
d4123972
编写于
3月 06, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add/check tSma schema methods
上级
e861fd6f
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
2482 addition
and
23 deletion
+2482
-23
include/common/tmsg.h
include/common/tmsg.h
+61
-7
include/common/tmsgdef.h
include/common/tmsgdef.h
+3
-0
include/common/trow.h
include/common/trow.h
+3
-3
source/dnode/vnode/inc/meta.h
source/dnode/vnode/inc/meta.h
+1
-0
source/dnode/vnode/inc/tsdb.h
source/dnode/vnode/inc/tsdb.h
+21
-0
source/dnode/vnode/src/inc/tsdbDef.h
source/dnode/vnode/src/inc/tsdbDef.h
+1
-0
source/dnode/vnode/src/inc/tsdbFS.h
source/dnode/vnode/src/inc/tsdbFS.h
+1
-0
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+95
-0
source/dnode/vnode/src/meta/metaBDBImpl.c
source/dnode/vnode/src/meta/metaBDBImpl.c
+52
-8
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+2180
-0
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+41
-0
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+9
-0
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+14
-5
未找到文件。
include/common/tmsg.h
浏览文件 @
d4123972
...
@@ -1866,10 +1866,59 @@ typedef struct {
...
@@ -1866,10 +1866,59 @@ typedef struct {
uint64_t
tableUid
;
// super/common table uid
uint64_t
tableUid
;
// super/common table uid
int64_t
interval
;
int64_t
interval
;
int64_t
sliding
;
int64_t
sliding
;
col_id_t
*
colIds
;
//
N.B.
sorted column ids
col_id_t
*
colIds
;
// sorted column ids
uint16_t
*
funcIds
;
//
N.B.
sorted sma function ids
uint16_t
*
funcIds
;
// sorted sma function ids
}
STSma
;
// Time-range-wise SMA
}
STSma
;
// Time-range-wise SMA
typedef
struct
{
int8_t
msgType
;
// 0 create, 1 recreate
STSma
tSma
;
STimeWindow
window
;
}
SCreateTSmaMsg
;
typedef
struct
{
STimeWindow
window
;
char
indexName
[
TSDB_INDEX_NAME_LEN
+
1
];
}
SDropTSmaMsg
;
typedef
struct
{
STimeWindow
tsWindow
;
// [skey, ekey]
uint64_t
tableUid
;
// sub/common table uid
int32_t
numOfBlocks
;
// number of sma blocks for each column, total number is numOfBlocks*numOfColId
int32_t
dataLen
;
// total data length
col_id_t
*
colIds
;
// e.g. 2,4,9,10
col_id_t
numOfColIds
;
// e.g. 4
char
data
[];
// the sma blocks
}
STSmaData
;
// TODO: move to the final location afte schema of STSma/STSmaData defined
static
FORCE_INLINE
void
tdDestroySmaData
(
STSmaData
*
pSmaData
)
{
if
(
pSmaData
)
{
if
(
pSmaData
->
colIds
)
{
tfree
(
pSmaData
->
colIds
);
}
tfree
(
pSmaData
);
}
}
// RSma: Time-range-wise Rollup SMA
// TODO: refactor when rSma grammar defined finally =>
typedef
struct
{
int64_t
interval
;
int32_t
retention
;
// unit: day
uint16_t
days
;
// unit: day
int8_t
intervalUnit
;
}
SSmaParams
;
// TODO: refactor when rSma grammar defined finally <=
typedef
struct
{
// TODO: refactor to use the real schema =>
STSma
tsma
;
float
xFilesFactor
;
SArray
*
smaParams
;
// SSmaParams
// TODO: refactor to use the real schema <=
}
SRSma
;
typedef
struct
{
typedef
struct
{
uint32_t
number
;
uint32_t
number
;
STSma
*
tSma
;
STSma
*
tSma
;
...
@@ -1885,12 +1934,17 @@ static FORCE_INLINE void tdDestroyTSma(STSma* pSma, bool releaseSelf) {
...
@@ -1885,12 +1934,17 @@ static FORCE_INLINE void tdDestroyTSma(STSma* pSma, bool releaseSelf) {
}
}
}
}
static
FORCE_INLINE
void
tdDestroyTSmaWrapper
(
STSmaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
tdDestroyTSmaWrapper
(
STSmaWrapper
*
pSW
,
bool
releaseSelf
)
{
if
(
pSW
&&
pSW
->
tSma
)
{
if
(
pSW
)
{
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
if
(
pSW
->
tSma
)
{
tdDestroyTSma
(
pSW
->
tSma
+
i
,
false
);
for
(
uint32_t
i
=
0
;
i
<
pSW
->
number
;
++
i
)
{
tdDestroyTSma
(
pSW
->
tSma
+
i
,
false
);
}
tfree
(
pSW
->
tSma
);
}
if
(
releaseSelf
)
{
free
(
pSW
);
}
}
tfree
(
pSW
->
tSma
);
}
}
}
}
...
...
include/common/tmsgdef.h
浏览文件 @
d4123972
...
@@ -184,6 +184,9 @@ enum {
...
@@ -184,6 +184,9 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBSCRIBE
,
"vnode-subscribe"
,
SMVSubscribeReq
,
SMVSubscribeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBSCRIBE
,
"vnode-subscribe"
,
SMVSubscribeReq
,
SMVSubscribeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CONSUME
,
"vnode-consume"
,
SMqCVConsumeReq
,
SMqCVConsumeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CONSUME
,
"vnode-consume"
,
SMqCVConsumeReq
,
SMqCVConsumeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_SMA
,
"vnode-create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
// Requests handled by QNODE
// Requests handled by QNODE
TD_NEW_MSG_SEG
(
TDMT_QND_MSG
)
TD_NEW_MSG_SEG
(
TDMT_QND_MSG
)
...
...
include/common/trow.h
浏览文件 @
d4123972
...
@@ -118,6 +118,8 @@ typedef struct {
...
@@ -118,6 +118,8 @@ typedef struct {
}
SKvRow
;
}
SKvRow
;
typedef
struct
{
typedef
struct
{
/// timestamp
TSKEY
ts
;
union
{
union
{
/// union field for encode and decode
/// union field for encode and decode
uint32_t
info
;
uint32_t
info
;
...
@@ -138,8 +140,6 @@ typedef struct {
...
@@ -138,8 +140,6 @@ typedef struct {
uint32_t
len
;
uint32_t
len
;
/// row version
/// row version
uint64_t
ver
;
uint64_t
ver
;
/// timestamp
TSKEY
ts
;
/// the inline data, maybe a tuple or a k-v tuple
/// the inline data, maybe a tuple or a k-v tuple
char
data
[];
char
data
[];
}
STSRow
;
}
STSRow
;
...
@@ -173,7 +173,7 @@ typedef struct {
...
@@ -173,7 +173,7 @@ typedef struct {
#define TD_ROW_DATA(r) ((r)->data)
#define TD_ROW_DATA(r) ((r)->data)
#define TD_ROW_LEN(r) ((r)->len)
#define TD_ROW_LEN(r) ((r)->len)
#define TD_ROW_KEY(r) ((r)->ts)
#define TD_ROW_KEY(r) ((r)->ts)
#define TD_ROW_KEY_ADDR(r)
POINTER_SHIFT((r), 16
)
#define TD_ROW_KEY_ADDR(r)
(r
)
// N.B. If without STSchema, getExtendedRowSize() is used to get the rowMaxBytes and
// N.B. If without STSchema, getExtendedRowSize() is used to get the rowMaxBytes and
// (int32_t)ceil((double)nCols/TD_VTYPE_PARTS) should be added if TD_SUPPORT_BITMAP defined.
// (int32_t)ceil((double)nCols/TD_VTYPE_PARTS) should be added if TD_SUPPORT_BITMAP defined.
...
...
source/dnode/vnode/inc/meta.h
浏览文件 @
d4123972
...
@@ -57,6 +57,7 @@ STbCfg * metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid);
...
@@ -57,6 +57,7 @@ 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
);
SSmaCfg
*
metaGetSmaInfoByName
(
SMeta
*
pMeta
,
const
char
*
indexName
);
STSmaWrapper
*
metaGetSmaInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
...
...
source/dnode/vnode/inc/tsdb.h
浏览文件 @
d4123972
...
@@ -87,6 +87,27 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp);
...
@@ -87,6 +87,27 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
/**
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
*
* @param pTsdb
* @param param
* @param pData
* @return int32_t
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
STSma
*
param
,
STSmaData
*
pData
);
/**
* @brief Insert RSma(Time-range-wise Rollup SMA) data.
*
* @param pTsdb
* @param param
* @param pData
* @return int32_t
*/
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
SRSma
*
param
,
STSmaData
*
pData
);
// STsdbCfg
// STsdbCfg
int
tsdbOptionsInit
(
STsdbCfg
*
);
int
tsdbOptionsInit
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
...
...
source/dnode/vnode/src/inc/tsdbDef.h
浏览文件 @
d4123972
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "tsdbMemory.h"
#include "tsdbMemory.h"
#include "tsdbOptions.h"
#include "tsdbOptions.h"
#include "tsdbReadImpl.h"
#include "tsdbReadImpl.h"
#include "tsdbSma.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
...
source/dnode/vnode/src/inc/tsdbFS.h
浏览文件 @
d4123972
...
@@ -42,6 +42,7 @@ typedef struct {
...
@@ -42,6 +42,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
STsdbFSMeta
meta
;
// FS meta
STsdbFSMeta
meta
;
// FS meta
SArray
*
df
;
// data file array
SArray
*
df
;
// data file array
SArray
*
smaf
;
// sma data file array
}
SFSStatus
;
}
SFSStatus
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/vnode/src/inc/tsdbSma.h
0 → 100644
浏览文件 @
d4123972
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_TSDB_SMA_H_
#define _TD_TSDB_SMA_H_
// insert/update interface
int32_t
tsdbInsertTSmaDataImpl
(
STsdb
*
pTsdb
,
STSma
*
param
,
STSmaData
*
pData
);
int32_t
tsdbInsertRSmaDataImpl
(
STsdb
*
pTsdb
,
SRSma
*
param
,
STSmaData
*
pData
);
// query interface
// TODO: This is the basic params, and should wrap the params to a queryHandle.
int32_t
tsdbGetTSmaDataImpl
(
STsdb
*
pTsdb
,
STSma
*
param
,
STSmaData
*
pData
,
STimeWindow
*
queryWin
,
int32_t
nMaxResult
);
// management interface
int32_t
tsdbGetTSmaStatus
(
STsdb
*
pTsdb
,
STSma
*
param
,
void
*
result
);
int32_t
tsdbRemoveTSmaData
(
STsdb
*
pTsdb
,
STSma
*
param
,
STimeWindow
*
pWin
);
// internal func
static
FORCE_INLINE
int32_t
tsdbEncodeTSmaKey
(
uint64_t
tableUid
,
col_id_t
colId
,
TSKEY
tsKey
,
void
**
pData
)
{
int32_t
len
=
0
;
len
+=
taosEncodeFixedU64
(
pData
,
tableUid
);
len
+=
taosEncodeFixedU16
(
pData
,
colId
);
len
+=
taosEncodeFixedI64
(
pData
,
tsKey
);
return
len
;
}
#if 0
typedef struct {
int minFid;
int midFid;
int maxFid;
TSKEY minKey;
} SRtn;
typedef struct {
uint64_t uid;
int64_t offset;
int64_t size;
} SKVRecord;
void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn);
static FORCE_INLINE int TSDB_KEY_FID(TSKEY key, int32_t days, int8_t precision) {
if (key < 0) {
return (int)((key + 1) / tsTickPerDay[precision] / days - 1);
} else {
return (int)((key / tsTickPerDay[precision] / days));
}
}
static FORCE_INLINE int tsdbGetFidLevel(int fid, SRtn *pRtn) {
if (fid >= pRtn->maxFid) {
return 0;
} else if (fid >= pRtn->midFid) {
return 1;
} else if (fid >= pRtn->minFid) {
return 2;
} else {
return -1;
}
}
#define TSDB_DEFAULT_BLOCK_ROWS(maxRows) ((maxRows)*4 / 5)
int tsdbEncodeKVRecord(void **buf, SKVRecord *pRecord);
void *tsdbDecodeKVRecord(void *buf, SKVRecord *pRecord);
void *tsdbCommitData(STsdbRepo *pRepo);
int tsdbApplyRtnOnFSet(STsdbRepo *pRepo, SDFileSet *pSet, SRtn *pRtn);
int tsdbWriteBlockInfoImpl(SDFile *pHeadf, STable *pTable, SArray *pSupA, SArray *pSubA, void **ppBuf, SBlockIdx *pIdx);
int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf);
int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDataCols *pDataCols, SBlock *pBlock,
bool isLast, bool isSuper, void **ppBuf, void **ppCBuf);
int tsdbApplyRtn(STsdbRepo *pRepo);
#endif
#endif
/* _TD_TSDB_SMA_H_ */
\ No newline at end of file
source/dnode/vnode/src/meta/metaBDBImpl.c
浏览文件 @
d4123972
...
@@ -833,6 +833,7 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) {
...
@@ -833,6 +833,7 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) {
}
}
pCur
->
uid
=
uid
;
pCur
->
uid
=
uid
;
// TODO: lock?
ret
=
pDB
->
pCtbIdx
->
cursor
(
pDB
->
pSmaIdx
,
NULL
,
&
(
pCur
->
pCur
),
0
);
ret
=
pDB
->
pCtbIdx
->
cursor
(
pDB
->
pSmaIdx
,
NULL
,
&
(
pCur
->
pCur
),
0
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
free
(
pCur
);
free
(
pCur
);
...
@@ -852,25 +853,68 @@ void metaCloseSmaCurosr(SMSmaCursor *pCur) {
...
@@ -852,25 +853,68 @@ void metaCloseSmaCurosr(SMSmaCursor *pCur) {
}
}
}
}
const
char
*
metaSmaCursorNext
(
SMSmaCursor
*
pCur
)
{
const
char
*
metaSmaCursorNext
(
SMSmaCursor
*
pCur
)
{
DBT
skey
=
{
0
};
DBT
skey
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pval
=
{
0
};
DBT
pval
=
{
0
};
void
*
pBuf
;
// Set key
// Set key
skey
.
data
=
&
(
pCur
->
uid
);
skey
.
data
=
&
(
pCur
->
uid
);
skey
.
size
=
sizeof
(
pCur
->
uid
);
skey
.
size
=
sizeof
(
pCur
->
uid
);
// TODO: lock?
if
(
pCur
->
pCur
->
pget
(
pCur
->
pCur
,
&
skey
,
&
pkey
,
&
pval
,
DB_NEXT
)
==
0
)
{
if
(
pCur
->
pCur
->
pget
(
pCur
->
pCur
,
&
skey
,
&
pkey
,
&
pval
,
DB_NEXT
)
==
0
)
{
const
char
*
indexName
=
(
const
char
*
)
pkey
.
data
;
const
char
*
indexName
=
(
const
char
*
)
pkey
.
data
;
assert
(
indexName
!=
NULL
);
assert
(
indexName
!=
NULL
);
return
indexName
;
return
indexName
;
}
else
{
}
else
{
return
0
;
return
NULL
;
}
}
}
}
STSmaWrapper
*
metaGetSmaInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
STSmaWrapper
*
pSW
=
NULL
;
pSW
=
calloc
(
sizeof
(
*
pSW
),
1
);
if
(
pSW
==
NULL
)
{
return
NULL
;
}
SMSmaCursor
*
pCur
=
metaOpenSmaCursor
(
pMeta
,
uid
);
if
(
pCur
==
NULL
)
{
free
(
pSW
);
return
NULL
;
}
DBT
skey
=
{.
data
=
&
(
pCur
->
uid
)};
DBT
pval
=
{.
size
=
sizeof
(
pCur
->
uid
)};
void
*
pBuf
=
NULL
;
while
(
true
)
{
// TODO: lock?
if
(
pCur
->
pCur
->
pget
(
pCur
->
pCur
,
&
skey
,
NULL
,
&
pval
,
DB_NEXT
)
==
0
)
{
++
pSW
->
number
;
STSma
*
tptr
=
(
STSma
*
)
realloc
(
pSW
->
tSma
,
pSW
->
number
*
sizeof
(
STSma
));
if
(
tptr
==
NULL
)
{
metaCloseSmaCurosr
(
pCur
);
tdDestroyTSmaWrapper
(
pSW
,
true
);
return
NULL
;
}
pSW
->
tSma
=
tptr
;
pBuf
=
pval
.
data
;
if
(
tDecodeTSma
(
pBuf
,
pSW
->
tSma
+
pSW
->
number
-
1
)
==
NULL
)
{
metaCloseSmaCurosr
(
pCur
);
tdDestroyTSmaWrapper
(
pSW
,
true
);
return
NULL
;
}
continue
;
}
break
;
}
metaCloseSmaCurosr
(
pCur
);
return
pSW
;
}
static
void
metaDBWLock
(
SMetaDB
*
pDB
)
{
static
void
metaDBWLock
(
SMetaDB
*
pDB
)
{
#if IMPL_WITH_LOCK
#if IMPL_WITH_LOCK
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
0 → 100644
浏览文件 @
d4123972
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
d4123972
...
@@ -15,6 +15,14 @@
...
@@ -15,6 +15,14 @@
#include "tsdbDef.h"
#include "tsdbDef.h"
/**
* @brief insert TS data
*
* @param pTsdb
* @param pMsg
* @param pRsp
* @return int
*/
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
)
{
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
)
{
// Check if mem is there. If not, create one.
// Check if mem is there. If not, create one.
if
(
pTsdb
->
mem
==
NULL
)
{
if
(
pTsdb
->
mem
==
NULL
)
{
...
@@ -24,4 +32,37 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
...
@@ -24,4 +32,37 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
}
}
}
}
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
}
/**
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
*
* @param pTsdb
* @param param
* @param pData
* @return int32_t
* TODO: Who is responsible for resource allocate and release?
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
STSma
*
param
,
STSmaData
*
pData
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tsdbInsertTSmaDataImpl
(
pTsdb
,
param
,
pData
))
<
0
)
{
tsdbWarn
(
"vgId:%d insert tSma data failed since %s"
,
REPO_ID
(
pTsdb
),
tstrerror
(
terrno
));
}
return
code
;
}
/**
* @brief Insert Time-range-wise Rollup Sma(RSma) data
*
* @param pTsdb
* @param param
* @param pData
* @return int32_t
*/
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
SRSma
*
param
,
STSmaData
*
pData
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tsdbInsertRSmaDataImpl
(
pTsdb
,
param
,
pData
))
<
0
)
{
tsdbWarn
(
"vgId:%d insert rSma data failed since %s"
,
REPO_ID
(
pTsdb
),
tstrerror
(
terrno
));
}
return
code
;
}
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
d4123972
...
@@ -132,6 +132,15 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -132,6 +132,15 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
if
(
tqProcessRebReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
if
(
tqProcessRebReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
}
}
}
break
;
}
break
;
case
TDMT_VND_CREATE_SMA
:
{
// timeRangeSMA
// 1. tdCreateSmaMeta(pVnode->pMeta,...);
// 2. tdCreateSmaDataInit();
// 3. tdCreateSmaData
}
break
;
case
TDMT_VND_CANCEL_SMA
:
{
// timeRangeSMA
}
break
;
case
TDMT_VND_DROP_SMA
:
{
// timeRangeSMA
}
break
;
default:
default:
ASSERT
(
0
);
ASSERT
(
0
);
break
;
break
;
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
d4123972
...
@@ -95,7 +95,7 @@ TEST(testCase, tSmaEncodeDecodeTest) {
...
@@ -95,7 +95,7 @@ TEST(testCase, tSmaEncodeDecodeTest) {
// resource release
// resource release
tdDestroyTSma
(
&
tSma
,
false
);
tdDestroyTSma
(
&
tSma
,
false
);
tdDestroyTSmaWrapper
(
&
dstTSmaWrapper
);
tdDestroyTSmaWrapper
(
&
dstTSmaWrapper
,
false
);
}
}
TEST
(
testCase
,
tSma_DB_Put_Get_Del_Test
)
{
TEST
(
testCase
,
tSma_DB_Put_Get_Del_Test
)
{
...
@@ -161,7 +161,7 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
...
@@ -161,7 +161,7 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
EXPECT_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
EXPECT_EQ
(
qSmaCfg
->
interval
,
tSma
.
interval
);
tdDestroyTSma
(
qSmaCfg
,
true
);
tdDestroyTSma
(
qSmaCfg
,
true
);
// get
valu
e by table uid
// get
index nam
e by table uid
SMSmaCursor
*
pSmaCur
=
metaOpenSmaCursor
(
pMeta
,
tbUid
);
SMSmaCursor
*
pSmaCur
=
metaOpenSmaCursor
(
pMeta
,
tbUid
);
assert
(
pSmaCur
!=
NULL
);
assert
(
pSmaCur
!=
NULL
);
uint32_t
indexCnt
=
0
;
uint32_t
indexCnt
=
0
;
...
@@ -176,6 +176,15 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
...
@@ -176,6 +176,15 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
EXPECT_EQ
(
indexCnt
,
2
);
EXPECT_EQ
(
indexCnt
,
2
);
metaCloseSmaCurosr
(
pSmaCur
);
metaCloseSmaCurosr
(
pSmaCur
);
// get wrapper by table uid
STSmaWrapper
*
pSW
=
metaGetSmaInfoByUid
(
pMeta
,
tbUid
);
assert
(
pSW
!=
NULL
);
EXPECT_EQ
(
pSW
->
number
,
2
);
EXPECT_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
EXPECT_EQ
(
pSW
->
tSma
->
tableUid
,
tSma
.
tableUid
);
EXPECT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
EXPECT_EQ
((
pSW
->
tSma
+
1
)
->
tableUid
,
tSma
.
tableUid
);
// resource release
// resource release
metaRemoveSmaFromDb
(
pMeta
,
smaIndexName1
);
metaRemoveSmaFromDb
(
pMeta
,
smaIndexName1
);
metaRemoveSmaFromDb
(
pMeta
,
smaIndexName2
);
metaRemoveSmaFromDb
(
pMeta
,
smaIndexName2
);
...
@@ -197,15 +206,15 @@ TEST(testCase, tSmaInsertTest) {
...
@@ -197,15 +206,15 @@ TEST(testCase, tSmaInsertTest) {
int32_t blockSize = tSma.numOfFuncIds * sizeof(int64_t);
int32_t blockSize = tSma.numOfFuncIds * sizeof(int64_t);
int32_t numOfColIds = 3;
int32_t numOfColIds = 3;
int32_t numOf
Sma
Blocks = 10;
int32_t numOfBlocks = 10;
int32_t dataLen = numOfColIds * numOf
Sma
Blocks * blockSize;
int32_t dataLen = numOfColIds * numOfBlocks * blockSize;
pSmaData = (STSmaData*)malloc(sizeof(STSmaData) + dataLen);
pSmaData = (STSmaData*)malloc(sizeof(STSmaData) + dataLen);
ASSERT_EQ(pSmaData != NULL, true);
ASSERT_EQ(pSmaData != NULL, true);
pSmaData->tableUid = 3232329230;
pSmaData->tableUid = 3232329230;
pSmaData->numOfColIds = numOfColIds;
pSmaData->numOfColIds = numOfColIds;
pSmaData->numOf
SmaBlocks = numOfSma
Blocks;
pSmaData->numOf
Blocks = numOf
Blocks;
pSmaData->dataLen = dataLen;
pSmaData->dataLen = dataLen;
pSmaData->tsWindow.skey = 1640000000;
pSmaData->tsWindow.skey = 1640000000;
pSmaData->tsWindow.ekey = 1645788649;
pSmaData->tsWindow.ekey = 1645788649;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录