Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
492ff11f
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
492ff11f
编写于
3月 25, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-34
上级
b01e8b8d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
28 deletion
+37
-28
src/common/inc/dataformat.h
src/common/inc/dataformat.h
+13
-7
src/common/src/dataformat.c
src/common/src/dataformat.c
+24
-21
未找到文件。
src/common/inc/dataformat.h
浏览文件 @
492ff11f
...
@@ -105,24 +105,30 @@ SDataRow tdDataRowDup(SDataRow row);
...
@@ -105,24 +105,30 @@ SDataRow tdDataRowDup(SDataRow row);
// ----------------- Data column structure
// ----------------- Data column structure
typedef
struct
SDataCol
{
typedef
struct
SDataCol
{
int32_t
len
;
int8_t
type
;
void
*
pData
;
int
bytes
;
int
len
;
void
*
pData
;
}
SDataCol
;
}
SDataCol
;
typedef
struct
{
typedef
struct
{
TSKEY
firstKey
;
int
maxRowSize
;
TSKEY
lastKey
;
int
maxCols
;
// max number of columns
int
maxPoints
;
// max number of points
int
numOfPoints
;
int
numOfPoints
;
int
numOfCols
;
int
numOfCols
;
// Total number of cols
void
*
buf
;
void
*
buf
;
SDataCol
cols
[];
SDataCol
cols
[];
}
SDataCols
;
}
SDataCols
;
#define keyCol(cols) (&((cols)->cols[0])) // Key column
#define keyCol(cols) (&((cols)->cols[0])) // Key column
#define dataColsKeyFirst(cols) ((int64_t *)(keyCol(cols)->pData))[0]
#define dataColsKeyLast(cols) ((int64_t *)(keyCol(cols)->pData))[(cols)->numOfPoints - 1]
SDataCols
*
tdNewDataCols
(
STSchema
*
pSchema
,
int
nRows
);
SDataCols
*
tdNewDataCols
(
int
maxRowSize
,
int
maxCols
,
int
maxRows
);
void
tdFreeDataCols
(
SDataCols
*
pCols
);
void
tdResetDataCols
(
SDataCols
*
pCols
);
void
tdResetDataCols
(
SDataCols
*
pCols
);
void
tdInitDataCols
(
SDataCols
*
pCols
,
STSchema
*
pSchema
);
void
tdFreeDataCols
(
SDataCols
*
pCols
);
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
,
STSchema
*
pSchema
);
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
,
STSchema
*
pSchema
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/common/src/dataformat.c
浏览文件 @
492ff11f
...
@@ -294,27 +294,34 @@ SDataRow tdDataRowDup(SDataRow row) {
...
@@ -294,27 +294,34 @@ SDataRow tdDataRowDup(SDataRow row) {
return
trow
;
return
trow
;
}
}
SDataCols
*
tdNewDataCols
(
STSchema
*
pSchema
,
int
nRows
)
{
SDataCols
*
tdNewDataCols
(
int
maxRowSize
,
int
maxCols
,
int
maxRows
)
{
int
nCols
=
schemaNCols
(
pSchema
);
SDataCols
*
pCols
=
(
SDataCols
*
)
calloc
(
1
,
sizeof
(
SDataCols
)
+
sizeof
(
SDataCol
)
*
maxCols
);
if
(
pCols
==
NULL
)
return
NULL
;
SDataCols
*
pInfo
=
(
SDataCols
*
)
calloc
(
1
,
sizeof
(
SDataCols
)
+
sizeof
(
SDataCol
)
*
nCols
);
if
(
pInfo
==
NULL
)
return
NULL
;
pCols
->
maxRowSize
=
maxRowSize
;
pCols
->
maxCols
=
maxCols
;
pInfo
->
numOfCols
=
nCols
;
pCols
->
maxPoints
=
maxRows
;
pInfo
->
firstKey
=
INT64_MIN
;
pInfo
->
lastKey
=
INT64_MAX
;
pCols
->
buf
=
malloc
(
maxRowSize
*
maxRows
);
pInfo
->
buf
=
malloc
(
tdMaxRowBytesFromSchema
(
pSchema
)
*
nRows
);
if
(
pCols
->
buf
==
NULL
)
{
if
(
pInfo
->
buf
==
NULL
)
{
free
(
pCols
);
free
(
pInfo
);
return
NULL
;
return
NULL
;
}
}
pInfo
->
cols
[
0
].
pData
=
pInfo
->
buf
;
return
pCols
;
for
(
int
i
=
1
;
i
<
nCols
;
i
++
)
{
}
pInfo
->
cols
[
i
].
pData
=
(
char
*
)(
pInfo
->
cols
[
i
-
1
].
pData
)
+
schemaColAt
(
pSchema
,
i
-
1
)
->
bytes
*
nRows
;
void
tdInitDataCols
(
SDataCols
*
pCols
,
STSchema
*
pSchema
)
{
// assert(schemaNCols(pSchema) <= pCols->numOfCols);
tdResetDataCols
(
pCols
);
pCols
->
numOfCols
=
schemaNCols
(
pSchema
);
pCols
->
cols
[
0
].
pData
=
pCols
->
buf
;
for
(
int
i
=
1
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
pCols
->
cols
[
i
].
pData
=
(
char
*
)(
pCols
->
cols
[
i
-
1
].
pData
)
+
schemaColAt
(
pSchema
,
i
-
1
)
->
bytes
*
pCols
->
maxPoints
;
}
}
return
p
Info
;
return
p
Cols
;
}
}
void
tdFreeDataCols
(
SDataCols
*
pCols
)
{
void
tdFreeDataCols
(
SDataCols
*
pCols
)
{
...
@@ -325,18 +332,14 @@ void tdFreeDataCols(SDataCols *pCols) {
...
@@ -325,18 +332,14 @@ void tdFreeDataCols(SDataCols *pCols) {
}
}
void
tdResetDataCols
(
SDataCols
*
pCols
)
{
void
tdResetDataCols
(
SDataCols
*
pCols
)
{
pCols
->
firstKey
=
INT64_MAX
;
pCols
->
lastKey
=
INT64_MIN
;
pCols
->
numOfPoints
=
0
;
pCols
->
numOfPoints
=
0
;
for
(
int
i
=
0
;
i
<
pCols
->
numOf
Cols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pCols
->
max
Cols
;
i
++
)
{
pCols
->
cols
[
i
].
len
=
0
;
pCols
->
cols
[
i
].
len
=
0
;
}
}
}
}
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
,
STSchema
*
pSchema
)
{
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
,
STSchema
*
pSchema
)
{
TSKEY
key
=
dataRowKey
(
row
);
TSKEY
key
=
dataRowKey
(
row
);
if
(
pCols
->
numOfPoints
==
0
)
pCols
->
firstKey
=
key
;
pCols
->
lastKey
=
key
;
for
(
int
i
=
0
;
i
<
pCols
->
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pCols
->
numOfCols
;
i
++
)
{
SDataCol
*
pCol
=
pCols
->
cols
+
i
;
SDataCol
*
pCol
=
pCols
->
cols
+
i
;
memcpy
((
void
*
)((
char
*
)(
pCol
->
pData
)
+
pCol
->
len
),
dataRowAt
(
row
,
colOffset
(
schemaColAt
(
pSchema
,
i
))),
memcpy
((
void
*
)((
char
*
)(
pCol
->
pData
)
+
pCol
->
len
),
dataRowAt
(
row
,
colOffset
(
schemaColAt
(
pSchema
,
i
))),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录