Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
895b48f8
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
895b48f8
编写于
11月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
96b4fbc2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
40 deletion
+38
-40
include/common/tdataformat.h
include/common/tdataformat.h
+0
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+36
-37
source/common/src/ttypes.c
source/common/src/ttypes.c
+2
-2
未找到文件。
include/common/tdataformat.h
浏览文件 @
895b48f8
...
...
@@ -90,7 +90,6 @@ void tTSchemaDestroy(STSchema *pTSchema);
// SRow ================================
int32_t
tRowBuild
(
SArray
*
aColVal
,
STSchema
*
pTSchema
,
SBuffer
*
pBuffer
);
void
tRowGet
(
SRow
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
int32_t
tRowToArr
(
SRow
*
pRow
,
STSchema
*
pTSchema
,
SArray
**
aColValP
);
// SRowIter ================================
int32_t
tRowIterOpen
(
SRow
*
pRow
,
STSchema
*
pTSchema
,
SRowIter
**
ppIter
);
...
...
source/common/src/tdataformat.c
浏览文件 @
895b48f8
...
...
@@ -47,17 +47,14 @@ int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData) {
static
int32_t
tGetTagVal
(
uint8_t
*
p
,
STagVal
*
pTagVal
,
int8_t
isJson
);
// SRow ========================================================================
#define ROW_FLG_KV ((uint8_t)0x10)
#define KV_TYPE_LIT 0
#define KV_TYPE_MID 1
#define KV_TYPE_BIG 2
#define KV_FLG_LIT ((uint8_t)0x10)
#define KV_FLG_MID ((uint8_t)0x20)
#define KV_FLG_BIG ((uint8_t)0x30)
#pragma pack(push, 1)
typedef
struct
{
int8_t
kvType
;
int16_t
nCol
;
char
idx
[];
char
idx
[];
// uint8_t * | uint16_t * | uint32_t *
}
SKVIdx
;
#pragma pack(pop)
...
...
@@ -75,27 +72,29 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SBuffer *pBuffer) {
SColVal
*
pColVal
=
(
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
int32_t
iTColumn
=
1
;
STColumn
*
pTColumn
=
pTSchema
->
columns
+
iTColumn
;
int32_t
ntp
=
sizeof
(
SRow
);
int32_t
nkv
=
sizeof
(
SRow
);
int32_t
ntp
=
0
;
int32_t
nkv
=
0
;
int32_t
maxIdx
=
0
;
int32_t
nidx
=
0
;
while
(
pTColumn
)
{
if
(
pColVal
)
{
ntp
+=
TYPE_BYTES
[
pTColumn
->
type
];
if
(
pColVal
->
cid
==
pTColumn
->
colId
)
{
ntp
+=
TYPE_BYTES
[
pTColumn
->
type
];
if
(
COL_VAL_IS_VALUE
(
pColVal
))
{
// VALUE
flag
|=
HAS_VALUE
;
maxIdx
=
nkv
;
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
ntp
=
ntp
+
tPutU32v
(
NULL
,
pColVal
->
value
.
nData
)
+
pColVal
->
value
.
nData
;
nkv
=
nkv
+
tPutI16v
(
NULL
,
pTColumn
->
colId
)
+
tPutU32v
(
NULL
,
pColVal
->
value
.
nData
)
+
pColVal
->
value
.
nData
;
}
else
{
nkv
=
nkv
+
TYPE_BYTES
[
pTColumn
->
type
];
nkv
=
nkv
+
tPutI16v
(
NULL
,
pTColumn
->
colId
)
+
TYPE_BYTES
[
pTColumn
->
type
];
}
nidx
++
;
}
else
if
(
COL_VAL_IS_NONE
(
pColVal
))
{
// NONE
flag
|=
HAS_NONE
;
}
else
if
(
COL_VAL_IS_NULL
(
pColVal
))
{
// NULL
flag
|=
HAS_NULL
;
maxIdx
=
nkv
;
nkv
+=
tPutI16v
(
NULL
,
-
pTColumn
->
colId
);
nidx
++
;
}
else
{
...
...
@@ -119,43 +118,45 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SBuffer *pBuffer) {
}
// compare ---------------
int32_t
nRow
=
0
;
switch
(
flag
)
{
case
HAS_NONE
:
case
HAS_NULL
:
n
Row
=
sizeof
(
SRow
);
n
tp
=
sizeof
(
SRow
);
break
;
case
HAS_VALUE
:
n
Row
=
ntp
;
n
tp
=
sizeof
(
SRow
)
+
ntp
;
break
;
case
(
HAS_NULL
|
HAS_NONE
):
// TODO
ntp
=
sizeof
(
SRow
)
+
BIT1_SIZE
(
pTSchema
->
numOfCols
-
1
);
break
;
case
(
HAS_VALUE
|
HAS_NONE
):
case
(
HAS_VALUE
|
HAS_NULL
):
ntp
=
ntp
+
BIT1_SIZE
(
pTSchema
->
numOfCols
);
nkv
=
nkv
+
sizeof
(
int32_t
)
*
nidx
;
if
(
ntp
<=
nkv
)
{
nRow
=
ntp
;
}
else
{
nRow
=
nkv
;
flag
|=
ROW_FLG_KV
;
}
ntp
=
sizeof
(
SRow
)
+
BIT1_SIZE
(
pTSchema
->
numOfCols
-
1
)
+
ntp
;
break
;
case
(
HAS_VALUE
|
HAS_NULL
|
HAS_NONE
):
ntp
=
ntp
+
BIT2_SIZE
(
pTSchema
->
numOfCols
);
nkv
=
nkv
+
sizeof
(
int32_t
)
*
nidx
;
if
(
ntp
<=
nkv
)
{
nRow
=
ntp
;
}
else
{
nRow
=
nkv
;
flag
|=
ROW_FLG_KV
;
}
ntp
=
sizeof
(
SRow
)
+
BIT2_SIZE
(
pTSchema
->
numOfCols
-
1
)
+
ntp
;
break
;
default:
ASSERT
(
0
);
break
;
}
if
(
maxIdx
<=
UINT8_MAX
)
{
nkv
=
sizeof
(
SRow
)
+
sizeof
(
SKVIdx
)
+
sizeof
(
uint8_t
)
*
nidx
+
nkv
;
flag
|=
KV_FLG_LIT
;
}
else
if
(
maxIdx
<=
UINT16_MAX
)
{
nkv
=
sizeof
(
SRow
)
+
sizeof
(
SKVIdx
)
+
sizeof
(
uint16_t
)
*
nidx
+
nkv
;
flag
|=
KV_FLG_MID
;
}
else
{
nkv
=
sizeof
(
SRow
)
+
sizeof
(
SKVIdx
)
+
sizeof
(
uint32_t
)
*
nidx
+
nkv
;
flag
|=
KV_FLG_BIG
;
}
int32_t
nRow
;
if
(
nkv
<
ntp
)
{
nRow
=
nkv
;
}
else
{
nRow
=
ntp
;
flag
&=
((
uint8_t
)
0x0f
);
}
// alloc --------------
SRow
*
pRow
=
NULL
;
// todo
...
...
@@ -177,7 +178,7 @@ int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SBuffer *pBuffer) {
pColVal
=
(
iColVal
<
nColVal
)
?
(
SColVal
*
)
taosArrayGet
(
aColVal
,
iColVal
)
:
NULL
;
iTColumn
=
1
;
pTColumn
=
pTSchema
->
columns
+
iTColumn
;
if
(
flag
&
ROW_FLG_KV
)
{
// KV
if
(
flag
&
0xf0
)
{
// KV
SKVIdx
*
pIdx
=
(
SKVIdx
*
)
pRow
->
data
;
uint8_t
*
pv
=
NULL
;
// todo
...
...
@@ -278,7 +279,7 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
return
;
}
if
(
pRow
->
flag
&
ROW_FLG_KV
)
{
// KV Row
if
(
pRow
->
flag
&
0xf0
)
{
// KV Row
SKVIdx
*
pIdx
=
(
SKVIdx
*
)
pRow
->
data
;
uint8_t
*
pv
=
pRow
->
data
+
sizeof
(
*
pIdx
)
+
sizeof
(
int32_t
)
*
pIdx
->
nCol
;
...
...
@@ -327,8 +328,6 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
}
}
int32_t
tRowToArr
(
SRow
*
pRow
,
STSchema
*
pTSchema
,
SArray
**
aColValP
)
{
return
0
;
}
// SRowIter ========================================
struct
SRowIter
{
SRow
*
pRow
;
...
...
@@ -405,7 +404,7 @@ SColVal *tRowIterNext(SRowIter *pIter) {
goto
_exit
;
}
if
(
pIter
->
pRow
->
flag
&
ROW_FLG_KV
)
{
// KV
if
(
pIter
->
pRow
->
flag
&
0xf0
)
{
// KV
if
(
pIter
->
iCol
<
pIter
->
pIdx
->
nCol
)
{
uint8_t
*
pData
=
pIter
->
pv
+
pIter
->
pIdx
->
idx
[
pIter
->
iCol
];
// todo
int16_t
cid
;
...
...
source/common/src/ttypes.c
浏览文件 @
895b48f8
...
...
@@ -61,7 +61,7 @@ tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
static
float
floatMin
=
-
FLT_MAX
,
floatMax
=
FLT_MAX
;
static
double
doubleMin
=
-
DBL_MAX
,
doubleMax
=
DBL_MAX
;
FORCE_INLINE
void
*
getDataMin
(
int32_t
type
,
void
*
value
)
{
FORCE_INLINE
void
*
getDataMin
(
int32_t
type
,
void
*
value
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
*
(
float
*
)
value
=
floatMin
;
...
...
@@ -77,7 +77,7 @@ FORCE_INLINE void *getDataMin(int32_t type, void* value) {
return
value
;
}
FORCE_INLINE
void
*
getDataMax
(
int32_t
type
,
void
*
value
)
{
FORCE_INLINE
void
*
getDataMax
(
int32_t
type
,
void
*
value
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
*
(
float
*
)
value
=
floatMax
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录