Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c7eab2a1
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c7eab2a1
编写于
1月 05, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make insert ts to mem work
上级
e9db1ee7
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
35 addition
and
116 deletion
+35
-116
include/common/tmsg.h
include/common/tmsg.h
+4
-4
source/common/src/tmsg.c
source/common/src/tmsg.c
+12
-12
source/dnode/vnode/tsdb/src/tsdbMemTable.c
source/dnode/vnode/tsdb/src/tsdbMemTable.c
+19
-100
未找到文件。
include/common/tmsg.h
浏览文件 @
c7eab2a1
...
...
@@ -194,10 +194,10 @@ typedef struct {
void
*
pMsg
;
}
SSubmitMsgIter
;
int
t
sdb
InitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
);
int
t
sdb
GetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
);
int
t
sdb
InitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
SMemRow
t
sdb
GetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
int
tInitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
);
int
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
);
int
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
SMemRow
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
typedef
struct
{
int32_t
index
;
// index of failed block in submit blocks
...
...
source/common/src/tmsg.c
浏览文件 @
c7eab2a1
...
...
@@ -27,7 +27,7 @@
#undef TD_MSG_SEG_CODE_
#include "tmsgdef.h"
int
t
sdb
InitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
)
{
int
tInitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
)
{
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP
;
return
-
1
;
...
...
@@ -44,7 +44,7 @@ int tsdbInitSubmitMsgIter(SSubmitMsg *pMsg, SSubmitMsgIter *pIter) {
return
0
;
}
int
t
sdb
GetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
)
{
int
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
)
{
if
(
pIter
->
len
==
0
)
{
pIter
->
len
+=
sizeof
(
SSubmitMsg
);
}
else
{
...
...
@@ -63,7 +63,7 @@ int tsdbGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
return
0
;
}
int
t
sdb
InitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
)
{
int
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
)
{
if
(
pBlock
->
dataLen
<=
0
)
return
-
1
;
pIter
->
totalLen
=
pBlock
->
dataLen
;
pIter
->
len
=
0
;
...
...
@@ -71,18 +71,18 @@ int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
return
0
;
}
SMemRow
tsdbGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
)
{
SMemRow
row
=
pIter
->
row
;
// firstly, get current row
if
(
row
==
NULL
)
return
NULL
;
SMemRow
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
)
{
SMemRow
row
=
pIter
->
row
;
pIter
->
len
+=
memRowTLen
(
row
);
if
(
pIter
->
len
>=
pIter
->
totalLen
)
{
// reach the end
pIter
->
row
=
NULL
;
if
(
pIter
->
len
>=
pIter
->
totalLen
)
{
return
NULL
;
}
else
{
pIter
->
row
=
(
char
*
)
row
+
memRowTLen
(
row
);
// secondly, move to next row
pIter
->
len
+=
memRowTLen
(
row
);
if
(
pIter
->
len
<
pIter
->
totalLen
)
{
pIter
->
row
=
POINTER_SHIFT
(
row
,
memRowTLen
(
row
));
}
return
row
;
}
}
int
tSerializeSVCreateTbReq
(
void
**
buf
,
SVCreateTbReq
*
pReq
)
{
...
...
source/dnode/vnode/tsdb/src/tsdbMemTable.c
浏览文件 @
c7eab2a1
...
...
@@ -108,9 +108,9 @@ int tsdbMemTableInsert(STsdb *pTsdb, STsdbMemTable *pMemTable, SSubmitMsg *pMsg,
return
-
1
;
}
t
sdb
InitSubmitMsgIter
(
pMsg
,
&
msgIter
);
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
);
while
(
true
)
{
t
sdb
GetSubmitMsgNext
(
&
msgIter
,
&
pBlock
);
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
);
if
(
pBlock
==
NULL
)
break
;
if
(
tsdbMemTableInsertTbData
(
pTsdb
,
pBlock
,
&
affectedrows
)
<
0
)
{
return
-
1
;
...
...
@@ -142,9 +142,9 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitMsg *pMsg) {
pMsg
->
length
=
htonl
(
pMsg
->
length
);
pMsg
->
numOfBlocks
=
htonl
(
pMsg
->
numOfBlocks
);
if
(
t
sdb
InitSubmitMsgIter
(
pMsg
,
&
msgIter
)
<
0
)
return
-
1
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
<
0
)
return
-
1
;
while
(
true
)
{
if
(
t
sdb
GetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
return
-
1
;
if
(
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
return
-
1
;
if
(
pBlock
==
NULL
)
break
;
pBlock
->
uid
=
htobe64
(
pBlock
->
uid
);
...
...
@@ -206,6 +206,10 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p
STsdbMemTable
*
pMemTable
=
pTsdb
->
mem
;
void
*
tptr
;
STbData
*
pTbData
;
SMemRow
row
;
TSKEY
keyMin
;
TSKEY
keyMax
;
// SMemTable *pMemTable = NULL;
// STableData *pTableData = NULL;
// STsdbCfg *pCfg = &(pRepo->config);
...
...
@@ -226,46 +230,22 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p
pTbData
=
*
(
STbData
**
)
tptr
;
}
t
sdb
InitSubmitBlkIter
(
pBlock
,
&
blkIter
);
tInitSubmitBlkIter
(
pBlock
,
&
blkIter
);
if
(
blkIter
.
row
==
NULL
)
return
0
;
TSKEY
firstRowKey
=
memRowKey
(
blkIter
.
row
);
// tsdbAllocBytes(pRepo, 0);
// pMemTable = pRepo->mem;
// ASSERT(pMemTable != NULL);
// ASSERT(pBlock->tid < pMeta->maxTables);
keyMin
=
memRowKey
(
blkIter
.
row
);
// pTable = pMeta->tables[pBlock->tid]
;
tSkipListPutBatchByIter
(
pTbData
->
pData
,
&
blkIter
,
(
iter_next_fn_t
)
tGetSubmitBlkNext
)
;
// ASSERT(pTable != NULL && TABLE_UID(pTable) == pBlock->uid);
// if (TABLE_TID(pTable) >= pMemTable->maxTables) {
// if (tsdbAdjustMemMaxTables(pMemTable, pMeta->maxTables) < 0) {
// return -1;
// }
// }
// pTableData = pMemTable->tData[TABLE_TID(pTable)];
// if (pTableData == NULL || pTableData->uid != TABLE_UID(pTable)) {
// if (pTableData != NULL) {
// taosWLockLatch(&(pMemTable->latch));
// pMemTable->tData[TABLE_TID(pTable)] = NULL;
// tsdbFreeTableData(pTableData);
// taosWUnLockLatch(&(pMemTable->latch));
// }
// pTableData = tsdbNewTableData(pCfg, pTable);
// if (pTableData == NULL) {
// tsdbError("vgId:%d failed to insert data to table %s uid %" PRId64 " tid %d since %s", REPO_ID(pRepo),
// TABLE_CHAR_NAME(pTable), TABLE_UID(pTable), TABLE_TID(pTable), tstrerror(terrno));
// return -1;
// }
// Set statistics
keyMax
=
memRowKey
(
blkIter
.
row
);
// pRepo->mem->tData[TABLE_TID(pTable)] = pTableData;
// }
pTbData
->
nrows
+=
pBlock
->
numOfRows
;
if
(
pTbData
->
keyMin
>
keyMin
)
pTbData
->
keyMin
=
keyMin
;
if
(
pTbData
->
keyMax
<
keyMax
)
pTbData
->
keyMax
=
keyMax
;
// ASSERT((pTableData != NULL) && pTableData->uid == TABLE_UID(pTable));
pMemTable
->
nRow
+=
pBlock
->
numOfRows
;
if
(
pMemTable
->
keyMin
>
keyMin
)
pMemTable
->
keyMin
=
keyMin
;
if
(
pMemTable
->
keyMax
<
keyMax
)
pMemTable
->
keyMax
=
keyMax
;
// SMemRow lastRow = NULL;
// int64_t osize = SL_SIZE(pTableData->pData);
...
...
@@ -632,45 +612,6 @@ int tsdbSyncCommitConfig(STsdbRepo* pRepo) {
return 0;
}
int tsdbAsyncCommit(STsdbRepo *pRepo) {
tsem_wait(&(pRepo->readyToCommit));
ASSERT(pRepo->imem == NULL);
if (pRepo->mem == NULL) {
tsem_post(&(pRepo->readyToCommit));
return 0;
}
if (pRepo->code != TSDB_CODE_SUCCESS) {
tsdbWarn("vgId:%d try to commit when TSDB not in good state: %s", REPO_ID(pRepo), tstrerror(terrno));
}
if (pRepo->appH.notifyStatus) pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_START, TSDB_CODE_SUCCESS);
if (tsdbLockRepo(pRepo) < 0) return -1;
pRepo->imem = pRepo->mem;
pRepo->mem = NULL;
tsdbScheduleCommit(pRepo, COMMIT_REQ);
if (tsdbUnlockRepo(pRepo) < 0) return -1;
return 0;
}
int tsdbSyncCommit(STsdbRepo *repo) {
STsdbRepo *pRepo = repo;
tsdbAsyncCommit(pRepo);
tsem_wait(&(pRepo->readyToCommit));
tsem_post(&(pRepo->readyToCommit));
if (pRepo->code != TSDB_CODE_SUCCESS) {
terrno = pRepo->code;
return -1;
} else {
terrno = TSDB_CODE_SUCCESS;
return 0;
}
}
/**
* This is an important function to load data or try to load data from memory skiplist iterator.
*
...
...
@@ -834,28 +775,6 @@ static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema *
return 0;
}
static int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
if (pBlock->dataLen <= 0) return -1;
pIter->totalLen = pBlock->dataLen;
pIter->len = 0;
pIter->row = (SMemRow)(pBlock->data + pBlock->schemaLen);
return 0;
}
static SMemRow tsdbGetSubmitBlkNext(SSubmitBlkIter *pIter) {
SMemRow row = pIter->row; // firstly, get current row
if (row == NULL) return NULL;
pIter->len += memRowTLen(row);
if (pIter->len >= pIter->totalLen) { // reach the end
pIter->row = NULL;
} else {
pIter->row = (char *)row + memRowTLen(row); // secondly, move to next row
}
return row;
}
static FORCE_INLINE int tsdbCheckRowRange(STsdbRepo *pRepo, STable *pTable, SMemRow row, TSKEY minKey, TSKEY maxKey,
TSKEY now) {
TSKEY rowKey = memRowKey(row);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录