Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fcd3b445
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看板
提交
fcd3b445
编写于
8月 05, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor datacols
上级
e11ae1f4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
42 addition
and
48 deletion
+42
-48
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+7
-9
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+19
-25
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+1
-1
src/tsdb/src/tsdbCompact.c
src/tsdb/src/tsdbCompact.c
+1
-1
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+0
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+3
-3
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+11
-8
未找到文件。
src/common/inc/tdataformat.h
浏览文件 @
fcd3b445
...
...
@@ -330,9 +330,9 @@ int tdAllocMemForCol(SDataCol *pCol, int maxPoints);
void
dataColInit
(
SDataCol
*
pDataCol
,
STColumn
*
pCol
,
int
maxPoints
);
int
dataColAppendVal
(
SDataCol
*
pCol
,
const
void
*
value
,
int
numOfRows
,
int
maxPoints
);
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
);
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
);
bool
isNEleNull
(
SDataCol
*
pCol
,
int
nEle
);
int
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
);
// Get the data pointer from a column-wised data
static
FORCE_INLINE
const
void
*
tdGetColDataOfRow
(
SDataCol
*
pCol
,
int
row
)
{
...
...
@@ -357,13 +357,11 @@ static FORCE_INLINE int32_t dataColGetNEleLen(SDataCol *pDataCol, int rows) {
}
typedef
struct
{
int
maxRowSize
;
int
maxCols
;
// max number of columns
int
maxPoints
;
// max number of points
int
numOfRows
;
int
numOfCols
;
// Total number of cols
int
sversion
;
// TODO: set sversion
int
maxCols
;
// max number of columns
int
maxPoints
;
// max number of points
int
numOfRows
;
int
numOfCols
;
// Total number of cols
int
sversion
;
// TODO: set sversion
SDataCol
*
cols
;
}
SDataCols
;
...
...
@@ -407,7 +405,7 @@ static FORCE_INLINE TSKEY dataColsKeyLast(SDataCols *pCols) {
}
}
SDataCols
*
tdNewDataCols
(
int
max
RowSize
,
int
max
Cols
,
int
maxRows
);
SDataCols
*
tdNewDataCols
(
int
maxCols
,
int
maxRows
);
void
tdResetDataCols
(
SDataCols
*
pCols
);
int
tdInitDataCols
(
SDataCols
*
pCols
,
STSchema
*
pSchema
);
SDataCols
*
tdDupDataCols
(
SDataCols
*
pCols
,
bool
keepData
);
...
...
src/common/src/tdataformat.c
浏览文件 @
fcd3b445
...
...
@@ -247,13 +247,10 @@ int dataColAppendVal(SDataCol *pCol, const void *value, int numOfRows, int maxPo
return
0
;
}
if
(
tdAllocMemForCol
(
pCol
,
maxPoints
)
<
0
)
return
-
1
;
if
(
numOfRows
>
0
)
{
// Find the first not null value, fill all previouse values as NULL
if
(
dataColSetNEleNull
(
pCol
,
numOfRows
,
maxPoints
)
<
0
)
return
-
1
;
}
else
{
if
(
tdAllocMemForCol
(
pCol
,
maxPoints
)
<
0
)
return
-
1
;
dataColSetNEleNull
(
pCol
,
numOfRows
);
}
}
...
...
@@ -269,13 +266,21 @@ int dataColAppendVal(SDataCol *pCol, const void *value, int numOfRows, int maxPo
memcpy
(
POINTER_SHIFT
(
pCol
->
pData
,
pCol
->
len
),
value
,
pCol
->
bytes
);
pCol
->
len
+=
pCol
->
bytes
;
}
return
-
1
;
return
0
;
}
static
FORCE_INLINE
const
void
*
tdGetColDataOfRowUnsafe
(
SDataCol
*
pCol
,
int
row
)
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
return
POINTER_SHIFT
(
pCol
->
pData
,
pCol
->
dataOff
[
row
]);
}
else
{
return
POINTER_SHIFT
(
pCol
->
pData
,
TYPE_BYTES
[
pCol
->
type
]
*
row
);
}
}
bool
isNEleNull
(
SDataCol
*
pCol
,
int
nEle
)
{
if
(
isAllRowsNull
(
pCol
))
return
true
;
for
(
int
i
=
0
;
i
<
nEle
;
i
++
)
{
if
(
!
isNull
(
tdGetColDataOfRow
(
pCol
,
i
),
pCol
->
type
))
return
false
;
if
(
!
isNull
(
tdGetColDataOfRow
Unsafe
(
pCol
,
i
),
pCol
->
type
))
return
false
;
}
return
true
;
}
...
...
@@ -292,11 +297,7 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index) {
}
}
int
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
,
int
maxPoints
)
{
if
(
tdAllocMemForCol
(
pCol
,
maxPoints
)){
return
-
1
;
}
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
)
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
len
=
0
;
for
(
int
i
=
0
;
i
<
nEle
;
i
++
)
{
...
...
@@ -306,7 +307,6 @@ int dataColSetNEleNull(SDataCol *pCol, int nEle, int maxPoints) {
setNullN
(
pCol
->
pData
,
pCol
->
type
,
pCol
->
bytes
,
nEle
);
pCol
->
len
=
TYPE_BYTES
[
pCol
->
type
]
*
nEle
;
}
return
0
;
}
void
dataColSetOffset
(
SDataCol
*
pCol
,
int
nEle
)
{
...
...
@@ -323,7 +323,7 @@ void dataColSetOffset(SDataCol *pCol, int nEle) {
}
}
SDataCols
*
tdNewDataCols
(
int
max
RowSize
,
int
max
Cols
,
int
maxRows
)
{
SDataCols
*
tdNewDataCols
(
int
maxCols
,
int
maxRows
)
{
SDataCols
*
pCols
=
(
SDataCols
*
)
calloc
(
1
,
sizeof
(
SDataCols
));
if
(
pCols
==
NULL
)
{
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
sizeof
(
SDataCols
),
strerror
(
errno
));
...
...
@@ -331,6 +331,9 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
}
pCols
->
maxPoints
=
maxRows
;
pCols
->
maxCols
=
maxCols
;
pCols
->
numOfRows
=
0
;
pCols
->
numOfCols
=
0
;
if
(
maxCols
>
0
)
{
pCols
->
cols
=
(
SDataCol
*
)
calloc
(
maxCols
,
sizeof
(
SDataCol
));
...
...
@@ -347,13 +350,8 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
pCols
->
cols
[
i
].
pData
=
NULL
;
pCols
->
cols
[
i
].
dataOff
=
NULL
;
}
pCols
->
maxCols
=
maxCols
;
}
pCols
->
maxRowSize
=
maxRowSize
;
return
pCols
;
}
...
...
@@ -372,10 +370,6 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
}
}
if
(
schemaTLen
(
pSchema
)
>
pCols
->
maxRowSize
)
{
pCols
->
maxRowSize
=
schemaTLen
(
pSchema
);
}
tdResetDataCols
(
pCols
);
pCols
->
numOfCols
=
schemaNCols
(
pSchema
);
...
...
@@ -404,7 +398,7 @@ SDataCols *tdFreeDataCols(SDataCols *pCols) {
}
SDataCols
*
tdDupDataCols
(
SDataCols
*
pDataCols
,
bool
keepData
)
{
SDataCols
*
pRet
=
tdNewDataCols
(
pDataCols
->
max
RowSize
,
pDataCols
->
max
Cols
,
pDataCols
->
maxPoints
);
SDataCols
*
pRet
=
tdNewDataCols
(
pDataCols
->
maxCols
,
pDataCols
->
maxPoints
);
if
(
pRet
==
NULL
)
return
NULL
;
pRet
->
numOfCols
=
pDataCols
->
numOfCols
;
...
...
@@ -593,7 +587,7 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
if
((
key1
>
key2
)
||
(
key1
==
key2
&&
!
TKEY_IS_DELETED
(
tkey2
)))
{
for
(
int
i
=
0
;
i
<
src2
->
numOfCols
;
i
++
)
{
ASSERT
(
target
->
cols
[
i
].
type
==
src2
->
cols
[
i
].
type
);
if
(
src2
->
cols
[
i
].
len
>
0
&&
(
forceSetNull
||
(
!
forceSetNull
&&
!
isNull
(
src2
->
cols
[
i
].
pData
,
src2
->
cols
[
i
].
type
))))
{
if
(
src2
->
cols
[
i
].
len
>
0
&&
(
forceSetNull
||
(
!
isNull
(
src2
->
cols
[
i
].
pData
,
src2
->
cols
[
i
].
type
))))
{
dataColAppendVal
(
&
(
target
->
cols
[
i
]),
tdGetColDataOfRow
(
src2
->
cols
+
i
,
*
iter2
),
target
->
numOfRows
,
target
->
maxPoints
);
}
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
fcd3b445
...
...
@@ -722,7 +722,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdbRepo *pRepo) {
return
-
1
;
}
pCommith
->
pDataCols
=
tdNewDataCols
(
0
,
0
,
pCfg
->
maxRowsPerFileBlock
);
pCommith
->
pDataCols
=
tdNewDataCols
(
0
,
pCfg
->
maxRowsPerFileBlock
);
if
(
pCommith
->
pDataCols
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbDestroyCommitH
(
pCommith
);
...
...
src/tsdb/src/tsdbCompact.c
浏览文件 @
fcd3b445
...
...
@@ -296,7 +296,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
return
-
1
;
}
pComph
->
pDataCols
=
tdNewDataCols
(
0
,
0
,
pCfg
->
maxRowsPerFileBlock
);
pComph
->
pDataCols
=
tdNewDataCols
(
0
,
pCfg
->
maxRowsPerFileBlock
);
if
(
pComph
->
pDataCols
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbDestroyCompactH
(
pComph
);
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
fcd3b445
...
...
@@ -17,7 +17,6 @@
#define TSDB_SUPER_TABLE_SL_LEVEL 5
#define DEFAULT_TAG_INDEX_COLUMN 0
static
int
tsdbCompareSchemaVersion
(
const
void
*
key1
,
const
void
*
key2
);
static
char
*
getTagIndexKey
(
const
void
*
pData
);
static
STable
*
tsdbNewTable
();
static
STable
*
tsdbCreateTableFromCfg
(
STableCfg
*
pCfg
,
bool
isSuper
,
STable
*
pSTable
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
fcd3b445
...
...
@@ -466,7 +466,7 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
tsdb
);
assert
(
pMeta
!=
NULL
);
pQueryHandle
->
pDataCols
=
tdNewDataCols
(
pMeta
->
max
RowBytes
,
pMeta
->
max
Cols
,
pQueryHandle
->
pTsdb
->
config
.
maxRowsPerFileBlock
);
pQueryHandle
->
pDataCols
=
tdNewDataCols
(
pMeta
->
maxCols
,
pQueryHandle
->
pTsdb
->
config
.
maxRowsPerFileBlock
);
if
(
pQueryHandle
->
pDataCols
==
NULL
)
{
tsdbError
(
"%p failed to malloc buf for pDataCols, %"
PRIu64
,
pQueryHandle
,
pQueryHandle
->
qId
);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
...
...
@@ -1446,7 +1446,7 @@ static int doBinarySearchKey(char* pValue, int num, TSKEY key, int order) {
return
midPos
;
}
int32_t
doCopyRowsFromFileBlock
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
int32_t
start
,
int32_t
end
)
{
static
int32_t
doCopyRowsFromFileBlock
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
int32_t
start
,
int32_t
end
)
{
char
*
pData
=
NULL
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
1
:
-
1
;
...
...
@@ -1481,7 +1481,7 @@ int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
num
)
*
pColInfo
->
info
.
bytes
;
}
if
(
pColInfo
->
info
.
colId
==
src
->
colId
)
{
if
(
!
isAllRowsNull
(
src
)
&&
pColInfo
->
info
.
colId
==
src
->
colId
)
{
if
(
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColInfo
->
info
.
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
memmove
(
pData
,
(
char
*
)
src
->
pData
+
bytes
*
start
,
bytes
*
num
);
}
else
{
// handle the var-string
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
fcd3b445
...
...
@@ -42,14 +42,14 @@ int tsdbInitReadH(SReadH *pReadh, STsdbRepo *pRepo) {
return
-
1
;
}
pReadh
->
pDCols
[
0
]
=
tdNewDataCols
(
0
,
0
,
pCfg
->
maxRowsPerFileBlock
);
pReadh
->
pDCols
[
0
]
=
tdNewDataCols
(
0
,
pCfg
->
maxRowsPerFileBlock
);
if
(
pReadh
->
pDCols
[
0
]
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbDestroyReadH
(
pReadh
);
return
-
1
;
}
pReadh
->
pDCols
[
1
]
=
tdNewDataCols
(
0
,
0
,
pCfg
->
maxRowsPerFileBlock
);
pReadh
->
pDCols
[
1
]
=
tdNewDataCols
(
0
,
pCfg
->
maxRowsPerFileBlock
);
if
(
pReadh
->
pDCols
[
1
]
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
tsdbDestroyReadH
(
pReadh
);
...
...
@@ -463,8 +463,9 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
SDataCol
*
pDataCol
=
&
(
pDataCols
->
cols
[
dcol
]);
if
(
dcol
!=
0
&&
ccol
>=
pBlockData
->
numOfCols
)
{
// Set current column as NULL and forward
// TODO: dataColSetNEleNull may fail
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
// TODO: tdAllocMemForCol may fail
tdAllocMemForCol
(
pDataCol
,
pDataCols
->
maxPoints
);
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
);
dcol
++
;
continue
;
}
...
...
@@ -504,8 +505,9 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
ccol
++
;
}
else
{
// Set current column as NULL and forward
// TODO: dataColSetNEleNull may fail
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
// TODO: tdAllocMemForCol may fail
tdAllocMemForCol
(
pDataCol
,
pDataCols
->
maxPoints
);
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
);
dcol
++
;
}
}
...
...
@@ -610,8 +612,9 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *
}
if
(
pBlockCol
==
NULL
)
{
// TODO: dataColSetNEleNull may fail
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
);
// TODO: tdAllocMemForCol may fail
tdAllocMemForCol
(
pDataCol
,
pDataCols
->
maxPoints
);
dataColSetNEleNull
(
pDataCol
,
pBlock
->
numOfRows
);
continue
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录