Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
72c26ef4
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
72c26ef4
编写于
8月 03, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5694]<fix>: refactor
上级
e8d10065
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
26 deletion
+27
-26
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+27
-26
未找到文件。
src/common/src/tdataformat.c
浏览文件 @
72c26ef4
...
...
@@ -23,18 +23,20 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
int
limit2
,
int
tRows
,
bool
forceSetNull
);
void
tdAllocMemForCol
(
SDataCol
*
pCol
,
int
maxPoints
)
{
if
(
pCol
->
pData
==
NULL
)
{
pCol
->
pData
=
malloc
(
maxPoints
*
pCol
->
bytes
);
pCol
->
spaceSize
=
maxPoints
*
pCol
->
bytes
;
if
(
pCol
->
pData
==
NULL
)
{
int
spaceNeeded
=
pCol
->
bytes
*
maxPoints
;
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
spaceNeeded
+=
sizeof
(
VarDataOffsetT
)
*
maxPoints
;
}
if
(
pCol
->
spaceSize
<
spaceNeeded
)
{
void
*
ptr
=
realloc
(
pCol
->
pData
,
spaceNeeded
);
if
(
ptr
==
NULL
)
{
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
pCol
->
spaceSize
,
strerror
(
errno
));
}
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
dataOff
=
malloc
(
maxPoints
*
sizeof
(
VarDataOffsetT
));
if
(
pCol
->
dataOff
==
NULL
)
{
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)(
maxPoints
*
sizeof
(
VarDataOffsetT
)),
strerror
(
errno
));
}
else
{
pCol
->
pData
=
ptr
;
pCol
->
spaceSize
=
spaceNeeded
;
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
dataOff
=
POINTER_SHIFT
(
ptr
,
pCol
->
bytes
*
maxPoints
);
}
}
}
...
...
@@ -330,6 +332,12 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
tdFreeDataCols
(
pCols
);
return
NULL
;
}
int
i
;
for
(
i
=
0
;
i
<
maxCols
;
i
++
)
{
pCols
->
cols
[
i
].
spaceSize
=
0
;
pCols
->
cols
[
i
].
pData
=
NULL
;
pCols
->
cols
[
i
].
dataOff
=
NULL
;
}
pCols
->
maxCols
=
maxCols
;
}
...
...
@@ -343,23 +351,15 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
int
tdInitDataCols
(
SDataCols
*
pCols
,
STSchema
*
pSchema
)
{
int
i
;
int
oldMaxCols
=
pCols
->
maxCols
;
if
(
oldMaxCols
>
0
)
{
for
(
i
=
0
;
i
<
oldMaxCols
;
i
++
)
{
if
(
i
>=
pSchema
->
numOfCols
||
(
pCols
->
cols
[
i
].
spaceSize
<
pSchema
->
columns
[
i
].
bytes
*
pCols
->
maxPoints
))
{
tfree
(
pCols
->
cols
[
i
].
pData
);
tfree
(
pCols
->
cols
[
i
].
dataOff
);
}
}
}
if
(
schemaNCols
(
pSchema
)
>
pCols
->
maxCols
)
{
if
(
schemaNCols
(
pSchema
)
>
oldMaxCols
)
{
pCols
->
maxCols
=
schemaNCols
(
pSchema
);
pCols
->
cols
=
(
SDataCol
*
)
realloc
(
pCols
->
cols
,
sizeof
(
SDataCol
)
*
pCols
->
maxCols
);
if
(
pCols
->
cols
==
NULL
)
return
-
1
;
for
(
i
=
oldMaxCols
;
i
<
pCols
->
maxCols
;
i
++
)
{
pCols
->
cols
[
i
].
pData
=
NULL
;
pCols
->
cols
[
i
].
dataOff
=
NULL
;
pCols
->
cols
[
i
].
spaceSize
=
0
;
}
if
(
pCols
->
cols
==
NULL
)
return
-
1
;
}
if
(
schemaTLen
(
pSchema
)
>
pCols
->
maxRowSize
)
{
...
...
@@ -384,7 +384,6 @@ SDataCols *tdFreeDataCols(SDataCols *pCols) {
for
(
i
=
0
;
i
<
maxCols
;
i
++
)
{
SDataCol
*
pCol
=
&
pCols
->
cols
[
i
];
tfree
(
pCol
->
pData
);
tfree
(
pCol
->
dataOff
);
}
free
(
pCols
->
cols
);
pCols
->
cols
=
NULL
;
...
...
@@ -416,12 +415,14 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
if
(
keepData
)
{
pRet
->
cols
[
i
].
len
=
pDataCols
->
cols
[
i
].
len
;
if
(
pDataCols
->
cols
[
i
].
len
>
0
)
{
pRet
->
cols
[
i
].
spaceSize
=
pDataCols
->
cols
[
i
].
spaceSize
;
pRet
->
cols
[
i
].
pData
=
malloc
(
pDataCols
->
cols
[
i
].
bytes
*
pDataCols
->
maxPoints
);
int
spaceSize
=
pDataCols
->
cols
[
i
].
bytes
*
pDataCols
->
maxPoints
;
pRet
->
cols
[
i
].
spaceSize
=
spaceSize
;
pRet
->
cols
[
i
].
pData
=
malloc
(
spaceSize
);
memcpy
(
pRet
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
len
);
if
(
IS_VAR_DATA_TYPE
(
pRet
->
cols
[
i
].
type
))
{
pRet
->
cols
[
i
].
dataOff
=
malloc
(
sizeof
(
VarDataOffsetT
)
*
pDataCols
->
maxPoints
);
memcpy
(
pRet
->
cols
[
i
].
dataOff
,
pDataCols
->
cols
[
i
].
dataOff
,
sizeof
(
VarDataOffsetT
)
*
pDataCols
->
maxPoints
);
int
dataOffSize
=
sizeof
(
VarDataOffsetT
)
*
pDataCols
->
maxPoints
;
pRet
->
cols
[
i
].
dataOff
=
malloc
(
dataOffSize
);
memcpy
(
pRet
->
cols
[
i
].
dataOff
,
pDataCols
->
cols
[
i
].
dataOff
,
dataOffSize
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录