Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a455105d
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看板
提交
a455105d
编写于
3月 09, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mark expired query window by SSmaStat
上级
aad01e01
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
4 deletion
+31
-4
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+31
-4
未找到文件。
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
a455105d
...
...
@@ -86,7 +86,12 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, STSma *param, STimeWin
static
int32_t
tsdbInitSmaStat
(
SSmaStat
**
pSmaStat
)
{
ASSERT
(
pSmaStat
!=
NULL
);
// TODO: lock and create when each put, or create during tsdbNew.
if
(
*
pSmaStat
!=
NULL
)
{
// no lock
return
TSDB_CODE_SUCCESS
;
}
// TODO: lock. lazy mode when update expired window, or hungry mode during tsdbNew.
if
(
*
pSmaStat
==
NULL
)
{
*
pSmaStat
=
(
SSmaStat
*
)
calloc
(
1
,
sizeof
(
SSmaStat
));
if
(
*
pSmaStat
==
NULL
)
{
...
...
@@ -149,6 +154,8 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, char *msg) {
return
TSDB_CODE_FAILED
;
}
tsdbInitSmaStat
(
&
pTsdb
->
pSmaStat
);
// lazy mode
// TODO: decode the msg => start
const
char
*
indexName
=
SMA_TEST_INDEX_NAME
;
const
int32_t
SMA_TEST_EXPIRED_WINDOW_SIZE
=
10
;
...
...
@@ -157,8 +164,8 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, char *msg) {
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
expiredWindows
[
i
]
=
now
+
i
;
}
// TODO: decode the msg <= end
// TODO: decode the msg <= end
SHashObj
*
pItemsHash
=
pTsdb
->
pSmaStat
->
smaStatItems
;
SSmaStatItem
*
pItem
=
(
SSmaStatItem
*
)
taosHashGet
(
pItemsHash
,
indexName
,
strlen
(
indexName
));
...
...
@@ -181,8 +188,12 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, char *msg) {
int8_t
state
=
TSDB_SMA_STAT_EXPIRED
;
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
if
(
taosHashPut
(
pItem
->
expiredWindows
,
&
expiredWindows
[
i
],
sizeof
(
TSKEY
),
&
state
,
sizeof
(
state
))
!=
0
)
{
// If error occurs during put expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would tell
// query module to query raw TS data.
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
// tell query module to query raw TS data.
// N.B.
// 1) It is assumed to be extemely little probability event of fail to taosHashPut.
// 2) This would solve the inconsistency to some extent, but not completely, unless we record all expired
// windows failed to put into hash table.
taosHashCleanup
(
pItem
->
expiredWindows
);
taosHashRemove
(
pItemsHash
,
indexName
,
sizeof
(
indexName
));
return
TSDB_CODE_FAILED
;
...
...
@@ -612,6 +623,22 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, STSma *param, STimeWindow
* @return int32_t
*/
int32_t
tsdbGetTSmaDataImpl
(
STsdb
*
pTsdb
,
STSma
*
param
,
STSmaData
*
pData
,
STimeWindow
*
queryWin
,
int32_t
nMaxResult
)
{
const
char
*
indexName
=
param
->
indexName
;
SSmaStatItem
*
pItem
=
(
SSmaStatItem
*
)
taosHashGet
(
pTsdb
->
pSmaStat
->
smaStatItems
,
indexName
,
strlen
(
indexName
));
if
(
pItem
==
NULL
)
{
// mark all window as expired and notify query module to query raw TS data.
return
TSDB_CODE_SUCCESS
;
}
int32_t
nQueryWin
=
0
;
for
(
int32_t
n
=
0
;
n
<
nQueryWin
;
++
n
)
{
TSKEY
thisWindow
=
n
;
if
(
taosHashGet
(
pItem
->
expiredWindows
,
&
thisWindow
,
sizeof
(
thisWindow
))
!=
NULL
)
{
// TODO: mark this window as expired.
}
}
STSmaReadH
tReadH
=
{
0
};
tsdbInitTSmaReadH
(
&
tReadH
,
pTsdb
,
param
,
pData
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录