Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
08848116
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看板
提交
08848116
编写于
5月 17, 2021
作者:
L
lichuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-4034]restore last not NULL column
上级
3b2d5f74
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
13 deletion
+55
-13
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+45
-0
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+10
-13
未找到文件。
src/tsdb/src/tsdbMain.c
浏览文件 @
08848116
...
...
@@ -645,6 +645,8 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) {
STable
*
pTable
=
pMeta
->
tables
[
i
];
if
(
pTable
==
NULL
)
continue
;
//tsdbInfo("tsdbRestoreInfo restore vgId:%d,table:%s", REPO_ID(pRepo), pTable->name->data);
if
(
tsdbSetReadTable
(
&
readh
,
pTable
)
<
0
)
{
tsdbDestroyReadH
(
&
readh
);
return
-
1
;
...
...
@@ -686,6 +688,49 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) {
pCol
->
offset
);
}
}
// restore NULL columns
if
(
CACHE_LAST_NULL_COLUMN
(
pCfg
))
{
STSchema
*
pSchema
=
tsdbGetTableSchema
(
pTable
);
int
numColumns
=
schemaNCols
(
pSchema
);
pTable
->
lastCols
=
(
SDataCol
*
)
malloc
(
numColumns
*
sizeof
(
SDataCol
));
if
(
pTable
->
lastCols
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
pTable
->
lastColNum
=
numColumns
;
SDataRow
row
=
taosTMalloc
(
dataRowMaxBytesFromSchema
(
pSchema
));
if
(
row
==
NULL
)
{
tfree
(
pTable
->
lastCols
);
pTable
->
lastColNum
=
0
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
tdInitDataRow
(
row
,
pSchema
);
SDataCol
*
pLatestCols
=
pTable
->
lastCols
;
for
(
i
=
0
;
i
<
pTable
->
lastColNum
;
++
i
)
{
STColumn
*
pTCol
=
schemaColAt
(
pSchema
,
i
);
SDataCol
*
pDataCol
=
&
(
pLatestCols
[
pTCol
->
colId
]);
pDataCol
->
pData
=
malloc
(
pTCol
->
bytes
);
pDataCol
->
bytes
=
pTCol
->
bytes
;
void
*
value
=
tdGetRowDataOfCol
(
row
,
(
int8_t
)
pTCol
->
type
,
TD_DATA_ROW_HEAD_SIZE
+
pTCol
->
offset
);
if
(
isNullN
(
value
,
pTCol
->
type
))
{
//tsdbInfo("tsdbRestoreInfo restore vgId:%d,table:%s cache column %d NULL", REPO_ID(pRepo), pTable->name->data, pTCol->colId);
continue
;
}
memcpy
(
pDataCol
->
pData
,
value
,
pDataCol
->
bytes
);
//tsdbInfo("tsdbRestoreInfo restore vgId:%d,table:%s cache column %d for %d,%s", REPO_ID(pRepo), pTable->name->data, pTCol->colId, pDataCol->bytes, (char*)pDataCol->pData);
pDataCol
->
ts
=
dataRowTKey
(
row
);
}
taosTZfree
(
row
);
}
}
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
08848116
...
...
@@ -965,11 +965,12 @@ static void tsdbFreeRows(STsdbRepo *pRepo, void **rows, int rowCounter) {
}
static
void
updateTableLatestColumn
(
STsdbRepo
*
pRepo
,
STable
*
pTable
,
SDataRow
row
)
{
//tsdb
Debug
("vgId:%d updateTableLatestColumn, row version:%d", REPO_ID(pRepo), dataRowVersion(row));
//tsdb
Info
("vgId:%d updateTableLatestColumn, row version:%d", REPO_ID(pRepo), dataRowVersion(row));
if
(
pTable
->
numOfSchemas
<=
0
)
{
return
;
}
STSchema
*
pSchema
=
pTable
->
schema
[
pTable
->
numOfSchemas
-
1
];
int
i
=
pTable
->
numOfSchemas
-
1
;
while
((
pSchema
==
NULL
||
pSchema
->
version
!=
dataRowVersion
(
row
))
&&
i
>=
0
)
{
...
...
@@ -983,21 +984,18 @@ static void updateTableLatestColumn(STsdbRepo *pRepo, STable *pTable, SDataRow r
SDataCol
*
pLatestCols
=
pTable
->
lastCols
;
for
(
int
j
=
0
;
j
<
schemaNCols
(
pSchema
);
j
++
)
{
if
(
j
>=
pTable
->
lastColNum
)
{
pTable
->
lastCols
=
realloc
(
pTable
->
lastCols
,
pTable
->
lastColNum
+
10
);
STColumn
*
pTCol
=
schemaColAt
(
pSchema
,
j
);
if
(
pTCol
->
colId
>=
pTable
->
lastColNum
)
{
pTable
->
lastCols
=
realloc
(
pTable
->
lastCols
,
pTCol
->
colId
+
5
);
for
(
i
=
0
;
i
<
10
;
++
i
)
{
pTable
->
lastCols
[
i
+
pTable
->
lastColNum
].
bytes
=
0
;
pTable
->
lastCols
[
i
+
pTable
->
lastColNum
].
pData
=
NULL
;
}
pTable
->
lastColNum
+=
10
;
}
STColumn
*
pTCol
=
schemaColAt
(
pSchema
,
j
);
if
(
pTCol
==
NULL
)
{
// since schema maybe changed, check if STColumn NULL then ignore
continue
;
pTable
->
lastColNum
+=
pTCol
->
colId
+
5
;
}
SDataCol
*
pDataCol
=
&
(
pLatestCols
[
j
]);
SDataCol
*
pDataCol
=
&
(
pLatestCols
[
pTCol
->
colId
]);
void
*
value
=
tdGetRowDataOfCol
(
row
,
(
int8_t
)
pTCol
->
type
,
TD_DATA_ROW_HEAD_SIZE
+
pSchema
->
columns
[
j
].
offset
);
if
(
isNullN
(
value
,
pTCol
->
type
))
{
continue
;
...
...
@@ -1010,9 +1008,8 @@ static void updateTableLatestColumn(STsdbRepo *pRepo, STable *pTable, SDataRow r
pDataCol
->
bytes
=
pSchema
->
columns
[
j
].
bytes
;
}
//tsdbDebug("vgId:%d cache column %d for %d,%p", REPO_ID(pRepo), j, pDataCol->bytes, pDataCol->pData);
memcpy
(
pDataCol
->
pData
,
value
,
pDataCol
->
bytes
);
//tsdbInfo("updateTableLatestColumn vgId:%d cache column %d for %d,%s", REPO_ID(pRepo), j, pDataCol->bytes, (char*)pDataCol->pData);
pDataCol
->
ts
=
dataRowTKey
(
row
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录