Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f09d73cf
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看板
提交
f09d73cf
编写于
6月 15, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-353
上级
77b4dcf8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
25 addition
and
15 deletion
+25
-15
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-0
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+24
-15
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
f09d73cf
...
...
@@ -307,6 +307,7 @@ SListNode* tsdbAllocBufBlockFromPool(STsdbRepo* pRepo);
int
tsdbInsertRowToMem
(
STsdbRepo
*
pRepo
,
SDataRow
row
,
STable
*
pTable
);
int
tsdbRefMemTable
(
STsdbRepo
*
pRepo
,
SMemTable
*
pMemTable
);
int
tsdbUnRefMemTable
(
STsdbRepo
*
pRepo
,
SMemTable
*
pMemTable
);
int
tsdbTakeMemSnapshot
(
STsdbRepo
*
pRepo
,
SMemTable
**
pMem
,
SMemTable
**
pIMem
);
// ------------------ tsdbFile.c
#define TSDB_KEY_FILEID(key, daysPerFile, precision) ((key) / tsMsPerDay[(precision)] / (daysPerFile))
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
f09d73cf
...
...
@@ -103,14 +103,14 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
}
int
tsdbRefMemTable
(
STsdbRepo
*
pRepo
,
SMemTable
*
pMemTable
)
{
ASSERT
(
IS_REPO_LOCKED
(
pRepo
));
ASSERT
(
pMemTable
!=
NULL
);
if
(
pMemTable
==
NULL
)
return
0
;
T_REF_INC
(
pMemTable
);
return
0
;
}
// Need to lock the repository
int
tsdbUnRefMemTable
(
STsdbRepo
*
pRepo
,
SMemTable
*
pMemTable
)
{
ASSERT
(
pMemTable
!=
NULL
)
;
if
(
pMemTable
==
NULL
)
return
0
;
if
(
T_REF_DEC
(
pMemTable
)
==
0
)
{
STsdbCfg
*
pCfg
=
&
pRepo
->
config
;
...
...
@@ -143,6 +143,17 @@ int tsdbUnRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) {
return
0
;
}
int
tsdbTakeMemSnapshot
(
STsdbRepo
*
pRepo
,
SMemTable
**
pMem
,
SMemTable
**
pIMem
)
{
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
-
1
;
*
pMem
=
pRepo
->
mem
;
*
pIMem
=
pRepo
->
mem
;
tsdbRefMemTable
(
pRepo
,
*
pMem
);
tsdbRefMemTable
(
pRepo
,
*
pIMem
);
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
}
// ---------------- LOCAL FUNCTIONS ----------------
static
FORCE_INLINE
STsdbBufBlock
*
tsdbGetCurrBufBlock
(
STsdbRepo
*
pRepo
)
{
ASSERT
(
pRepo
!=
NULL
);
...
...
@@ -171,10 +182,16 @@ static void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) {
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
if
(
tsdbUnRefMemTable
(
pRepo
,
pRepo
->
imem
)
<
0
)
{
tsdbError
(
"vgId:%d failed to unref memtable since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
))
return
NULL
;
}
}
ASSERT
(
pRepo
->
commit
==
0
);
SMemTable
*
pImem
=
pRepo
->
imem
;
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_START
);
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
NULL
;
pRepo
->
imem
=
pRepo
->
mem
;
...
...
@@ -322,20 +339,12 @@ static char *tsdbGetTsTupleKey(const void *data) { return dataRowTuple(data); }
static
void
*
tsdbCommitData
(
void
*
arg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
arg
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
ASSERT
(
pRepo
->
imem
!=
NULL
)
;
SMemTable
*
pMem
=
pRepo
->
imem
;
ASSERT
(
pRepo
->
commit
==
1
);
ASSERT
(
pMem
!=
NULL
);
tsdbPrint
(
"vgId:%d start to commit! keyFirst "
PRId64
" keyLast "
PRId64
" numOfRows "
PRId64
,
REPO_ID
(
pRepo
),
pRepo
->
imem
->
keyFirst
,
pRepo
->
imem
->
keyLast
,
pRepo
->
imem
->
numOfRows
);
// STsdbMeta * pMeta = pRepo->tsdbMeta;
// STsdbCache *pCache = pRepo->tsdbCache;
// STsdbCfg * pCfg = &(pRepo->config);
// SDataCols * pDataCols = NULL;
// SRWHelper whelper = {{0}};
// if (pCache->imem == NULL) return NULL;
tsdbPrint
(
"vgId:%d, starting to commit...."
,
pRepo
->
config
.
tsdbId
);
tsdbPrint
(
"vgId:%d start to commit! keyFirst %"
PRId64
" keyLast %"
PRId64
" numOfRows %"
PRId64
,
REPO_ID
(
pRepo
),
pMem
->
keyFirst
,
pMem
->
keyLast
,
pMem
->
numOfRows
);
// Create the iterator to read from cache
SSkipListIterator
**
iters
=
tsdbCreateTableIters
(
pRepo
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录