Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
a60fc0f7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a60fc0f7
编写于
6月 18, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-353
上级
65552dc4
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
97 addition
and
71 deletion
+97
-71
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-1
src/tsdb/src/tsdbBuffer.c
src/tsdb/src/tsdbBuffer.c
+2
-1
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+63
-40
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+22
-16
src/util/src/hash.c
src/util/src/hash.c
+1
-3
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+4
-8
src/util/src/tlist.c
src/util/src/tlist.c
+4
-2
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
a60fc0f7
...
@@ -298,7 +298,7 @@ STSchema* tsdbGetTableSchema(STable* pTable);
...
@@ -298,7 +298,7 @@ STSchema* tsdbGetTableSchema(STable* pTable);
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
uint64_t
uid
);
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
uint64_t
uid
);
STSchema
*
tsdbGetTableSchemaByVersion
(
STable
*
pTable
,
int16_t
version
);
STSchema
*
tsdbGetTableSchemaByVersion
(
STable
*
pTable
,
int16_t
version
);
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
);
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
);
int
tsdbUpdateTable
(
STsdb
Meta
*
pMeta
,
STable
*
pTable
,
STableCfg
*
pCfg
);
int
tsdbUpdateTable
(
STsdb
Repo
*
pRepo
,
STable
*
pTable
,
STableCfg
*
pCfg
);
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbRLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbRLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepoMeta
(
STsdbRepo
*
pRepo
);
...
...
src/tsdb/src/tsdbBuffer.c
浏览文件 @
a60fc0f7
...
@@ -67,7 +67,7 @@ int tsdbOpenBufPool(STsdbRepo *pRepo) {
...
@@ -67,7 +67,7 @@ int tsdbOpenBufPool(STsdbRepo *pRepo) {
ASSERT
(
pPool
!=
NULL
);
ASSERT
(
pPool
!=
NULL
);
pPool
->
bufBlockSize
=
pCfg
->
cacheBlockSize
*
1024
*
1024
;
pPool
->
bufBlockSize
=
pCfg
->
cacheBlockSize
*
1024
*
1024
;
// MB
pPool
->
tBufBlocks
=
pCfg
->
totalBlocks
;
pPool
->
tBufBlocks
=
pCfg
->
totalBlocks
;
pPool
->
nBufBlocks
=
0
;
pPool
->
nBufBlocks
=
0
;
pPool
->
index
=
0
;
pPool
->
index
=
0
;
...
@@ -106,6 +106,7 @@ void tsdbCloseBufPool(STsdbRepo *pRepo) {
...
@@ -106,6 +106,7 @@ void tsdbCloseBufPool(STsdbRepo *pRepo) {
while
((
pNode
=
tdListPopHead
(
pBufPool
->
bufBlockList
))
!=
NULL
)
{
while
((
pNode
=
tdListPopHead
(
pBufPool
->
bufBlockList
))
!=
NULL
)
{
tdListNodeGetData
(
pBufPool
->
bufBlockList
,
pNode
,
(
void
*
)(
&
pBufBlock
));
tdListNodeGetData
(
pBufPool
->
bufBlockList
,
pNode
,
(
void
*
)(
&
pBufBlock
));
tsdbFreeBufBlock
(
pBufBlock
);
tsdbFreeBufBlock
(
pBufBlock
);
free
(
pNode
);
}
}
}
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
a60fc0f7
...
@@ -67,6 +67,7 @@ static int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks);
...
@@ -67,6 +67,7 @@ static int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks);
static
int
keyFGroupCompFunc
(
const
void
*
key
,
const
void
*
fgroup
);
static
int
keyFGroupCompFunc
(
const
void
*
key
,
const
void
*
fgroup
);
static
int
tsdbEncodeCfg
(
void
**
buf
,
STsdbCfg
*
pCfg
);
static
int
tsdbEncodeCfg
(
void
**
buf
,
STsdbCfg
*
pCfg
);
static
void
*
tsdbDecodeCfg
(
void
*
buf
,
STsdbCfg
*
pCfg
);
static
void
*
tsdbDecodeCfg
(
void
*
buf
,
STsdbCfg
*
pCfg
);
static
int
tsdbCheckTableSchema
(
STsdbRepo
*
pRepo
,
SSubmitBlk
*
pBlock
,
STable
*
pTable
);
// Function declaration
// Function declaration
int32_t
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
)
{
int32_t
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
)
{
...
@@ -81,7 +82,7 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) {
...
@@ -81,7 +82,7 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) {
if
(
tsdbSetRepoEnv
(
rootDir
,
pCfg
)
<
0
)
return
-
1
;
if
(
tsdbSetRepoEnv
(
rootDir
,
pCfg
)
<
0
)
return
-
1
;
tsdbTrace
(
tsdbTrace
(
"vgId%d tsdb env create succeed! cacheBlockSize %d totalBlocks %d maxTables %d daysPerFile %d keep "
"vgId
:
%d tsdb env create succeed! cacheBlockSize %d totalBlocks %d maxTables %d daysPerFile %d keep "
"%d minRowsPerFileBlock %d maxRowsPerFileBlock %d precision %d compression %d"
,
"%d minRowsPerFileBlock %d maxRowsPerFileBlock %d precision %d compression %d"
,
pCfg
->
tsdbId
,
pCfg
->
cacheBlockSize
,
pCfg
->
totalBlocks
,
pCfg
->
maxTables
,
pCfg
->
daysPerFile
,
pCfg
->
keep
,
pCfg
->
tsdbId
,
pCfg
->
cacheBlockSize
,
pCfg
->
totalBlocks
,
pCfg
->
maxTables
,
pCfg
->
daysPerFile
,
pCfg
->
keep
,
pCfg
->
minRowsPerFileBlock
,
pCfg
->
maxRowsPerFileBlock
,
pCfg
->
precision
,
pCfg
->
compression
);
pCfg
->
minRowsPerFileBlock
,
pCfg
->
maxRowsPerFileBlock
,
pCfg
->
precision
,
pCfg
->
compression
);
...
@@ -142,6 +143,7 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
...
@@ -142,6 +143,7 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
if
(
repo
==
NULL
)
return
;
if
(
repo
==
NULL
)
return
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
int
vgId
=
REPO_ID
(
pRepo
);
if
(
toCommit
)
{
if
(
toCommit
)
{
tsdbAsyncCommit
(
pRepo
);
tsdbAsyncCommit
(
pRepo
);
...
@@ -151,7 +153,8 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
...
@@ -151,7 +153,8 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
tsdbCloseFileH
(
pRepo
);
tsdbCloseFileH
(
pRepo
);
tsdbCloseBufPool
(
pRepo
);
tsdbCloseBufPool
(
pRepo
);
tsdbCloseMeta
(
pRepo
);
tsdbCloseMeta
(
pRepo
);
tsdbTrace
(
"vgId:%d repository is closed"
,
REPO_ID
(
pRepo
));
tsdbFreeRepo
(
pRepo
);
tsdbTrace
(
"vgId:%d repository is closed"
,
vgId
);
}
}
int32_t
tsdbInsertData
(
TSDB_REPO_T
*
repo
,
SSubmitMsg
*
pMsg
,
SShellSubmitRspMsg
*
pRsp
)
{
int32_t
tsdbInsertData
(
TSDB_REPO_T
*
repo
,
SSubmitMsg
*
pMsg
,
SShellSubmitRspMsg
*
pRsp
)
{
...
@@ -170,7 +173,6 @@ int32_t tsdbInsertData(TSDB_REPO_T *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *
...
@@ -170,7 +173,6 @@ int32_t tsdbInsertData(TSDB_REPO_T *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *
while
((
pBlock
=
tsdbGetSubmitMsgNext
(
&
msgIter
))
!=
NULL
)
{
while
((
pBlock
=
tsdbGetSubmitMsgNext
(
&
msgIter
))
!=
NULL
)
{
if
(
tsdbInsertDataToTable
(
pRepo
,
pBlock
,
now
,
&
affectedrows
)
<
0
)
{
if
(
tsdbInsertDataToTable
(
pRepo
,
pBlock
,
now
,
&
affectedrows
)
<
0
)
{
pRsp
->
affectedRows
=
htonl
(
affectedrows
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -534,7 +536,7 @@ static int32_t tsdbSaveConfig(char *rootDir, STsdbCfg *pCfg) {
...
@@ -534,7 +536,7 @@ static int32_t tsdbSaveConfig(char *rootDir, STsdbCfg *pCfg) {
}
}
int
tlen
=
tsdbEncodeCfg
((
void
*
)(
&
pBuf
),
pCfg
);
int
tlen
=
tsdbEncodeCfg
((
void
*
)(
&
pBuf
),
pCfg
);
ASSERT
(
tlen
+
sizeof
(
TSCKSUM
)
<=
TSDB_FILE_HEAD_SIZE
);
ASSERT
(
(
tlen
+
sizeof
(
TSCKSUM
)
<=
TSDB_FILE_HEAD_SIZE
)
&&
(
POINTER_DISTANCE
(
pBuf
,
buf
)
==
tlen
)
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
buf
,
TSDB_FILE_HEAD_SIZE
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
buf
,
TSDB_FILE_HEAD_SIZE
);
...
@@ -718,43 +720,12 @@ static int32_t tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, TSKEY
...
@@ -718,43 +720,12 @@ static int32_t tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, TSKEY
return
-
1
;
return
-
1
;
}
}
// Check schema version
// Check schema version and update schema if needed
int32_t
tversion
=
pBlock
->
sversion
;
if
(
tsdbCheckTableSchema
(
pRepo
,
pBlock
,
pTable
)
<
0
)
{
STSchema
*
pSchema
=
tsdbGetTableSchema
(
pTable
);
tsdbError
(
"vgId:%d failed to insert data to table %s since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
ASSERT
(
pSchema
!=
NULL
);
tstrerror
(
terrno
));
int16_t
nversion
=
schemaVersion
(
pSchema
);
if
(
tversion
>
nversion
)
{
tsdbTrace
(
"vgId:%d table %s tid %d server schema version %d is older than clien version %d, try to config."
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
),
nversion
,
tversion
);
void
*
msg
=
(
*
pRepo
->
appH
.
configFunc
)(
REPO_ID
(
pRepo
),
TABLE_TID
(
pTable
));
if
(
msg
==
NULL
)
return
-
1
;
// TODO: Deal with error her
STableCfg
*
pTableCfg
=
tsdbCreateTableCfgFromMsg
(
msg
);
STable
*
pTableUpdate
=
NULL
;
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
pTableUpdate
=
tsdbGetTableByUid
(
pMeta
,
pTableCfg
->
superUid
);
}
else
{
pTableUpdate
=
pTable
;
}
int32_t
code
=
tsdbUpdateTable
(
pMeta
,
pTableUpdate
,
pTableCfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
tsdbClearTableCfg
(
pTableCfg
);
rpcFreeCont
(
msg
);
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
tversion
);
}
else
if
(
tversion
<
nversion
)
{
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
tversion
);
if
(
pSchema
==
NULL
)
{
tsdbError
(
"vgId:%d table %s tid %d invalid schema version %d from client"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
),
tversion
);
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
return
-
1
;
return
-
1
;
}
}
}
SSubmitBlkIter
blkIter
=
{
0
};
SSubmitBlkIter
blkIter
=
{
0
};
SDataRow
row
=
NULL
;
SDataRow
row
=
NULL
;
...
@@ -777,6 +748,8 @@ static int32_t tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, TSKEY
...
@@ -777,6 +748,8 @@ static int32_t tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, TSKEY
(
*
affectedrows
)
++
;
(
*
affectedrows
)
++
;
points
++
;
points
++
;
}
}
STSchema
*
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
pBlock
->
sversion
);
pRepo
->
stat
.
pointsWritten
+=
points
*
schemaNCols
(
pSchema
);
pRepo
->
stat
.
pointsWritten
+=
points
*
schemaNCols
(
pSchema
);
pRepo
->
stat
.
totalStorage
+=
points
*
schemaVLen
(
pSchema
);
pRepo
->
stat
.
totalStorage
+=
points
*
schemaVLen
(
pSchema
);
...
@@ -820,6 +793,7 @@ static SDataRow tsdbGetSubmitBlkNext(SSubmitBlkIter *pIter) {
...
@@ -820,6 +793,7 @@ static SDataRow tsdbGetSubmitBlkNext(SSubmitBlkIter *pIter) {
}
}
static
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
)
{
static
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
)
{
// TODO
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
SFileGroup
*
pFGroup
=
NULL
;
SFileGroup
*
pFGroup
=
NULL
;
...
@@ -943,6 +917,55 @@ static void *tsdbDecodeCfg(void *buf, STsdbCfg *pCfg) {
...
@@ -943,6 +917,55 @@ static void *tsdbDecodeCfg(void *buf, STsdbCfg *pCfg) {
return
buf
;
return
buf
;
}
}
static
int
tsdbCheckTableSchema
(
STsdbRepo
*
pRepo
,
SSubmitBlk
*
pBlock
,
STable
*
pTable
)
{
ASSERT
(
pTable
!=
NULL
);
STSchema
*
pSchema
=
tsdbGetTableSchema
(
pTable
);
int
sversion
=
schemaVersion
(
pSchema
);
if
(
pBlock
->
sversion
==
sversion
)
return
0
;
if
(
pBlock
->
sversion
>
sversion
)
{
// need to config
tsdbTrace
(
"vgId:%d table %s tid %d has version %d smaller than client version %d, try to config"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
),
sversion
,
pBlock
->
sversion
);
if
(
pRepo
->
appH
.
configFunc
)
{
void
*
msg
=
(
*
pRepo
->
appH
.
configFunc
)(
REPO_ID
(
pRepo
),
TABLE_TID
(
pTable
));
if
(
msg
==
NULL
)
{
tsdbError
(
"vgId:%d failed to config table %s tid %d since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
),
tstrerror
(
terrno
));
return
-
1
;
}
STableCfg
*
pTableCfg
=
tsdbCreateTableCfgFromMsg
(
msg
);
if
(
pTableCfg
==
NULL
)
{
rpcFreeCont
(
msg
);
return
-
1
;
}
if
(
tsdbUpdateTable
(
pRepo
,
(
TABLE_TYPE
(
pTable
)
==
TSDB_CHILD_TABLE
)
?
pTable
->
pSuper
:
pTable
,
pTableCfg
)
<
0
)
{
tsdbError
(
"vgId:%d failed to update table %s since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tstrerror
(
terrno
));
tsdbClearTableCfg
(
pTableCfg
);
rpcFreeCont
(
msg
);
return
-
1
;
}
tsdbClearTableCfg
(
pTableCfg
);
rpcFreeCont
(
msg
);
}
else
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
return
-
1
;
}
}
else
{
if
(
tsdbGetTableSchemaByVersion
(
pTable
,
pBlock
->
sversion
)
==
NULL
)
{
tsdbError
(
"vgId:%d invalid submit schema version %d to table %s tid %d from client"
,
REPO_ID
(
pRepo
),
pBlock
->
sversion
,
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
));
}
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
return
-
1
;
}
return
0
;
}
static
int
tsdbAlterCacheTotalBlocks
(
STsdbRepo
*
pRepo
,
int
totalBlocks
)
{
static
int
tsdbAlterCacheTotalBlocks
(
STsdbRepo
*
pRepo
,
int
totalBlocks
)
{
// TODO
// TODO
// STsdbCache *pCache = pRepo->tsdbCache;
// STsdbCache *pCache = pRepo->tsdbCache;
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
a60fc0f7
...
@@ -74,7 +74,7 @@ int tsdbCreateTable(TSDB_REPO_T *repo, STableCfg *pCfg) {
...
@@ -74,7 +74,7 @@ int tsdbCreateTable(TSDB_REPO_T *repo, STableCfg *pCfg) {
// TODO
// TODO
if
(
super
->
type
!=
TSDB_SUPER_TABLE
)
return
-
1
;
if
(
super
->
type
!=
TSDB_SUPER_TABLE
)
return
-
1
;
if
(
super
->
tableId
.
uid
!=
pCfg
->
superUid
)
return
-
1
;
if
(
super
->
tableId
.
uid
!=
pCfg
->
superUid
)
return
-
1
;
tsdbUpdateTable
(
p
Meta
,
super
,
pCfg
);
tsdbUpdateTable
(
p
Repo
,
super
,
pCfg
);
}
}
}
}
...
@@ -279,7 +279,7 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
...
@@ -279,7 +279,7 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
STable
*
super
=
tsdbGetTableByUid
(
pMeta
,
pTableCfg
->
superUid
);
STable
*
super
=
tsdbGetTableByUid
(
pMeta
,
pTableCfg
->
superUid
);
ASSERT
(
super
!=
NULL
);
ASSERT
(
super
!=
NULL
);
int32_t
code
=
tsdbUpdateTable
(
p
Meta
,
super
,
pTableCfg
);
int32_t
code
=
tsdbUpdateTable
(
p
Repo
,
super
,
pTableCfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -447,16 +447,21 @@ STSchema *tsdbGetTableTagSchema(STable *pTable) {
...
@@ -447,16 +447,21 @@ STSchema *tsdbGetTableTagSchema(STable *pTable) {
}
}
}
}
int
tsdbUpdateTable
(
STsdbMeta
*
pMeta
,
STable
*
pTable
,
STableCfg
*
pCfg
)
{
int
tsdbUpdateTable
(
STsdbRepo
*
pRepo
,
STable
*
pTable
,
STableCfg
*
pCfg
)
{
ASSERT
(
pTable
->
type
!=
TSDB_CHILD_TABLE
);
// TODO: this function can only be called when there is no query and commit on this table
bool
isChanged
=
false
;
ASSERT
(
TABLE_TYPE
(
pTable
)
!=
TSDB_CHILD_TABLE
);
bool
changed
=
false
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
schemaVersion
(
pTable
->
tagSchema
)
<
schemaVersion
(
pCfg
->
tagSchema
))
{
if
(
schemaVersion
(
pTable
->
tagSchema
)
<
schemaVersion
(
pCfg
->
tagSchema
))
{
int32_t
code
=
tsdbUpdateTableTagSchema
(
pTable
,
pCfg
->
tagSchema
);
if
(
tsdbUpdateTableTagSchema
(
pTable
,
pCfg
->
tagSchema
)
<
0
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
code
;
tsdbError
(
"vgId:%d failed to update table %s tag schema since %s"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tstrerror
(
terrno
));
return
-
1
;
}
}
isChanged
=
true
;
}
changed
=
true
;
}
}
STSchema
*
pTSchema
=
tsdbGetTableSchema
(
pTable
);
STSchema
*
pTSchema
=
tsdbGetTableSchema
(
pTable
);
...
@@ -471,18 +476,19 @@ int tsdbUpdateTable(STsdbMeta *pMeta, STable *pTable, STableCfg *pCfg) {
...
@@ -471,18 +476,19 @@ int tsdbUpdateTable(STsdbMeta *pMeta, STable *pTable, STableCfg *pCfg) {
pTable
->
schema
[
pTable
->
numOfSchemas
-
1
]
=
tSchema
;
pTable
->
schema
[
pTable
->
numOfSchemas
-
1
]
=
tSchema
;
}
}
isChanged
=
true
;
pMeta
->
maxRowBytes
=
MAX
(
pMeta
->
maxRowBytes
,
dataRowMaxBytesFromSchema
(
pCfg
->
schema
));
pMeta
->
maxCols
=
MAX
(
pMeta
->
maxCols
,
schemaNCols
(
pCfg
->
schema
));
changed
=
true
;
}
}
if
(
isChanged
)
{
if
(
changed
)
{
// TODO
int
tlen
=
tsdbGetTableEncodeSize
(
TSDB_UPDATE_META
,
pTable
);
// char *buf = malloc(1024 * 1024);
void
*
buf
=
tsdbAllocBytes
(
pRepo
,
tlen
);
// tsdbEncodeTable(buf, pTable);
tsdbInsertTableAct
(
pRepo
,
TSDB_UPDATE_META
,
buf
,
pTable
);
// // tsdbInsertMetaRecord(pMeta->mfh, pTable->tableId.uid, buf, bufLen);
// free(buf);
}
}
return
TSDB_CODE_SUCCESS
;
return
0
;
}
}
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
)
{
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
)
{
...
...
src/util/src/hash.c
浏览文件 @
a60fc0f7
...
@@ -309,9 +309,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
...
@@ -309,9 +309,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
}
}
void
taosHashCleanup
(
SHashObj
*
pHashObj
)
{
void
taosHashCleanup
(
SHashObj
*
pHashObj
)
{
if
(
pHashObj
==
NULL
||
pHashObj
->
capacity
<=
0
)
{
if
(
pHashObj
==
NULL
)
return
;
return
;
}
SHashNode
*
pNode
,
*
pNext
;
SHashNode
*
pNode
,
*
pNext
;
...
...
src/util/src/tkvstore.c
浏览文件 @
a60fc0f7
...
@@ -58,25 +58,21 @@ int tdCreateKVStore(char *fname) {
...
@@ -58,25 +58,21 @@ int tdCreateKVStore(char *fname) {
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
uError
(
"failed to open file %s since %s"
,
fname
,
strerror
(
errno
));
uError
(
"failed to open file %s since %s"
,
fname
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
if
(
tdInitKVStoreHeader
(
fd
,
fname
)
<
0
)
{
close
(
fd
);
return
-
1
;
return
-
1
;
}
}
if
(
tdInitKVStoreHeader
(
fd
,
fname
)
<
0
)
goto
_err
;
if
(
fsync
(
fd
)
<
0
)
{
if
(
fsync
(
fd
)
<
0
)
{
uError
(
"failed to fsync file %s since %s"
,
fname
,
strerror
(
errno
));
uError
(
"failed to fsync file %s since %s"
,
fname
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
close
(
fd
);
goto
_err
;
return
-
1
;
}
}
if
(
close
(
fd
)
<
0
)
{
if
(
close
(
fd
)
<
0
)
{
uError
(
"failed to close file %s since %s"
,
fname
,
strerror
(
errno
));
uError
(
"failed to close file %s since %s"
,
fname
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
goto
_err
;
}
}
return
0
;
return
0
;
...
...
src/util/src/tlist.c
浏览文件 @
a60fc0f7
...
@@ -39,8 +39,10 @@ void tdListEmpty(SList *list) {
...
@@ -39,8 +39,10 @@ void tdListEmpty(SList *list) {
}
}
void
tdListFree
(
SList
*
list
)
{
void
tdListFree
(
SList
*
list
)
{
if
(
list
)
{
tdListEmpty
(
list
);
tdListEmpty
(
list
);
free
(
list
);
free
(
list
);
}
}
}
void
tdListPrependNode
(
SList
*
list
,
SListNode
*
node
)
{
void
tdListPrependNode
(
SList
*
list
,
SListNode
*
node
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录