Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f4196fe0
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
f4196fe0
编写于
12月 05, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'refact/submit_req' of github.com:taosdata/TDengine into refact/submit_req
上级
1024cba3
283bf01c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
101 addition
and
20 deletion
+101
-20
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+101
-20
未找到文件。
source/common/src/tdataformat.c
浏览文件 @
f4196fe0
...
@@ -63,9 +63,9 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson);
...
@@ -63,9 +63,9 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson);
#define KV_FLG_MID ((uint8_t)0x20)
#define KV_FLG_MID ((uint8_t)0x20)
#define KV_FLG_BIG ((uint8_t)0x30)
#define KV_FLG_BIG ((uint8_t)0x30)
#define
ROW_BIT
_NONE ((uint8_t)0x0)
#define
BIT_FLG
_NONE ((uint8_t)0x0)
#define
ROW_BIT
_NULL ((uint8_t)0x1)
#define
BIT_FLG
_NULL ((uint8_t)0x1)
#define
ROW_BIT
_VALUE ((uint8_t)0x2)
#define
BIT_FLG
_VALUE ((uint8_t)0x2)
#pragma pack(push, 1)
#pragma pack(push, 1)
typedef
struct
{
typedef
struct
{
...
@@ -314,7 +314,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -314,7 +314,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
if
(
pColVal
)
{
if
(
pColVal
)
{
if
(
pColVal
->
cid
==
pTColumn
->
colId
)
{
if
(
pColVal
->
cid
==
pTColumn
->
colId
)
{
if
(
COL_VAL_IS_VALUE
(
pColVal
))
{
// VALUE
if
(
COL_VAL_IS_VALUE
(
pColVal
))
{
// VALUE
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT
_VALUE
);
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
BIT_FLG
_VALUE
);
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
*
(
int32_t
*
)(
pf
+
pTColumn
->
offset
)
=
nv
;
*
(
int32_t
*
)(
pf
+
pTColumn
->
offset
)
=
nv
;
...
@@ -327,24 +327,24 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
...
@@ -327,24 +327,24 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow) {
memcpy
(
pf
+
pTColumn
->
offset
,
&
pColVal
->
value
.
val
,
TYPE_BYTES
[
pTColumn
->
type
]);
memcpy
(
pf
+
pTColumn
->
offset
,
&
pColVal
->
value
.
val
,
TYPE_BYTES
[
pTColumn
->
type
]);
}
}
}
else
if
(
COL_VAL_IS_NONE
(
pColVal
))
{
// NONE
}
else
if
(
COL_VAL_IS_NONE
(
pColVal
))
{
// NONE
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT
_NONE
);
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
BIT_FLG
_NONE
);
if
(
pf
)
memset
(
pf
+
pTColumn
->
offset
,
0
,
TYPE_BYTES
[
pTColumn
->
type
]);
if
(
pf
)
memset
(
pf
+
pTColumn
->
offset
,
0
,
TYPE_BYTES
[
pTColumn
->
type
]);
}
else
{
// NULL
}
else
{
// NULL
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
ROW_BIT
_NULL
);
ROW_SET_BITMAP
(
pb
,
flag
,
iTColumn
-
1
,
BIT_FLG
_NULL
);
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
;
pColVal
=
(
++
iColVal
<
nColVal
)
?
&
colVals
[
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
,
BIT_FLG
_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
)
?
&
colVals
[
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
,
BIT_FLG
_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
;
}
}
...
@@ -459,7 +459,7 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
...
@@ -459,7 +459,7 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
}
else
{
}
else
{
uint8_t
*
pf
;
uint8_t
*
pf
;
uint8_t
*
pv
;
uint8_t
*
pv
;
uint8_t
bv
=
ROW_BIT
_VALUE
;
uint8_t
bv
=
BIT_FLG
_VALUE
;
switch
(
pRow
->
flag
)
{
switch
(
pRow
->
flag
)
{
case
(
HAS_NULL
|
HAS_NONE
):
case
(
HAS_NULL
|
HAS_NONE
):
...
@@ -487,10 +487,10 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
...
@@ -487,10 +487,10 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
break
;
break
;
}
}
if
(
bv
==
ROW_BIT
_NONE
)
{
if
(
bv
==
BIT_FLG
_NONE
)
{
*
pColVal
=
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
);
*
pColVal
=
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
);
return
;
return
;
}
else
if
(
bv
==
ROW_BIT
_NULL
)
{
}
else
if
(
bv
==
BIT_FLG
_NULL
)
{
*
pColVal
=
COL_VAL_NULL
(
pTColumn
->
colId
,
pTColumn
->
type
);
*
pColVal
=
COL_VAL_NULL
(
pTColumn
->
colId
,
pTColumn
->
type
);
return
;
return
;
}
}
...
@@ -615,6 +615,7 @@ int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag) {
...
@@ -615,6 +615,7 @@ int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag) {
if
(
iEnd
-
iStart
>
1
)
{
if
(
iEnd
-
iStart
>
1
)
{
code
=
tRowMergeImpl
(
aRowP
,
pTSchema
,
iStart
,
iEnd
,
flag
);
code
=
tRowMergeImpl
(
aRowP
,
pTSchema
,
iStart
,
iEnd
,
flag
);
if
(
code
)
return
code
;
}
}
// the array is also changing, so the iStart just ++ instead of iEnd
// the array is also changing, so the iStart just ++ instead of iEnd
...
@@ -789,7 +790,7 @@ SColVal *tRowIterNext(SRowIter *pIter) {
...
@@ -789,7 +790,7 @@ SColVal *tRowIterNext(SRowIter *pIter) {
goto
_exit
;
goto
_exit
;
}
}
}
else
{
// Tuple
}
else
{
// Tuple
uint8_t
bv
=
ROW_BIT
_VALUE
;
uint8_t
bv
=
BIT_FLG
_VALUE
;
if
(
pIter
->
pb
)
{
if
(
pIter
->
pb
)
{
switch
(
pIter
->
pRow
->
flag
)
{
switch
(
pIter
->
pRow
->
flag
)
{
case
(
HAS_NULL
|
HAS_NONE
):
case
(
HAS_NULL
|
HAS_NONE
):
...
@@ -810,10 +811,10 @@ SColVal *tRowIterNext(SRowIter *pIter) {
...
@@ -810,10 +811,10 @@ SColVal *tRowIterNext(SRowIter *pIter) {
break
;
break
;
}
}
if
(
bv
==
ROW_BIT
_NONE
)
{
if
(
bv
==
BIT_FLG
_NONE
)
{
pIter
->
cv
=
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
);
pIter
->
cv
=
COL_VAL_NONE
(
pTColumn
->
colId
,
pTColumn
->
type
);
goto
_exit
;
goto
_exit
;
}
else
if
(
bv
==
ROW_BIT
_NULL
)
{
}
else
if
(
bv
==
BIT_FLG
_NULL
)
{
pIter
->
cv
=
COL_VAL_NULL
(
pTColumn
->
colId
,
pTColumn
->
type
);
pIter
->
cv
=
COL_VAL_NULL
(
pTColumn
->
colId
,
pTColumn
->
type
);
goto
_exit
;
goto
_exit
;
}
}
...
@@ -947,11 +948,11 @@ static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData
...
@@ -947,11 +948,11 @@ static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData
break
;
break
;
}
}
if
(
bv
==
ROW_BIT
_NONE
)
{
if
(
bv
==
BIT_FLG
_NONE
)
{
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NONE
](
pColData
,
NULL
,
0
);
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NONE
](
pColData
,
NULL
,
0
);
if
(
code
)
goto
_exit
;
if
(
code
)
goto
_exit
;
goto
_continue
;
goto
_continue
;
}
else
if
(
bv
==
ROW_BIT
_NULL
)
{
}
else
if
(
bv
==
BIT_FLG
_NULL
)
{
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NULL
](
pColData
,
NULL
,
0
);
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NULL
](
pColData
,
NULL
,
0
);
if
(
code
)
goto
_exit
;
if
(
code
)
goto
_exit
;
goto
_continue
;
goto
_continue
;
...
@@ -2133,6 +2134,88 @@ _exit:
...
@@ -2133,6 +2134,88 @@ _exit:
return
code
;
return
code
;
}
}
static
void
tColDataSort
(
SColData
*
aColData
,
int32_t
nColData
)
{
if
(
aColData
[
0
].
nVal
==
0
)
return
;
// TODO
}
static
void
tColDataMergeImpl
(
SColData
*
pColData
,
int32_t
iStart
,
int32_t
iEnd
/* not included */
)
{
switch
(
pColData
->
flag
)
{
case
HAS_NONE
:
case
HAS_NULL
:
{
pColData
->
nVal
=
pColData
->
nVal
-
(
iEnd
-
iStart
);
}
break
;
case
HAS_NULL
|
HAS_NONE
:
{
if
(
GET_BIT1
(
pColData
->
pBitMap
,
iStart
)
==
BIT_FLG_NONE
)
{
for
(
int32_t
i
=
iStart
+
1
;
i
<
iEnd
;
++
i
)
{
if
(
GET_BIT1
(
pColData
->
pBitMap
,
i
)
==
BIT_FLG_NULL
)
{
SET_BIT1
(
pColData
->
pBitMap
,
iStart
,
BIT_FLG_NULL
);
break
;
}
}
}
for
(
int32_t
i
=
iEnd
,
j
=
iStart
+
1
;
i
<
pColData
->
nVal
;
++
i
,
++
j
)
{
SET_BIT1
(
pColData
->
pBitMap
,
j
,
GET_BIT1
(
pColData
->
pBitMap
,
i
));
}
pColData
->
nVal
=
pColData
->
nVal
-
(
iEnd
-
iStart
);
uint8_t
flag
=
0
;
for
(
int32_t
i
=
0
;
i
<
pColData
->
nVal
;
++
i
)
{
uint8_t
bv
=
GET_BIT1
(
pColData
->
pBitMap
,
i
);
if
(
bv
==
BIT_FLG_NONE
)
{
flag
|=
HAS_NONE
;
}
else
if
(
bv
==
BIT_FLG_NULL
)
{
flag
|=
HAS_NULL
;
}
else
{
ASSERT
(
0
);
}
if
(
flag
==
pColData
->
flag
)
break
;
}
pColData
->
flag
=
flag
;
}
break
;
case
HAS_VALUE
:
{
// TODO
pColData
->
nVal
=
pColData
->
nVal
-
(
iEnd
-
iStart
);
}
break
;
case
HAS_VALUE
|
HAS_NONE
:
{
// TODO
pColData
->
nVal
=
pColData
->
nVal
-
(
iEnd
-
iStart
);
}
break
;
case
HAS_VALUE
|
HAS_NULL
:
{
// TODO
pColData
->
nVal
=
pColData
->
nVal
-
(
iEnd
-
iStart
);
}
break
;
case
HAS_VALUE
|
HAS_NULL
|
HAS_NONE
:
{
// TODO
pColData
->
nVal
=
pColData
->
nVal
-
(
iEnd
-
iStart
);
}
break
;
default:
ASSERT
(
0
);
break
;
}
}
static
void
tColDataMerge
(
SColData
*
aColData
,
int32_t
nColData
)
{
int32_t
iStart
=
0
;
for
(;;)
{
if
(
iStart
>=
aColData
[
0
].
nVal
)
break
;
int32_t
iEnd
=
iStart
+
1
;
while
(
iEnd
<
aColData
[
0
].
nVal
)
{
if
(((
TSKEY
*
)
aColData
[
0
].
pData
)[
iEnd
]
!=
((
TSKEY
*
)
aColData
[
0
].
pData
)[
iStart
])
break
;
iEnd
++
;
}
if
(
iEnd
-
iStart
>
1
)
{
for
(
int32_t
i
=
0
;
i
<
nColData
;
i
++
)
{
tColDataMergeImpl
(
&
aColData
[
i
],
iStart
,
iEnd
);
}
}
iStart
++
;
}
}
void
tColDataSortMerge
(
SArray
*
colDataArr
)
{
void
tColDataSortMerge
(
SArray
*
colDataArr
)
{
int32_t
nColData
=
TARRAY_SIZE
(
colDataArr
);
int32_t
nColData
=
TARRAY_SIZE
(
colDataArr
);
SColData
*
aColData
=
(
SColData
*
)
TARRAY_DATA
(
colDataArr
);
SColData
*
aColData
=
(
SColData
*
)
TARRAY_DATA
(
colDataArr
);
...
@@ -2160,14 +2243,12 @@ void tColDataSortMerge(SArray *colDataArr) {
...
@@ -2160,14 +2243,12 @@ void tColDataSortMerge(SArray *colDataArr) {
// sort -------
// sort -------
if
(
doSort
)
{
if
(
doSort
)
{
ASSERT
(
0
);
tColDataSort
(
aColData
,
nColData
);
// todo
}
}
// merge -------
// merge -------
if
(
doMerge
)
{
if
(
doMerge
)
{
ASSERT
(
0
);
tColDataMerge
(
aColData
,
nColData
);
// todo
}
}
_exit:
_exit:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录