Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
91a5378f
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看板
提交
91a5378f
编写于
7月 11, 2021
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tiny code optimization
上级
c329bb4d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
19 deletion
+12
-19
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+11
-17
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-2
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
91a5378f
...
@@ -49,13 +49,11 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableComInfo *tinfo) {
...
@@ -49,13 +49,11 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableComInfo *tinfo) {
return
tinfo
->
rowSize
+
PAYLOAD_HEADER_LEN
+
PAYLOAD_COL_HEAD_LEN
*
tinfo
->
numOfColumns
;
return
tinfo
->
rowSize
+
PAYLOAD_HEADER_LEN
+
PAYLOAD_COL_HEAD_LEN
*
tinfo
->
numOfColumns
;
}
}
int
initSMemRowHelper
(
SMemRowHelper
*
pHelper
,
SSchema
*
pSSchema
,
uint16_t
nCols
,
uint16_t
allNullColsLen
)
{
int
initSMemRowHelper
(
SMemRowHelper
*
pHelper
,
SSchema
*
pSSchema
,
uint16_t
nCols
,
uint16_t
allNullColsLen
)
{
ASSERT
(
nCols
>
0
);
pHelper
->
allNullLen
=
allNullColsLen
;
// TODO: get allNullColsLen when creating or altering table meta
pHelper
->
allNullLen
=
allNullColsLen
;
// TODO: get allNullColsLen when creating or altering table meta
if
(
pHelper
->
allNullLen
==
0
)
{
if
(
pHelper
->
allNullLen
==
0
)
{
for
(
uint16_t
i
=
0
;
i
<
nCols
;
++
i
)
{
for
(
uint16_t
i
=
0
;
i
<
nCols
;
++
i
)
{
uint8_t
type
=
pSSchema
[
i
].
type
;
uint8_t
type
=
pSSchema
[
i
].
type
;
int32_t
typeLen
=
TYPE_BYTES
[
type
];
int32_t
typeLen
=
TYPE_BYTES
[
type
];
ASSERT
(
typeLen
>
0
);
pHelper
->
allNullLen
+=
typeLen
;
pHelper
->
allNullLen
+=
typeLen
;
if
(
TSDB_DATA_TYPE_BINARY
==
type
)
{
if
(
TSDB_DATA_TYPE_BINARY
==
type
)
{
pHelper
->
allNullLen
+=
(
sizeof
(
VarDataLenT
)
+
CHAR_BYTES
);
pHelper
->
allNullLen
+=
(
sizeof
(
VarDataLenT
)
+
CHAR_BYTES
);
...
@@ -787,14 +785,12 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
...
@@ -787,14 +785,12 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
SParsedDataColInfo
*
spd
=
&
pDataBlocks
->
boundColumnInfo
;
SParsedDataColInfo
*
spd
=
&
pDataBlocks
->
boundColumnInfo
;
SSchema
*
schema
=
tscGetTableSchema
(
pDataBlocks
->
pTableMeta
);
SSchema
*
schema
=
tscGetTableSchema
(
pDataBlocks
->
pTableMeta
);
TDRowTLenT
dataRowLen
=
pHelper
->
allNullLen
;
int32_t
rowSize
=
0
;
TDRowTLenT
kvRowLen
=
TD_MEM_ROW_KV_VER_SIZE
;
int32_t
dataRowLen
=
pHelper
->
allNullLen
;
int32_t
kvRowLen
=
TD_MEM_ROW_KV_VER_SIZE
;
TDRowTLenT
payloadValOffset
=
0
;
TDRowTLenT
payloadValOffset
=
0
;
TDRowLenT
colValOffset
=
0
;
TDRowLenT
colValOffset
=
0
;
ASSERT
(
dataRowLen
>
0
);
ASSERT
(
dataRowLen
>
0
);
payloadSetNCols
(
payload
,
spd
->
numOfBound
);
payloadSetNCols
(
payload
,
spd
->
numOfBound
);
payloadValOffset
=
payloadValuesOffset
(
payload
);
// rely on payloadNCols
payloadValOffset
=
payloadValuesOffset
(
payload
);
// rely on payloadNCols
payloadSetTLen
(
payload
,
payloadValOffset
);
payloadSetTLen
(
payload
,
payloadValOffset
);
...
@@ -810,7 +806,6 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
...
@@ -810,7 +806,6 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
char
*
start
=
payload
+
spd
->
cols
[
colIndex
].
offset
;
char
*
start
=
payload
+
spd
->
cols
[
colIndex
].
offset
;
SSchema
*
pSchema
=
&
schema
[
colIndex
];
// get colId here
SSchema
*
pSchema
=
&
schema
[
colIndex
];
// get colId here
rowSize
+=
pSchema
->
bytes
;
index
=
0
;
index
=
0
;
sToken
=
tStrGetToken
(
*
str
,
&
index
,
true
);
sToken
=
tStrGetToken
(
*
str
,
&
index
,
true
);
...
@@ -879,9 +874,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
...
@@ -879,9 +874,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
}
else
{
}
else
{
ASSERT
(
spd
->
colIdxInfo
[
i
].
finalIdx
==
0
);
ASSERT
(
spd
->
colIdxInfo
[
i
].
finalIdx
==
0
);
}
}
}
else
{
}
ASSERT
(
spd
->
colIdxInfo
==
NULL
);
}
// the primary key locates in 1st column
// the primary key locates in 1st column
int32_t
ret
=
tsParseOneColumnKV
(
pSchema
,
&
sToken
,
payload
,
kvPrimaryKeyStart
,
kvStart
,
pInsertParam
->
msg
,
str
,
int32_t
ret
=
tsParseOneColumnKV
(
pSchema
,
&
sToken
,
payload
,
kvPrimaryKeyStart
,
kvStart
,
pInsertParam
->
msg
,
str
,
isPrimaryKey
,
timePrec
,
payloadValOffset
+
colValOffset
,
&
colValAppended
,
isPrimaryKey
,
timePrec
,
payloadValOffset
+
colValOffset
,
&
colValAppended
,
...
@@ -1050,7 +1043,7 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
...
@@ -1050,7 +1043,7 @@ int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int3
// expand the allocated size
// expand the allocated size
if
(
remain
<
rowSize
*
factor
)
{
if
(
remain
<
rowSize
*
factor
)
{
while
(
remain
<
rowSize
*
factor
)
{
while
(
remain
<
rowSize
*
factor
)
{
pDataBlock
->
nAllocSize
=
(
uint32_t
)(
pDataBlock
->
nAllocSize
*
2
);
pDataBlock
->
nAllocSize
=
(
uint32_t
)(
pDataBlock
->
nAllocSize
*
1
.
5
);
remain
=
pDataBlock
->
nAllocSize
-
pDataBlock
->
size
;
remain
=
pDataBlock
->
nAllocSize
-
pDataBlock
->
size
;
}
}
...
@@ -1553,7 +1546,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1553,7 +1546,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
index
=
0
;
int32_t
index
=
0
;
SStrToken
sToken
=
tStrGetToken
(
str
,
&
index
,
false
);
SStrToken
sToken
=
tStrGetToken
(
str
,
&
index
,
false
);
str
+=
index
;
str
+=
index
;
...
@@ -1561,6 +1554,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1561,6 +1554,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"( is expected"
,
sToken
.
z
);
code
=
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"( is expected"
,
sToken
.
z
);
goto
_clean
;
goto
_clean
;
}
}
bool
isOrdered
=
true
;
bool
isOrdered
=
true
;
int32_t
lastColIdx
=
-
1
;
int32_t
lastColIdx
=
-
1
;
while
(
1
)
{
while
(
1
)
{
...
@@ -1621,13 +1615,13 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1621,13 +1615,13 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
goto
_clean
;
goto
_clean
;
}
}
SBoundIdxInfo
*
pColIdx
=
pColInfo
->
colIdxInfo
;
SBoundIdxInfo
*
pColIdx
=
pColInfo
->
colIdxInfo
;
for
(
in
t
i
=
0
;
i
<
pColInfo
->
numOfBound
;
++
i
)
{
for
(
uint16_
t
i
=
0
;
i
<
pColInfo
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
schemaColIdx
=
(
uint16_t
)
pColInfo
->
boundedColumns
[
i
];
pColIdx
[
i
].
schemaColIdx
=
(
uint16_t
)
pColInfo
->
boundedColumns
[
i
];
pColIdx
[
i
].
boundIdx
=
(
uint16_t
)
i
;
pColIdx
[
i
].
boundIdx
=
i
;
}
}
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
for
(
in
t
i
=
0
;
i
<
pColInfo
->
numOfBound
;
++
i
)
{
for
(
uint16_
t
i
=
0
;
i
<
pColInfo
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
finalIdx
=
(
uint16_t
)
i
;
pColIdx
[
i
].
finalIdx
=
i
;
}
}
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
91a5378f
...
@@ -1755,7 +1755,7 @@ static SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) {
...
@@ -1755,7 +1755,7 @@ static SMemRow tdGenMemRowFromBuilder(SMemRowBuilder* pBuilder) {
#endif
#endif
}
else
if
(
memRowType
==
SMEM_ROW_KV
)
{
}
else
if
(
memRowType
==
SMEM_ROW_KV
)
{
ASSERT
(
nColsBound
<
=
nCols
);
ASSERT
(
nColsBound
<
nCols
);
SKVRow
kvRow
=
(
SKVRow
)
memRowKvBody
(
memRow
);
SKVRow
kvRow
=
(
SKVRow
)
memRowKvBody
(
memRow
);
kvRowSetLen
(
kvRow
,
(
TDRowLenT
)(
TD_KV_ROW_HEAD_SIZE
+
sizeof
(
SColIdx
)
*
nColsBound
));
kvRowSetLen
(
kvRow
,
(
TDRowLenT
)(
TD_KV_ROW_HEAD_SIZE
+
sizeof
(
SColIdx
)
*
nColsBound
));
kvRowSetNCols
(
kvRow
,
nColsBound
);
kvRowSetNCols
(
kvRow
,
nColsBound
);
...
@@ -1846,7 +1846,6 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bo
...
@@ -1846,7 +1846,6 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, bo
}
}
static
int32_t
getRowExpandSize
(
STableMeta
*
pTableMeta
)
{
static
int32_t
getRowExpandSize
(
STableMeta
*
pTableMeta
)
{
// add prefix len of KV type SMemRow(we may use SDataRow or SKVRow)
int32_t
result
=
TD_MEM_ROW_DATA_HEAD_SIZE
;
int32_t
result
=
TD_MEM_ROW_DATA_HEAD_SIZE
;
int32_t
columns
=
tscGetNumOfColumns
(
pTableMeta
);
int32_t
columns
=
tscGetNumOfColumns
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录