Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
235cd626
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看板
提交
235cd626
编写于
12月 12, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code optimization and merge develop
上级
93af9fbc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
15 deletion
+28
-15
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+5
-5
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+21
-10
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+2
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
235cd626
...
...
@@ -117,6 +117,7 @@ typedef struct SParsedDataColInfo {
uint16_t
flen
;
// TODO: get from STSchema
uint16_t
allNullLen
;
// TODO: get from STSchema
uint16_t
extendedVarLen
;
uint16_t
boundColsLen
;
// len of bound columns
int32_t
*
boundedColumns
;
// bound column idx according to schema
SBoundColumn
*
cols
;
SBoundIdxInfo
*
colIdxInfo
;
...
...
@@ -150,8 +151,7 @@ typedef struct {
int
tsParseTime
(
SStrToken
*
pToken
,
int64_t
*
time
,
char
**
next
,
char
*
error
,
int16_t
timePrec
);
int
initMemRowBuilder
(
SMemRowBuilder
*
pBuilder
,
uint32_t
nRows
,
uint32_t
nCols
,
uint32_t
nBoundCols
,
int32_t
allNullLen
);
int
initMemRowBuilder
(
SMemRowBuilder
*
pBuilder
,
uint32_t
nRows
,
uint32_t
nCols
,
SParsedDataColInfo
*
pColInfo
);
void
destroyMemRowBuilder
(
SMemRowBuilder
*
pBuilder
);
/**
...
...
@@ -531,12 +531,12 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableDataBlocks *pBlock) {
return
pBlock
->
rowSize
+
TD_MEM_ROW_DATA_HEAD_SIZE
+
pBlock
->
boundColumnInfo
.
extendedVarLen
;
}
static
FORCE_INLINE
bool
check
And
ConvertMemRow
(
SMemRow
row
,
int32_t
dataLen
,
int32_t
kvLen
)
{
static
FORCE_INLINE
bool
checkConvertMemRow
(
SMemRow
row
,
int32_t
dataLen
,
int32_t
kvLen
)
{
if
(
isDataRow
(
row
))
{
if
(
kvLen
<
(
dataLen
*
KVRatioConvert
))
{
if
(
isConvertToKvRow
(
kvLen
,
dataLen
))
{
return
true
;
}
}
else
if
(
kvLen
>
dataLen
)
{
}
else
if
(
isConvertToDataRow
(
kvLen
,
dataLen
)
)
{
return
true
;
}
return
false
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
235cd626
...
...
@@ -41,9 +41,8 @@ enum {
static
int32_t
tscAllocateMemIfNeed
(
STableDataBlocks
*
pDataBlock
,
int32_t
rowSize
,
int32_t
*
numOfRows
);
static
int32_t
parseBoundColumns
(
SInsertStatementParam
*
pInsertParam
,
SParsedDataColInfo
*
pColInfo
,
SSchema
*
pSchema
,
char
*
str
,
char
**
end
);
int
initMemRowBuilder
(
SMemRowBuilder
*
pBuilder
,
uint32_t
nRows
,
uint32_t
nCols
,
uint32_t
nBoundCols
,
int32_t
allNullLen
)
{
ASSERT
(
nRows
>=
0
&&
nCols
>
0
&&
(
nBoundCols
<=
nCols
));
int
initMemRowBuilder
(
SMemRowBuilder
*
pBuilder
,
uint32_t
nRows
,
uint32_t
nCols
,
SParsedDataColInfo
*
pColInfo
)
{
ASSERT
(
nRows
>=
0
&&
nCols
>
0
&&
(
pColInfo
->
numOfBound
<=
nCols
));
if
(
nRows
>
0
)
{
// already init(bind multiple rows by single column)
if
(
pBuilder
->
compareStat
==
ROW_COMPARE_NEED
&&
(
pBuilder
->
rowInfo
!=
NULL
))
{
...
...
@@ -52,11 +51,21 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint3
}
// default compareStat is ROW_COMPARE_NO_NEED
if
(
nBoundCols
==
0
)
{
// file input
if
(
pColInfo
->
numOfBound
==
0
)
{
// file input
pBuilder
->
memRowType
=
SMEM_ROW_DATA
;
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pColInfo
->
extendedVarLen
==
0
)
{
// all columns are NoVarType, we can calculate the memRowType precisely
uint32_t
dataLen
=
pColInfo
->
allNullLen
+
TD_MEM_ROW_DATA_HEAD_SIZE
;
uint32_t
kvLen
=
TD_MEM_ROW_KV_HEAD_SIZE
+
pColInfo
->
numOfBound
*
sizeof
(
SColIdx
)
+
pColInfo
->
boundColsLen
;
if
(
isConvertToKvRow
(
kvLen
,
dataLen
))
{
pBuilder
->
memRowType
=
SMEM_ROW_KV
;
}
else
{
pBuilder
->
memRowType
=
SMEM_ROW_DATA
;
}
return
TSDB_CODE_SUCCESS
;
}
else
{
float
boundRatio
=
((
float
)
nBoundCols
/
(
float
)
nCols
);
float
boundRatio
=
((
float
)
pColInfo
->
numOfBound
/
(
float
)
nCols
);
if
(
boundRatio
<
KVRatioKV
)
{
pBuilder
->
memRowType
=
SMEM_ROW_KV
;
...
...
@@ -74,7 +83,7 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint3
}
}
pBuilder
->
kvRowInitLen
=
TD_MEM_ROW_KV_HEAD_SIZE
+
nBoundCols
*
sizeof
(
SColIdx
);
pBuilder
->
kvRowInitLen
=
TD_MEM_ROW_KV_HEAD_SIZE
+
pColInfo
->
numOfBound
*
sizeof
(
SColIdx
);
if
(
nRows
>
0
)
{
pBuilder
->
rowInfo
=
tcalloc
(
nRows
,
sizeof
(
SMemRowInfo
));
...
...
@@ -83,7 +92,7 @@ int initMemRowBuilder(SMemRowBuilder *pBuilder, uint32_t nRows, uint3
}
for
(
int
i
=
0
;
i
<
nRows
;
++
i
)
{
(
pBuilder
->
rowInfo
+
i
)
->
dataLen
=
TD_MEM_ROW_DATA_HEAD_SIZE
+
allNullLen
;
(
pBuilder
->
rowInfo
+
i
)
->
dataLen
=
TD_MEM_ROW_DATA_HEAD_SIZE
+
pColInfo
->
allNullLen
;
(
pBuilder
->
rowInfo
+
i
)
->
kvLen
=
pBuilder
->
kvRowInitLen
;
}
}
...
...
@@ -552,7 +561,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
// 2. check and set convert flag
bool
isNeedConvertRow
=
false
;
if
(
pBuilder
->
compareStat
==
ROW_COMPARE_NEED
)
{
isNeedConvertRow
=
check
And
ConvertMemRow
(
row
,
dataLen
,
kvLen
);
isNeedConvertRow
=
checkConvertMemRow
(
row
,
dataLen
,
kvLen
);
}
// 3. set the null value for the columns that do not assign values
...
...
@@ -630,8 +639,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SIn
int32_t
extendedRowSize
=
getExtendedRowSize
(
pDataBlock
);
if
(
TSDB_CODE_SUCCESS
!=
(
code
=
initMemRowBuilder
(
&
pDataBlock
->
rowBuilder
,
0
,
tinfo
.
numOfColumns
,
pDataBlock
->
boundColumnInfo
.
numOfBound
,
pDataBlock
->
boundColumnInfo
.
allNullLen
)))
{
(
code
=
initMemRowBuilder
(
&
pDataBlock
->
rowBuilder
,
0
,
tinfo
.
numOfColumns
,
&
pDataBlock
->
boundColumnInfo
)))
{
return
code
;
}
int32_t
convertOffset
=
0
;
...
...
@@ -688,6 +696,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32
pColInfo
->
numOfCols
=
numOfCols
;
pColInfo
->
numOfBound
=
numOfCols
;
pColInfo
->
orderStatus
=
ORDER_STATUS_ORDERED
;
// default is ORDERED for non-bound mode
pColInfo
->
boundColsLen
=
0
;
pColInfo
->
boundedColumns
=
calloc
(
pColInfo
->
numOfCols
,
sizeof
(
int32_t
));
pColInfo
->
cols
=
calloc
(
pColInfo
->
numOfCols
,
sizeof
(
SBoundColumn
));
pColInfo
->
colIdxInfo
=
NULL
;
...
...
@@ -1297,6 +1306,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
pColInfo
->
cols
[
t
].
valStat
=
VAL_STAT_HAS
;
pColInfo
->
boundedColumns
[
pColInfo
->
numOfBound
]
=
t
;
++
pColInfo
->
numOfBound
;
pColInfo
->
boundColsLen
+=
pSchema
[
t
].
bytes
;
findColumnIndex
=
true
;
if
(
isOrdered
&&
(
lastColIdx
>
t
))
{
isOrdered
=
false
;
...
...
@@ -1320,6 +1330,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
pColInfo
->
cols
[
t
].
valStat
=
VAL_STAT_HAS
;
pColInfo
->
boundedColumns
[
pColInfo
->
numOfBound
]
=
t
;
++
pColInfo
->
numOfBound
;
pColInfo
->
boundColsLen
+=
pSchema
[
t
].
bytes
;
findColumnIndex
=
true
;
if
(
isOrdered
&&
(
lastColIdx
>
t
))
{
isOrdered
=
false
;
...
...
src/common/inc/tdataformat.h
浏览文件 @
235cd626
...
...
@@ -625,6 +625,8 @@ typedef void *SMemRow;
#define isKvRowT(t) (SMEM_ROW_KV == (((uint8_t)(t)) & 0x01))
#define isKvRow(r) (SMEM_ROW_KV == memRowType(r))
#define isNeedConvertRow(r) (((*(uint8_t *)(r)) & 0x80) == SMEM_ROW_CONVERT)
#define isConvertToKvRow(k, d) ((k) < ((d)*KVRatioConvert))
#define isConvertToDataRow(k, d) ((k) > (d))
#define memRowDataBody(r) POINTER_SHIFT(r, TD_MEM_ROW_TYPE_SIZE) // section after flag
#define memRowKvBody(r) \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录