Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f807a85
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
2f807a85
编写于
11月 09, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into enh/TD-20288
上级
9f7e0672
aeb16925
变更
34
展开全部
隐藏空白更改
内联
并排
Showing
34 changed file
with
1103 addition
and
678 deletion
+1103
-678
cmake/taostools_CMakeLists.txt.in
cmake/taostools_CMakeLists.txt.in
+1
-1
include/common/tdataformat.h
include/common/tdataformat.h
+1
-1
include/common/tmsg.h
include/common/tmsg.h
+1
-1
include/common/tmsgdef.h
include/common/tmsgdef.h
+2
-1
include/libs/stream/streamState.h
include/libs/stream/streamState.h
+7
-5
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-0
source/client/src/clientMain.c
source/client/src/clientMain.c
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+25
-0
source/dnode/mnode/impl/inc/mndConsumer.h
source/dnode/mnode/impl/inc/mndConsumer.h
+1
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+65
-4
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+19
-3
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+127
-34
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+19
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+25
-52
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+3
-0
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+1
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+24
-9
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+158
-79
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+2
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+32
-4
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+2
-0
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+161
-80
source/libs/sync/inc/syncRespMgr.h
source/libs/sync/inc/syncRespMgr.h
+4
-5
source/libs/sync/inc/syncTools.h
source/libs/sync/inc/syncTools.h
+0
-3
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+2
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+86
-148
source/libs/sync/src/syncRespMgr.c
source/libs/sync/src/syncRespMgr.c
+59
-55
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+12
-4
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+2
-2
source/util/src/tlog.c
source/util/src/tlog.c
+4
-4
tests/script/tsim/stream/basic1.sim
tests/script/tsim/stream/basic1.sim
+253
-175
tests/script/tsim/stream/session0.sim
tests/script/tsim/stream/session0.sim
+1
-1
未找到文件。
cmake/taostools_CMakeLists.txt.in
浏览文件 @
2f807a85
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# taos-tools
# taos-tools
ExternalProject_Add(taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG
0fb640b
GIT_TAG
a921bd4
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
#BUILD_IN_SOURCE TRUE
...
...
include/common/tdataformat.h
浏览文件 @
2f807a85
...
@@ -130,7 +130,7 @@ void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn)
...
@@ -130,7 +130,7 @@ void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn)
void
tColDataClear
(
SColData
*
pColData
);
void
tColDataClear
(
SColData
*
pColData
);
int32_t
tColDataAppendValue
(
SColData
*
pColData
,
SColVal
*
pColVal
);
int32_t
tColDataAppendValue
(
SColData
*
pColData
,
SColVal
*
pColVal
);
void
tColDataGetValue
(
SColData
*
pColData
,
int32_t
iVal
,
SColVal
*
pColVal
);
void
tColDataGetValue
(
SColData
*
pColData
,
int32_t
iVal
,
SColVal
*
pColVal
);
uint8_t
tColDataGetBitValue
(
SColData
*
pColData
,
int32_t
iVal
);
uint8_t
tColDataGetBitValue
(
const
SColData
*
pColData
,
int32_t
iVal
);
int32_t
tColDataCopy
(
SColData
*
pColDataSrc
,
SColData
*
pColDataDest
);
int32_t
tColDataCopy
(
SColData
*
pColDataSrc
,
SColData
*
pColDataDest
);
extern
void
(
*
tColDataCalcSMA
[])(
SColData
*
pColData
,
int64_t
*
sum
,
int64_t
*
max
,
int64_t
*
min
,
int16_t
*
numOfNull
);
extern
void
(
*
tColDataCalcSMA
[])(
SColData
*
pColData
,
int64_t
*
sum
,
int64_t
*
max
,
int64_t
*
min
,
int16_t
*
numOfNull
);
...
...
include/common/tmsg.h
浏览文件 @
2f807a85
...
@@ -1806,7 +1806,7 @@ int32_t tDeserializeSCMCreateTopicRsp(void* buf, int32_t bufLen, SCMCreateTopicR
...
@@ -1806,7 +1806,7 @@ int32_t tDeserializeSCMCreateTopicRsp(void* buf, int32_t bufLen, SCMCreateTopicR
typedef
struct
{
typedef
struct
{
int64_t
consumerId
;
int64_t
consumerId
;
}
SMqConsumerLostMsg
,
SMqConsumerRecoverMsg
;
}
SMqConsumerLostMsg
,
SMqConsumerRecoverMsg
,
SMqConsumerClearMsg
;
typedef
struct
{
typedef
struct
{
int64_t
consumerId
;
int64_t
consumerId
;
...
...
include/common/tmsgdef.h
浏览文件 @
2f807a85
...
@@ -149,7 +149,7 @@ enum {
...
@@ -149,7 +149,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_DO_REBALANCE
,
"do-rebalance"
,
SMqDoRebalanceMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_DO_REBALANCE
,
"do-rebalance"
,
SMqDoRebalanceMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_DROP_CGROUP
,
"drop-cgroup"
,
SMqDropCGroupReq
,
SMqDropCGroupRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_DROP_CGROUP
,
"drop-cgroup"
,
SMqDropCGroupReq
,
SMqDropCGroupRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_UNUSED2
,
"unused2"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_UNUSED2
,
"unused2"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_TIMER
,
"mq-tmr"
,
SMTimerReq
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_TIMER
,
"
t
mq-tmr"
,
SMTimerReq
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TELEM_TIMER
,
"telem-tmr"
,
SMTimerReq
,
SMTimerReq
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TELEM_TIMER
,
"telem-tmr"
,
SMTimerReq
,
SMTimerReq
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TRANS_TIMER
,
"trans-tmr"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TRANS_TIMER
,
"trans-tmr"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TTL_TIMER
,
"ttl-tmr"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TTL_TIMER
,
"ttl-tmr"
,
NULL
,
NULL
)
...
@@ -171,6 +171,7 @@ enum {
...
@@ -171,6 +171,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_SHOW_VARIABLES
,
"show-variables"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SHOW_VARIABLES
,
"show-variables"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SERVER_VERSION
,
"server-version"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SERVER_VERSION
,
"server-version"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_UPTIME_TIMER
,
"uptime-timer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_UPTIME_TIMER
,
"uptime-timer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_LOST_CONSUMER_CLEAR
,
"lost-consumer-clear"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MAX_MSG
,
"mnd-max"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MAX_MSG
,
"mnd-max"
,
NULL
,
NULL
)
TD_NEW_MSG_SEG
(
TDMT_VND_MSG
)
TD_NEW_MSG_SEG
(
TDMT_VND_MSG
)
...
...
include/libs/stream/streamState.h
浏览文件 @
2f807a85
...
@@ -60,19 +60,19 @@ int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
...
@@ -60,19 +60,19 @@ int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
int32_t
streamStateClear
(
SStreamState
*
pState
);
int32_t
streamStateClear
(
SStreamState
*
pState
);
void
streamStateSetNumber
(
SStreamState
*
pState
,
int32_t
number
);
void
streamStateSetNumber
(
SStreamState
*
pState
,
int32_t
number
);
int32_t
streamStateSessionAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateSessionAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
TSKEY
gap
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateSessionPut
(
SStreamState
*
pState
,
const
SSessionKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateSessionPut
(
SStreamState
*
pState
,
const
SSessionKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateSessionGet
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateSessionGet
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateSessionDel
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
int32_t
streamStateSessionDel
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
int32_t
streamStateSessionClear
(
SStreamState
*
pState
);
int32_t
streamStateSessionClear
(
SStreamState
*
pState
);
int32_t
streamStateSessionGetKVByCur
(
SStreamStateCur
*
pCur
,
SSessionKey
*
pKey
,
const
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateSessionGetKVByCur
(
SStreamStateCur
*
pCur
,
SSessionKey
*
pKey
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateStateAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
char
*
pKeyData
,
int32_t
keyDataLen
,
int32_t
streamStateStateAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
char
*
pKeyData
,
int32_t
keyDataLen
,
state_key_cmpr_fn
fn
,
void
**
pVal
,
int32_t
*
pVLen
);
state_key_cmpr_fn
fn
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateSessionGetKey
(
SStreamState
*
pState
,
const
SSessionKey
*
key
,
SSessionKey
*
curKey
);
int32_t
streamStateSessionGetKey
ByRange
(
SStreamState
*
pState
,
const
SSessionKey
*
range
,
SSessionKey
*
curKey
);
SStreamStateCur
*
streamStateSessionSeekKeyNext
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
SStreamStateCur
*
streamStateSessionSeekKeyNext
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
SStreamStateCur
*
streamStateSessionSeekKeyCurrentPrev
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
SStreamStateCur
*
streamStateSessionSeekKeyCurrentPrev
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
SStreamStateCur
*
streamStateSession
GetCur
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
SStreamStateCur
*
streamStateSession
SeekKeyCurrentNext
(
SStreamState
*
pState
,
const
SSessionKey
*
key
);
int32_t
streamStateFillPut
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateFillPut
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateFillGet
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateFillGet
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
...
@@ -99,7 +99,9 @@ int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur);
...
@@ -99,7 +99,9 @@ int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur);
int32_t
streamStateCurNext
(
SStreamState
*
pState
,
SStreamStateCur
*
pCur
);
int32_t
streamStateCurNext
(
SStreamState
*
pState
,
SStreamStateCur
*
pCur
);
int32_t
streamStateCurPrev
(
SStreamState
*
pState
,
SStreamStateCur
*
pCur
);
int32_t
streamStateCurPrev
(
SStreamState
*
pState
,
SStreamStateCur
*
pCur
);
// char* streamStateSessionDump(SStreamState* pState);
#if 0
char* streamStateSessionDump(SStreamState* pState);
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/libs/sync/sync.h
浏览文件 @
2f807a85
...
@@ -139,6 +139,7 @@ typedef struct SSyncFSM {
...
@@ -139,6 +139,7 @@ typedef struct SSyncFSM {
void
(
*
FpReConfigCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SReConfigCbMeta
*
pMeta
);
void
(
*
FpReConfigCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SReConfigCbMeta
*
pMeta
);
void
(
*
FpLeaderTransferCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpLeaderTransferCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
bool
(
*
FpApplyQueueEmptyCb
)(
const
struct
SSyncFSM
*
pFsm
);
bool
(
*
FpApplyQueueEmptyCb
)(
const
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpApplyQueueItems
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeLeaderCb
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeLeaderCb
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeFollowerCb
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeFollowerCb
)(
const
struct
SSyncFSM
*
pFsm
);
...
...
source/client/src/clientMain.c
浏览文件 @
2f807a85
...
@@ -990,7 +990,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
...
@@ -990,7 +990,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
// all data has returned to App already, no need to try again
// all data has returned to App already, no need to try again
if
(
pResultInfo
->
completed
)
{
if
(
pResultInfo
->
completed
)
{
// it is a local executed query, no need to do async fetch
// it is a local executed query, no need to do async fetch
if
(
QUERY_EXEC_MODE_
LOCAL
=
=
pRequest
->
body
.
execMode
)
{
if
(
QUERY_EXEC_MODE_
SCHEDULE
!
=
pRequest
->
body
.
execMode
)
{
if
(
pResultInfo
->
localResultFetched
)
{
if
(
pResultInfo
->
localResultFetched
)
{
pResultInfo
->
numOfRows
=
0
;
pResultInfo
->
numOfRows
=
0
;
pResultInfo
->
current
=
0
;
pResultInfo
->
current
=
0
;
...
...
source/common/src/tdataformat.c
浏览文件 @
2f807a85
...
@@ -1557,7 +1557,7 @@ void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
...
@@ -1557,7 +1557,7 @@ void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
tColDataGetValueImpl
[
pColData
->
flag
](
pColData
,
iVal
,
pColVal
);
tColDataGetValueImpl
[
pColData
->
flag
](
pColData
,
iVal
,
pColVal
);
}
}
uint8_t
tColDataGetBitValue
(
SColData
*
pColData
,
int32_t
iVal
)
{
uint8_t
tColDataGetBitValue
(
const
SColData
*
pColData
,
int32_t
iVal
)
{
uint8_t
v
;
uint8_t
v
;
switch
(
pColData
->
flag
)
{
switch
(
pColData
->
flag
)
{
case
HAS_NONE
:
case
HAS_NONE
:
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
2f807a85
...
@@ -191,6 +191,16 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -191,6 +191,16 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
dInfo
(
"vgId:%d, replica:%d id:%d fqdn:%s port:%u"
,
req
.
vgId
,
i
,
req
.
replicas
[
i
].
id
,
req
.
replicas
[
i
].
fqdn
,
dInfo
(
"vgId:%d, replica:%d id:%d fqdn:%s port:%u"
,
req
.
vgId
,
i
,
req
.
replicas
[
i
].
id
,
req
.
replicas
[
i
].
fqdn
,
req
.
replicas
[
i
].
port
);
req
.
replicas
[
i
].
port
);
}
}
SReplica
*
pReplica
=
&
req
.
replicas
[
req
.
selfIndex
];
if
(
pReplica
->
id
!=
pMgmt
->
pData
->
dnodeId
||
pReplica
->
port
!=
tsServerPort
||
strcmp
(
pReplica
->
fqdn
,
tsLocalFqdn
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
dError
(
"vgId:%d, dnodeId:%d ep:%s:%u not matched with local dnode"
,
req
.
vgId
,
pReplica
->
id
,
pReplica
->
fqdn
,
pReplica
->
port
);
return
-
1
;
}
vmGenerateVnodeCfg
(
&
req
,
&
vnodeCfg
);
vmGenerateVnodeCfg
(
&
req
,
&
vnodeCfg
);
if
(
vmTsmaAdjustDays
(
&
vnodeCfg
,
&
req
)
<
0
)
{
if
(
vmTsmaAdjustDays
(
&
vnodeCfg
,
&
req
)
<
0
)
{
...
@@ -285,6 +295,15 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -285,6 +295,15 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
alterReq
.
selfIndex
];
if
(
pReplica
->
id
!=
pMgmt
->
pData
->
dnodeId
||
pReplica
->
port
!=
tsServerPort
||
strcmp
(
pReplica
->
fqdn
,
tsLocalFqdn
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
dError
(
"vgId:%d, dnodeId:%d ep:%s:%u not matched with local dnode"
,
alterReq
.
vgId
,
pReplica
->
id
,
pReplica
->
fqdn
,
pReplica
->
port
);
return
-
1
;
}
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
)
{
dError
(
"vgId:%d, failed to alter replica since %s"
,
vgId
,
terrstr
());
dError
(
"vgId:%d, failed to alter replica since %s"
,
vgId
,
terrstr
());
...
@@ -341,6 +360,12 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -341,6 +360,12 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t
vgId
=
dropReq
.
vgId
;
int32_t
vgId
=
dropReq
.
vgId
;
dDebug
(
"vgId:%d, start to drop vnode"
,
vgId
);
dDebug
(
"vgId:%d, start to drop vnode"
,
vgId
);
if
(
dropReq
.
dnodeId
!=
pMgmt
->
pData
->
dnodeId
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
dError
(
"vgId:%d, dnodeId:%d not matched with local dnode"
,
dropReq
.
vgId
,
dropReq
.
dnodeId
);
return
-
1
;
}
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
)
{
dDebug
(
"vgId:%d, failed to drop since %s"
,
vgId
,
terrstr
());
dDebug
(
"vgId:%d, failed to drop since %s"
,
vgId
,
terrstr
());
...
...
source/dnode/mnode/impl/inc/mndConsumer.h
浏览文件 @
2f807a85
...
@@ -44,6 +44,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer);
...
@@ -44,6 +44,7 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer);
SSdbRow
*
mndConsumerActionDecode
(
SSdbRaw
*
pRaw
);
SSdbRow
*
mndConsumerActionDecode
(
SSdbRaw
*
pRaw
);
int32_t
mndSetConsumerCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqConsumerObj
*
pConsumer
);
int32_t
mndSetConsumerCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqConsumerObj
*
pConsumer
);
int32_t
mndSetConsumerDropLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqConsumerObj
*
pConsumer
);
bool
mndRebTryStart
();
bool
mndRebTryStart
();
void
mndRebEnd
();
void
mndRebEnd
();
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
2f807a85
...
@@ -32,7 +32,8 @@
...
@@ -32,7 +32,8 @@
#define MND_CONSUMER_VER_NUMBER 1
#define MND_CONSUMER_VER_NUMBER 1
#define MND_CONSUMER_RESERVE_SIZE 64
#define MND_CONSUMER_RESERVE_SIZE 64
#define MND_CONSUMER_LOST_HB_CNT 3
#define MND_CONSUMER_LOST_HB_CNT 3
#define MND_CONSUMER_LOST_CLEAR_THRESHOLD 43200
static
int8_t
mqRebInExecCnt
=
0
;
static
int8_t
mqRebInExecCnt
=
0
;
...
@@ -50,6 +51,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg);
...
@@ -50,6 +51,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg);
static
int32_t
mndProcessMqHbReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessMqHbReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessMqTimerMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessMqTimerMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerLostMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerLostMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerClearMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerRecoverMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerRecoverMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndInitConsumer
(
SMnode
*
pMnode
)
{
int32_t
mndInitConsumer
(
SMnode
*
pMnode
)
{
...
@@ -69,6 +71,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
...
@@ -69,6 +71,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_TIMER
,
mndProcessMqTimerMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_TIMER
,
mndProcessMqTimerMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_CONSUMER_LOST
,
mndProcessConsumerLostMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_CONSUMER_LOST
,
mndProcessConsumerLostMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_CONSUMER_RECOVER
,
mndProcessConsumerRecoverMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_CONSUMER_RECOVER
,
mndProcessConsumerRecoverMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TMQ_LOST_CONSUMER_CLEAR
,
mndProcessConsumerClearMsg
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONSUMERS
,
mndRetrieveConsumer
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONSUMERS
,
mndRetrieveConsumer
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONSUMERS
,
mndCancelGetNextConsumer
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONSUMERS
,
mndCancelGetNextConsumer
);
...
@@ -162,6 +165,43 @@ FAIL:
...
@@ -162,6 +165,43 @@ FAIL:
return
-
1
;
return
-
1
;
}
}
static
int32_t
mndProcessConsumerClearMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqConsumerClearMsg
*
pClearMsg
=
pMsg
->
pCont
;
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
pClearMsg
->
consumerId
);
if
(
pConsumer
==
NULL
)
{
return
0
;
}
mInfo
(
"receive consumer clear msg, consumer id %"
PRId64
", status %s"
,
pClearMsg
->
consumerId
,
mndConsumerStatusName
(
pConsumer
->
status
));
if
(
pConsumer
->
status
!=
MQ_CONSUMER_STATUS__LOST_REBD
)
{
mndReleaseConsumer
(
pMnode
,
pConsumer
);
return
-
1
;
}
SMqConsumerObj
*
pConsumerNew
=
tNewSMqConsumerObj
(
pConsumer
->
consumerId
,
pConsumer
->
cgroup
);
pConsumerNew
->
updateType
=
CONSUMER_UPDATE__LOST
;
mndReleaseConsumer
(
pMnode
,
pConsumer
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_NOTHING
,
pMsg
,
"clear-csm"
);
if
(
pTrans
==
NULL
)
goto
FAIL
;
if
(
mndSetConsumerDropLogs
(
pMnode
,
pTrans
,
pConsumerNew
)
!=
0
)
goto
FAIL
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
FAIL
;
tDeleteSMqConsumerObj
(
pConsumerNew
);
taosMemoryFree
(
pConsumerNew
);
mndTransDrop
(
pTrans
);
return
0
;
FAIL:
tDeleteSMqConsumerObj
(
pConsumerNew
);
taosMemoryFree
(
pConsumerNew
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
static
SMqRebInfo
*
mndGetOrCreateRebSub
(
SHashObj
*
pHash
,
const
char
*
key
)
{
static
SMqRebInfo
*
mndGetOrCreateRebSub
(
SHashObj
*
pHash
,
const
char
*
key
)
{
SMqRebInfo
*
pRebInfo
=
taosHashGet
(
pHash
,
key
,
strlen
(
key
)
+
1
);
SMqRebInfo
*
pRebInfo
=
taosHashGet
(
pHash
,
key
,
strlen
(
key
)
+
1
);
if
(
pRebInfo
==
NULL
)
{
if
(
pRebInfo
==
NULL
)
{
...
@@ -206,15 +246,28 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
...
@@ -206,15 +246,28 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
SMqConsumerLostMsg
*
pLostMsg
=
rpcMallocCont
(
sizeof
(
SMqConsumerLostMsg
));
SMqConsumerLostMsg
*
pLostMsg
=
rpcMallocCont
(
sizeof
(
SMqConsumerLostMsg
));
pLostMsg
->
consumerId
=
pConsumer
->
consumerId
;
pLostMsg
->
consumerId
=
pConsumer
->
consumerId
;
SRpcMsg
pR
pcMsg
=
{
SRpcMsg
r
pcMsg
=
{
.
msgType
=
TDMT_MND_TMQ_CONSUMER_LOST
,
.
msgType
=
TDMT_MND_TMQ_CONSUMER_LOST
,
.
pCont
=
pLostMsg
,
.
pCont
=
pLostMsg
,
.
contLen
=
sizeof
(
SMqConsumerLostMsg
),
.
contLen
=
sizeof
(
SMqConsumerLostMsg
),
};
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
pR
pcMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
r
pcMsg
);
}
}
if
(
status
==
MQ_CONSUMER_STATUS__LOST_REBD
||
status
==
MQ_CONSUMER_STATUS__READY
)
{
if
(
status
==
MQ_CONSUMER_STATUS__READY
)
{
// do nothing
// do nothing
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST_REBD
)
{
if
(
hbStatus
>
MND_CONSUMER_LOST_CLEAR_THRESHOLD
)
{
SMqConsumerClearMsg
*
pClearMsg
=
rpcMallocCont
(
sizeof
(
SMqConsumerClearMsg
));
pClearMsg
->
consumerId
=
pConsumer
->
consumerId
;
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_TMQ_LOST_CONSUMER_CLEAR
,
.
pCont
=
pClearMsg
,
.
contLen
=
sizeof
(
SMqConsumerClearMsg
),
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
}
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
)
{
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
)
{
taosRLockLatch
(
&
pConsumer
->
lock
);
taosRLockLatch
(
&
pConsumer
->
lock
);
int32_t
topicNum
=
taosArrayGetSize
(
pConsumer
->
currentTopics
);
int32_t
topicNum
=
taosArrayGetSize
(
pConsumer
->
currentTopics
);
...
@@ -444,6 +497,14 @@ FAIL:
...
@@ -444,6 +497,14 @@ FAIL:
return
-
1
;
return
-
1
;
}
}
int32_t
mndSetConsumerDropLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqConsumerObj
*
pConsumer
)
{
SSdbRaw
*
pCommitRaw
=
mndConsumerActionEncode
(
pConsumer
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
return
0
;
}
int32_t
mndSetConsumerCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqConsumerObj
*
pConsumer
)
{
int32_t
mndSetConsumerCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqConsumerObj
*
pConsumer
)
{
SSdbRaw
*
pCommitRaw
=
mndConsumerActionEncode
(
pConsumer
);
SSdbRaw
*
pCommitRaw
=
mndConsumerActionEncode
(
pConsumer
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
pCommitRaw
==
NULL
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
2f807a85
...
@@ -205,8 +205,23 @@ static void mndBecomeLeader(const SSyncFSM *pFsm) {
...
@@ -205,8 +205,23 @@ static void mndBecomeLeader(const SSyncFSM *pFsm) {
static
bool
mndApplyQueueEmpty
(
const
SSyncFSM
*
pFsm
)
{
static
bool
mndApplyQueueEmpty
(
const
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pMnode
->
msgCb
,
1
,
APPLY_QUEUE
);
if
(
pMnode
!=
NULL
&&
pMnode
->
msgCb
.
qsizeFp
!=
NULL
)
{
return
(
itemSize
==
0
);
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pMnode
->
msgCb
,
1
,
APPLY_QUEUE
);
return
(
itemSize
==
0
);
}
else
{
return
true
;
}
}
static
int32_t
mndApplyQueueItems
(
const
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
if
(
pMnode
!=
NULL
&&
pMnode
->
msgCb
.
qsizeFp
!=
NULL
)
{
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pMnode
->
msgCb
,
1
,
APPLY_QUEUE
);
return
itemSize
;
}
else
{
return
-
1
;
}
}
}
SSyncFSM
*
mndSyncMakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
mndSyncMakeFsm
(
SMnode
*
pMnode
)
{
...
@@ -218,6 +233,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
...
@@ -218,6 +233,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpLeaderTransferCb
=
NULL
;
pFsm
->
FpLeaderTransferCb
=
NULL
;
pFsm
->
FpApplyQueueEmptyCb
=
mndApplyQueueEmpty
;
pFsm
->
FpApplyQueueEmptyCb
=
mndApplyQueueEmpty
;
pFsm
->
FpApplyQueueItems
=
mndApplyQueueItems
;
pFsm
->
FpReConfigCb
=
NULL
;
pFsm
->
FpReConfigCb
=
NULL
;
pFsm
->
FpBecomeLeaderCb
=
mndBecomeLeader
;
pFsm
->
FpBecomeLeaderCb
=
mndBecomeLeader
;
pFsm
->
FpBecomeFollowerCb
=
mndBecomeFollower
;
pFsm
->
FpBecomeFollowerCb
=
mndBecomeFollower
;
...
@@ -291,7 +307,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -291,7 +307,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
SRpcMsg
req
=
{.
msgType
=
TDMT_MND_APPLY_MSG
,
.
contLen
=
sdbGetRawTotalSize
(
pRaw
)};
SRpcMsg
req
=
{.
msgType
=
TDMT_MND_APPLY_MSG
,
.
contLen
=
sdbGetRawTotalSize
(
pRaw
)};
if
(
req
.
contLen
<=
0
)
return
-
1
;
if
(
req
.
contLen
<=
0
)
return
-
1
;
req
.
pCont
=
rpcMallocCont
(
req
.
contLen
);
req
.
pCont
=
rpcMallocCont
(
req
.
contLen
);
if
(
req
.
pCont
==
NULL
)
return
-
1
;
if
(
req
.
pCont
==
NULL
)
return
-
1
;
memcpy
(
req
.
pCont
,
pRaw
,
req
.
contLen
);
memcpy
(
req
.
pCont
,
pRaw
,
req
.
contLen
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
2f807a85
...
@@ -893,7 +893,7 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
...
@@ -893,7 +893,7 @@ static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int or
}
}
}
}
int32_t
getEndPosInDataBlock
(
STsdbReader
*
pReader
,
SBlockData
*
pBlockData
,
SDataBlk
*
pBlock
,
int32_t
pos
)
{
static
int32_t
getEndPosInDataBlock
(
STsdbReader
*
pReader
,
SBlockData
*
pBlockData
,
SDataBlk
*
pBlock
,
int32_t
pos
)
{
// NOTE: reverse the order to find the end position in data block
// NOTE: reverse the order to find the end position in data block
int32_t
endPos
=
-
1
;
int32_t
endPos
=
-
1
;
bool
asc
=
ASCENDING_TRAVERSE
(
pReader
->
order
);
bool
asc
=
ASCENDING_TRAVERSE
(
pReader
->
order
);
...
@@ -910,6 +910,117 @@ int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SData
...
@@ -910,6 +910,117 @@ int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SData
return
endPos
;
return
endPos
;
}
}
static
void
copyPrimaryTsCol
(
const
SBlockData
*
pBlockData
,
SFileBlockDumpInfo
*
pDumpInfo
,
SColumnInfoData
*
pColData
,
int32_t
dumpedRows
,
bool
asc
)
{
if
(
asc
)
{
memcpy
(
pColData
->
pData
,
&
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
],
dumpedRows
*
sizeof
(
int64_t
));
}
else
{
int32_t
startIndex
=
pDumpInfo
->
rowIndex
-
dumpedRows
+
1
;
memcpy
(
pColData
->
pData
,
&
pBlockData
->
aTSKEY
[
startIndex
],
dumpedRows
*
sizeof
(
int64_t
));
// todo: opt perf by extract the loop
// reverse the array list
int32_t
mid
=
dumpedRows
>>
1u
;
int64_t
*
pts
=
(
int64_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
}
}
// a faster version of copy procedure.
static
void
copyNumericCols
(
const
SColData
*
pData
,
SFileBlockDumpInfo
*
pDumpInfo
,
SColumnInfoData
*
pColData
,
int32_t
dumpedRows
,
bool
asc
)
{
uint8_t
*
p
=
NULL
;
if
(
asc
)
{
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
pDumpInfo
->
rowIndex
;
}
else
{
int32_t
startIndex
=
pDumpInfo
->
rowIndex
-
dumpedRows
+
1
;
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
startIndex
;
}
int32_t
step
=
asc
?
1
:-
1
;
// make sure it is aligned to 8bit
ASSERT
((((
uint64_t
)
pColData
->
pData
)
&
(
0x8
-
1
))
==
0
);
// 1. copy data in a batch model
memcpy
(
pColData
->
pData
,
p
,
dumpedRows
*
tDataTypes
[
pData
->
type
].
bytes
);
// 2. reverse the array list in case of descending order scan data block
if
(
!
asc
)
{
switch
(
pColData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int64_t
*
pts
=
(
int64_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int8_t
*
pts
=
(
int8_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int16_t
*
pts
=
(
int16_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
{
int32_t
mid
=
dumpedRows
>>
1u
;
int32_t
*
pts
=
(
int32_t
*
)
pColData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
mid
;
++
j
)
{
int64_t
t
=
pts
[
j
];
pts
[
j
]
=
pts
[
dumpedRows
-
j
-
1
];
pts
[
dumpedRows
-
j
-
1
]
=
t
;
}
break
;
}
}
}
// 3. if the null value exists, check items one-by-one
if
(
pData
->
flag
!=
HAS_VALUE
)
{
int32_t
rowIndex
=
0
;
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
dumpedRows
;
j
+=
step
,
rowIndex
++
)
{
uint8_t
v
=
tColDataGetBitValue
(
pData
,
j
);
if
(
v
==
0
||
v
==
1
)
{
colDataSetNull_f
(
pColData
->
nullbitmap
,
rowIndex
);
pColData
->
hasNull
=
true
;
}
}
}
}
static
int32_t
copyBlockDataToSDataBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pBlockScanInfo
)
{
static
int32_t
copyBlockDataToSDataBlock
(
STsdbReader
*
pReader
,
STableBlockScanInfo
*
pBlockScanInfo
)
{
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
...
@@ -949,24 +1060,17 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -949,24 +1060,17 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
}
}
endIndex
+=
step
;
endIndex
+=
step
;
int32_t
remain
=
asc
?
(
endIndex
-
pDumpInfo
->
rowIndex
)
:
(
pDumpInfo
->
rowIndex
-
endIndex
);
int32_t
dumpedRows
=
asc
?
(
endIndex
-
pDumpInfo
->
rowIndex
)
:
(
pDumpInfo
->
rowIndex
-
endIndex
);
if
(
remain
>
pReader
->
capacity
)
{
// output buffer check
if
(
dumpedRows
>
pReader
->
capacity
)
{
// output buffer check
remain
=
pReader
->
capacity
;
dumpedRows
=
pReader
->
capacity
;
}
}
int32_t
i
=
0
;
int32_t
rowIndex
=
0
;
int32_t
rowIndex
=
0
;
int32_t
i
=
0
;
SColumnInfoData
*
pColData
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pColData
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
if
(
pColData
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
pColData
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
asc
)
{
copyPrimaryTsCol
(
pBlockData
,
pDumpInfo
,
pColData
,
dumpedRows
,
asc
);
memcpy
(
pColData
->
pData
,
&
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
],
remain
*
sizeof
(
int64_t
));
}
else
{
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
remain
;
j
+=
step
)
{
colDataAppendInt64
(
pColData
,
rowIndex
++
,
&
pBlockData
->
aTSKEY
[
j
]);
}
}
i
+=
1
;
i
+=
1
;
}
}
...
@@ -981,23 +1085,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -981,23 +1085,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
colIndex
+=
1
;
colIndex
+=
1
;
}
else
if
(
pData
->
cid
==
pColData
->
info
.
colId
)
{
}
else
if
(
pData
->
cid
==
pColData
->
info
.
colId
)
{
if
(
pData
->
flag
==
HAS_NONE
||
pData
->
flag
==
HAS_NULL
||
pData
->
flag
==
(
HAS_NULL
|
HAS_NONE
))
{
if
(
pData
->
flag
==
HAS_NONE
||
pData
->
flag
==
HAS_NULL
||
pData
->
flag
==
(
HAS_NULL
|
HAS_NONE
))
{
colDataAppendNNULL
(
pColData
,
0
,
remain
);
colDataAppendNNULL
(
pColData
,
0
,
dumpedRows
);
}
else
{
}
else
{
if
(
IS_NUMERIC_TYPE
(
pColData
->
info
.
type
)
&&
asc
)
{
if
(
IS_MATHABLE_TYPE
(
pColData
->
info
.
type
))
{
uint8_t
*
p
=
pData
->
pData
+
tDataTypes
[
pData
->
type
].
bytes
*
pDumpInfo
->
rowIndex
;
copyNumericCols
(
pData
,
pDumpInfo
,
pColData
,
dumpedRows
,
asc
);
memcpy
(
pColData
->
pData
,
p
,
remain
*
tDataTypes
[
pData
->
type
].
bytes
);
}
else
{
// varchar/nchar type
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
dumpedRows
;
j
+=
step
)
{
// null value exists, check one-by-one
if
(
pData
->
flag
!=
HAS_VALUE
)
{
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
remain
;
j
+=
step
,
rowIndex
++
)
{
uint8_t
v
=
tColDataGetBitValue
(
pData
,
j
);
if
(
v
==
0
||
v
==
1
)
{
colDataSetNull_f
(
pColData
->
nullbitmap
,
rowIndex
);
}
}
}
}
else
{
for
(
int32_t
j
=
pDumpInfo
->
rowIndex
;
rowIndex
<
remain
;
j
+=
step
)
{
tColDataGetValue
(
pData
,
j
,
&
cv
);
tColDataGetValue
(
pData
,
j
,
&
cv
);
doCopyColVal
(
pColData
,
rowIndex
++
,
i
,
&
cv
,
pSupInfo
);
doCopyColVal
(
pColData
,
rowIndex
++
,
i
,
&
cv
,
pSupInfo
);
}
}
...
@@ -1007,7 +1100,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -1007,7 +1100,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
colIndex
+=
1
;
colIndex
+=
1
;
i
+=
1
;
i
+=
1
;
}
else
{
// the specified column does not exist in file block, fill with null data
}
else
{
// the specified column does not exist in file block, fill with null data
colDataAppendNNULL
(
pColData
,
0
,
remain
);
colDataAppendNNULL
(
pColData
,
0
,
dumpedRows
);
i
+=
1
;
i
+=
1
;
}
}
}
}
...
@@ -1015,12 +1108,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -1015,12 +1108,12 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
// fill the mis-matched columns with null value
// fill the mis-matched columns with null value
while
(
i
<
numOfOutputCols
)
{
while
(
i
<
numOfOutputCols
)
{
pColData
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
pColData
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
colDataAppendNNULL
(
pColData
,
0
,
remain
);
colDataAppendNNULL
(
pColData
,
0
,
dumpedRows
);
i
+=
1
;
i
+=
1
;
}
}
pResBlock
->
info
.
rows
=
remain
;
pResBlock
->
info
.
rows
=
dumpedRows
;
pDumpInfo
->
rowIndex
+=
step
*
remain
;
pDumpInfo
->
rowIndex
+=
step
*
dumpedRows
;
// check if current block are all handled
// check if current block are all handled
if
(
pDumpInfo
->
rowIndex
>=
0
&&
pDumpInfo
->
rowIndex
<
pBlock
->
nRow
)
{
if
(
pDumpInfo
->
rowIndex
>=
0
&&
pDumpInfo
->
rowIndex
<
pBlock
->
nRow
)
{
...
@@ -1039,7 +1132,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -1039,7 +1132,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
int32_t
unDumpedRows
=
asc
?
pBlock
->
nRow
-
pDumpInfo
->
rowIndex
:
pDumpInfo
->
rowIndex
+
1
;
int32_t
unDumpedRows
=
asc
?
pBlock
->
nRow
-
pDumpInfo
->
rowIndex
:
pDumpInfo
->
rowIndex
+
1
;
tsdbDebug
(
"%p copy file block to sdatablock, global index:%d, table index:%d, brange:%"
PRId64
"-%"
PRId64
tsdbDebug
(
"%p copy file block to sdatablock, global index:%d, table index:%d, brange:%"
PRId64
"-%"
PRId64
", rows:%d, remain:%d, minVer:%"
PRId64
", maxVer:%"
PRId64
", elapsed time:%.2f ms, %s"
,
", rows:%d, remain:%d, minVer:%"
PRId64
", maxVer:%"
PRId64
", elapsed time:%.2f ms, %s"
,
pReader
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlock
->
minKey
.
ts
,
pBlock
->
maxKey
.
ts
,
remain
,
pReader
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlock
->
minKey
.
ts
,
pBlock
->
maxKey
.
ts
,
dumpedRows
,
unDumpedRows
,
pBlock
->
minVer
,
pBlock
->
maxVer
,
elapsedTime
,
pReader
->
idStr
);
unDumpedRows
,
pBlock
->
minVer
,
pBlock
->
maxVer
,
elapsedTime
,
pReader
->
idStr
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
2f807a85
...
@@ -438,8 +438,24 @@ static void vnodeBecomeLeader(const SSyncFSM *pFsm) {
...
@@ -438,8 +438,24 @@ static void vnodeBecomeLeader(const SSyncFSM *pFsm) {
static
bool
vnodeApplyQueueEmpty
(
const
SSyncFSM
*
pFsm
)
{
static
bool
vnodeApplyQueueEmpty
(
const
SSyncFSM
*
pFsm
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
SVnode
*
pVnode
=
pFsm
->
data
;
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pVnode
->
msgCb
,
pVnode
->
config
.
vgId
,
APPLY_QUEUE
);
return
(
itemSize
==
0
);
if
(
pVnode
!=
NULL
&&
pVnode
->
msgCb
.
qsizeFp
!=
NULL
)
{
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pVnode
->
msgCb
,
pVnode
->
config
.
vgId
,
APPLY_QUEUE
);
return
(
itemSize
==
0
);
}
else
{
return
true
;
}
}
static
int32_t
vnodeApplyQueueItems
(
const
SSyncFSM
*
pFsm
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
if
(
pVnode
!=
NULL
&&
pVnode
->
msgCb
.
qsizeFp
!=
NULL
)
{
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pVnode
->
msgCb
,
pVnode
->
config
.
vgId
,
APPLY_QUEUE
);
return
itemSize
;
}
else
{
return
-
1
;
}
}
}
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
...
@@ -452,6 +468,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
...
@@ -452,6 +468,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm
->
FpRestoreFinishCb
=
vnodeRestoreFinish
;
pFsm
->
FpRestoreFinishCb
=
vnodeRestoreFinish
;
pFsm
->
FpLeaderTransferCb
=
NULL
;
pFsm
->
FpLeaderTransferCb
=
NULL
;
pFsm
->
FpApplyQueueEmptyCb
=
vnodeApplyQueueEmpty
;
pFsm
->
FpApplyQueueEmptyCb
=
vnodeApplyQueueEmpty
;
pFsm
->
FpApplyQueueItems
=
vnodeApplyQueueItems
;
pFsm
->
FpBecomeLeaderCb
=
vnodeBecomeLeader
;
pFsm
->
FpBecomeLeaderCb
=
vnodeBecomeLeader
;
pFsm
->
FpBecomeFollowerCb
=
vnodeBecomeFollower
;
pFsm
->
FpBecomeFollowerCb
=
vnodeBecomeFollower
;
pFsm
->
FpReConfigCb
=
NULL
;
pFsm
->
FpReConfigCb
=
NULL
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
2f807a85
...
@@ -264,6 +264,7 @@ typedef struct SExchangeInfo {
...
@@ -264,6 +264,7 @@ typedef struct SExchangeInfo {
SLoadRemoteDataInfo
loadInfo
;
SLoadRemoteDataInfo
loadInfo
;
uint64_t
self
;
uint64_t
self
;
SLimitInfo
limitInfo
;
SLimitInfo
limitInfo
;
int64_t
openedTs
;
// start exec time stamp
}
SExchangeInfo
;
}
SExchangeInfo
;
typedef
struct
SScanInfo
{
typedef
struct
SScanInfo
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
2f807a85
...
@@ -1846,40 +1846,41 @@ static void* setAllSourcesCompleted(SOperatorInfo* pOperator, int64_t startTs) {
...
@@ -1846,40 +1846,41 @@ static void* setAllSourcesCompleted(SOperatorInfo* pOperator, int64_t startTs) {
return
NULL
;
return
NULL
;
}
}
static
void
concurrentlyLoadRemoteDataImpl
(
SOperatorInfo
*
pOperator
,
SExchangeInfo
*
pExchangeInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
static
int32_t
getCompletedSources
(
const
SArray
*
pArray
)
{
int32_t
code
=
0
;
size_t
total
=
taosArrayGetSize
(
pArray
);
int64_t
startTs
=
taosGetTimestampUs
();
size_t
totalSources
=
taosArrayGetSize
(
pExchangeInfo
->
pSources
);
int32_t
completed
=
0
;
int32_t
completed
=
0
;
for
(
int32_t
k
=
0
;
k
<
total
Sources
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
total
;
++
k
)
{
SSourceDataInfo
*
p
=
taosArrayGet
(
p
ExchangeInfo
->
pSourceDataInfo
,
k
);
SSourceDataInfo
*
p
=
taosArrayGet
(
p
Array
,
k
);
if
(
p
->
status
==
EX_SOURCE_DATA_EXHAUSTED
)
{
if
(
p
->
status
==
EX_SOURCE_DATA_EXHAUSTED
)
{
completed
+=
1
;
completed
+=
1
;
}
}
}
}
return
completed
;
}
static
void
concurrentlyLoadRemoteDataImpl
(
SOperatorInfo
*
pOperator
,
SExchangeInfo
*
pExchangeInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
int32_t
code
=
0
;
size_t
totalSources
=
taosArrayGetSize
(
pExchangeInfo
->
pSourceDataInfo
);
int32_t
completed
=
getCompletedSources
(
pExchangeInfo
->
pSourceDataInfo
);
if
(
completed
==
totalSources
)
{
if
(
completed
==
totalSources
)
{
setAllSourcesCompleted
(
pOperator
,
start
Ts
);
setAllSourcesCompleted
(
pOperator
,
pExchangeInfo
->
opened
Ts
);
return
;
return
;
}
}
while
(
1
)
{
while
(
1
)
{
// printf("1\n");
tsem_wait
(
&
pExchangeInfo
->
ready
);
tsem_wait
(
&
pExchangeInfo
->
ready
);
// printf("2\n");
for
(
int32_t
i
=
0
;
i
<
totalSources
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
totalSources
;
++
i
)
{
SSourceDataInfo
*
pDataInfo
=
taosArrayGet
(
pExchangeInfo
->
pSourceDataInfo
,
i
);
SSourceDataInfo
*
pDataInfo
=
taosArrayGet
(
pExchangeInfo
->
pSourceDataInfo
,
i
);
if
(
pDataInfo
->
status
==
EX_SOURCE_DATA_EXHAUSTED
)
{
if
(
pDataInfo
->
status
==
EX_SOURCE_DATA_EXHAUSTED
)
{
// printf("========:%d is completed\n", i);
continue
;
continue
;
}
}
// printf("index:%d - status:%d\n", i, pDataInfo->status);
if
(
pDataInfo
->
status
!=
EX_SOURCE_DATA_READY
)
{
if
(
pDataInfo
->
status
!=
EX_SOURCE_DATA_READY
)
{
// printf("-----------%d, status:%d, continue\n", i, pDataInfo->status);
continue
;
continue
;
}
}
...
@@ -1895,27 +1896,18 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
...
@@ -1895,27 +1896,18 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
if
(
pRsp
->
numOfRows
==
0
)
{
if
(
pRsp
->
numOfRows
==
0
)
{
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
// printf("%d completed, try next\n", i);
qDebug
(
"%s vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, rowsOfSource:%"
PRIu64
qDebug
(
"%s vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
",
completed:%d
try next %d/%"
PRIzu
,
", totalRows:%"
PRIu64
", try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pDataInfo
->
totalRows
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pDataInfo
->
totalRows
,
pExchangeInfo
->
loadInfo
.
totalRows
,
completed
,
i
+
1
,
totalSources
);
pExchangeInfo
->
loadInfo
.
totalRows
,
i
+
1
,
totalSources
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
break
;
// if (completed == totalSources) {
// return;
// } else {
// break;
// }
break
;
}
}
SRetrieveTableRsp
*
pRetrieveRsp
=
pDataInfo
->
pRsp
;
SRetrieveTableRsp
*
pRetrieveRsp
=
pDataInfo
->
pRsp
;
int32_t
index
=
0
;
int32_t
index
=
0
;
char
*
pStart
=
pRetrieveRsp
->
data
;
char
*
pStart
=
pRetrieveRsp
->
data
;
while
(
index
++
<
pRetrieveRsp
->
numOfBlocks
)
{
while
(
index
++
<
pRetrieveRsp
->
numOfBlocks
)
{
printf
(
"results, numOfBLock: %d
\n
"
,
pRetrieveRsp
->
numOfBlocks
);
SSDataBlock
*
pb
=
createOneDataBlock
(
pExchangeInfo
->
pDummyBlock
,
false
);
SSDataBlock
*
pb
=
createOneDataBlock
(
pExchangeInfo
->
pDummyBlock
,
false
);
code
=
extractDataBlockFromFetchRsp
(
pb
,
pStart
,
NULL
,
&
pStart
);
code
=
extractDataBlockFromFetchRsp
(
pb
,
pStart
,
NULL
,
&
pStart
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -1926,25 +1918,16 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
...
@@ -1926,25 +1918,16 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
taosArrayPush
(
pExchangeInfo
->
pResultBlockList
,
&
pb
);
taosArrayPush
(
pExchangeInfo
->
pResultBlockList
,
&
pb
);
}
}
updateLoadRemoteInfo
(
pLoadInfo
,
pRetrieveRsp
->
numOfRows
,
pRetrieveRsp
->
compLen
,
start
Ts
,
pOperator
);
updateLoadRemoteInfo
(
pLoadInfo
,
pRetrieveRsp
->
numOfRows
,
pRetrieveRsp
->
compLen
,
pExchangeInfo
->
opened
Ts
,
pOperator
);
// int32_t completed = 0;
if
(
pRsp
->
completed
==
1
)
{
if
(
pRsp
->
completed
==
1
)
{
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
// for (int32_t k = 0; k < totalSources; ++k) {
// SSourceDataInfo* p = taosArrayGet(pExchangeInfo->pSourceDataInfo, k);
// if (p->status == EX_SOURCE_DATA_EXHAUSTED) {
// completed += 1;
// }
// }
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, blocks:%d, numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
" execId:%d index:%d completed, blocks:%d, numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", total:%.2f Kb,
completed:%d
try next %d/%"
PRIzu
,
", total:%.2f Kb, try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pRsp
->
numOfBlocks
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pRsp
->
numOfBlocks
,
pRsp
->
numOfRows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
/
1024
.
0
,
pRsp
->
numOfRows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
/
1024
.
0
,
completed
,
i
+
1
,
totalSources
);
i
+
1
,
totalSources
);
}
else
{
}
else
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d blocks:%d, numOfRows:%d, totalRows:%"
PRIu64
", total:%.2f Kb"
,
" execId:%d blocks:%d, numOfRows:%d, totalRows:%"
PRIu64
", total:%.2f Kb"
,
...
@@ -1962,23 +1945,12 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
...
@@ -1962,23 +1945,12 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
goto
_error
;
goto
_error
;
}
}
}
}
// if (completed == totalSources) {
// setAllSourcesCompleted(pOperator, startTs);
// }
return
;
return
;
}
}
// end loop
int32_t
completed
=
0
;
for
(
int32_t
k
=
0
;
k
<
totalSources
;
++
k
)
{
SSourceDataInfo
*
p
=
taosArrayGet
(
pExchangeInfo
->
pSourceDataInfo
,
k
);
if
(
p
->
status
==
EX_SOURCE_DATA_EXHAUSTED
)
{
completed
+=
1
;
}
}
if
(
completed
==
totalSources
)
{
int32_t
complete1
=
getCompletedSources
(
pExchangeInfo
->
pSourceDataInfo
);
if
(
complete1
==
totalSources
)
{
qDebug
(
"all sources are completed, %s"
,
GET_TASKID
(
pTaskInfo
));
return
;
return
;
}
}
}
}
...
@@ -2097,6 +2069,7 @@ static int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
...
@@ -2097,6 +2069,7 @@ static int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
pExchangeInfo
->
openedTs
=
taosGetTimestampUs
();
}
}
OPTR_SET_OPENED
(
pOperator
);
OPTR_SET_OPENED
(
pOperator
);
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
2f807a85
...
@@ -918,6 +918,8 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
...
@@ -918,6 +918,8 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
blockDataDestroy
(
pResBlock
);
blockDataDestroy
(
pResBlock
);
}
}
}
}
taosArrayDestroy
(
pParInfo
->
rowIds
);
pParInfo
->
rowIds
=
NULL
;
blockDataUpdateTsWindow
(
pDest
,
pInfo
->
tsColIndex
);
blockDataUpdateTsWindow
(
pDest
,
pInfo
->
tsColIndex
);
pDest
->
info
.
groupId
=
pParInfo
->
groupId
;
pDest
->
info
.
groupId
=
pParInfo
->
groupId
;
pOperator
->
resultInfo
.
totalRows
+=
pDest
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
pDest
->
info
.
rows
;
...
@@ -1016,6 +1018,7 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
...
@@ -1016,6 +1018,7 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
cleanupExprSupp
(
&
pInfo
->
tbnameCalSup
);
cleanupExprSupp
(
&
pInfo
->
tbnameCalSup
);
cleanupExprSupp
(
&
pInfo
->
tagCalSup
);
cleanupExprSupp
(
&
pInfo
->
tagCalSup
);
blockDataDestroy
(
pInfo
->
pDelRes
);
blockDataDestroy
(
pInfo
->
pDelRes
);
taosHashCleanup
(
pInfo
->
pPartitions
);
taosMemoryFreeClear
(
param
);
taosMemoryFreeClear
(
param
);
}
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
2f807a85
...
@@ -1438,7 +1438,7 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
...
@@ -1438,7 +1438,7 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
uint64_t
groupId
=
getGroupIdByData
(
pInfo
,
uidCol
[
i
],
startData
[
i
],
version
);
uint64_t
groupId
=
getGroupIdByData
(
pInfo
,
uidCol
[
i
],
startData
[
i
],
version
);
// gap must be 0.
// gap must be 0.
SSessionKey
startWin
=
{
0
};
SSessionKey
startWin
=
{
0
};
getCurSessionWindow
(
pInfo
->
windowSup
.
pStreamAggSup
,
startData
[
i
],
end
Data
[
i
],
groupId
,
&
startWin
);
getCurSessionWindow
(
pInfo
->
windowSup
.
pStreamAggSup
,
startData
[
i
],
start
Data
[
i
],
groupId
,
&
startWin
);
if
(
IS_INVALID_SESSION_WIN_KEY
(
startWin
))
{
if
(
IS_INVALID_SESSION_WIN_KEY
(
startWin
))
{
// window has been closed.
// window has been closed.
continue
;
continue
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
2f807a85
...
@@ -3550,7 +3550,7 @@ void getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endT
...
@@ -3550,7 +3550,7 @@ void getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endT
pKey
->
win
.
skey
=
startTs
;
pKey
->
win
.
skey
=
startTs
;
pKey
->
win
.
ekey
=
endTs
;
pKey
->
win
.
ekey
=
endTs
;
pKey
->
groupId
=
groupId
;
pKey
->
groupId
=
groupId
;
int32_t
code
=
streamStateSessionGetKey
(
pAggSup
->
pState
,
pKey
,
pKey
);
int32_t
code
=
streamStateSessionGetKey
ByRange
(
pAggSup
->
pState
,
pKey
,
pKey
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SET_SESSION_WIN_KEY_INVALID
(
pKey
);
SET_SESSION_WIN_KEY_INVALID
(
pKey
);
}
}
...
@@ -3561,10 +3561,11 @@ bool isInvalidSessionWin(SResultWindowInfo* pWinInfo) { return pWinInfo->session
...
@@ -3561,10 +3561,11 @@ bool isInvalidSessionWin(SResultWindowInfo* pWinInfo) { return pWinInfo->session
void
setSessionOutputBuf
(
SStreamAggSupporter
*
pAggSup
,
TSKEY
startTs
,
TSKEY
endTs
,
uint64_t
groupId
,
void
setSessionOutputBuf
(
SStreamAggSupporter
*
pAggSup
,
TSKEY
startTs
,
TSKEY
endTs
,
uint64_t
groupId
,
SResultWindowInfo
*
pCurWin
)
{
SResultWindowInfo
*
pCurWin
)
{
pCurWin
->
sessionWin
.
groupId
=
groupId
;
pCurWin
->
sessionWin
.
groupId
=
groupId
;
pCurWin
->
sessionWin
.
win
.
skey
=
startTs
-
pAggSup
->
gap
;
pCurWin
->
sessionWin
.
win
.
skey
=
startTs
;
pCurWin
->
sessionWin
.
win
.
ekey
=
endTs
+
pAggSup
->
gap
;
pCurWin
->
sessionWin
.
win
.
ekey
=
endTs
;
int32_t
size
=
pAggSup
->
resultRowSize
;
int32_t
size
=
pAggSup
->
resultRowSize
;
int32_t
code
=
streamStateSessionAddIfNotExist
(
pAggSup
->
pState
,
&
pCurWin
->
sessionWin
,
&
pCurWin
->
pOutputBuf
,
&
size
);
int32_t
code
=
streamStateSessionAddIfNotExist
(
pAggSup
->
pState
,
&
pCurWin
->
sessionWin
,
pAggSup
->
gap
,
&
pCurWin
->
pOutputBuf
,
&
size
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pCurWin
->
isOutput
=
true
;
pCurWin
->
isOutput
=
true
;
}
else
{
}
else
{
...
@@ -3575,7 +3576,7 @@ void setSessionOutputBuf(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endT
...
@@ -3575,7 +3576,7 @@ void setSessionOutputBuf(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endT
int32_t
getSessionWinBuf
(
SStreamAggSupporter
*
pAggSup
,
SStreamStateCur
*
pCur
,
SResultWindowInfo
*
pWinInfo
)
{
int32_t
getSessionWinBuf
(
SStreamAggSupporter
*
pAggSup
,
SStreamStateCur
*
pCur
,
SResultWindowInfo
*
pWinInfo
)
{
int32_t
size
=
0
;
int32_t
size
=
0
;
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
pWinInfo
->
sessionWin
,
(
const
void
**
)
&
pWinInfo
->
pOutputBuf
,
&
size
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
pWinInfo
->
sessionWin
,
&
pWinInfo
->
pOutputBuf
,
&
size
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -3680,7 +3681,7 @@ SStreamStateCur* getNextSessionWinInfo(SStreamAggSupporter* pAggSup, SSHashObj*
...
@@ -3680,7 +3681,7 @@ SStreamStateCur* getNextSessionWinInfo(SStreamAggSupporter* pAggSup, SSHashObj*
setSessionWinOutputInfo
(
pStUpdated
,
pNextWin
);
setSessionWinOutputInfo
(
pStUpdated
,
pNextWin
);
int32_t
size
=
0
;
int32_t
size
=
0
;
pNextWin
->
sessionWin
=
pCurWin
->
sessionWin
;
pNextWin
->
sessionWin
=
pCurWin
->
sessionWin
;
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
pNextWin
->
sessionWin
,
(
const
void
**
)
&
pNextWin
->
pOutputBuf
,
&
size
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
pNextWin
->
sessionWin
,
&
pNextWin
->
pOutputBuf
,
&
size
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SET_SESSION_WIN_INVALID
(
*
pNextWin
);
SET_SESSION_WIN_INVALID
(
*
pNextWin
);
}
}
...
@@ -3894,9 +3895,11 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
...
@@ -3894,9 +3895,11 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
SOperatorInfo
*
pChild
=
taosArrayGetP
(
pInfo
->
pChildren
,
j
);
SOperatorInfo
*
pChild
=
taosArrayGetP
(
pInfo
->
pChildren
,
j
);
SStreamSessionAggOperatorInfo
*
pChInfo
=
pChild
->
info
;
SStreamSessionAggOperatorInfo
*
pChInfo
=
pChild
->
info
;
SStreamAggSupporter
*
pChAggSup
=
&
pChInfo
->
streamAggSup
;
SStreamAggSupporter
*
pChAggSup
=
&
pChInfo
->
streamAggSup
;
SStreamStateCur
*
pCur
=
streamStateSessionGetCur
(
pChAggSup
->
pState
,
pWinKey
);
SSessionKey
chWinKey
=
*
pWinKey
;
SResultRow
*
pResult
=
NULL
;
chWinKey
.
win
.
ekey
=
chWinKey
.
win
.
skey
;
SResultRow
*
pChResult
=
NULL
;
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentNext
(
pChAggSup
->
pState
,
&
chWinKey
);
SResultRow
*
pResult
=
NULL
;
SResultRow
*
pChResult
=
NULL
;
while
(
1
)
{
while
(
1
)
{
SResultWindowInfo
childWin
=
{
0
};
SResultWindowInfo
childWin
=
{
0
};
childWin
.
sessionWin
=
*
pWinKey
;
childWin
.
sessionWin
=
*
pWinKey
;
...
@@ -4112,6 +4115,12 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
...
@@ -4112,6 +4115,12 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
initGroupResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
initGroupResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
#if 0
char* pBuf = streamStateSessionDump(pAggSup->pState);
qDebug("===stream===final session%s", pBuf);
taosMemoryFree(pBuf);
#endif
doBuildDeleteDataBlock
(
pInfo
->
pStDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
doBuildDeleteDataBlock
(
pInfo
->
pStDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pInfo
->
pDelRes
,
IS_FINAL_OP
(
pInfo
)
?
"final session"
:
"single session"
);
printDataBlock
(
pInfo
->
pDelRes
,
IS_FINAL_OP
(
pInfo
)
?
"final session"
:
"single session"
);
...
@@ -4306,6 +4315,12 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
...
@@ -4306,6 +4315,12 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
initGroupResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
initGroupResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
pBInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pBInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
#if 0
char* pBuf = streamStateSessionDump(pAggSup->pState);
qDebug("===stream===semi session%s", pBuf);
taosMemoryFree(pBuf);
#endif
doBuildSessionResult
(
pOperator
,
pAggSup
->
pState
,
&
pInfo
->
groupResInfo
,
pBInfo
->
pRes
);
doBuildSessionResult
(
pOperator
,
pAggSup
->
pState
,
&
pInfo
->
groupResInfo
,
pBInfo
->
pRes
);
if
(
pBInfo
->
pRes
->
info
.
rows
>
0
)
{
if
(
pBInfo
->
pRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pBInfo
->
pRes
,
"semi session"
);
printDataBlock
(
pBInfo
->
pRes
,
"semi session"
);
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
2f807a85
...
@@ -911,6 +911,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
...
@@ -911,6 +911,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
case
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
plist
=
(
float
*
)
pCol
->
pData
;
float
*
plist
=
(
float
*
)
pCol
->
pData
;
// float val = 0;
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
...
@@ -918,8 +919,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
...
@@ -918,8 +919,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
numOfElem
+=
1
;
numOfElem
+=
1
;
pAvgRes
->
count
+=
1
;
pAvgRes
->
count
+=
1
;
pAvgRes
->
sum
.
dsum
+=
plist
[
i
];
pAvgRes
->
sum
.
dsum
+=
plist
[
i
];
}
}
// pAvgRes->sum.dsum = val;
break
;
break
;
}
}
...
@@ -1278,14 +1280,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1278,14 +1280,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1309,14 +1317,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1309,14 +1317,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1340,14 +1354,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1340,14 +1354,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1371,14 +1391,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1371,14 +1391,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1404,14 +1430,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1404,14 +1430,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1435,14 +1467,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1435,14 +1467,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1466,14 +1504,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1466,14 +1504,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1497,14 +1541,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1497,14 +1541,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1529,14 +1579,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1529,14 +1579,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
// ignore the equivalent data value
if
((
*
val
)
==
pData
[
i
])
{
// NOTE: An faster version to avoid one additional comparison with FPU.
continue
;
if
(
isMinFunc
)
{
// min
}
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
((
*
val
<
pData
[
i
])
^
isMinFunc
)
{
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
*
val
=
pData
[
i
];
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
}
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
}
}
...
@@ -1559,7 +1615,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1559,7 +1615,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
}
}
pBuf
->
assign
=
true
;
pBuf
->
assign
=
true
;
}
else
{
}
else
{
// ignore the equivalent data value
#if 0
if ((*val) == pData[i]) {
if ((*val) == pData[i]) {
continue;
continue;
}
}
...
@@ -1570,6 +1626,23 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
...
@@ -1570,6 +1626,23 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
}
}
}
}
#endif
// NOTE: An faster version to avoid one additional comparison with FPU.
if
(
isMinFunc
)
{
// min
if
(
*
val
>
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
else
{
// max
if
(
*
val
<
pData
[
i
])
{
*
val
=
pData
[
i
];
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
updateTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
}
}
}
}
}
numOfElems
+=
1
;
numOfElems
+=
1
;
...
@@ -2934,6 +3007,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
...
@@ -2934,6 +3007,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
}
}
}
#else
#else
int64_t
*
pts
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
startRowIndex
+
pInput
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
startRowIndex
+
pInput
->
numOfRows
;
++
i
)
{
if
(
pInputCol
->
hasNull
&&
colDataIsNull
(
pInputCol
,
pInput
->
totalRows
,
i
,
pColAgg
))
{
if
(
pInputCol
->
hasNull
&&
colDataIsNull
(
pInputCol
,
pInput
->
totalRows
,
i
,
pColAgg
))
{
continue
;
continue
;
...
@@ -2942,13 +3016,14 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
...
@@ -2942,13 +3016,14 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
numOfElems
++
;
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
TSKEY
cts
=
getRowPTs
(
pInput
->
pPTS
,
i
)
;
TSKEY
cts
=
pts
[
i
]
;
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
>
cts
)
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
>
cts
)
{
doSaveCurrentVal
(
pCtx
,
i
,
cts
,
pInputCol
->
info
.
type
,
data
);
doSaveCurrentVal
(
pCtx
,
i
,
cts
,
pInputCol
->
info
.
type
,
data
);
pResInfo
->
numOfRes
=
1
;
pResInfo
->
numOfRes
=
1
;
}
}
}
}
#endif
#endif
if
(
numOfElems
==
0
)
{
if
(
numOfElems
==
0
)
{
// save selectivity value for column consisted of all null values
// save selectivity value for column consisted of all null values
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
...
@@ -3020,6 +3095,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -3020,6 +3095,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
}
}
}
}
#else
#else
int64_t
*
pts
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
if
(
pInputCol
->
hasNull
&&
colDataIsNull
(
pInputCol
,
pInput
->
totalRows
,
i
,
pColAgg
))
{
if
(
pInputCol
->
hasNull
&&
colDataIsNull
(
pInputCol
,
pInput
->
totalRows
,
i
,
pColAgg
))
{
continue
;
continue
;
...
@@ -3028,15 +3104,16 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -3028,15 +3104,16 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
numOfElems
++
;
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
TSKEY
cts
=
getRowPTs
(
pInput
->
pPTS
,
i
)
;
TSKEY
cts
=
pts
[
i
]
;
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
cts
)
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
cts
)
{
doSaveCurrentVal
(
pCtx
,
i
,
cts
,
type
,
data
);
doSaveCurrentVal
(
pCtx
,
i
,
cts
,
type
,
data
);
pResInfo
->
numOfRes
=
1
;
pResInfo
->
numOfRes
=
1
;
}
}
}
}
#endif
#endif
// save selectivity value for column consisted of all null values
if
(
numOfElems
==
0
)
{
if
(
numOfElems
==
0
)
{
// save selectivity value for column consisted of all null values
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
}
}
SET_VAL
(
pResInfo
,
numOfElems
,
1
);
SET_VAL
(
pResInfo
,
numOfElems
,
1
);
...
@@ -3216,11 +3293,13 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
...
@@ -3216,11 +3293,13 @@ int32_t lastRowFunction(SqlFunctionCtx* pCtx) {
}
}
}
}
#else
#else
int64_t
*
pts
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
TSKEY
cts
=
getRowPTs
(
pInput
->
pPTS
,
i
);
TSKEY
cts
=
pts
[
i
];
numOfElems
++
;
numOfElems
++
;
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
cts
)
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
cts
)
{
doSaveLastrow
(
pCtx
,
data
,
i
,
cts
,
pInfo
);
doSaveLastrow
(
pCtx
,
data
,
i
,
cts
,
pInfo
);
pResInfo
->
numOfRes
=
1
;
pResInfo
->
numOfRes
=
1
;
...
...
source/libs/function/src/tudf.c
浏览文件 @
2f807a85
...
@@ -131,7 +131,8 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
...
@@ -131,7 +131,8 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
char
udfdPathLdLib
[
1024
]
=
{
0
};
char
udfdPathLdLib
[
1024
]
=
{
0
};
size_t
udfdLdLibPathLen
=
strlen
(
tsUdfdLdLibPath
);
size_t
udfdLdLibPathLen
=
strlen
(
tsUdfdLdLibPath
);
strncpy
(
udfdPathLdLib
,
tsUdfdLdLibPath
,
udfdLdLibPathLen
);
strncpy
(
udfdPathLdLib
,
tsUdfdLdLibPath
,
tListLen
(
udfdPathLdLib
));
udfdPathLdLib
[
udfdLdLibPathLen
]
=
':'
;
udfdPathLdLib
[
udfdLdLibPathLen
]
=
':'
;
strncpy
(
udfdPathLdLib
+
udfdLdLibPathLen
+
1
,
pathTaosdLdLib
,
sizeof
(
udfdPathLdLib
)
-
udfdLdLibPathLen
-
1
);
strncpy
(
udfdPathLdLib
+
udfdLdLibPathLen
+
1
,
pathTaosdLdLib
,
sizeof
(
udfdPathLdLib
)
-
udfdLdLibPathLen
-
1
);
if
(
udfdLdLibPathLen
+
taosdLdLibPathLen
<
1024
)
{
if
(
udfdLdLibPathLen
+
taosdLdLibPathLen
<
1024
)
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
2f807a85
...
@@ -2393,6 +2393,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -2393,6 +2393,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_SUPER_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
if
(
TSDB_SUPER_TABLE
==
pRealTable
->
pMeta
->
tableType
)
{
pCxt
->
stableQuery
=
true
;
pCxt
->
stableQuery
=
true
;
}
}
if
(
TSDB_SYSTEM_TABLE
==
pRealTable
->
pMeta
->
tableType
&&
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isTimeLineResult
=
false
;
}
code
=
addNamespace
(
pCxt
,
pRealTable
);
code
=
addNamespace
(
pCxt
,
pRealTable
);
}
}
break
;
break
;
...
@@ -3428,6 +3431,19 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
...
@@ -3428,6 +3431,19 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
return
(
SNode
*
)
pCol
;
return
(
SNode
*
)
pCol
;
}
}
// 0 means equal, 1 means the left shall prevail, -1 means the right shall prevail
static
int32_t
dataTypeComp
(
const
SDataType
*
l
,
const
SDataType
*
r
)
{
if
(
l
->
type
!=
r
->
type
)
{
return
1
;
}
if
(
l
->
bytes
!=
r
->
bytes
)
{
return
l
->
bytes
>
r
->
bytes
?
1
:
-
1
;
}
return
(
l
->
precision
==
r
->
precision
&&
l
->
scale
==
r
->
scale
)
?
0
:
1
;
}
static
int32_t
translateSetOperProject
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
static
int32_t
translateSetOperProject
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
SNodeList
*
pLeftProjections
=
getProjectList
(
pSetOperator
->
pLeft
);
SNodeList
*
pLeftProjections
=
getProjectList
(
pSetOperator
->
pLeft
);
SNodeList
*
pRightProjections
=
getProjectList
(
pSetOperator
->
pRight
);
SNodeList
*
pRightProjections
=
getProjectList
(
pSetOperator
->
pRight
);
...
@@ -3440,7 +3456,8 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
...
@@ -3440,7 +3456,8 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
FORBOTH
(
pLeft
,
pLeftProjections
,
pRight
,
pRightProjections
)
{
FORBOTH
(
pLeft
,
pLeftProjections
,
pRight
,
pRightProjections
)
{
SExprNode
*
pLeftExpr
=
(
SExprNode
*
)
pLeft
;
SExprNode
*
pLeftExpr
=
(
SExprNode
*
)
pLeft
;
SExprNode
*
pRightExpr
=
(
SExprNode
*
)
pRight
;
SExprNode
*
pRightExpr
=
(
SExprNode
*
)
pRight
;
if
(
!
dataTypeEqual
(
&
pLeftExpr
->
resType
,
&
pRightExpr
->
resType
))
{
int32_t
comp
=
dataTypeComp
(
&
pLeftExpr
->
resType
,
&
pRightExpr
->
resType
);
if
(
comp
>
0
)
{
SNode
*
pRightFunc
=
NULL
;
SNode
*
pRightFunc
=
NULL
;
int32_t
code
=
createCastFunc
(
pCxt
,
pRight
,
pLeftExpr
->
resType
,
&
pRightFunc
);
int32_t
code
=
createCastFunc
(
pCxt
,
pRight
,
pLeftExpr
->
resType
,
&
pRightFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
@@ -3448,9 +3465,20 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
...
@@ -3448,9 +3465,20 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
}
}
REPLACE_LIST2_NODE
(
pRightFunc
);
REPLACE_LIST2_NODE
(
pRightFunc
);
pRightExpr
=
(
SExprNode
*
)
pRightFunc
;
pRightExpr
=
(
SExprNode
*
)
pRightFunc
;
}
}
else
if
(
comp
<
0
)
{
strcpy
(
pRightExpr
->
aliasName
,
pLeftExpr
->
aliasName
);
SNode
*
pLeftFunc
=
NULL
;
pRightExpr
->
aliasName
[
strlen
(
pLeftExpr
->
aliasName
)]
=
'\0'
;
int32_t
code
=
createCastFunc
(
pCxt
,
pLeft
,
pRightExpr
->
resType
,
&
pLeftFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
REPLACE_LIST1_NODE
(
pLeftFunc
);
SExprNode
*
pLeftFuncExpr
=
(
SExprNode
*
)
pLeftFunc
;
snprintf
(
pLeftFuncExpr
->
aliasName
,
sizeof
(
pLeftFuncExpr
->
aliasName
),
"%s"
,
pLeftExpr
->
aliasName
);
snprintf
(
pLeftFuncExpr
->
userAlias
,
sizeof
(
pLeftFuncExpr
->
userAlias
),
"%s"
,
pLeftExpr
->
userAlias
);
pLeft
=
pLeftFunc
;
pLeftExpr
=
pLeftFuncExpr
;
}
snprintf
(
pRightExpr
->
aliasName
,
sizeof
(
pRightExpr
->
aliasName
),
"%s"
,
pLeftExpr
->
aliasName
);
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSetOperator
->
pProjectionList
,
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSetOperator
->
pProjectionList
,
createSetOperProject
(
pSetOperator
->
stmtName
,
pLeft
)))
{
createSetOperProject
(
pSetOperator
->
stmtName
,
pLeft
)))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
2f807a85
...
@@ -425,6 +425,8 @@ TEST_F(ParserSelectTest, informationSchema) {
...
@@ -425,6 +425,8 @@ TEST_F(ParserSelectTest, informationSchema) {
run
(
"SELECT * FROM ins_databases WHERE name = 'information_schema'"
);
run
(
"SELECT * FROM ins_databases WHERE name = 'information_schema'"
);
run
(
"SELECT * FROM ins_tags WHERE db_name = 'test' and table_name = 'st1'"
);
run
(
"SELECT * FROM ins_tags WHERE db_name = 'test' and table_name = 'st1'"
);
run
(
"SELECT * FROM (SELECT table_name FROM ins_tables) t WHERE table_name = 'a'"
);
}
}
TEST_F
(
ParserSelectTest
,
withoutFrom
)
{
TEST_F
(
ParserSelectTest
,
withoutFrom
)
{
...
...
source/libs/stream/src/streamState.c
浏览文件 @
2f807a85
...
@@ -29,7 +29,7 @@ typedef struct SStateSessionKey {
...
@@ -29,7 +29,7 @@ typedef struct SStateSessionKey {
int64_t
opNum
;
int64_t
opNum
;
}
SStateSessionKey
;
}
SStateSessionKey
;
static
inline
int
sessionKeyCmpr
(
const
SSessionKey
*
pWin1
,
const
SSessionKey
*
pWin2
)
{
static
inline
int
session
Range
KeyCmpr
(
const
SSessionKey
*
pWin1
,
const
SSessionKey
*
pWin2
)
{
if
(
pWin1
->
groupId
>
pWin2
->
groupId
)
{
if
(
pWin1
->
groupId
>
pWin2
->
groupId
)
{
return
1
;
return
1
;
}
else
if
(
pWin1
->
groupId
<
pWin2
->
groupId
)
{
}
else
if
(
pWin1
->
groupId
<
pWin2
->
groupId
)
{
...
@@ -45,6 +45,28 @@ static inline int sessionKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pW
...
@@ -45,6 +45,28 @@ static inline int sessionKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pW
return
0
;
return
0
;
}
}
static
inline
int
sessionWinKeyCmpr
(
const
SSessionKey
*
pWin1
,
const
SSessionKey
*
pWin2
)
{
if
(
pWin1
->
groupId
>
pWin2
->
groupId
)
{
return
1
;
}
else
if
(
pWin1
->
groupId
<
pWin2
->
groupId
)
{
return
-
1
;
}
if
(
pWin1
->
win
.
skey
>
pWin2
->
win
.
skey
)
{
return
1
;
}
else
if
(
pWin1
->
win
.
skey
<
pWin2
->
win
.
skey
)
{
return
-
1
;
}
if
(
pWin1
->
win
.
ekey
>
pWin2
->
win
.
ekey
)
{
return
1
;
}
else
if
(
pWin1
->
win
.
ekey
<
pWin2
->
win
.
ekey
)
{
return
-
1
;
}
return
0
;
}
static
inline
int
stateSessionKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
static
inline
int
stateSessionKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
SStateSessionKey
*
pWin1
=
(
SStateSessionKey
*
)
pKey1
;
SStateSessionKey
*
pWin1
=
(
SStateSessionKey
*
)
pKey1
;
SStateSessionKey
*
pWin2
=
(
SStateSessionKey
*
)
pKey2
;
SStateSessionKey
*
pWin2
=
(
SStateSessionKey
*
)
pKey2
;
...
@@ -55,7 +77,7 @@ static inline int stateSessionKeyCmpr(const void* pKey1, int kLen1, const void*
...
@@ -55,7 +77,7 @@ static inline int stateSessionKeyCmpr(const void* pKey1, int kLen1, const void*
return
-
1
;
return
-
1
;
}
}
return
sessionKeyCmpr
(
&
pWin1
->
key
,
&
pWin2
->
key
);
return
session
Win
KeyCmpr
(
&
pWin1
->
key
,
&
pWin2
->
key
);
}
}
static
inline
int
stateKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
static
inline
int
stateKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
...
@@ -400,7 +422,6 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key
...
@@ -400,7 +422,6 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key
SStateKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
SStateKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
int32_t
c
=
0
;
int32_t
c
=
0
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateKey
),
&
c
)
<
0
)
{
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateKey
),
&
c
)
<
0
)
{
tdbTbcClose
(
pCur
->
pCur
);
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
NULL
;
return
NULL
;
}
}
...
@@ -426,7 +447,6 @@ SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey*
...
@@ -426,7 +447,6 @@ SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey*
int32_t
c
=
0
;
int32_t
c
=
0
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
key
,
sizeof
(
SWinKey
),
&
c
)
<
0
)
{
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
key
,
sizeof
(
SWinKey
),
&
c
)
<
0
)
{
tdbTbcClose
(
pCur
->
pCur
);
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
NULL
;
return
NULL
;
}
}
...
@@ -452,7 +472,6 @@ SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey*
...
@@ -452,7 +472,6 @@ SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey*
int32_t
c
=
0
;
int32_t
c
=
0
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
key
,
sizeof
(
SWinKey
),
&
c
)
<
0
)
{
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
key
,
sizeof
(
SWinKey
),
&
c
)
<
0
)
{
tdbTbcClose
(
pCur
->
pCur
);
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
NULL
;
return
NULL
;
}
}
...
@@ -496,33 +515,18 @@ int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, cons
...
@@ -496,33 +515,18 @@ int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, cons
return
tdbTbUpsert
(
pState
->
pSessionStateDb
,
&
sKey
,
sizeof
(
SStateSessionKey
),
value
,
vLen
,
&
pState
->
txn
);
return
tdbTbUpsert
(
pState
->
pSessionStateDb
,
&
sKey
,
sizeof
(
SStateSessionKey
),
value
,
vLen
,
&
pState
->
txn
);
}
}
SStreamStateCur
*
streamStateSessionGetRanomCur
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
if
(
pCur
==
NULL
)
return
NULL
;
tdbTbcOpen
(
pState
->
pSessionStateDb
,
&
pCur
->
pCur
,
NULL
);
int32_t
c
=
-
2
;
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
);
if
(
c
!=
0
)
{
streamStateFreeCur
(
pCur
);
return
NULL
;
}
pCur
->
number
=
pState
->
number
;
return
pCur
;
}
int32_t
streamStateSessionGet
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
)
{
int32_t
streamStateSessionGet
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
)
{
SStreamStateCur
*
pCur
=
streamStateSessionGetRanomCur
(
pState
,
key
);
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentNext
(
pState
,
key
);
SSessionKey
resKey
=
*
key
;
void
*
tmp
=
NULL
;
void
*
tmp
=
NULL
;
if
(
streamStateSessionGetKVByCur
(
pCur
,
key
,
(
const
void
**
)
&
tmp
,
pVLen
)
==
0
)
{
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
resKey
,
&
tmp
,
pVLen
);
if
(
code
==
0
)
{
*
key
=
resKey
;
*
pVal
=
tdbRealloc
(
NULL
,
*
pVLen
);
*
pVal
=
tdbRealloc
(
NULL
,
*
pVLen
);
memcpy
(
*
pVal
,
tmp
,
*
pVLen
);
memcpy
(
*
pVal
,
tmp
,
*
pVLen
);
streamStateFreeCur
(
pCur
);
return
0
;
}
}
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
-
1
;
return
code
;
}
}
int32_t
streamStateSessionDel
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
int32_t
streamStateSessionDel
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
...
@@ -544,7 +548,6 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, cons
...
@@ -544,7 +548,6 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, cons
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
int32_t
c
=
0
;
int32_t
c
=
0
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
)
<
0
)
{
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
)
<
0
)
{
tdbTbcClose
(
pCur
->
pCur
);
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
NULL
;
return
NULL
;
}
}
...
@@ -558,6 +561,34 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, cons
...
@@ -558,6 +561,34 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, cons
return
pCur
;
return
pCur
;
}
}
SStreamStateCur
*
streamStateSessionSeekKeyCurrentNext
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
if
(
pCur
==
NULL
)
{
return
NULL
;
}
pCur
->
number
=
pState
->
number
;
if
(
tdbTbcOpen
(
pState
->
pSessionStateDb
,
&
pCur
->
pCur
,
NULL
)
<
0
)
{
streamStateFreeCur
(
pCur
);
return
NULL
;
}
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
int32_t
c
=
0
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
)
<
0
)
{
streamStateFreeCur
(
pCur
);
return
NULL
;
}
if
(
c
<=
0
)
return
pCur
;
if
(
tdbTbcMoveToNext
(
pCur
->
pCur
)
<
0
)
{
streamStateFreeCur
(
pCur
);
return
NULL
;
}
return
pCur
;
}
SStreamStateCur
*
streamStateSessionSeekKeyNext
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
SStreamStateCur
*
streamStateSessionSeekKeyNext
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
if
(
pCur
==
NULL
)
{
if
(
pCur
==
NULL
)
{
...
@@ -572,7 +603,6 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess
...
@@ -572,7 +603,6 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
int32_t
c
=
0
;
int32_t
c
=
0
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
)
<
0
)
{
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
)
<
0
)
{
tdbTbcClose
(
pCur
->
pCur
);
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
NULL
;
return
NULL
;
}
}
...
@@ -586,13 +616,13 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess
...
@@ -586,13 +616,13 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess
return
pCur
;
return
pCur
;
}
}
int32_t
streamStateSessionGetKVByCur
(
SStreamStateCur
*
pCur
,
SSessionKey
*
pKey
,
const
void
**
pVal
,
int32_t
*
pVLen
)
{
int32_t
streamStateSessionGetKVByCur
(
SStreamStateCur
*
pCur
,
SSessionKey
*
pKey
,
void
**
pVal
,
int32_t
*
pVLen
)
{
if
(
!
pCur
)
{
if
(
!
pCur
)
{
return
-
1
;
return
-
1
;
}
}
const
SStateSessionKey
*
pKTmp
=
NULL
;
SStateSessionKey
*
pKTmp
=
NULL
;
int32_t
kLen
;
int32_t
kLen
;
if
(
tdbTbcGet
(
pCur
->
pCur
,
(
const
void
**
)
&
pKTmp
,
&
kLen
,
pVal
,
pVLen
)
<
0
)
{
if
(
tdbTbcGet
(
pCur
->
pCur
,
(
const
void
**
)
&
pKTmp
,
&
kLen
,
(
const
void
**
)
pVal
,
pVLen
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
if
(
pKTmp
->
opNum
!=
pCur
->
number
)
{
if
(
pKTmp
->
opNum
!=
pCur
->
number
)
{
...
@@ -606,15 +636,15 @@ int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, c
...
@@ -606,15 +636,15 @@ int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, c
}
}
int32_t
streamStateSessionClear
(
SStreamState
*
pState
)
{
int32_t
streamStateSessionClear
(
SStreamState
*
pState
)
{
SSessionKey
key
=
{.
win
.
skey
=
0
,
.
win
.
ekey
=
0
,
.
groupId
=
0
};
SSessionKey
key
=
{.
win
.
skey
=
0
,
.
win
.
ekey
=
0
,
.
groupId
=
0
};
streamStateSessionPut
(
pState
,
&
key
,
NULL
,
0
);
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentNext
(
pState
,
&
key
);
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyNext
(
pState
,
&
key
);
while
(
1
)
{
while
(
1
)
{
SSessionKey
delKey
=
{
0
};
SSessionKey
delKey
=
{
0
};
void
*
buf
=
NULL
;
void
*
buf
=
NULL
;
int32_t
size
=
0
;
int32_t
size
=
0
;
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
delKey
,
buf
,
&
size
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
delKey
,
&
buf
,
&
size
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
ASSERT
(
size
>
0
);
memset
(
buf
,
0
,
size
);
memset
(
buf
,
0
,
size
);
streamStateSessionPut
(
pState
,
&
delKey
,
buf
,
size
);
streamStateSessionPut
(
pState
,
&
delKey
,
buf
,
size
);
}
else
{
}
else
{
...
@@ -623,61 +653,104 @@ int32_t streamStateSessionClear(SStreamState* pState) {
...
@@ -623,61 +653,104 @@ int32_t streamStateSessionClear(SStreamState* pState) {
streamStateCurNext
(
pState
,
pCur
);
streamStateCurNext
(
pState
,
pCur
);
}
}
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
streamStateSessionDel
(
pState
,
&
key
);
return
0
;
return
0
;
}
}
SStreamStateCur
*
streamStateSessionGetCur
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
int32_t
streamStateSessionGetKeyByRange
(
SStreamState
*
pState
,
const
SSessionKey
*
key
,
SSessionKey
*
curKey
)
{
SStreamStateCur
*
pCur
=
streamStateSessionGetRanomCur
(
pState
,
key
);
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
SSessionKey
resKey
=
*
key
;
if
(
pCur
==
NULL
)
{
while
(
1
)
{
return
-
1
;
streamStateCurPrev
(
pState
,
pCur
);
}
SSessionKey
tmpKey
=
*
key
;
pCur
->
number
=
pState
->
number
;
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
tmpKey
,
NULL
,
0
);
if
(
tdbTbcOpen
(
pState
->
pSessionStateDb
,
&
pCur
->
pCur
,
NULL
)
<
0
)
{
if
(
code
==
0
&&
sessionKeyCmpr
(
key
,
&
tmpKey
)
==
0
)
{
streamStateFreeCur
(
pCur
);
resKey
=
tmpKey
;
return
-
1
;
}
else
{
break
;
}
}
}
streamStateFreeCur
(
pCur
);
return
streamStateSessionGetRanomCur
(
pState
,
&
resKey
);
}
int32_t
streamStateSessionGetKey
(
SStreamState
*
pState
,
const
SSessionKey
*
key
,
SSessionKey
*
curKey
)
{
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
SStreamStateCur
*
pCur
=
streamStateSessionGetRanomCur
(
pState
,
key
);
int32_t
c
=
0
;
SSessionKey
resKey
=
*
key
;
if
(
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SStateSessionKey
),
&
c
)
<
0
)
{
int32_t
res
=
-
1
;
streamStateFreeCur
(
pCur
);
while
(
1
)
{
return
-
1
;
SSessionKey
tmpKey
=
*
key
;
}
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
tmpKey
,
NULL
,
0
);
if
(
code
==
0
&&
sessionKeyCmpr
(
key
,
&
tmpKey
)
==
0
)
{
SSessionKey
resKey
=
*
key
;
res
=
0
;
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
resKey
,
NULL
,
0
);
resKey
=
tmpKey
;
if
(
code
==
0
&&
sessionRangeKeyCmpr
(
key
,
&
resKey
)
==
0
)
{
streamStateCurPrev
(
pState
,
pCur
);
*
curKey
=
resKey
;
}
else
{
streamStateFreeCur
(
pCur
);
break
;
return
code
;
}
if
(
c
>
0
)
{
streamStateCurNext
(
pState
,
pCur
);
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
resKey
,
NULL
,
0
);
if
(
code
==
0
&&
sessionRangeKeyCmpr
(
key
,
&
resKey
)
==
0
)
{
*
curKey
=
resKey
;
streamStateFreeCur
(
pCur
);
return
code
;
}
}
else
if
(
c
<
0
)
{
streamStateCurPrev
(
pState
,
pCur
);
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
resKey
,
NULL
,
0
);
if
(
code
==
0
&&
sessionRangeKeyCmpr
(
key
,
&
resKey
)
==
0
)
{
*
curKey
=
resKey
;
streamStateFreeCur
(
pCur
);
return
code
;
}
}
}
}
*
curKey
=
resKey
;
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
res
;
return
-
1
;
}
}
int32_t
streamStateSessionAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
)
{
int32_t
streamStateSessionAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
TSKEY
gap
,
void
**
pVal
,
int32_t
*
pVLen
)
{
// todo refactor
// todo refactor
SStreamStateCur
*
pCur
=
streamStateSessionGetRanomCur
(
pState
,
key
);
int32_t
res
=
0
;
int32_t
size
=
*
pVLen
;
SSessionKey
originKey
=
*
key
;
void
*
tmp
=
NULL
;
SSessionKey
searchKey
=
*
key
;
*
pVal
=
tdbRealloc
(
NULL
,
size
);
searchKey
.
win
.
skey
=
key
->
win
.
skey
-
gap
;
memset
(
*
pVal
,
0
,
size
);
searchKey
.
win
.
ekey
=
key
->
win
.
ekey
+
gap
;
if
(
streamStateSessionGetKVByCur
(
pCur
,
key
,
(
const
void
**
)
&
tmp
,
pVLen
)
==
0
)
{
int32_t
valSize
=
*
pVLen
;
memcpy
(
*
pVal
,
tmp
,
*
pVLen
);
void
*
tmp
=
tdbRealloc
(
NULL
,
valSize
);
if
(
!
tmp
)
{
return
-
1
;
}
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentPrev
(
pState
,
key
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
key
,
pVal
,
pVLen
);
if
(
code
==
0
)
{
if
(
sessionRangeKeyCmpr
(
&
searchKey
,
key
)
==
0
)
{
memcpy
(
tmp
,
*
pVal
,
valSize
);
streamStateSessionDel
(
pState
,
key
);
goto
_end
;
}
streamStateCurNext
(
pState
,
pCur
);
}
else
{
*
key
=
originKey
;
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
0
;
pCur
=
streamStateSessionSeekKeyNext
(
pState
,
key
)
;
}
}
code
=
streamStateSessionGetKVByCur
(
pCur
,
key
,
pVal
,
pVLen
);
if
(
code
==
0
)
{
if
(
sessionRangeKeyCmpr
(
&
searchKey
,
key
)
==
0
)
{
memcpy
(
tmp
,
*
pVal
,
valSize
);
streamStateSessionDel
(
pState
,
key
);
goto
_end
;
}
}
*
key
=
originKey
;
res
=
1
;
memset
(
tmp
,
0
,
valSize
);
_end:
*
pVal
=
tmp
;
streamStateFreeCur
(
pCur
);
streamStateFreeCur
(
pCur
);
return
1
;
return
res
;
}
}
int32_t
streamStateStateAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
char
*
pKeyData
,
int32_t
keyDataLen
,
int32_t
streamStateStateAddIfNotExist
(
SStreamState
*
pState
,
SSessionKey
*
key
,
char
*
pKeyData
,
int32_t
keyDataLen
,
...
@@ -692,16 +765,18 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch
...
@@ -692,16 +765,18 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch
}
}
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentPrev
(
pState
,
key
);
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentPrev
(
pState
,
key
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
key
,
(
const
void
**
)
pVal
,
pVLen
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
key
,
pVal
,
pVLen
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
if
(
key
->
win
.
skey
<=
tmpKey
.
win
.
skey
&&
tmpKey
.
win
.
ekey
<=
key
->
win
.
ekey
)
{
if
(
key
->
win
.
skey
<=
tmpKey
.
win
.
skey
&&
tmpKey
.
win
.
ekey
<=
key
->
win
.
ekey
)
{
memcpy
(
tmp
,
*
pVal
,
valSize
);
memcpy
(
tmp
,
*
pVal
,
valSize
);
streamStateSessionDel
(
pState
,
key
);
goto
_end
;
goto
_end
;
}
}
void
*
stateKey
=
(
char
*
)(
*
pVal
)
+
(
valSize
-
keyDataLen
);
void
*
stateKey
=
(
char
*
)(
*
pVal
)
+
(
valSize
-
keyDataLen
);
if
(
fn
(
pKeyData
,
stateKey
)
==
true
)
{
if
(
fn
(
pKeyData
,
stateKey
)
==
true
)
{
memcpy
(
tmp
,
*
pVal
,
valSize
);
memcpy
(
tmp
,
*
pVal
,
valSize
);
streamStateSessionDel
(
pState
,
key
);
goto
_end
;
goto
_end
;
}
}
...
@@ -712,11 +787,12 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch
...
@@ -712,11 +787,12 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch
pCur
=
streamStateSessionSeekKeyNext
(
pState
,
key
);
pCur
=
streamStateSessionSeekKeyNext
(
pState
,
key
);
}
}
code
=
streamStateSessionGetKVByCur
(
pCur
,
key
,
(
const
void
**
)
pVal
,
pVLen
);
code
=
streamStateSessionGetKVByCur
(
pCur
,
key
,
pVal
,
pVLen
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
void
*
stateKey
=
(
char
*
)(
*
pVal
)
+
(
valSize
-
keyDataLen
);
void
*
stateKey
=
(
char
*
)(
*
pVal
)
+
(
valSize
-
keyDataLen
);
if
(
fn
(
pKeyData
,
stateKey
)
==
true
)
{
if
(
fn
(
pKeyData
,
stateKey
)
==
true
)
{
memcpy
(
tmp
,
*
pVal
,
valSize
);
memcpy
(
tmp
,
*
pVal
,
valSize
);
streamStateSessionDel
(
pState
,
key
);
goto
_end
;
goto
_end
;
}
}
}
}
...
@@ -746,8 +822,11 @@ char* streamStateSessionDump(SStreamState* pState) {
...
@@ -746,8 +822,11 @@ char* streamStateSessionDump(SStreamState* pState) {
tdbTbcMoveToFirst(pCur->pCur);
tdbTbcMoveToFirst(pCur->pCur);
SSessionKey key = {0};
SSessionKey key = {0};
int32_t code = streamStateSessionGetKVByCur(pCur, &key, NULL, 0);
void* buf = NULL;
int32_t bufSize = 0;
int32_t code = streamStateSessionGetKVByCur(pCur, &key, &buf, &bufSize);
if (code != 0) {
if (code != 0) {
streamStateFreeCur(pCur);
return NULL;
return NULL;
}
}
...
@@ -762,12 +841,14 @@ char* streamStateSessionDump(SStreamState* pState) {
...
@@ -762,12 +841,14 @@ char* streamStateSessionDump(SStreamState* pState) {
key = (SSessionKey){0};
key = (SSessionKey){0};
code = streamStateSessionGetKVByCur(pCur, &key, NULL, 0);
code = streamStateSessionGetKVByCur(pCur, &key, NULL, 0);
if (code != 0) {
if (code != 0) {
streamStateFreeCur(pCur);
return dumpBuf;
return dumpBuf;
}
}
len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.win.skey);
len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.win.skey);
len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey);
len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey);
len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId);
len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId);
}
}
streamStateFreeCur(pCur);
return dumpBuf;
return dumpBuf;
}
}
#endif
#endif
source/libs/sync/inc/syncRespMgr.h
浏览文件 @
2f807a85
...
@@ -41,13 +41,12 @@ typedef struct SSyncRespMgr {
...
@@ -41,13 +41,12 @@ typedef struct SSyncRespMgr {
SSyncRespMgr
*
syncRespMgrCreate
(
void
*
data
,
int64_t
ttl
);
SSyncRespMgr
*
syncRespMgrCreate
(
void
*
data
,
int64_t
ttl
);
void
syncRespMgrDestroy
(
SSyncRespMgr
*
pObj
);
void
syncRespMgrDestroy
(
SSyncRespMgr
*
pObj
);
int64_t
syncRespMgrAdd
(
SSyncRespMgr
*
pObj
,
SRespStub
*
pStub
);
uint64_t
syncRespMgrAdd
(
SSyncRespMgr
*
pObj
,
const
SRespStub
*
pStub
);
int32_t
syncRespMgrDel
(
SSyncRespMgr
*
pObj
,
uint64_t
index
);
int32_t
syncRespMgrDel
(
SSyncRespMgr
*
pObj
,
uint64_t
seq
);
int32_t
syncRespMgrGet
(
SSyncRespMgr
*
pObj
,
uint64_t
index
,
SRespStub
*
pStub
);
int32_t
syncRespMgrGet
(
SSyncRespMgr
*
pObj
,
uint64_t
seq
,
SRespStub
*
pStub
);
int32_t
syncRespMgrGetAndDel
(
SSyncRespMgr
*
pObj
,
uint64_t
index
,
SRespStub
*
pStub
);
int32_t
syncRespMgrGetAndDel
(
SSyncRespMgr
*
pObj
,
uint64_t
seq
,
SRpcHandleInfo
*
pInfo
);
void
syncRespClean
(
SSyncRespMgr
*
pObj
);
void
syncRespClean
(
SSyncRespMgr
*
pObj
);
void
syncRespCleanRsp
(
SSyncRespMgr
*
pObj
);
void
syncRespCleanRsp
(
SSyncRespMgr
*
pObj
);
void
syncRespCleanByTTL
(
SSyncRespMgr
*
pObj
,
int64_t
ttl
,
bool
rsp
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncTools.h
浏览文件 @
2f807a85
...
@@ -26,9 +26,6 @@ typedef struct SRaftId {
...
@@ -26,9 +26,6 @@ typedef struct SRaftId {
SyncGroupId
vgId
;
SyncGroupId
vgId
;
}
SRaftId
;
}
SRaftId
;
// for compatibility, the same as syncPropose
int32_t
syncForwardToPeer
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
// ------------------ for debug -------------------
// ------------------ for debug -------------------
void
syncRpcMsgPrint
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint2
(
char
*
s
,
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint2
(
char
*
s
,
SRpcMsg
*
pMsg
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
2f807a85
...
@@ -246,7 +246,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -246,7 +246,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) {
}
else
{
}
else
{
// error
// error
char
logBuf
[
128
];
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"ignore, get local entry error, append-index:%"
PRId64
,
appendIndex
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"ignore, get local entry error, append-index:%"
PRId64
" err:%d"
,
appendIndex
,
terrno
);
syncLogRecvAppendEntries
(
ths
,
pMsg
,
logBuf
);
syncLogRecvAppendEntries
(
ths
,
pMsg
,
logBuf
);
syncEntryDestory
(
pLocalEntry
);
syncEntryDestory
(
pLocalEntry
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
2f807a85
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRespMgr.c
浏览文件 @
2f807a85
...
@@ -13,21 +13,22 @@
...
@@ -13,21 +13,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#define _DEFAULT_SOURCE
#include "syncRespMgr.h"
#include "syncRespMgr.h"
#include "syncRaftEntry.h"
#include "syncRaftEntry.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
SSyncRespMgr
*
syncRespMgrCreate
(
void
*
data
,
int64_t
ttl
)
{
SSyncRespMgr
*
syncRespMgrCreate
(
void
*
data
,
int64_t
ttl
)
{
SSyncRespMgr
*
pObj
=
(
SSyncRespMgr
*
)
taosMemoryMalloc
(
sizeof
(
SSyncRespMgr
));
SSyncRespMgr
*
pObj
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncRespMgr
));
if
(
pObj
==
NULL
)
{
if
(
pObj
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
memset
(
pObj
,
0
,
sizeof
(
SSyncRespMgr
));
pObj
->
pRespHash
=
pObj
->
pRespHash
=
taosHashInit
(
sizeof
(
uint64_t
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
taosHashInit
(
sizeof
(
uint64_t
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
ASSERT
(
pObj
->
pRespHash
!=
NULL
);
if
(
pObj
->
pRespHash
==
NULL
)
return
NULL
;
pObj
->
ttl
=
ttl
;
pObj
->
ttl
=
ttl
;
pObj
->
data
=
data
;
pObj
->
data
=
data
;
pObj
->
seqNum
=
0
;
pObj
->
seqNum
=
0
;
...
@@ -38,93 +39,84 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) {
...
@@ -38,93 +39,84 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) {
void
syncRespMgrDestroy
(
SSyncRespMgr
*
pObj
)
{
void
syncRespMgrDestroy
(
SSyncRespMgr
*
pObj
)
{
if
(
pObj
!=
NULL
)
{
if
(
pObj
!=
NULL
)
{
taosThreadMutexLock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexLock
(
&
pObj
->
mutex
);
taosHashCleanup
(
pObj
->
pRespHash
);
taosHashCleanup
(
pObj
->
pRespHash
);
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
taosThreadMutexDestroy
(
&
(
pObj
->
mutex
));
taosThreadMutexDestroy
(
&
(
pObj
->
mutex
));
taosMemoryFree
(
pObj
);
taosMemoryFree
(
pObj
);
}
}
}
}
int64_t
syncRespMgrAdd
(
SSyncRespMgr
*
pObj
,
SRespStub
*
pStub
)
{
uint64_t
syncRespMgrAdd
(
SSyncRespMgr
*
pObj
,
const
SRespStub
*
pStub
)
{
taosThreadMutexLock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexLock
(
&
pObj
->
mutex
);
uint64_t
keyCode
=
++
(
pObj
->
seqNum
);
uint64_t
seq
=
++
(
pObj
->
seqNum
);
taosHashPut
(
pObj
->
pRespHash
,
&
keyCode
,
sizeof
(
keyCode
),
pStub
,
sizeof
(
SRespStub
));
int32_t
code
=
taosHashPut
(
pObj
->
pRespHash
,
&
seq
,
sizeof
(
uint64_t
),
pStub
,
sizeof
(
SRespStub
));
sNTrace
(
pObj
->
data
,
"save message handle:%p, type:%s seq:%"
PRIu64
" code:0x%x"
,
pStub
->
rpcMsg
.
info
.
handle
,
TMSG_INFO
(
pStub
->
rpcMsg
.
msgType
),
seq
,
code
);
sNTrace
(
pObj
->
data
,
"save message handle, type:%s seq:%"
PRIu64
" handle:%p"
,
TMSG_INFO
(
pStub
->
rpcMsg
.
msgType
),
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
keyCode
,
pStub
->
rpcMsg
.
info
.
handle
);
return
seq
;
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
return
keyCode
;
}
}
int32_t
syncRespMgrDel
(
SSyncRespMgr
*
pObj
,
uint64_t
index
)
{
int32_t
syncRespMgrDel
(
SSyncRespMgr
*
pObj
,
uint64_t
seq
)
{
taosThreadMutexLock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexLock
(
&
pObj
->
mutex
);
taosHashRemove
(
pObj
->
pRespHash
,
&
index
,
sizeof
(
index
));
int32_t
code
=
taosHashRemove
(
pObj
->
pRespHash
,
&
seq
,
sizeof
(
seq
));
sNTrace
(
pObj
->
data
,
"remove message handle, seq:%"
PRIu64
" code:%d"
,
seq
,
code
);
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
return
0
;
return
code
;
}
}
int32_t
syncRespMgrGet
(
SSyncRespMgr
*
pObj
,
uint64_t
index
,
SRespStub
*
pStub
)
{
int32_t
syncRespMgrGet
(
SSyncRespMgr
*
pObj
,
uint64_t
seq
,
SRespStub
*
pStub
)
{
taosThreadMutexLock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexLock
(
&
pObj
->
mutex
);
void
*
pTmp
=
taosHashGet
(
pObj
->
pRespHash
,
&
index
,
sizeof
(
index
));
SRespStub
*
pTmp
=
taosHashGet
(
pObj
->
pRespHash
,
&
seq
,
sizeof
(
uint64_t
));
if
(
pTmp
!=
NULL
)
{
if
(
pTmp
!=
NULL
)
{
memcpy
(
pStub
,
pTmp
,
sizeof
(
SRespStub
));
memcpy
(
pStub
,
pTmp
,
sizeof
(
SRespStub
));
sNTrace
(
pObj
->
data
,
"get message handle, type:%s seq:%"
PRIu64
" handle:%p"
,
TMSG_INFO
(
pStub
->
rpcMsg
.
msgType
),
seq
,
pStub
->
rpcMsg
.
info
.
handle
);
sNTrace
(
pObj
->
data
,
"get message handle, type:%s seq:%"
PRIu64
" handle:%p"
,
TMSG_INFO
(
pStub
->
rpcMsg
.
msgType
),
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
index
,
pStub
->
rpcMsg
.
info
.
handle
);
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
return
1
;
// get one object
return
1
;
// get one object
}
}
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
return
0
;
// get none object
return
0
;
// get none object
}
}
int32_t
syncRespMgrGetAndDel
(
SSyncRespMgr
*
pObj
,
uint64_t
index
,
SRespStub
*
pStub
)
{
int32_t
syncRespMgrGetAndDel
(
SSyncRespMgr
*
pObj
,
uint64_t
seq
,
SRpcHandleInfo
*
pInfo
)
{
taosThreadMutexLock
(
&
(
pObj
->
mutex
)
);
taosThreadMutexLock
(
&
pObj
->
mutex
);
void
*
pTmp
=
taosHashGet
(
pObj
->
pRespHash
,
&
index
,
sizeof
(
index
));
SRespStub
*
pStub
=
taosHashGet
(
pObj
->
pRespHash
,
&
seq
,
sizeof
(
uint64_t
));
if
(
pTmp
!=
NULL
)
{
if
(
pStub
!=
NULL
)
{
memcpy
(
pStub
,
pTmp
,
sizeof
(
SRespStub
));
*
pInfo
=
pStub
->
rpcMsg
.
info
;
sNTrace
(
pObj
->
data
,
"get-and-del message handle:%p, type:%s seq:%"
PRIu64
,
pStub
->
rpcMsg
.
info
.
handle
,
TMSG_INFO
(
pStub
->
rpcMsg
.
msgType
),
seq
);
taosHashRemove
(
pObj
->
pRespHash
,
&
seq
,
sizeof
(
uint64_t
));
sNTrace
(
pObj
->
data
,
"get-and-del message handle, type:%s seq:%"
PRIu64
" handle:%p"
,
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
TMSG_INFO
(
pStub
->
rpcMsg
.
msgType
),
index
,
pStub
->
rpcMsg
.
info
.
handle
);
taosHashRemove
(
pObj
->
pRespHash
,
&
index
,
sizeof
(
index
));
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
return
1
;
// get one object
return
1
;
// get one object
}
}
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
return
0
;
// get none object
}
void
syncRespCleanRsp
(
SSyncRespMgr
*
pObj
)
{
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
taosThreadMutexLock
(
&
(
pObj
->
mutex
));
return
0
;
// get none object
syncRespCleanByTTL
(
pObj
,
-
1
,
true
);
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
}
void
syncRespClean
(
SSyncRespMgr
*
pObj
)
{
taosThreadMutexLock
(
&
(
pObj
->
mutex
));
syncRespCleanByTTL
(
pObj
,
pObj
->
ttl
,
false
);
taosThreadMutexUnlock
(
&
(
pObj
->
mutex
));
}
}
void
syncRespCleanByTTL
(
SSyncRespMgr
*
pObj
,
int64_t
ttl
,
bool
rsp
)
{
static
void
syncRespCleanByTTL
(
SSyncRespMgr
*
pObj
,
int64_t
ttl
,
bool
rsp
)
{
SRespStub
*
pStub
=
(
SRespStub
*
)
taosHashIterate
(
pObj
->
pRespHash
,
NULL
);
SRespStub
*
pStub
=
(
SRespStub
*
)
taosHashIterate
(
pObj
->
pRespHash
,
NULL
);
int
cnt
=
0
;
int
cnt
=
0
;
int
sum
=
0
;
int
sum
=
0
;
SSyncNode
*
pSyncNode
=
pObj
->
data
;
SSyncNode
*
pSyncNode
=
pObj
->
data
;
SArray
*
delIndexArray
=
taosArrayInit
(
0
,
sizeof
(
uint64_t
));
SArray
*
delIndexArray
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
ASSERT
(
delIndexArray
!=
NULL
);
if
(
delIndexArray
==
NULL
)
return
;
sDebug
(
"vgId:%d, resp mgr begin clean by ttl"
,
pSyncNode
->
vgId
);
sDebug
(
"vgId:%d, resp mgr begin clean by ttl"
,
pSyncNode
->
vgId
);
while
(
pStub
)
{
while
(
pStub
)
{
size_t
len
;
size_t
len
;
void
*
key
=
taosHashGetKey
(
pStub
,
&
len
);
void
*
key
=
taosHashGetKey
(
pStub
,
&
len
);
uint64_t
*
pSeqNum
=
(
uint64_t
*
)
key
;
uint64_t
*
pSeqNum
=
(
uint64_t
*
)
key
;
sum
++
;
sum
++
;
...
@@ -149,15 +141,15 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
...
@@ -149,15 +141,15 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
pStub
->
rpcMsg
.
contLen
=
0
;
pStub
->
rpcMsg
.
contLen
=
0
;
// TODO: and make rpcMsg body, call commit cb
// TODO: and make rpcMsg body, call commit cb
// pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &
(pStub->rpcMsg)
, cbMeta);
// pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &
pStub->rpcMsg
, cbMeta);
pStub
->
rpcMsg
.
code
=
TSDB_CODE_SYN_NOT_LEADER
;
pStub
->
rpcMsg
.
code
=
TSDB_CODE_SYN_NOT_LEADER
;
if
(
pStub
->
rpcMsg
.
info
.
handle
!=
NULL
)
{
if
(
pStub
->
rpcMsg
.
info
.
handle
!=
NULL
)
{
tmsgSendRsp
(
&
(
pStub
->
rpcMsg
)
);
tmsgSendRsp
(
&
pStub
->
rpcMsg
);
}
}
}
}
pStub
=
(
SRespStub
*
)
taosHashIterate
(
pObj
->
pRespHash
,
pStub
);
pStub
=
taosHashIterate
(
pObj
->
pRespHash
,
pStub
);
}
}
int32_t
arraySize
=
taosArrayGetSize
(
delIndexArray
);
int32_t
arraySize
=
taosArrayGetSize
(
delIndexArray
);
...
@@ -170,3 +162,15 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
...
@@ -170,3 +162,15 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
}
}
taosArrayDestroy
(
delIndexArray
);
taosArrayDestroy
(
delIndexArray
);
}
}
void
syncRespCleanRsp
(
SSyncRespMgr
*
pObj
)
{
taosThreadMutexLock
(
&
pObj
->
mutex
);
syncRespCleanByTTL
(
pObj
,
-
1
,
true
);
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
}
void
syncRespClean
(
SSyncRespMgr
*
pObj
)
{
taosThreadMutexLock
(
&
pObj
->
mutex
);
syncRespCleanByTTL
(
pObj
,
pObj
->
ttl
,
false
);
taosThreadMutexUnlock
(
&
pObj
->
mutex
);
}
source/libs/sync/src/syncUtil.c
浏览文件 @
2f807a85
...
@@ -205,7 +205,7 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
...
@@ -205,7 +205,7 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
if
(
i
<
pSyncNode
->
replicaNum
-
1
)
{
if
(
i
<
pSyncNode
->
replicaNum
-
1
)
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
" %"
PRId64
", "
,
i
,
pState
->
lastSendIndex
,
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
" %"
PRId64
", "
,
i
,
pState
->
lastSendIndex
,
pState
->
lastSendTime
);
pState
->
lastSendTime
);
}
else
{
}
else
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
" %"
PRId64
"}"
,
i
,
pState
->
lastSendIndex
,
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
" %"
PRId64
"}"
,
i
,
pState
->
lastSendIndex
,
pState
->
lastSendTime
);
pState
->
lastSendTime
);
...
@@ -216,6 +216,9 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
...
@@ -216,6 +216,9 @@ static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
void
syncPrintNodeLog
(
const
char
*
flags
,
ELogLevel
level
,
int32_t
dflag
,
SSyncNode
*
pNode
,
const
char
*
format
,
...)
{
void
syncPrintNodeLog
(
const
char
*
flags
,
ELogLevel
level
,
int32_t
dflag
,
SSyncNode
*
pNode
,
const
char
*
format
,
...)
{
if
(
pNode
==
NULL
||
pNode
->
pRaftCfg
!=
NULL
&&
pNode
->
pRaftStore
==
NULL
||
pNode
->
pLogStore
==
NULL
)
return
;
if
(
pNode
==
NULL
||
pNode
->
pRaftCfg
!=
NULL
&&
pNode
->
pRaftStore
==
NULL
||
pNode
->
pLogStore
==
NULL
)
return
;
// save error code, otherwise it will be overwritten
int32_t
errCode
=
terrno
;
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
if
(
pNode
->
pFsm
!=
NULL
&&
pNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
if
(
pNode
->
pFsm
!=
NULL
&&
pNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
pNode
->
pFsm
->
FpGetSnapshotInfo
(
pNode
->
pFsm
,
&
snapshot
);
pNode
->
pFsm
->
FpGetSnapshotInfo
(
pNode
->
pFsm
,
&
snapshot
);
...
@@ -242,16 +245,21 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
...
@@ -242,16 +245,21 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
int32_t
writeLen
=
vsnprintf
(
eventLog
,
sizeof
(
eventLog
),
format
,
argpointer
);
int32_t
writeLen
=
vsnprintf
(
eventLog
,
sizeof
(
eventLog
),
format
,
argpointer
);
va_end
(
argpointer
);
va_end
(
argpointer
);
int32_t
aqItems
=
pNode
->
pFsm
->
FpApplyQueueItems
(
pNode
->
pFsm
);
// restore error code
terrno
=
errCode
;
taosPrintLog
(
flags
,
level
,
dflag
,
taosPrintLog
(
flags
,
level
,
dflag
,
"vgId:%d, sync %s "
"vgId:%d, sync %s "
"%s"
"%s"
", tm:%"
PRIu64
", cmt:%"
PRId64
", fst:%"
PRId64
", lst:%"
PRId64
", min:%"
PRId64
", snap:%"
PRId64
", tm:%"
PRIu64
", cmt:%"
PRId64
", fst:%"
PRId64
", lst:%"
PRId64
", min:%"
PRId64
", snap:%"
PRId64
", snap-tm:%"
PRIu64
", sby:%d,
stgy
:%d, bch:%d, r-num:%d, lcfg:%"
PRId64
", snap-tm:%"
PRIu64
", sby:%d,
aq
:%d, bch:%d, r-num:%d, lcfg:%"
PRId64
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s, %s"
,
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s, %s"
,
pNode
->
vgId
,
syncStr
(
pNode
->
state
),
eventLog
,
pNode
->
pRaftStore
->
currentTerm
,
pNode
->
commitIndex
,
pNode
->
vgId
,
syncStr
(
pNode
->
state
),
eventLog
,
pNode
->
pRaftStore
->
currentTerm
,
pNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
pNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
logBeginIndex
,
logLastIndex
,
pNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pNode
->
pRaftCfg
->
isStandBy
,
pNode
->
pRaftCfg
->
snapshotStrategy
,
pNode
->
pRaftCfg
->
batchSize
,
pNode
->
pRaftCfg
->
isStandBy
,
aqItems
,
pNode
->
pRaftCfg
->
batchSize
,
pNode
->
replicaNum
,
pNode
->
replicaNum
,
pNode
->
pRaftCfg
->
lastConfigIndex
,
pNode
->
changing
,
pNode
->
restoreFinish
,
quorum
,
pNode
->
pRaftCfg
->
lastConfigIndex
,
pNode
->
changing
,
pNode
->
restoreFinish
,
quorum
,
pNode
->
electTimerLogicClock
,
pNode
->
heartbeatTimerLogicClockUser
,
peerStr
,
cfgStr
);
pNode
->
electTimerLogicClock
,
pNode
->
heartbeatTimerLogicClockUser
,
peerStr
,
cfgStr
);
}
}
...
...
source/libs/transport/src/transCli.c
浏览文件 @
2f807a85
...
@@ -474,7 +474,7 @@ void* destroyConnPool(void* pool) {
...
@@ -474,7 +474,7 @@ void* destroyConnPool(void* pool) {
}
}
static
SCliConn
*
getConnFromPool
(
void
*
pool
,
char
*
ip
,
uint32_t
port
)
{
static
SCliConn
*
getConnFromPool
(
void
*
pool
,
char
*
ip
,
uint32_t
port
)
{
char
key
[
32
]
=
{
0
};
char
key
[
TSDB_FQDN_LEN
+
64
]
=
{
0
};
CONN_CONSTRUCT_HASH_KEY
(
key
,
ip
,
port
);
CONN_CONSTRUCT_HASH_KEY
(
key
,
ip
,
port
);
SConnList
*
plist
=
taosHashGet
((
SHashObj
*
)
pool
,
key
,
strlen
(
key
));
SConnList
*
plist
=
taosHashGet
((
SHashObj
*
)
pool
,
key
,
strlen
(
key
));
...
@@ -525,7 +525,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
...
@@ -525,7 +525,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
conn
->
status
=
ConnInPool
;
conn
->
status
=
ConnInPool
;
if
(
conn
->
list
==
NULL
)
{
if
(
conn
->
list
==
NULL
)
{
char
key
[
32
]
=
{
0
};
char
key
[
TSDB_FQDN_LEN
+
64
]
=
{
0
};
CONN_CONSTRUCT_HASH_KEY
(
key
,
conn
->
ip
,
conn
->
port
);
CONN_CONSTRUCT_HASH_KEY
(
key
,
conn
->
ip
,
conn
->
port
);
tTrace
(
"%s conn %p added to conn pool, read buf cap:%d"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
conn
->
readBuf
.
cap
);
tTrace
(
"%s conn %p added to conn pool, read buf cap:%d"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
conn
->
readBuf
.
cap
);
conn
->
list
=
taosHashGet
((
SHashObj
*
)
pool
,
key
,
strlen
(
key
));
conn
->
list
=
taosHashGet
((
SHashObj
*
)
pool
,
key
,
strlen
(
key
));
...
...
source/util/src/tlog.c
浏览文件 @
2f807a85
...
@@ -317,14 +317,14 @@ static void taosGetLogFileName(char *fn) {
...
@@ -317,14 +317,14 @@ static void taosGetLogFileName(char *fn) {
for
(
int32_t
i
=
0
;
i
<
tsLogObj
.
fileNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
tsLogObj
.
fileNum
;
i
++
)
{
char
fileName
[
LOG_FILE_NAME_LEN
];
char
fileName
[
LOG_FILE_NAME_LEN
];
s
printf
(
fileName
,
"%s%d.0"
,
fn
,
i
);
s
nprintf
(
fileName
,
LOG_FILE_NAME_LEN
,
"%s%d.0"
,
fn
,
i
);
bool
file1open
=
taosCheckFileIsOpen
(
fileName
);
bool
file1open
=
taosCheckFileIsOpen
(
fileName
);
s
printf
(
fileName
,
"%s%d.1"
,
fn
,
i
);
s
nprintf
(
fileName
,
LOG_FILE_NAME_LEN
,
"%s%d.1"
,
fn
,
i
);
bool
file2open
=
taosCheckFileIsOpen
(
fileName
);
bool
file2open
=
taosCheckFileIsOpen
(
fileName
);
if
(
!
file1open
&&
!
file2open
)
{
if
(
!
file1open
&&
!
file2open
)
{
s
printf
(
tsLogObj
.
logName
,
"%s%d"
,
fn
,
i
);
s
nprintf
(
tsLogObj
.
logName
,
LOG_FILE_NAME_LEN
,
"%s%d"
,
fn
,
i
);
return
;
return
;
}
}
}
}
...
@@ -598,7 +598,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg
...
@@ -598,7 +598,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg
remainSize
=
(
start
>
end
)
?
(
start
-
end
-
1
)
:
(
start
+
LOG_BUF_SIZE
(
pLogBuf
)
-
end
-
1
);
remainSize
=
(
start
>
end
)
?
(
start
-
end
-
1
)
:
(
start
+
LOG_BUF_SIZE
(
pLogBuf
)
-
end
-
1
);
if
(
lostLine
>
0
)
{
if
(
lostLine
>
0
)
{
s
printf
(
tmpBuf
,
"...Lost %"
PRId64
" lines here...
\n
"
,
lostLine
);
s
nprintf
(
tmpBuf
,
tListLen
(
tmpBuf
)
,
"...Lost %"
PRId64
" lines here...
\n
"
,
lostLine
);
tmpBufLen
=
(
int32_t
)
strlen
(
tmpBuf
);
tmpBufLen
=
(
int32_t
)
strlen
(
tmpBuf
);
}
}
...
...
tests/script/tsim/stream/basic1.sim
浏览文件 @
2f807a85
...
@@ -23,443 +23,516 @@ sql insert into t1 values(1648791223001,2,2,3,1.1);
...
@@ -23,443 +23,516 @@ sql insert into t1 values(1648791223001,2,2,3,1.1);
sql insert into t1 values(1648791233002,3,2,3,2.1);
sql insert into t1 values(1648791233002,3,2,3,2.1);
sql insert into t1 values(1648791243003,4,2,3,3.1);
sql insert into t1 values(1648791243003,4,2,3,3.1);
sql insert into t1 values(1648791213004,4,2,3,4.1);
sql insert into t1 values(1648791213004,4,2,3,4.1);
sleep 1000
$loop_count = 0
loop0:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
if $rows != 4 then
$loop_count = $loop_count + 1
print ======$rows
if $loop_count == 20 then
return -1
return -1
endi
endi
if $rows != 4 then
print =====rows=$rows
goto loop0
endi
# row 0
# row 0
if $data01 != 2 then
if $data01 != 2 then
print ======$data01
print =====
data01
=$data01
return -1
goto loop0
endi
endi
if $data02 != 2 then
if $data02 != 2 then
print ======$data02
print =====
data02
=$data02
return -1
goto loop0
endi
endi
if $data03 != 5 then
if $data03 != 5 then
print ======$data03
print =====
data03
=$data03
return -1
goto loop0
endi
endi
if $data04 != 2 then
if $data04 != 2 then
print ======$data04
print =====
data04
=$data04
return -1
goto loop0
endi
endi
if $data05 != 3 then
if $data05 != 3 then
print ======$data05
print =====
data05
=$data05
return -1
goto loop0
endi
endi
# row 1
# row 1
if $data11 != 1 then
if $data11 != 1 then
print ======$data11
print =====
data11
=$data11
return -1
goto loop0
endi
endi
if $data12 != 1 then
if $data12 != 1 then
print ======$data12
print =====
data12
=$data12
return -1
goto loop0
endi
endi
if $data13 != 2 then
if $data13 != 2 then
print ======$data13
print =====
data13
=$data13
return -1
goto loop0
endi
endi
if $data14 != 2 then
if $data14 != 2 then
print ======$data14
print =====
data14
=$data14
return -1
goto loop0
endi
endi
if $data15 != 3 then
if $data15 != 3 then
print ======$data15
print =====
data15
=$data15
return -1
goto loop0
endi
endi
# row 2
# row 2
if $data21 != 1 then
if $data21 != 1 then
print ======$data21
print =====
data21
=$data21
return -1
return -1
endi
endi
if $data22 != 1 then
if $data22 != 1 then
print ======$data22
print =====
data22
=$data22
return -1
return -1
endi
endi
if $data23 != 3 then
if $data23 != 3 then
print ======$data23
print =====
data23
=$data23
return -1
return -1
endi
endi
if $data24 != 2 then
if $data24 != 2 then
print ======$data24
print =====
data24
=$data24
return -1
return -1
endi
endi
if $data25 != 3 then
if $data25 != 3 then
print ======$data25
print =====
data25
=$data25
return -1
return -1
endi
endi
# row 3
# row 3
if $data31 != 1 then
if $data31 != 1 then
print ======$data31
print =====
data31
=$data31
return -1
return -1
endi
endi
if $data32 != 1 then
if $data32 != 1 then
print ======$data32
print =====
data32
=$data32
return -1
return -1
endi
endi
if $data33 != 4 then
if $data33 != 4 then
print ======$data33
print =====
data33
=$data33
return -1
return -1
endi
endi
if $data34 != 2 then
if $data34 != 2 then
print ======$data34
print =====
data34
=$data34
return -1
return -1
endi
endi
if $data35 != 3 then
if $data35 != 3 then
print ======$data35
print =====
data35
=$data35
return -1
return -1
endi
endi
sql insert into t1 values(1648791223001,12,14,13,11.1);
sql insert into t1 values(1648791223001,12,14,13,11.1);
sleep 500
$loop_count = 0
loop1:
sleep 200
sql select * from streamt;
sql select * from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
print count(*) , count(d) , sum(a) , max(b) , min(c)
print count(*) , count(d) , sum(a) , max(b) , min(c)
print 0: $data00 , $data01 , $data02 , $data03 , $data04 , $data05
print 0: $data00 , $data01 , $data02 , $data03 , $data04 , $data05
print 1: $data10 , $data11 , $data12 , $data13 , $data14 , $data15
print 1: $data10 , $data11 , $data12 , $data13 , $data14 , $data15
if $rows != 4 then
if $rows != 4 then
print ======$rows
print ======$rows
return -
1
goto loop
1
endi
endi
# row 0
# row 0
if $data01 != 2 then
if $data01 != 2 then
print ======$data01
print =====
data01
=$data01
return -
1
goto loop
1
endi
endi
if $data02 != 2 then
if $data02 != 2 then
print ======$data02
print =====
data02
=$data02
return -
1
goto loop
1
endi
endi
if $data03 != 5 then
if $data03 != 5 then
print ======$data03
print =====
data03
=$data03
return -
1
goto loop
1
endi
endi
if $data04 != 2 then
if $data04 != 2 then
print ======$data04
print =====
data04
=$data04
return -
1
goto loop
1
endi
endi
if $data05 != 3 then
if $data05 != 3 then
print ======$data05
print =====
data05
=$data05
return -
1
goto loop
1
endi
endi
# row 1
# row 1
if $data11 != 1 then
if $data11 != 1 then
print ======$data11
print =====
data11
=$data11
return -
1
goto loop
1
endi
endi
if $data12 != 1 then
if $data12 != 1 then
print ======$data12
print =====
data12
=$data12
return -
1
goto loop
1
endi
endi
if $data13 != 12 then
if $data13 != 12 then
print ======$data13
print =====
data13
=$data13
return -
1
goto loop
1
endi
endi
if $data14 != 14 then
if $data14 != 14 then
print ======$data14
print =====
data14
=$data14
return -
1
goto loop
1
endi
endi
if $data15 != 13 then
if $data15 != 13 then
print ======$data15
print =====
data15
=$data15
return -
1
goto loop
1
endi
endi
# row 2
# row 2
if $data21 != 1 then
if $data21 != 1 then
print ======$data21
print =====
data21
=$data21
return -1
return -1
endi
endi
if $data22 != 1 then
if $data22 != 1 then
print ======$data22
print =====
data22
=$data22
return -1
return -1
endi
endi
if $data23 != 3 then
if $data23 != 3 then
print ======$data23
print =====
data23
=$data23
return -1
return -1
endi
endi
if $data24 != 2 then
if $data24 != 2 then
print ======$data24
print =====
data24
=$data24
return -1
return -1
endi
endi
if $data25 != 3 then
if $data25 != 3 then
print ======$data25
print =====
data25
=$data25
return -1
return -1
endi
endi
# row 3
# row 3
if $data31 != 1 then
if $data31 != 1 then
print ======$data31
print =====
data31
=$data31
return -1
return -1
endi
endi
if $data32 != 1 then
if $data32 != 1 then
print ======$data32
print =====
data32
=$data32
return -1
return -1
endi
endi
if $data33 != 4 then
if $data33 != 4 then
print ======$data33
print =====
data33
=$data33
return -1
return -1
endi
endi
if $data34 != 2 then
if $data34 != 2 then
print ======$data34
print =====
data34
=$data34
return -1
return -1
endi
endi
if $data35 != 3 then
if $data35 != 3 then
print ======$data35
print =====
data35
=$data35
return -1
return -1
endi
endi
sql insert into t1 values(1648791223002,12,14,13,11.1);
sql insert into t1 values(1648791223002,12,14,13,11.1);
sleep 100
$loop_count = 0
loop2:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
# row 1
# row 1
if $data11 != 2 then
if $data11 != 2 then
print ======$data11
print =====
data11
=$data11
return -1
goto loop2
endi
endi
if $data12 != 2 then
if $data12 != 2 then
print ======$data12
print =====
data12
=$data12
return -1
goto loop2
endi
endi
if $data13 != 24 then
if $data13 != 24 then
print ======$data13
print =====
data13
=$data13
return -1
goto loop2
endi
endi
if $data14 != 14 then
if $data14 != 14 then
print ======$data14
print =====
data14
=$data14
return -1
goto loop2
endi
endi
if $data15 != 13 then
if $data15 != 13 then
print ======$data15
print =====
data15
=$data15
return -1
goto loop2
endi
endi
sql insert into t1 values(1648791223003,12,14,13,11.1);
sql insert into t1 values(1648791223003,12,14,13,11.1);
sleep 100
$loop_count = 0
loop3:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
# row 1
# row 1
if $data11 != 3 then
if $data11 != 3 then
print ======$data11
print =====
data11
=$data11
return -1
goto loop3
endi
endi
if $data12 != 3 then
if $data12 != 3 then
print ======$data12
print =====
data12
=$data12
return -1
goto loop3
endi
endi
if $data13 != 36 then
if $data13 != 36 then
print ======$data13
print =====
data13
=$data13
return -1
goto loop3
endi
endi
if $data14 != 14 then
if $data14 != 14 then
print ======$data14
print =====
data14
=$data14
return -1
goto loop3
endi
endi
if $data15 != 13 then
if $data15 != 13 then
print ======$data15
print =====
data15
=$data15
return -1
goto loop3
endi
endi
sql insert into t1 values(1648791223001,1,1,1,1.1);
sql insert into t1 values(1648791223001,1,1,1,1.1);
sql insert into t1 values(1648791223002,2,2,2,2.1);
sql insert into t1 values(1648791223002,2,2,2,2.1);
sql insert into t1 values(1648791223003,3,3,3,3.1);
sql insert into t1 values(1648791223003,3,3,3,3.1);
sleep 100
$loop_count = 0
loop4:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
# row 1
# row 1
if $data11 != 3 then
if $data11 != 3 then
print ======$data11
print =====
data11
=$data11
return -1
goto loop4
endi
endi
if $data12 != 3 then
if $data12 != 3 then
print ======$data12
print =====
data12
=$data12
return -1
goto loop4
endi
endi
if $data13 != 6 then
if $data13 != 6 then
print ======$data13
print =====
data13
=$data13
return -1
goto loop4
endi
endi
if $data14 != 3 then
if $data14 != 3 then
print ======$data14
print =====
data14
=$data14
return -1
goto loop4
endi
endi
if $data15 != 1 then
if $data15 != 1 then
print ======$data15
print =====
data15
=$data15
return -1
goto loop4
endi
endi
sql insert into t1 values(1648791233003,3,2,3,2.1);
sql insert into t1 values(1648791233003,3,2,3,2.1);
sql insert into t1 values(1648791233002,5,6,7,8.1);
sql insert into t1 values(1648791233002,5,6,7,8.1);
sql insert into t1 values(1648791233002,3,2,3,2.1);
sql insert into t1 values(1648791233002,3,2,3,2.1);
sleep 100
$loop_count = 0
loop5:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
# row 2
# row 2
if $data21 != 2 then
if $data21 != 2 then
print ======$data21
print =====
data21
=$data21
return -1
goto loop5
endi
endi
if $data22 != 2 then
if $data22 != 2 then
print ======$data22
print =====
data22
=$data22
return -1
goto loop5
endi
endi
if $data23 != 6 then
if $data23 != 6 then
print ======$data23
print =====
data23
=$data23
return -1
goto loop5
endi
endi
if $data24 != 2 then
if $data24 != 2 then
print ======$data24
print =====
data24
=$data24
return -1
goto loop5
endi
endi
if $data25 != 3 then
if $data25 != 3 then
print ======$data25
print =====
data25
=$data25
return -1
goto loop5
endi
endi
sql insert into t1 values(1648791213004,4,2,3,4.1) (1648791213006,5,4,7,9.1) (1648791213004,40,20,30,40.1) (1648791213005,4,2,3,4.1);
sql insert into t1 values(1648791213004,4,2,3,4.1) (1648791213006,5,4,7,9.1) (1648791213004,40,20,30,40.1) (1648791213005,4,2,3,4.1);
sleep 100
$loop_count = 0
loop6:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
# row 0
# row 0
if $data01 != 4 then
if $data01 != 4 then
print ======$data01
print =====
data01
=$data01
return -1
goto loop6
endi
endi
if $data02 != 4 then
if $data02 != 4 then
print ======$data02
print =====
data02
=$data02
return -1
goto loop6
endi
endi
if $data03 != 50 then
if $data03 != 50 then
print ======$data03 != 50
print =====
data03
=$data03 != 50
return -1
goto loop6
endi
endi
if $data04 != 20 then
if $data04 != 20 then
print ======$data04 != 20
print =====
data04
=$data04 != 20
return -1
goto loop6
endi
endi
if $data05 != 3 then
if $data05 != 3 then
print ======$data05
print =====
data05
=$data05
return -1
goto loop6
endi
endi
sql insert into t1 values(1648791223004,4,2,3,4.1) (1648791233006,5,4,7,9.1) (1648791223004,40,20,30,40.1) (1648791233005,4,2,3,4.1);
sql insert into t1 values(1648791223004,4,2,3,4.1) (1648791233006,5,4,7,9.1) (1648791223004,40,20,30,40.1) (1648791233005,4,2,3,4.1);
sleep 100
$loop_count = 0
loop7:
sleep 200
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
$loop_count = $loop_count + 1
if $loop_count == 20 then
return -1
endi
# row 1
# row 1
if $data11 != 4 then
if $data11 != 4 then
print ======$data11
print =====
data11
=$data11
return -1
goto loop7
endi
endi
if $data12 != 4 then
if $data12 != 4 then
print ======$data12
print =====
data12
=$data12
return -1
goto loop7
endi
endi
if $data13 != 46 then
if $data13 != 46 then
print ======$data13 != 46
print =====
data13
=$data13 != 46
return -1
goto loop7
endi
endi
if $data14 != 20 then
if $data14 != 20 then
print ======$data14 != 20
print =====
data14
=$data14 != 20
return -1
goto loop7
endi
endi
if $data15 != 1 then
if $data15 != 1 then
print ======$data15
print =====
data15
=$data15
return -1
goto loop7
endi
endi
# row 2
# row 2
if $data21 != 4 then
if $data21 != 4 then
print ======$data21
print =====
data21
=$data21
return -1
goto loop7
endi
endi
if $data22 != 4 then
if $data22 != 4 then
print ======$data22
print =====
data22
=$data22
return -1
goto loop7
endi
endi
if $data23 != 15 then
if $data23 != 15 then
print ======$data23
print =====
data23
=$data23
return -1
goto loop7
endi
endi
if $data24 != 4 then
if $data24 != 4 then
print ======$data24
print =====
data24
=$data24
return -1
goto loop7
endi
endi
if $data25 != 3 then
if $data25 != 3 then
print ======$data25
print =====
data25
=$data25
return -1
goto loop7
endi
endi
sql create database test2 vgroups 1;
sql create database test2 vgroups 1;
...
@@ -479,11 +552,11 @@ sql insert into t1 values(1648791213000,1,1,1,1.0) t2 values(1648791213000,2,2,2
...
@@ -479,11 +552,11 @@ sql insert into t1 values(1648791213000,1,1,1,1.0) t2 values(1648791213000,2,2,2
$loop_count = 0
$loop_count = 0
loop
0
:
loop
8
:
sleep
3
00
sleep
2
00
$loop_count = $loop_count + 1
$loop_count = $loop_count + 1
if $loop_count ==
1
0 then
if $loop_count ==
2
0 then
return -1
return -1
endi
endi
...
@@ -491,7 +564,7 @@ sql select * from streamt;
...
@@ -491,7 +564,7 @@ sql select * from streamt;
if $rows != 4 then
if $rows != 4 then
print =====rows=$rows
print =====rows=$rows
goto loop
0
goto loop
8
endi
endi
sql insert into t1 values(1648791213000,5,5,5,5.0) t2 values(1648791213000,6,6,6,6.0) t5 values(1648791213000,7,7,7,7.0);
sql insert into t1 values(1648791213000,5,5,5,5.0) t2 values(1648791213000,6,6,6,6.0) t5 values(1648791213000,7,7,7,7.0);
...
@@ -499,11 +572,11 @@ sql insert into t1 values(1648791213000,5,5,5,5.0) t2 values(1648791213000,6,6,6
...
@@ -499,11 +572,11 @@ sql insert into t1 values(1648791213000,5,5,5,5.0) t2 values(1648791213000,6,6,6
$loop_count = 0
$loop_count = 0
loop
1
:
loop
9
:
sleep
3
00
sleep
2
00
$loop_count = $loop_count + 1
$loop_count = $loop_count + 1
if $loop_count ==
1
0 then
if $loop_count ==
2
0 then
return -1
return -1
endi
endi
...
@@ -511,51 +584,51 @@ sql select * from streamt order by c4 desc;
...
@@ -511,51 +584,51 @@ sql select * from streamt order by c4 desc;
if $rows != 5 then
if $rows != 5 then
print =====rows=$rows
print =====rows=$rows
goto loop
1
goto loop
9
endi
endi
# row 0
# row 0
if $data01 != 1 then
if $data01 != 1 then
print =====data01=$data01
print =====data01=$data01
goto loop
1
goto loop
9
endi
endi
if $data02 != 7 then
if $data02 != 7 then
print =====data02=$data02
print =====data02=$data02
goto loop
1
goto loop
9
endi
endi
# row 1
# row 1
if $data11 != 1 then
if $data11 != 1 then
print =====data11=$data11
print =====data11=$data11
goto loop
1
goto loop
9
endi
endi
if $data12 != 6 then
if $data12 != 6 then
print =====data12=$data12
print =====data12=$data12
goto loop
1
goto loop
9
endi
endi
# row 2
# row 2
if $data21 != 1 then
if $data21 != 1 then
print =====data21=$data21
print =====data21=$data21
goto loop
1
goto loop
9
endi
endi
if $data22 != 5 then
if $data22 != 5 then
print =====data22=$data22
print =====data22=$data22
goto loop
1
goto loop
9
endi
endi
sql insert into t1 values(1648791213000,8,8,8,8.0);
sql insert into t1 values(1648791213000,8,8,8,8.0);
$loop_count = 0
$loop_count = 0
loop
2
:
loop
10
:
sleep
3
00
sleep
2
00
$loop_count = $loop_count + 1
$loop_count = $loop_count + 1
if $loop_count ==
1
0 then
if $loop_count ==
2
0 then
return -1
return -1
endi
endi
...
@@ -564,28 +637,29 @@ sql select * from streamt order by c4 desc;
...
@@ -564,28 +637,29 @@ sql select * from streamt order by c4 desc;
# row 0
# row 0
if $data01 != 1 then
if $data01 != 1 then
print =====data01=$data01
print =====data01=$data01
goto loop
2
goto loop
10
endi
endi
if $data02 != 8 then
if $data02 != 8 then
print =====data02=$data02
print =====data02=$data02
goto loop
2
goto loop
10
endi
endi
$loop_count = 0
$loop_count = 0
loop3:
loop11:
sleep 300
sleep 200
sql select count(*) from streamt3;
$loop_count = $loop_count + 1
$loop_count = $loop_count + 1
if $loop_count ==
1
0 then
if $loop_count ==
2
0 then
return -1
return -1
endi
endi
sql select count(*) from streamt3;
# row 0
# row 0
if $data00 != 5 then
if $data00 != 5 then
print =====data00=$data00
print =====data00=$data00
goto loop
3
goto loop
11
endi
endi
#max,min selectivity
#max,min selectivity
...
@@ -601,25 +675,26 @@ sql insert into ts1 values(1648791222001,2,2,3);
...
@@ -601,25 +675,26 @@ sql insert into ts1 values(1648791222001,2,2,3);
sleep 50
sleep 50
$loop_count = 0
$loop_count = 0
loop3:
loop12:
sleep 200
sql select * from streamtST3;
sql select * from streamtST3;
sleep 300
$loop_count = $loop_count + 1
$loop_count = $loop_count + 1
if $loop_count ==
1
0 then
if $loop_count ==
2
0 then
return -1
return -1
endi
endi
# row 0
# row 0
if $data02 != 1 then
if $data02 != 1 then
print =====data02=$data02
print =====data02=$data02
goto loop
3
goto loop
12
endi
endi
# row 1
# row 1
if $data12 != 2 then
if $data12 != 2 then
print =====data12=$data12
print =====data12=$data12
goto loop
3
goto loop
12
endi
endi
...
@@ -629,19 +704,22 @@ sql create table t1(ts timestamp, a int, b int , c int, d double);
...
@@ -629,19 +704,22 @@ sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from t1 where a > 5 interval(10s);
sql create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from t1 where a > 5 interval(10s);
sql insert into t1 values(1648791213000,1,2,3,1.0);
sql insert into t1 values(1648791213000,1,2,3,1.0);
$loop_count = 0
loop13:
sleep 200
sleep 200
sql select * from streamt4;
sql select * from streamt4;
# row 0
# row 0
if $rows != 0 then
if $rows != 0 then
print =====rows=$rows
print =====rows=$rows
return -1
goto loop13
endi
endi
sql insert into t1 values(1648791213000,6,2,3,1.0);
sql insert into t1 values(1648791213000,6,2,3,1.0);
$loop_count = 0
$loop_count = 0
loop4:
loop
1
4:
sleep 200
sleep 200
sql select * from streamt4;
sql select * from streamt4;
...
@@ -652,13 +730,13 @@ endi
...
@@ -652,13 +730,13 @@ endi
if $data01 != 1 then
if $data01 != 1 then
print =====data01=$data01
print =====data01=$data01
goto loop4
goto loop
1
4
endi
endi
sql insert into t1 values(1648791213000,2,2,3,1.0);
sql insert into t1 values(1648791213000,2,2,3,1.0);
$loop_count = 0
$loop_count = 0
loop5:
loop
1
5:
sleep 200
sleep 200
sql select * from streamt4;
sql select * from streamt4;
...
@@ -669,7 +747,7 @@ endi
...
@@ -669,7 +747,7 @@ endi
if $rows != 0 then
if $rows != 0 then
print =====rows=$rows
print =====rows=$rows
goto loop5
goto loop
1
5
endi
endi
...
...
tests/script/tsim/stream/session0.sim
浏览文件 @
2f807a85
...
@@ -201,7 +201,7 @@ if $loop_count == 10 then
...
@@ -201,7 +201,7 @@ if $loop_count == 10 then
endi
endi
if $rows != 1 then
if $rows != 1 then
print ======$rows
print =====
rows
=$rows
goto loop2
goto loop2
endi
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录