Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e8d10065
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看板
提交
e8d10065
编写于
8月 03, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5694]<hot-fix>: fix memory alloc
上级
9de8ca67
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
32 deletion
+42
-32
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+2
-2
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+39
-22
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+1
-8
未找到文件。
src/common/inc/tdataformat.h
浏览文件 @
e8d10065
...
...
@@ -325,6 +325,8 @@ typedef struct SDataCol {
#define isAllRowsNull(pCol) ((pCol)->len == 0)
static
FORCE_INLINE
void
dataColReset
(
SDataCol
*
pDataCol
)
{
pDataCol
->
len
=
0
;
}
void
tdAllocMemForCol
(
SDataCol
*
pCol
,
int
maxPoints
);
void
dataColInit
(
SDataCol
*
pDataCol
,
STColumn
*
pCol
,
int
maxPoints
);
void
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
);
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
);
...
...
@@ -358,12 +360,10 @@ typedef struct {
int
maxRowSize
;
int
maxCols
;
// max number of columns
int
maxPoints
;
// max number of points
//int bufSize;
int
numOfRows
;
int
numOfCols
;
// Total number of cols
int
sversion
;
// TODO: set sversion
//void * buf;
SDataCol
*
cols
;
}
SDataCols
;
...
...
src/common/src/tdataformat.c
浏览文件 @
e8d10065
...
...
@@ -22,6 +22,24 @@
static
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
int
limit1
,
SDataCols
*
src2
,
int
*
iter2
,
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
)
{
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
));
}
}
}
}
/**
* Duplicate the schema and return a new object
*/
...
...
@@ -214,9 +232,6 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, int maxPoints) {
pDataCol
->
offset
=
colOffset
(
pCol
)
+
TD_DATA_ROW_HEAD_SIZE
;
pDataCol
->
len
=
0
;
pDataCol
->
spaceSize
=
pDataCol
->
bytes
*
maxPoints
;
pDataCol
->
pData
=
NULL
;
pDataCol
->
dataOff
=
NULL
;
}
// value from timestamp should be TKEY here instead of TSKEY
void
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
)
{
...
...
@@ -232,14 +247,7 @@ void dataColAppendVal(SDataCol *pCol, const void *value, int numOfRows, int maxP
// Find the first not null value, fill all previouse values as NULL
dataColSetNEleNull
(
pCol
,
numOfRows
,
maxPoints
);
}
else
{
if
(
pCol
->
pData
==
NULL
)
{
pCol
->
pData
=
malloc
(
maxPoints
*
pCol
->
bytes
);
ASSERT
(
pCol
->
pData
!=
NULL
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
dataOff
=
malloc
(
maxPoints
*
sizeof
(
VarDataOffsetT
));
ASSERT
(
pCol
->
dataOff
!=
NULL
);
}
}
tdAllocMemForCol
(
pCol
,
maxPoints
);
}
}
...
...
@@ -277,15 +285,8 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
}
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
)
{
if
(
pCol
->
pData
==
NULL
)
{
pCol
->
pData
=
malloc
(
maxPoints
*
pCol
->
bytes
);
ASSERT
(
pCol
->
pData
!=
NULL
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
dataOff
=
malloc
(
maxPoints
*
sizeof
(
VarDataOffsetT
));
ASSERT
(
pCol
->
dataOff
!=
NULL
);
}
}
if
(
isAllRowsNull
(
pCol
))
return
;
tdAllocMemForCol
(
pCol
,
maxPoints
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
len
=
0
;
...
...
@@ -340,9 +341,24 @@ 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
)
{
pCols
->
maxCols
=
schemaNCols
(
pSchema
);
pCols
->
cols
=
(
SDataCol
*
)
realloc
(
pCols
->
cols
,
sizeof
(
SDataCol
)
*
pCols
->
maxCols
);
for
(
i
=
oldMaxCols
;
i
<
pCols
->
maxCols
;
i
++
)
{
pCols
->
cols
[
i
].
pData
=
NULL
;
pCols
->
cols
[
i
].
dataOff
=
NULL
;
}
if
(
pCols
->
cols
==
NULL
)
return
-
1
;
}
...
...
@@ -353,7 +369,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
tdResetDataCols
(
pCols
);
pCols
->
numOfCols
=
schemaNCols
(
pSchema
);
for
(
i
nt
i
=
0
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
for
(
i
=
0
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
dataColInit
(
pCols
->
cols
+
i
,
schemaColAt
(
pSchema
,
i
),
pCols
->
maxPoints
);
}
...
...
@@ -392,7 +408,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
pRet
->
cols
[
i
].
bytes
=
pDataCols
->
cols
[
i
].
bytes
;
pRet
->
cols
[
i
].
offset
=
pDataCols
->
cols
[
i
].
offset
;
pRet
->
cols
[
i
].
spaceSize
=
pDataCols
->
cols
[
i
].
spaceSize
;
pRet
->
cols
[
i
].
spaceSize
=
0
;
pRet
->
cols
[
i
].
len
=
0
;
pRet
->
cols
[
i
].
dataOff
=
NULL
;
pRet
->
cols
[
i
].
pData
=
NULL
;
...
...
@@ -400,6 +416,7 @@ 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
);
memcpy
(
pRet
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
len
);
if
(
IS_VAR_DATA_TYPE
(
pRet
->
cols
[
i
].
type
))
{
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
e8d10065
...
...
@@ -518,14 +518,7 @@ static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, void *content, int32
return
-
1
;
}
if
(
pDataCol
->
pData
==
NULL
)
{
pDataCol
->
pData
=
malloc
(
maxPoints
*
pDataCol
->
bytes
);
ASSERT
(
pDataCol
->
pData
!=
NULL
);
if
(
IS_VAR_DATA_TYPE
(
pDataCol
->
type
))
{
pDataCol
->
dataOff
=
malloc
(
maxPoints
*
sizeof
(
VarDataOffsetT
));
ASSERT
(
pDataCol
->
dataOff
!=
NULL
);
}
}
tdAllocMemForCol
(
pDataCol
,
maxPoints
);
// Decode the data
if
(
comp
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录