Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e11ae1f4
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看板
提交
e11ae1f4
编写于
8月 05, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
memory alloc may fail
上级
c3413fd8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
12 deletion
+24
-12
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+2
-2
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+17
-9
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+2
-0
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+0
-1
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+3
-0
未找到文件。
src/common/inc/tdataformat.h
浏览文件 @
e11ae1f4
...
@@ -328,11 +328,11 @@ static FORCE_INLINE void dataColReset(SDataCol *pDataCol) { pDataCol->len = 0; }
...
@@ -328,11 +328,11 @@ static FORCE_INLINE void dataColReset(SDataCol *pDataCol) { pDataCol->len = 0; }
int
tdAllocMemForCol
(
SDataCol
*
pCol
,
int
maxPoints
);
int
tdAllocMemForCol
(
SDataCol
*
pCol
,
int
maxPoints
);
void
dataColInit
(
SDataCol
*
pDataCol
,
STColumn
*
pCol
,
int
maxPoints
);
void
dataColInit
(
SDataCol
*
pDataCol
,
STColumn
*
pCol
,
int
maxPoints
);
void
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
);
int
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
);
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
);
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
);
bool
isNEleNull
(
SDataCol
*
pCol
,
int
nEle
);
bool
isNEleNull
(
SDataCol
*
pCol
,
int
nEle
);
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
);
int
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
);
// Get the data pointer from a column-wised data
// Get the data pointer from a column-wised data
static
FORCE_INLINE
const
void
*
tdGetColDataOfRow
(
SDataCol
*
pCol
,
int
row
)
{
static
FORCE_INLINE
const
void
*
tdGetColDataOfRow
(
SDataCol
*
pCol
,
int
row
)
{
...
...
src/common/src/tdataformat.c
浏览文件 @
e11ae1f4
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
static
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
int
limit1
,
SDataCols
*
src2
,
int
*
iter2
,
static
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
int
limit1
,
SDataCols
*
src2
,
int
*
iter2
,
int
limit2
,
int
tRows
,
bool
forceSetNull
);
int
limit2
,
int
tRows
,
bool
forceSetNull
);
//TODO: change caller to use return val
int
tdAllocMemForCol
(
SDataCol
*
pCol
,
int
maxPoints
)
{
int
tdAllocMemForCol
(
SDataCol
*
pCol
,
int
maxPoints
)
{
int
spaceNeeded
=
pCol
->
bytes
*
maxPoints
;
int
spaceNeeded
=
pCol
->
bytes
*
maxPoints
;
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
...
@@ -31,7 +30,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
...
@@ -31,7 +30,7 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
if
(
pCol
->
spaceSize
<
spaceNeeded
)
{
if
(
pCol
->
spaceSize
<
spaceNeeded
)
{
void
*
ptr
=
realloc
(
pCol
->
pData
,
spaceNeeded
);
void
*
ptr
=
realloc
(
pCol
->
pData
,
spaceNeeded
);
if
(
ptr
==
NULL
)
{
if
(
ptr
==
NULL
)
{
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
pCol
->
spaceSize
,
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
spaceNeeded
,
strerror
(
errno
));
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -239,20 +238,22 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, int maxPoints) {
...
@@ -239,20 +238,22 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, int maxPoints) {
pDataCol
->
len
=
0
;
pDataCol
->
len
=
0
;
}
}
// value from timestamp should be TKEY here instead of TSKEY
// value from timestamp should be TKEY here instead of TSKEY
void
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
)
{
int
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
)
{
ASSERT
(
pCol
!=
NULL
&&
value
!=
NULL
);
ASSERT
(
pCol
!=
NULL
&&
value
!=
NULL
);
if
(
isAllRowsNull
(
pCol
))
{
if
(
isAllRowsNull
(
pCol
))
{
if
(
isNull
(
value
,
pCol
->
type
))
{
if
(
isNull
(
value
,
pCol
->
type
))
{
// all null value yet, just return
// all null value yet, just return
return
;
return
0
;
}
}
if
(
numOfRows
>
0
)
{
if
(
numOfRows
>
0
)
{
// Find the first not null value, fill all previouse values as NULL
// Find the first not null value, fill all previouse values as NULL
dataColSetNEleNull
(
pCol
,
numOfRows
,
maxPoints
);
if
(
dataColSetNEleNull
(
pCol
,
numOfRows
,
maxPoints
)
<
0
)
return
-
1
;
}
else
{
}
else
{
tdAllocMemForCol
(
pCol
,
maxPoints
);
if
(
tdAllocMemForCol
(
pCol
,
maxPoints
)
<
0
)
return
-
1
;
}
}
}
}
...
@@ -268,6 +269,7 @@ void dataColAppendVal(SDataCol *pCol, const void *value, int numOfRows, int maxP
...
@@ -268,6 +269,7 @@ void dataColAppendVal(SDataCol *pCol, const void *value, int numOfRows, int maxP
memcpy
(
POINTER_SHIFT
(
pCol
->
pData
,
pCol
->
len
),
value
,
pCol
->
bytes
);
memcpy
(
POINTER_SHIFT
(
pCol
->
pData
,
pCol
->
len
),
value
,
pCol
->
bytes
);
pCol
->
len
+=
pCol
->
bytes
;
pCol
->
len
+=
pCol
->
bytes
;
}
}
return
-
1
;
}
}
bool
isNEleNull
(
SDataCol
*
pCol
,
int
nEle
)
{
bool
isNEleNull
(
SDataCol
*
pCol
,
int
nEle
)
{
...
@@ -290,8 +292,10 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
...
@@ -290,8 +292,10 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
}
}
}
}
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
)
{
int
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
)
{
tdAllocMemForCol
(
pCol
,
maxPoints
);
if
(
tdAllocMemForCol
(
pCol
,
maxPoints
)){
return
-
1
;
}
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
len
=
0
;
pCol
->
len
=
0
;
...
@@ -302,6 +306,7 @@ void dataColSetNEleNull(SDataCol *pCol, int nEle, int maxPoints) {
...
@@ -302,6 +306,7 @@ void dataColSetNEleNull(SDataCol *pCol, int nEle, int maxPoints) {
setNullN
(
pCol
->
pData
,
pCol
->
type
,
pCol
->
bytes
,
nEle
);
setNullN
(
pCol
->
pData
,
pCol
->
type
,
pCol
->
bytes
,
nEle
);
pCol
->
len
=
TYPE_BYTES
[
pCol
->
type
]
*
nEle
;
pCol
->
len
=
TYPE_BYTES
[
pCol
->
type
]
*
nEle
;
}
}
return
0
;
}
}
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
)
{
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
)
{
...
@@ -414,7 +419,10 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
...
@@ -414,7 +419,10 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
if
(
keepData
)
{
if
(
keepData
)
{
if
(
pDataCols
->
cols
[
i
].
len
>
0
)
{
if
(
pDataCols
->
cols
[
i
].
len
>
0
)
{
tdAllocMemForCol
(
&
pRet
->
cols
[
i
],
pRet
->
maxPoints
);
if
(
tdAllocMemForCol
(
&
pRet
->
cols
[
i
],
pRet
->
maxPoints
)
<
0
)
{
tdFreeDataCols
(
pRet
);
return
NULL
;
}
pRet
->
cols
[
i
].
len
=
pDataCols
->
cols
[
i
].
len
;
pRet
->
cols
[
i
].
len
=
pDataCols
->
cols
[
i
].
len
;
memcpy
(
pRet
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
len
);
memcpy
(
pRet
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
pData
,
pDataCols
->
cols
[
i
].
len
);
if
(
IS_VAR_DATA_TYPE
(
pRet
->
cols
[
i
].
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pRet
->
cols
[
i
].
type
))
{
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
e11ae1f4
...
@@ -1277,6 +1277,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
...
@@ -1277,6 +1277,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
if
(
key1
<
key2
)
{
if
(
key1
<
key2
)
{
for
(
int
i
=
0
;
i
<
pDataCols
->
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pDataCols
->
numOfCols
;
i
++
)
{
//TODO: dataColAppendVal may fail
dataColAppendVal
(
pTarget
->
cols
+
i
,
tdGetColDataOfRow
(
pDataCols
->
cols
+
i
,
*
iter
),
pTarget
->
numOfRows
,
dataColAppendVal
(
pTarget
->
cols
+
i
,
tdGetColDataOfRow
(
pDataCols
->
cols
+
i
,
*
iter
),
pTarget
->
numOfRows
,
pTarget
->
maxPoints
);
pTarget
->
maxPoints
);
}
}
...
@@ -1308,6 +1309,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
...
@@ -1308,6 +1309,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
ASSERT
(
!
isRowDel
);
ASSERT
(
!
isRowDel
);
for
(
int
i
=
0
;
i
<
pDataCols
->
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pDataCols
->
numOfCols
;
i
++
)
{
//TODO: dataColAppendVal may fail
dataColAppendVal
(
pTarget
->
cols
+
i
,
tdGetColDataOfRow
(
pDataCols
->
cols
+
i
,
*
iter
),
pTarget
->
numOfRows
,
dataColAppendVal
(
pTarget
->
cols
+
i
,
tdGetColDataOfRow
(
pDataCols
->
cols
+
i
,
*
iter
),
pTarget
->
numOfRows
,
pTarget
->
maxPoints
);
pTarget
->
maxPoints
);
}
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
e11ae1f4
...
@@ -751,7 +751,6 @@ static SMemRow tsdbInsertDupKeyMerge(SMemRow row1, SMemRow row2, STsdbRepo* pRep
...
@@ -751,7 +751,6 @@ static SMemRow tsdbInsertDupKeyMerge(SMemRow row1, SMemRow row2, STsdbRepo* pRep
memRowCpy
(
pMem
,
tmp
);
memRowCpy
(
pMem
,
tmp
);
(
*
pPoints
)
++
;
(
*
pPoints
)
++
;
*
pLastRow
=
pMem
;
*
pLastRow
=
pMem
;
return
pMem
;
return
pMem
;
}
}
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
e11ae1f4
...
@@ -463,6 +463,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
...
@@ -463,6 +463,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
SDataCol
*
pDataCol
=
&
(
pDataCols
->
cols
[
dcol
]);
SDataCol
*
pDataCol
=
&
(
pDataCols
->
cols
[
dcol
]);
if
(
dcol
!=
0
&&
ccol
>=
pBlockData
->
numOfCols
)
{
if
(
dcol
!=
0
&&
ccol
>=
pBlockData
->
numOfCols
)
{
// Set current column as NULL and forward
// Set current column as NULL and forward
// TODO: dataColSetNEleNull may fail
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
dcol
++
;
dcol
++
;
continue
;
continue
;
...
@@ -503,6 +504,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
...
@@ -503,6 +504,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
ccol
++
;
ccol
++
;
}
else
{
}
else
{
// Set current column as NULL and forward
// Set current column as NULL and forward
// TODO: dataColSetNEleNull may fail
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
dcol
++
;
dcol
++
;
}
}
...
@@ -608,6 +610,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *
...
@@ -608,6 +610,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *
}
}
if
(
pBlockCol
==
NULL
)
{
if
(
pBlockCol
==
NULL
)
{
// TODO: dataColSetNEleNull may fail
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
continue
;
continue
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录