Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
365843ec
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看板
未验证
提交
365843ec
编写于
9月 16, 2021
作者:
M
Minglei Jin
提交者:
GitHub
9月 16, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7947 from taosdata/hotfix/TD-6636-M
<TD-6636><hotfix>: row convert fix and schema version fetch optimize
上级
ba198c79
727612fd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
41 addition
and
33 deletion
+41
-33
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/tsdb/inc/tsdbMeta.h
src/tsdb/inc/tsdbMeta.h
+11
-5
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+5
-3
src/tsdb/src/tsdbCompact.c
src/tsdb/src/tsdbCompact.c
+1
-1
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+1
-1
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+7
-7
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+7
-7
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+7
-7
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+1
-1
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
365843ec
...
@@ -580,7 +580,7 @@ static FORCE_INLINE void convertToSKVRow(SMemRow dest, SMemRow src, SSchema *pSc
...
@@ -580,7 +580,7 @@ static FORCE_INLINE void convertToSKVRow(SMemRow dest, SMemRow src, SSchema *pSc
SKVRow
kvRow
=
memRowKvBody
(
dest
);
SKVRow
kvRow
=
memRowKvBody
(
dest
);
memRowSetType
(
dest
,
SMEM_ROW_KV
);
memRowSetType
(
dest
,
SMEM_ROW_KV
);
memRowSetKvVersion
(
kvRow
,
dataRowVersion
(
dataRow
));
memRowSetKvVersion
(
dest
,
dataRowVersion
(
dataRow
));
kvRowSetNCols
(
kvRow
,
nBoundCols
);
kvRowSetNCols
(
kvRow
,
nBoundCols
);
kvRowSetLen
(
kvRow
,
(
TDRowLenT
)(
TD_KV_ROW_HEAD_SIZE
+
sizeof
(
SColIdx
)
*
nBoundCols
));
kvRowSetLen
(
kvRow
,
(
TDRowLenT
)(
TD_KV_ROW_HEAD_SIZE
+
sizeof
(
SColIdx
)
*
nBoundCols
));
...
...
src/tsdb/inc/tsdbMeta.h
浏览文件 @
365843ec
...
@@ -74,7 +74,7 @@ void tsdbFreeMeta(STsdbMeta* pMeta);
...
@@ -74,7 +74,7 @@ void tsdbFreeMeta(STsdbMeta* pMeta);
int
tsdbOpenMeta
(
STsdbRepo
*
pRepo
);
int
tsdbOpenMeta
(
STsdbRepo
*
pRepo
);
int
tsdbCloseMeta
(
STsdbRepo
*
pRepo
);
int
tsdbCloseMeta
(
STsdbRepo
*
pRepo
);
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
,
int8_t
rowType
);
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbRLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbRLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepoMeta
(
STsdbRepo
*
pRepo
);
...
@@ -99,7 +99,9 @@ static FORCE_INLINE int tsdbCompareSchemaVersion(const void *key1, const void *k
...
@@ -99,7 +99,9 @@ static FORCE_INLINE int tsdbCompareSchemaVersion(const void *key1, const void *k
}
}
}
}
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int16_t
_version
)
{
// set rowType to -1 at default if have no relationship with row
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int16_t
_version
,
int8_t
rowType
)
{
STable
*
pDTable
=
(
pTable
->
pSuper
!=
NULL
)
?
pTable
->
pSuper
:
pTable
;
// for performance purpose
STable
*
pDTable
=
(
pTable
->
pSuper
!=
NULL
)
?
pTable
->
pSuper
:
pTable
;
// for performance purpose
STSchema
*
pSchema
=
NULL
;
STSchema
*
pSchema
=
NULL
;
STSchema
*
pTSchema
=
NULL
;
STSchema
*
pTSchema
=
NULL
;
...
@@ -110,8 +112,12 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
...
@@ -110,8 +112,12 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
}
else
{
// get the schema with version
}
else
{
// get the schema with version
void
*
ptr
=
taosArraySearch
(
pDTable
->
schema
,
&
_version
,
tsdbCompareSchemaVersion
,
TD_EQ
);
void
*
ptr
=
taosArraySearch
(
pDTable
->
schema
,
&
_version
,
tsdbCompareSchemaVersion
,
TD_EQ
);
if
(
ptr
==
NULL
)
{
if
(
ptr
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
if
(
rowType
==
SMEM_ROW_KV
)
{
goto
_exit
;
ptr
=
taosArrayGetLast
(
pDTable
->
schema
);
}
else
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
goto
_exit
;
}
}
}
pTSchema
=
*
(
STSchema
**
)
ptr
;
pTSchema
=
*
(
STSchema
**
)
ptr
;
}
}
...
@@ -130,7 +136,7 @@ _exit:
...
@@ -130,7 +136,7 @@ _exit:
}
}
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchema
(
STable
*
pTable
)
{
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchema
(
STable
*
pTable
)
{
return
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
return
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
);
}
}
static
FORCE_INLINE
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
)
{
static
FORCE_INLINE
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
)
{
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
365843ec
...
@@ -866,7 +866,7 @@ static int tsdbCommitToTable(SCommitH *pCommith, int tid) {
...
@@ -866,7 +866,7 @@ static int tsdbCommitToTable(SCommitH *pCommith, int tid) {
}
}
static
int
tsdbSetCommitTable
(
SCommitH
*
pCommith
,
STable
*
pTable
)
{
static
int
tsdbSetCommitTable
(
SCommitH
*
pCommith
,
STable
*
pTable
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
);
pCommith
->
pTable
=
pTable
;
pCommith
->
pTable
=
pTable
;
...
@@ -1283,7 +1283,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
...
@@ -1283,7 +1283,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
(
*
iter
)
++
;
(
*
iter
)
++
;
}
else
if
(
key1
>
key2
)
{
}
else
if
(
key1
>
key2
)
{
if
(
pSchema
==
NULL
||
schemaVersion
(
pSchema
)
!=
memRowVersion
(
row
))
{
if
(
pSchema
==
NULL
||
schemaVersion
(
pSchema
)
!=
memRowVersion
(
row
))
{
pSchema
=
tsdbGetTableSchemaImpl
(
pCommitIter
->
pTable
,
false
,
false
,
memRowVersion
(
row
));
pSchema
=
tsdbGetTableSchemaImpl
(
pCommitIter
->
pTable
,
false
,
false
,
memRowVersion
(
row
),
(
int8_t
)
memRowType
(
row
));
ASSERT
(
pSchema
!=
NULL
);
ASSERT
(
pSchema
!=
NULL
);
}
}
...
@@ -1304,7 +1305,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
...
@@ -1304,7 +1305,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
if
(
update
!=
TD_ROW_DISCARD_UPDATE
)
{
if
(
update
!=
TD_ROW_DISCARD_UPDATE
)
{
//copy mem data
//copy mem data
if
(
pSchema
==
NULL
||
schemaVersion
(
pSchema
)
!=
memRowVersion
(
row
))
{
if
(
pSchema
==
NULL
||
schemaVersion
(
pSchema
)
!=
memRowVersion
(
row
))
{
pSchema
=
tsdbGetTableSchemaImpl
(
pCommitIter
->
pTable
,
false
,
false
,
memRowVersion
(
row
));
pSchema
=
tsdbGetTableSchemaImpl
(
pCommitIter
->
pTable
,
false
,
false
,
memRowVersion
(
row
),
(
int8_t
)
memRowType
(
row
));
ASSERT
(
pSchema
!=
NULL
);
ASSERT
(
pSchema
!=
NULL
);
}
}
...
...
src/tsdb/src/tsdbCompact.c
浏览文件 @
365843ec
...
@@ -431,7 +431,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
...
@@ -431,7 +431,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
if
(
pTh
->
pTable
==
NULL
||
pTh
->
pBlkIdx
==
NULL
)
continue
;
if
(
pTh
->
pTable
==
NULL
||
pTh
->
pBlkIdx
==
NULL
)
continue
;
pSchema
=
tsdbGetTableSchemaImpl
(
pTh
->
pTable
,
true
,
true
,
-
1
);
pSchema
=
tsdbGetTableSchemaImpl
(
pTh
->
pTable
,
true
,
true
,
-
1
,
-
1
);
taosArrayClear
(
pComph
->
aSupBlk
);
taosArrayClear
(
pComph
->
aSupBlk
);
if
((
tdInitDataCols
(
pComph
->
pDataCols
,
pSchema
)
<
0
)
||
(
tdInitDataCols
(
pReadh
->
pDCols
[
0
],
pSchema
)
<
0
)
||
if
((
tdInitDataCols
(
pComph
->
pDataCols
,
pSchema
)
<
0
)
||
(
tdInitDataCols
(
pReadh
->
pDCols
[
0
],
pSchema
)
<
0
)
||
(
tdInitDataCols
(
pReadh
->
pDCols
[
1
],
pSchema
)
<
0
))
{
(
tdInitDataCols
(
pReadh
->
pDCols
[
1
],
pSchema
)
<
0
))
{
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
365843ec
...
@@ -617,7 +617,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) {
...
@@ -617,7 +617,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) {
STable
*
pTable
=
pMeta
->
tables
[
i
];
STable
*
pTable
=
pMeta
->
tables
[
i
];
if
(
pTable
&&
pTable
->
type
==
TSDB_STREAM_TABLE
)
{
if
(
pTable
&&
pTable
->
type
==
TSDB_STREAM_TABLE
)
{
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
),
0
);
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
),
0
);
}
}
}
}
}
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
365843ec
...
@@ -582,7 +582,7 @@ static int tsdbAdjustMemMaxTables(SMemTable *pMemTable, int maxTables) {
...
@@ -582,7 +582,7 @@ static int tsdbAdjustMemMaxTables(SMemTable *pMemTable, int maxTables) {
static
int
tsdbAppendTableRowToCols
(
STable
*
pTable
,
SDataCols
*
pCols
,
STSchema
**
ppSchema
,
SMemRow
row
)
{
static
int
tsdbAppendTableRowToCols
(
STable
*
pTable
,
SDataCols
*
pCols
,
STSchema
**
ppSchema
,
SMemRow
row
)
{
if
(
pCols
)
{
if
(
pCols
)
{
if
(
*
ppSchema
==
NULL
||
schemaVersion
(
*
ppSchema
)
!=
memRowVersion
(
row
))
{
if
(
*
ppSchema
==
NULL
||
schemaVersion
(
*
ppSchema
)
!=
memRowVersion
(
row
))
{
*
ppSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
memRowVersion
(
row
));
*
ppSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
memRowVersion
(
row
)
,
(
int8_t
)
memRowType
(
row
)
);
if
(
*
ppSchema
==
NULL
)
{
if
(
*
ppSchema
==
NULL
)
{
ASSERT
(
false
);
ASSERT
(
false
);
return
-
1
;
return
-
1
;
...
@@ -730,7 +730,7 @@ static SMemRow tsdbInsertDupKeyMerge(SMemRow row1, SMemRow row2, STsdbRepo* pRep
...
@@ -730,7 +730,7 @@ static SMemRow tsdbInsertDupKeyMerge(SMemRow row1, SMemRow row2, STsdbRepo* pRep
if
(
pSchema2
!=
NULL
&&
schemaVersion
(
pSchema2
)
==
dv1
)
{
if
(
pSchema2
!=
NULL
&&
schemaVersion
(
pSchema2
)
==
dv1
)
{
*
ppSchema1
=
pSchema2
;
*
ppSchema1
=
pSchema2
;
}
else
{
}
else
{
*
ppSchema1
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
memRowVersion
(
row1
));
*
ppSchema1
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
memRowVersion
(
row1
)
,
(
int8_t
)
memRowType
(
row1
)
);
}
}
pSchema1
=
*
ppSchema1
;
pSchema1
=
*
ppSchema1
;
}
}
...
@@ -739,7 +739,7 @@ static SMemRow tsdbInsertDupKeyMerge(SMemRow row1, SMemRow row2, STsdbRepo* pRep
...
@@ -739,7 +739,7 @@ static SMemRow tsdbInsertDupKeyMerge(SMemRow row1, SMemRow row2, STsdbRepo* pRep
if
(
schemaVersion
(
pSchema1
)
==
dv2
)
{
if
(
schemaVersion
(
pSchema1
)
==
dv2
)
{
pSchema2
=
pSchema1
;
pSchema2
=
pSchema1
;
}
else
{
}
else
{
*
ppSchema2
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
memRowVersion
(
row2
));
*
ppSchema2
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
memRowVersion
(
row2
)
,
(
int8_t
)
memRowType
(
row2
)
);
pSchema2
=
*
ppSchema2
;
pSchema2
=
*
ppSchema2
;
}
}
}
}
...
@@ -847,7 +847,7 @@ static int tsdbInsertDataToTable(STsdbRepo* pRepo, SSubmitBlk* pBlock, int32_t *
...
@@ -847,7 +847,7 @@ static int tsdbInsertDataToTable(STsdbRepo* pRepo, SSubmitBlk* pBlock, int32_t *
}
}
}
}
STSchema
*
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
pBlock
->
sversion
);
STSchema
*
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
pBlock
->
sversion
,
-
1
);
pRepo
->
stat
.
pointsWritten
+=
points
*
schemaNCols
(
pSchema
);
pRepo
->
stat
.
pointsWritten
+=
points
*
schemaNCols
(
pSchema
);
pRepo
->
stat
.
totalStorage
+=
points
*
schemaVLen
(
pSchema
);
pRepo
->
stat
.
totalStorage
+=
points
*
schemaVLen
(
pSchema
);
...
@@ -894,7 +894,7 @@ static int tsdbGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
...
@@ -894,7 +894,7 @@ static int tsdbGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
static
int
tsdbCheckTableSchema
(
STsdbRepo
*
pRepo
,
SSubmitBlk
*
pBlock
,
STable
*
pTable
)
{
static
int
tsdbCheckTableSchema
(
STsdbRepo
*
pRepo
,
SSubmitBlk
*
pBlock
,
STable
*
pTable
)
{
ASSERT
(
pTable
!=
NULL
);
ASSERT
(
pTable
!=
NULL
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
);
int
sversion
=
schemaVersion
(
pSchema
);
int
sversion
=
schemaVersion
(
pSchema
);
if
(
pBlock
->
sversion
==
sversion
)
{
if
(
pBlock
->
sversion
==
sversion
)
{
...
@@ -951,7 +951,7 @@ static int tsdbCheckTableSchema(STsdbRepo *pRepo, SSubmitBlk *pBlock, STable *pT
...
@@ -951,7 +951,7 @@ static int tsdbCheckTableSchema(STsdbRepo *pRepo, SSubmitBlk *pBlock, STable *pT
}
}
}
else
{
}
else
{
ASSERT
(
pBlock
->
sversion
>=
0
);
ASSERT
(
pBlock
->
sversion
>=
0
);
if
(
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
pBlock
->
sversion
)
==
NULL
)
{
if
(
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
pBlock
->
sversion
,
-
1
)
==
NULL
)
{
tsdbError
(
"vgId:%d invalid submit schema version %d to table %s tid %d from client"
,
REPO_ID
(
pRepo
),
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
));
pBlock
->
sversion
,
TABLE_CHAR_NAME
(
pTable
),
TABLE_TID
(
pTable
));
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
...
@@ -972,7 +972,7 @@ static void updateTableLatestColumn(STsdbRepo *pRepo, STable *pTable, SMemRow ro
...
@@ -972,7 +972,7 @@ static void updateTableLatestColumn(STsdbRepo *pRepo, STable *pTable, SMemRow ro
return
;
return
;
}
}
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row
));
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row
)
,
(
int8_t
)
memRowType
(
row
)
);
if
(
pSchema
==
NULL
)
{
if
(
pSchema
==
NULL
)
{
return
;
return
;
}
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
365843ec
...
@@ -534,8 +534,8 @@ STable *tsdbGetTableByUid(STsdbMeta *pMeta, uint64_t uid) {
...
@@ -534,8 +534,8 @@ STable *tsdbGetTableByUid(STsdbMeta *pMeta, uint64_t uid) {
return
*
(
STable
**
)
ptr
;
return
*
(
STable
**
)
ptr
;
}
}
STSchema
*
tsdbGetTableSchemaByVersion
(
STable
*
pTable
,
int16_t
_version
)
{
STSchema
*
tsdbGetTableSchemaByVersion
(
STable
*
pTable
,
int16_t
_version
,
int8_t
rowType
)
{
return
tsdbGetTableSchemaImpl
(
pTable
,
true
,
false
,
_version
);
return
tsdbGetTableSchemaImpl
(
pTable
,
true
,
false
,
_version
,
rowType
);
}
}
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
)
{
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
)
{
...
@@ -652,7 +652,7 @@ int tsdbInitColIdCacheWithSchema(STable* pTable, STSchema* pSchema) {
...
@@ -652,7 +652,7 @@ int tsdbInitColIdCacheWithSchema(STable* pTable, STSchema* pSchema) {
}
}
STSchema
*
tsdbGetTableLatestSchema
(
STable
*
pTable
)
{
STSchema
*
tsdbGetTableLatestSchema
(
STable
*
pTable
)
{
return
tsdbGetTableSchemaByVersion
(
pTable
,
-
1
);
return
tsdbGetTableSchemaByVersion
(
pTable
,
-
1
,
-
1
);
}
}
int
tsdbUpdateLastColSchema
(
STable
*
pTable
,
STSchema
*
pNewSchema
)
{
int
tsdbUpdateLastColSchema
(
STable
*
pTable
,
STSchema
*
pNewSchema
)
{
...
@@ -957,7 +957,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
...
@@ -957,7 +957,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
}
}
if
(
TABLE_TYPE
(
pTable
)
!=
TSDB_CHILD_TABLE
)
{
if
(
TABLE_TYPE
(
pTable
)
!=
TSDB_CHILD_TABLE
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
);
if
(
schemaNCols
(
pSchema
)
>
pMeta
->
maxCols
)
pMeta
->
maxCols
=
schemaNCols
(
pSchema
);
if
(
schemaNCols
(
pSchema
)
>
pMeta
->
maxCols
)
pMeta
->
maxCols
=
schemaNCols
(
pSchema
);
if
(
schemaTLen
(
pSchema
)
>
pMeta
->
maxRowBytes
)
pMeta
->
maxRowBytes
=
schemaTLen
(
pSchema
);
if
(
schemaTLen
(
pSchema
)
>
pMeta
->
maxRowBytes
)
pMeta
->
maxRowBytes
=
schemaTLen
(
pSchema
);
}
}
...
@@ -965,7 +965,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
...
@@ -965,7 +965,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
if
(
lock
&&
tsdbUnlockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
if
(
lock
&&
tsdbUnlockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_STREAM_TABLE
&&
addIdx
)
{
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_STREAM_TABLE
&&
addIdx
)
{
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
),
1
);
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
),
1
);
}
}
tsdbDebug
(
"vgId:%d table %s tid %d uid %"
PRIu64
" is added to meta"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tsdbDebug
(
"vgId:%d table %s tid %d uid %"
PRIu64
" is added to meta"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
...
@@ -984,7 +984,7 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
...
@@ -984,7 +984,7 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
SListNode
*
pNode
=
NULL
;
SListNode
*
pNode
=
NULL
;
STable
*
tTable
=
NULL
;
STable
*
tTable
=
NULL
;
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
);
int
maxCols
=
schemaNCols
(
pSchema
);
int
maxCols
=
schemaNCols
(
pSchema
);
int
maxRowBytes
=
schemaTLen
(
pSchema
);
int
maxRowBytes
=
schemaTLen
(
pSchema
);
...
@@ -1018,7 +1018,7 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
...
@@ -1018,7 +1018,7 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro
for
(
int
i
=
0
;
i
<
pMeta
->
maxTables
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pMeta
->
maxTables
;
i
++
)
{
STable
*
_pTable
=
pMeta
->
tables
[
i
];
STable
*
_pTable
=
pMeta
->
tables
[
i
];
if
(
_pTable
!=
NULL
)
{
if
(
_pTable
!=
NULL
)
{
pSchema
=
tsdbGetTableSchemaImpl
(
_pTable
,
false
,
false
,
-
1
);
pSchema
=
tsdbGetTableSchemaImpl
(
_pTable
,
false
,
false
,
-
1
,
-
1
);
maxCols
=
MAX
(
maxCols
,
schemaNCols
(
pSchema
));
maxCols
=
MAX
(
maxCols
,
schemaNCols
(
pSchema
));
maxRowBytes
=
MAX
(
maxRowBytes
,
schemaTLen
(
pSchema
));
maxRowBytes
=
MAX
(
maxRowBytes
,
schemaTLen
(
pSchema
));
}
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
365843ec
...
@@ -1582,7 +1582,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
...
@@ -1582,7 +1582,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
int32_t
numOfColsOfRow1
=
0
;
int32_t
numOfColsOfRow1
=
0
;
if
(
pSchema1
==
NULL
)
{
if
(
pSchema1
==
NULL
)
{
pSchema1
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row1
));
pSchema1
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row1
)
,
(
int8_t
)
memRowType
(
row1
)
);
}
}
if
(
isRow1DataRow
)
{
if
(
isRow1DataRow
)
{
numOfColsOfRow1
=
schemaNCols
(
pSchema1
);
numOfColsOfRow1
=
schemaNCols
(
pSchema1
);
...
@@ -1594,7 +1594,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
...
@@ -1594,7 +1594,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
if
(
row2
)
{
if
(
row2
)
{
isRow2DataRow
=
isDataRow
(
row2
);
isRow2DataRow
=
isDataRow
(
row2
);
if
(
pSchema2
==
NULL
)
{
if
(
pSchema2
==
NULL
)
{
pSchema2
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row2
));
pSchema2
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row2
)
,
(
int8_t
)
memRowType
(
row2
)
);
}
}
if
(
isRow2DataRow
)
{
if
(
isRow2DataRow
)
{
numOfColsOfRow2
=
schemaNCols
(
pSchema2
);
numOfColsOfRow2
=
schemaNCols
(
pSchema2
);
...
@@ -1961,11 +1961,11 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
...
@@ -1961,11 +1961,11 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
if
((
key
<
tsArray
[
pos
]
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
if
((
key
<
tsArray
[
pos
]
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
(
key
>
tsArray
[
pos
]
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
(
key
>
tsArray
[
pos
]
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
if
(
rv1
!=
memRowVersion
(
row1
))
{
if
(
rv1
!=
memRowVersion
(
row1
))
{
pSchema1
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row1
));
pSchema1
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row1
)
,
(
int8_t
)
memRowType
(
row1
)
);
rv1
=
memRowVersion
(
row1
);
rv1
=
memRowVersion
(
row1
);
}
}
if
(
row2
&&
rv2
!=
memRowVersion
(
row2
))
{
if
(
row2
&&
rv2
!=
memRowVersion
(
row2
))
{
pSchema2
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row2
));
pSchema2
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row2
)
,
(
int8_t
)
memRowType
(
row2
)
);
rv2
=
memRowVersion
(
row2
);
rv2
=
memRowVersion
(
row2
);
}
}
...
@@ -1986,11 +1986,11 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
...
@@ -1986,11 +1986,11 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
doCopyRowsFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
pos
,
pos
);
doCopyRowsFromFileBlock
(
pQueryHandle
,
pQueryHandle
->
outputCapacity
,
numOfRows
,
pos
,
pos
);
}
}
if
(
rv1
!=
memRowVersion
(
row1
))
{
if
(
rv1
!=
memRowVersion
(
row1
))
{
pSchema1
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row1
));
pSchema1
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row1
)
,
(
int8_t
)
memRowType
(
row1
)
);
rv1
=
memRowVersion
(
row1
);
rv1
=
memRowVersion
(
row1
);
}
}
if
(
row2
&&
rv2
!=
memRowVersion
(
row2
))
{
if
(
row2
&&
rv2
!=
memRowVersion
(
row2
))
{
pSchema2
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row2
));
pSchema2
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row2
)
,
(
int8_t
)
memRowType
(
row2
)
);
rv2
=
memRowVersion
(
row2
);
rv2
=
memRowVersion
(
row2
);
}
}
...
@@ -2654,7 +2654,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
...
@@ -2654,7 +2654,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
win
->
ekey
=
key
;
win
->
ekey
=
key
;
if
(
rv
!=
memRowVersion
(
row
))
{
if
(
rv
!=
memRowVersion
(
row
))
{
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row
));
pSchema
=
tsdbGetTableSchemaByVersion
(
pTable
,
memRowVersion
(
row
)
,
(
int8_t
)
memRowType
(
row
)
);
rv
=
memRowVersion
(
row
);
rv
=
memRowVersion
(
row
);
}
}
mergeTwoRowFromMem
(
pQueryHandle
,
maxRowsToRead
,
numOfRows
,
row
,
NULL
,
numOfCols
,
pTable
,
pSchema
,
NULL
,
true
);
mergeTwoRowFromMem
(
pQueryHandle
,
maxRowsToRead
,
numOfRows
,
row
,
NULL
,
numOfCols
,
pTable
,
pSchema
,
NULL
,
true
);
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
365843ec
...
@@ -153,7 +153,7 @@ int tsdbLoadBlockIdx(SReadH *pReadh) {
...
@@ -153,7 +153,7 @@ int tsdbLoadBlockIdx(SReadH *pReadh) {
}
}
int
tsdbSetReadTable
(
SReadH
*
pReadh
,
STable
*
pTable
)
{
int
tsdbSetReadTable
(
SReadH
*
pReadh
,
STable
*
pTable
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
,
-
1
);
pReadh
->
pTable
=
pTable
;
pReadh
->
pTable
=
pTable
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录