Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fad06f61
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
fad06f61
编写于
11月 29, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize code
上级
048f6ef5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
25 deletion
+16
-25
include/util/tarray.h
include/util/tarray.h
+3
-13
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+12
-11
source/util/src/tarray.c
source/util/src/tarray.c
+1
-1
未找到文件。
include/util/tarray.h
浏览文件 @
fad06f61
...
@@ -22,19 +22,6 @@
...
@@ -22,19 +22,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#if 0
#define TARRAY(TYPE) \
struct { \
int32_t tarray_size_; \
int32_t tarray_neles_; \
struct TYPE* td_array_data_; \
}
#define TARRAY_SIZE(ARRAY) (ARRAY)->tarray_size_
#define TARRAY_NELES(ARRAY) (ARRAY)->tarray_neles_
#define TARRAY_ELE_AT(ARRAY, IDX) ((ARRAY)->td_array_data_ + idx)
#endif
#define TARRAY_MIN_SIZE 8
#define TARRAY_MIN_SIZE 8
#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize))
#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize))
#define TARRAY_ELEM_IDX(array, ele) (POINTER_DISTANCE(ele, (array)->pData) / (array)->elemSize)
#define TARRAY_ELEM_IDX(array, ele) (POINTER_DISTANCE(ele, (array)->pData) / (array)->elemSize)
...
@@ -46,6 +33,9 @@ typedef struct SArray {
...
@@ -46,6 +33,9 @@ typedef struct SArray {
void
*
pData
;
void
*
pData
;
}
SArray
;
}
SArray
;
#define TARRAY_SIZE(array) ((array)->size)
#define TARRAY_DATA(array) ((array)->pData)
/**
/**
*
*
* @param size
* @param size
...
...
source/common/src/tdataformat.c
浏览文件 @
fad06f61
...
@@ -100,16 +100,17 @@ typedef struct {
...
@@ -100,16 +100,17 @@ typedef struct {
int32_t
tRowBuild
(
SArray
*
aColVal
,
STSchema
*
pTSchema
,
SRow
**
ppRow
)
{
int32_t
tRowBuild
(
SArray
*
aColVal
,
STSchema
*
pTSchema
,
SRow
**
ppRow
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
ASSERT
(
taosArrayGetSize
(
aColVal
)
>
0
);
ASSERT
(
TARRAY_SIZE
(
aColVal
)
>
0
);
ASSERT
(((
SColVal
*
)
aColVal
->
pData
)[
0
].
cid
==
PRIMARYKEY_TIMESTAMP_COL_ID
);
ASSERT
(((
SColVal
*
)
aColVal
->
pData
)[
0
].
cid
==
PRIMARYKEY_TIMESTAMP_COL_ID
);
ASSERT
(((
SColVal
*
)
aColVal
->
pData
)[
0
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(((
SColVal
*
)
aColVal
->
pData
)[
0
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
// scan ---------------
// scan ---------------
SRow
*
pRow
=
NULL
;
SRow
*
pRow
=
NULL
;
SColVal
*
colVals
=
(
SColVal
*
)
TARRAY_DATA
(
aColVal
);
uint8_t
flag
=
0
;
uint8_t
flag
=
0
;
int32_t
iColVal
=
1
;
int32_t
iColVal
=
1
;
const
int32_t
nColVal
=
taosArrayGetSize
(
aColVal
);
const
int32_t
nColVal
=
TARRAY_SIZE
(
aColVal
);
SColVal
*
pColVal
=
(
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
SColVal
*
pColVal
=
(
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
int32_t
iTColumn
=
1
;
int32_t
iTColumn
=
1
;
STColumn
*
pTColumn
=
pTSchema
->
columns
+
iTColumn
;
STColumn
*
pTColumn
=
pTSchema
->
columns
+
iTColumn
;
int32_t
ntp
=
0
;
int32_t
ntp
=
0
;
...
@@ -142,13 +143,13 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -142,13 +143,13 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
}
}
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
}
else
if
(
pColVal
->
cid
>
pTColumn
->
colId
)
{
// NONE
}
else
if
(
pColVal
->
cid
>
pTColumn
->
colId
)
{
// NONE
flag
|=
HAS_NONE
;
flag
|=
HAS_NONE
;
ntp
+=
TYPE_BYTES
[
pTColumn
->
type
];
ntp
+=
TYPE_BYTES
[
pTColumn
->
type
];
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
}
else
{
}
else
{
pColVal
=
(
++
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
}
}
}
else
{
// NONE
}
else
{
// NONE
flag
|=
HAS_NONE
;
flag
|=
HAS_NONE
;
...
@@ -206,7 +207,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -206,7 +207,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
}
}
// build --------------
// build --------------
pColVal
=
(
SColVal
*
)
taosArrayGet
(
aColVal
,
0
)
;
pColVal
=
&
colVals
[
0
]
;
pRow
->
flag
=
flag
;
pRow
->
flag
=
flag
;
pRow
->
rsv
=
0
;
pRow
->
rsv
=
0
;
...
@@ -219,7 +220,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -219,7 +220,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
}
}
iColVal
=
1
;
iColVal
=
1
;
pColVal
=
(
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
iTColumn
=
1
;
iTColumn
=
1
;
pTColumn
=
pTSchema
->
columns
+
iTColumn
;
pTColumn
=
pTSchema
->
columns
+
iTColumn
;
if
(
flag
>>
4
)
{
// KV
if
(
flag
>>
4
)
{
// KV
...
@@ -271,11 +272,11 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -271,11 +272,11 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
}
}
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
}
else
if
(
pColVal
->
cid
>
pTColumn
->
colId
)
{
// NONE
}
else
if
(
pColVal
->
cid
>
pTColumn
->
colId
)
{
// NONE
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
}
else
{
}
else
{
pColVal
=
(
++
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
}
}
}
else
{
// NONE
}
else
{
// NONE
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
...
@@ -337,13 +338,13 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -337,13 +338,13 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
}
}
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
}
else
if
(
pColVal
->
cid
>
pTColumn
->
colId
)
{
// NONE
}
else
if
(
pColVal
->
cid
>
pTColumn
->
colId
)
{
// NONE
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT_NONE
);
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT_NONE
);
if
(
pf
)
memset
(
pf
+
pTColumn
->
offset
,
0
,
TYPE_BYTES
[
pTColumn
->
type
]);
if
(
pf
)
memset
(
pf
+
pTColumn
->
offset
,
0
,
TYPE_BYTES
[
pTColumn
->
type
]);
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
pTColumn
=
(
++
iTColumn
<
pTSchema
->
numOfCols
)
?
pTSchema
->
columns
+
iTColumn
:
NULL
;
}
else
{
}
else
{
pColVal
=
(
++
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
iColVal
]
:
NULL
;
}
}
}
else
{
// NONE
}
else
{
// NONE
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT_NONE
);
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT_NONE
);
...
...
source/util/src/tarray.c
浏览文件 @
fad06f61
...
@@ -228,7 +228,7 @@ size_t taosArrayGetSize(const SArray* pArray) {
...
@@ -228,7 +228,7 @@ size_t taosArrayGetSize(const SArray* pArray) {
if
(
pArray
==
NULL
)
{
if
(
pArray
==
NULL
)
{
return
0
;
return
0
;
}
}
return
pArray
->
size
;
return
TARRAY_SIZE
(
pArray
)
;
}
}
void
taosArraySetSize
(
SArray
*
pArray
,
size_t
size
)
{
void
taosArraySetSize
(
SArray
*
pArray
,
size_t
size
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录