Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
09b76a8a
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看板
提交
09b76a8a
编写于
7月 11, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more tsdb row refact
上级
59a83adf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
107 deletion
+7
-107
include/common/tdataformat.h
include/common/tdataformat.h
+0
-34
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+7
-73
未找到文件。
include/common/tdataformat.h
浏览文件 @
09b76a8a
...
...
@@ -230,20 +230,6 @@ struct STag {
memcpy(varDataVal(x), (str), (_size)); \
} while (0);
// ----------------- TSDB COLUMN DEFINITION
#define colType(col) ((col)->type)
#define colFlags(col) ((col)->flags)
#define colColId(col) ((col)->colId)
#define colBytes(col) ((col)->bytes)
#define colOffset(col) ((col)->offset)
#define colSetType(col, t) (colType(col) = (t))
#define colSetFlags(col, f) (colFlags(col) = (f))
#define colSetColId(col, id) (colColId(col) = (id))
#define colSetBytes(col, b) (colBytes(col) = (b))
#define colSetOffset(col, o) (colOffset(col) = (o))
// ----------------- TSDB SCHEMA DEFINITION
#define schemaNCols(s) ((s)->numOfCols)
...
...
@@ -254,26 +240,6 @@ struct STag {
#define schemaColAt(s, i) ((s)->columns + i)
#define tdFreeSchema(s) taosMemoryFreeClear((s))
STSchema
*
tdDupSchema
(
const
STSchema
*
pSchema
);
int32_t
tdEncodeSchema
(
void
**
buf
,
STSchema
*
pSchema
);
void
*
tdDecodeSchema
(
void
*
buf
,
STSchema
**
pRSchema
);
static
FORCE_INLINE
int32_t
comparColId
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
int16_t
*
)
key1
>
((
STColumn
*
)
key2
)
->
colId
)
{
return
1
;
}
else
if
(
*
(
int16_t
*
)
key1
<
((
STColumn
*
)
key2
)
->
colId
)
{
return
-
1
;
}
else
{
return
0
;
}
}
static
FORCE_INLINE
STColumn
*
tdGetColOfID
(
STSchema
*
pSchema
,
int16_t
colId
)
{
void
*
ptr
=
bsearch
(
&
colId
,
(
void
*
)
pSchema
->
columns
,
schemaNCols
(
pSchema
),
sizeof
(
STColumn
),
comparColId
);
if
(
ptr
==
NULL
)
return
NULL
;
return
(
STColumn
*
)
ptr
;
}
// ----------------- SCHEMA BUILDER DEFINITION
typedef
struct
{
int32_t
tCols
;
...
...
source/common/src/tdataformat.c
浏览文件 @
09b76a8a
...
...
@@ -1065,72 +1065,6 @@ _err:
}
#if 1 // ===================================================================================================================
/**
* Duplicate the schema and return a new object
*/
STSchema
*
tdDupSchema
(
const
STSchema
*
pSchema
)
{
int
tlen
=
sizeof
(
STSchema
)
+
sizeof
(
STColumn
)
*
schemaNCols
(
pSchema
);
STSchema
*
tSchema
=
(
STSchema
*
)
taosMemoryMalloc
(
tlen
);
if
(
tSchema
==
NULL
)
return
NULL
;
memcpy
((
void
*
)
tSchema
,
(
void
*
)
pSchema
,
tlen
);
return
tSchema
;
}
/**
* Encode a schema to dst, and return the next pointer
*/
int
tdEncodeSchema
(
void
**
buf
,
STSchema
*
pSchema
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
schemaVersion
(
pSchema
));
tlen
+=
taosEncodeFixedI32
(
buf
,
schemaNCols
(
pSchema
));
for
(
int
i
=
0
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
STColumn
*
pCol
=
schemaColAt
(
pSchema
,
i
);
tlen
+=
taosEncodeFixedI8
(
buf
,
colType
(
pCol
));
tlen
+=
taosEncodeFixedI8
(
buf
,
colFlags
(
pCol
));
tlen
+=
taosEncodeFixedI16
(
buf
,
colColId
(
pCol
));
tlen
+=
taosEncodeFixedI16
(
buf
,
colBytes
(
pCol
));
}
return
tlen
;
}
/**
* Decode a schema from a binary.
*/
void
*
tdDecodeSchema
(
void
*
buf
,
STSchema
**
pRSchema
)
{
int
version
=
0
;
int
numOfCols
=
0
;
STSchemaBuilder
schemaBuilder
;
buf
=
taosDecodeFixedI32
(
buf
,
&
version
);
buf
=
taosDecodeFixedI32
(
buf
,
&
numOfCols
);
if
(
tdInitTSchemaBuilder
(
&
schemaBuilder
,
version
)
<
0
)
return
NULL
;
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
col_type_t
type
=
0
;
int8_t
flags
=
0
;
col_id_t
colId
=
0
;
col_bytes_t
bytes
=
0
;
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
flags
);
buf
=
taosDecodeFixedI16
(
buf
,
&
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
bytes
);
if
(
tdAddColToSchema
(
&
schemaBuilder
,
type
,
flags
,
colId
,
bytes
)
<
0
)
{
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
return
NULL
;
}
}
*
pRSchema
=
tdGetSchemaFromBuilder
(
&
schemaBuilder
);
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
return
buf
;
}
int
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
schema_ver_t
version
)
{
if
(
pBuilder
==
NULL
)
return
-
1
;
...
...
@@ -1167,22 +1101,22 @@ int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, c
}
STColumn
*
pCol
=
&
(
pBuilder
->
columns
[
pBuilder
->
nCols
]);
colSetType
(
pCol
,
type
)
;
colSetColId
(
pCol
,
colId
)
;
colSetFlags
(
pCol
,
flags
)
;
pCol
->
type
=
type
;
pCol
->
colId
=
colId
;
pCol
->
flags
=
flags
;
if
(
pBuilder
->
nCols
==
0
)
{
colSetOffset
(
pCol
,
0
)
;
pCol
->
offset
=
0
;
}
else
{
STColumn
*
pTCol
=
&
(
pBuilder
->
columns
[
pBuilder
->
nCols
-
1
]);
colSetOffset
(
pCol
,
pTCol
->
offset
+
TYPE_BYTES
[
pTCol
->
type
])
;
pCol
->
offset
=
pTCol
->
offset
+
TYPE_BYTES
[
pTCol
->
type
]
;
}
if
(
IS_VAR_DATA_TYPE
(
type
))
{
colSetBytes
(
pCol
,
bytes
)
;
pCol
->
bytes
=
bytes
;
pBuilder
->
tlen
+=
(
TYPE_BYTES
[
type
]
+
bytes
);
pBuilder
->
vlen
+=
bytes
-
sizeof
(
VarDataLenT
);
}
else
{
colSetBytes
(
pCol
,
TYPE_BYTES
[
type
])
;
pCol
->
bytes
=
TYPE_BYTES
[
type
]
;
pBuilder
->
tlen
+=
TYPE_BYTES
[
type
];
pBuilder
->
vlen
+=
TYPE_BYTES
[
type
];
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录