Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c3cf7f52
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看板
提交
c3cf7f52
编写于
5月 11, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact data format
上级
4a2d0d6a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
5 deletion
+48
-5
include/common/tdataformat.h
include/common/tdataformat.h
+7
-0
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+41
-5
未找到文件。
include/common/tdataformat.h
浏览文件 @
c3cf7f52
...
@@ -31,7 +31,9 @@ typedef struct STColumn STColumn;
...
@@ -31,7 +31,9 @@ typedef struct STColumn STColumn;
typedef
struct
STSchema
STSchema
;
typedef
struct
STSchema
STSchema
;
typedef
struct
STSRow2
STSRow2
;
typedef
struct
STSRow2
STSRow2
;
typedef
struct
STSRowBuilder
STSRowBuilder
;
typedef
struct
STSRowBuilder
STSRowBuilder
;
typedef
struct
SKVIdx
SKVIdx
;
#define TD_TP_ROW 0x0U
#define TD_KV_ROW 0x1U
#define TD_KV_ROW 0x1U
// STSchema
// STSchema
...
@@ -83,6 +85,11 @@ struct STSRow2 {
...
@@ -83,6 +85,11 @@ struct STSRow2 {
struct
STSRowBuilder
{
struct
STSRowBuilder
{
STColumn
*
pTColumn
;
STColumn
*
pTColumn
;
STSchema
*
pTSchema
;
STSchema
*
pTSchema
;
int32_t
nCols
;
int32_t
kvVLen
;
uint8_t
*
pKV
;
int32_t
tpVLen
;
uint8_t
*
pTuple
;
STSRow2
row
;
STSRow2
row
;
};
};
...
...
source/common/src/tdataformat.c
浏览文件 @
c3cf7f52
...
@@ -19,6 +19,11 @@
...
@@ -19,6 +19,11 @@
#include "tdatablock.h"
#include "tdatablock.h"
#include "tlog.h"
#include "tlog.h"
struct
SKVIdx
{
int32_t
cid
;
int32_t
offset
;
};
int32_t
tEncodeTSRow
(
SEncoder
*
pEncoder
,
const
STSRow2
*
pRow
)
{
int32_t
tEncodeTSRow
(
SEncoder
*
pEncoder
,
const
STSRow2
*
pRow
)
{
if
(
tEncodeI64
(
pEncoder
,
pRow
->
ts
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pRow
->
ts
)
<
0
)
return
-
1
;
if
(
tEncodeU32v
(
pEncoder
,
pRow
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeU32v
(
pEncoder
,
pRow
->
flags
)
<
0
)
return
-
1
;
...
@@ -97,6 +102,11 @@ int32_t tTSRowBuilderReset(STSRowBuilder *pBuilder) {
...
@@ -97,6 +102,11 @@ int32_t tTSRowBuilderReset(STSRowBuilder *pBuilder) {
pBuilder
->
pTColumn
->
flags
&=
(
~
COL_VAL_SET
);
pBuilder
->
pTColumn
->
flags
&=
(
~
COL_VAL_SET
);
}
}
pBuilder
->
nCols
=
0
;
pBuilder
->
kvVLen
=
0
;
pBuilder
->
tpVLen
=
0
;
pBuilder
->
row
.
flags
=
0
;
return
0
;
return
0
;
}
}
...
@@ -125,8 +135,7 @@ int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, const uint8_t *pD
...
@@ -125,8 +135,7 @@ int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, const uint8_t *pD
}
}
pBuilder
->
pTColumn
->
flags
|=
COL_VAL_SET
;
pBuilder
->
pTColumn
->
flags
|=
COL_VAL_SET
;
pBuilder
->
nCols
++
;
// TODO
return
0
;
return
0
;
}
}
...
@@ -135,10 +144,37 @@ int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow) {
...
@@ -135,10 +144,37 @@ int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow) {
return
-
1
;
return
-
1
;
}
}
// chose which type row to return
if
(
pBuilder
->
nCols
*
sizeof
(
SKVIdx
)
+
pBuilder
->
kvVLen
<
pBuilder
->
pTSchema
->
flen
+
pBuilder
->
tpVLen
)
{
// encode as TD_KV_ROW
pBuilder
->
row
.
flags
|=
TD_KV_ROW
;
pBuilder
->
row
.
ncols
=
pBuilder
->
nCols
;
pBuilder
->
row
.
nData
=
pBuilder
->
nCols
*
sizeof
(
SKVIdx
)
+
pBuilder
->
kvVLen
;
pBuilder
->
row
.
pData
=
pBuilder
->
pKV
;
if
(
true
/* tuple row is chosen */
)
{
if
(
pBuilder
->
nCols
<
pBuilder
->
pTSchema
->
numOfCols
)
{
// set non-set values as None
memmove
(
pBuilder
->
pKV
+
sizeof
(
SKVIdx
)
*
pBuilder
->
nCols
,
pBuilder
->
pKV
+
sizeof
(
SKVIdx
)
*
pBuilder
->
pTSchema
->
numOfCols
,
pBuilder
->
kvVLen
);
}
}
else
{
// encode as TD_TUPLE_ROW
pBuilder
->
row
.
flags
&=
(
~
TD_KV_ROW
);
pBuilder
->
row
.
sver
=
pBuilder
->
pTSchema
->
version
;
pBuilder
->
row
.
nData
=
pBuilder
->
pTSchema
->
flen
+
pBuilder
->
tpVLen
;
pBuilder
->
row
.
pData
=
pBuilder
->
pTuple
;
if
(
pBuilder
->
nCols
<
pBuilder
->
pTSchema
->
numOfCols
)
{
// set non-set cols as None
for
(
int32_t
iCol
=
1
;
iCol
<
pBuilder
->
pTSchema
->
numOfCols
;
iCol
++
)
{
pBuilder
->
pTColumn
=
&
pBuilder
->
pTSchema
->
columns
[
iCol
];
if
(
pBuilder
->
pTColumn
->
flags
&
COL_VAL_SET
)
continue
;
{
// set None (todo)
}
pBuilder
->
pTColumn
->
flags
|=
COL_VAL_SET
;
}
}
}
}
*
ppRow
=
&
pBuilder
->
row
;
*
ppRow
=
&
pBuilder
->
row
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录