Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c1a3a085
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看板
提交
c1a3a085
编写于
2月 15, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finish code
上级
b60392b6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
140 addition
and
73 deletion
+140
-73
include/common/tdataformat.h
include/common/tdataformat.h
+1
-1
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+1
-1
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+138
-71
未找到文件。
include/common/tdataformat.h
浏览文件 @
c1a3a085
...
...
@@ -205,7 +205,7 @@ struct SColData {
int32_t
numOfNull
;
// # of null
int32_t
numOfValue
;
// # of vale
int32_t
nVal
;
uint8_t
flag
;
int8_t
flag
;
uint8_t
*
pBitMap
;
int32_t
*
aOffset
;
int32_t
nData
;
...
...
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
c1a3a085
...
...
@@ -22,7 +22,7 @@
* us: 3600*1000000*8765*1000 // 1970 + 1000 years
* ns: 3600*1000000000*8765*292 // 1970 + 292 years
*/
static
int64_t
tsMaxKeyByPrecision
[]
=
{
31556995200000L
,
31556995200000000L
,
9214646400000000000L
};
int64_t
tsMaxKeyByPrecision
[]
=
{
31556995200000L
,
31556995200000000L
,
9214646400000000000L
};
// static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
c1a3a085
...
...
@@ -13,7 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bits/stdint-intn.h>
#include "tencode.h"
#include "tmsg.h"
#include "vnd.h"
#include "vnode.h"
#include "vnodeInt.h"
static
int32_t
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
...
...
@@ -31,6 +36,48 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq
static
int32_t
vnodeProcessBatchDeleteReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessCompactVnodeReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodePreprocessCreateTableReq
(
SVnode
*
pVnode
,
SDecoder
*
pCoder
,
int64_t
ctime
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
if
(
tStartDecode
(
pCoder
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// flags
if
(
tDecodeI32v
(
pCoder
,
NULL
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// name
char
*
name
=
NULL
;
if
(
tDecodeCStr
(
pCoder
,
&
name
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// uid
int64_t
uid
=
metaGetTableEntryUidByName
(
pVnode
->
pMeta
,
name
);
if
(
uid
==
0
)
{
uid
=
tGenIdPI64
();
}
*
(
int64_t
*
)(
pCoder
->
data
+
pCoder
->
pos
)
=
uid
;
// ctime
*
(
int64_t
*
)(
pCoder
->
data
+
pCoder
->
pos
+
8
)
=
ctime
;
tEndDecode
(
pCoder
);
_exit:
if
(
code
)
{
vError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
}
else
{
vTrace
(
"vgId:%d %s done, table:%s uid generated:%"
PRId64
,
TD_VID
(
pVnode
),
__func__
,
name
,
uid
);
}
return
code
;
}
static
int32_t
vnodePreProcessCreateTableMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -50,26 +97,8 @@ static int32_t vnodePreProcessCreateTableMsg(SVnode *pVnode, SRpcMsg *pMsg) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
for
(
int32_t
iReq
=
0
;
iReq
<
nReqs
;
iReq
++
)
{
tb_uid_t
uid
=
tGenIdPI64
();
char
*
name
=
NULL
;
if
(
tStartDecode
(
&
dc
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tDecodeI32v
(
&
dc
,
NULL
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tDecodeCStr
(
&
dc
,
&
name
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
)
=
uid
;
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
+
8
)
=
ctime
;
vTrace
(
"vgId:%d table:%s uid:%"
PRId64
" is generated"
,
pVnode
->
config
.
vgId
,
name
,
uid
);
tEndDecode
(
&
dc
);
code
=
vnodePreprocessCreateTableReq
(
pVnode
,
&
dc
,
ctime
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
tEndDecode
(
&
dc
);
...
...
@@ -78,80 +107,118 @@ _exit:
tDecoderClear
(
&
dc
);
return
code
;
}
static
int32_t
vnodePreProcessSubmit
Msg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
extern
int64_t
tsMaxKeyByPrecision
[];
static
int32_t
vnodePreProcessSubmit
TbData
(
SVnode
*
pVnode
,
SDecoder
*
pCoder
,
int64_t
ctime
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
int64_t
ctime
=
taosGetTimestampMs
();
SDecoder
dc
=
{
0
};
if
(
tStartDecode
(
pCoder
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
tDecoderInit
(
&
dc
,
(
uint8_t
*
)
pMsg
->
pCont
+
sizeof
(
SMsgHead
),
pMsg
->
contLen
-
sizeof
(
SMsgHead
));
tStartDecode
(
&
dc
);
SSubmitTbData
submitTbData
;
if
(
tDecodeI32v
(
pCoder
,
&
submitTbData
.
flags
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
uint64_t
nSubmitTbData
;
if
(
tDecodeU64v
(
&
dc
,
&
nSubmitTbData
)
<
0
)
{
if
(
submitTbData
.
flags
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
code
=
vnodePreprocessCreateTableReq
(
pVnode
,
pCoder
,
ctime
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// submit data
if
(
tDecodeI64
(
pCoder
,
&
submitTbData
.
suid
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tDecodeI64
(
pCoder
,
&
submitTbData
.
uid
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tDecodeI32v
(
pCoder
,
&
submitTbData
.
sver
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
for
(
int32_t
i
=
0
;
i
<
nSubmitTbData
;
i
++
)
{
if
(
tStartDecode
(
&
dc
)
<
0
)
{
// scan and check
TSKEY
now
=
ctime
;
if
(
pVnode
->
config
.
tsdbCfg
.
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
now
*=
1000
;
}
else
if
(
pVnode
->
config
.
tsdbCfg
.
precision
==
TSDB_TIME_PRECISION_NANO
)
{
now
*=
1000000
;
}
TSKEY
minKey
=
now
-
tsTickPerMin
[
pVnode
->
config
.
tsdbCfg
.
precision
]
*
pVnode
->
config
.
tsdbCfg
.
keep2
;
TSKEY
maxKey
=
tsMaxKeyByPrecision
[
pVnode
->
config
.
tsdbCfg
.
precision
];
if
(
submitTbData
.
flags
&
SUBMIT_REQ_COLUMN_DATA_FORMAT
)
{
uint64_t
nColData
;
if
(
tDecodeU64v
(
pCoder
,
&
nColData
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
)
;
goto
_exit
;
}
int32_t
flags
;
if
(
tDecodeI32v
(
&
dc
,
&
flags
)
<
0
)
{
SColData
colData
=
{
0
};
pCoder
->
pos
+=
tGetColData
(
pCoder
->
data
+
pCoder
->
pos
,
&
colData
);
for
(
int32_t
iRow
=
0
;
iRow
<
colData
.
nVal
;
iRow
++
)
{
if
(((
TSKEY
*
)
colData
.
pData
)[
iRow
]
<
minKey
||
((
TSKEY
*
)
colData
.
pData
)[
iRow
]
>
maxKey
)
{
code
=
TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE
;
goto
_exit
;
}
}
}
else
{
uint64_t
nRow
;
if
(
tDecodeU64v
(
pCoder
,
&
nRow
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
)
;
goto
_exit
;
}
if
(
flags
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
// SVCreateTbReq
if
(
tStartDecode
(
&
dc
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
for
(
int32_t
iRow
=
0
;
iRow
<
nRow
;
++
iRow
)
{
SRow
*
pRow
=
(
SRow
*
)(
pCoder
->
data
+
pCoder
->
pos
);
pCoder
->
pos
+=
pRow
->
len
;
if
(
tDecodeI32v
(
&
dc
,
NULL
)
<
0
)
{
code
=
TSDB_CODE_
INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
)
;
if
(
pRow
->
ts
<
minKey
||
pRow
->
ts
>
maxKey
)
{
code
=
TSDB_CODE_
TDB_TIMESTAMP_OUT_OF_RANGE
;
goto
_exit
;
}
}
}
char
*
name
=
NULL
;
if
(
tDecodeCStr
(
&
dc
,
&
name
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
tEndDecode
(
pCoder
);
int64_t
uid
=
metaGetTableEntryUidByName
(
pVnode
->
pMeta
,
name
);
if
(
uid
==
0
)
{
uid
=
tGenIdPI64
();
}
_exit:
return
0
;
}
static
int32_t
vnodePreProcessSubmitMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
)
=
uid
;
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
+
8
)
=
ctime
;
SDecoder
*
pCoder
=
&
(
SDecoder
){
0
};
tEndDecode
(
&
dc
);
tDecoderInit
(
pCoder
,
(
uint8_t
*
)
pMsg
->
pCont
+
sizeof
(
SMsgHead
),
pMsg
->
contLen
-
sizeof
(
SMsgHead
)
);
// SSubmitTbData
int64_t
suid
;
if
(
tDecodeI64
(
&
dc
,
&
suid
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tStartDecode
(
pCoder
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
)
=
uid
;
}
uint64_t
nSubmitTbData
;
if
(
tDecodeU64v
(
pCoder
,
&
nSubmitTbData
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
tEndDecode
(
&
dc
);
int64_t
ctime
=
taosGetTimestampMs
();
for
(
int32_t
i
=
0
;
i
<
nSubmitTbData
;
i
++
)
{
code
=
vnodePreProcessSubmitTbData
(
pVnode
,
pCoder
,
ctime
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
tEndDecode
(
&
dc
);
tDecoderClear
(
&
dc
);
tEndDecode
(
pCoder
);
_exit:
tDecoderClear
(
pCoder
);
return
code
;
}
...
...
@@ -923,11 +990,11 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
}
tDecoderClear
(
&
dc
);
// check
code
=
tsdbScanAndConvertSubmitMsg
(
pVnode
->
pTsdb
,
pSubmitReq
);
if
(
code
)
{
goto
_exit
;
}
//
//
check
//
code = tsdbScanAndConvertSubmitMsg(pVnode->pTsdb, pSubmitReq);
//
if (code) {
//
goto _exit;
//
}
for
(
int32_t
i
=
0
;
i
<
TARRAY_SIZE
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pSubmitReq
->
aSubmitTbData
,
i
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录