Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
244b552f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
244b552f
编写于
1月 28, 2022
作者:
L
Liu Jicong
提交者:
GitHub
1月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10076 from taosdata/feature/tq
mq support stable subscribe
上级
236393e1
610c812e
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
707 addition
and
563 deletion
+707
-563
include/client/taos.h
include/client/taos.h
+9
-7
include/common/common.h
include/common/common.h
+4
-0
include/libs/executor/executor.h
include/libs/executor/executor.h
+12
-2
include/libs/function/function.h
include/libs/function/function.h
+15
-15
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+4
-4
include/libs/planner/plannerOp.h
include/libs/planner/plannerOp.h
+2
-1
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+190
-111
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+56
-6
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+47
-30
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-0
source/dnode/vnode/inc/tsdb.h
source/dnode/vnode/inc/tsdb.h
+13
-13
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+5
-5
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+6
-7
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+40
-46
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+5
-3
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+10
-10
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+2
-2
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+1
-19
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+135
-154
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+2
-2
source/libs/function/inc/taggfunction.h
source/libs/function/inc/taggfunction.h
+1
-1
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+109
-109
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+1
-1
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+32
-12
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+0
-3
source/util/src/terror.c
source/util/src/terror.c
+3
-0
src/connector/grafanaplugin
src/connector/grafanaplugin
+1
-0
未找到文件。
include/client/taos.h
浏览文件 @
244b552f
...
@@ -204,12 +204,19 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
...
@@ -204,12 +204,19 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
);
DLL_EXPORT
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
);
/* --------------------------TMQ INTERFACE------------------------------- */
typedef
struct
tmq_resp_err_t
tmq_resp_err_t
;
typedef
struct
tmq_topic_vgroup_t
tmq_topic_vgroup_t
;
typedef
struct
tmq_topic_vgroup_list_t
tmq_topic_vgroup_list_t
;
typedef
void
(
tmq_commit_cb
(
tmq_t
*
,
tmq_resp_err_t
,
tmq_topic_vgroup_list_t
*
,
void
*
param
));
DLL_EXPORT
tmq_list_t
*
tmq_list_new
();
DLL_EXPORT
tmq_list_t
*
tmq_list_new
();
DLL_EXPORT
int32_t
tmq_list_append
(
tmq_list_t
*
,
char
*
);
DLL_EXPORT
int32_t
tmq_list_append
(
tmq_list_t
*
,
char
*
);
DLL_EXPORT
tmq_conf_t
*
tmq_conf_new
();
DLL_EXPORT
tmq_conf_t
*
tmq_conf_new
();
DLL_EXPORT
int32_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
);
DLL_EXPORT
int32_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
);
DLL_EXPORT
void
tmq_conf_set_offset_commit_cb
(
tmq_conf_t
*
conf
,
tmq_commit_cb
*
cb
);
DLL_EXPORT
TAOS_RES
*
taos_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
);
DLL_EXPORT
TAOS_RES
*
taos_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
);
...
@@ -217,13 +224,8 @@ DLL_EXPORT tmq_t* taos_consumer_new(void* conn, tmq_conf_t* conf, char* errstr,
...
@@ -217,13 +224,8 @@ DLL_EXPORT tmq_t* taos_consumer_new(void* conn, tmq_conf_t* conf, char* errstr,
DLL_EXPORT
TAOS_RES
*
tmq_subscribe
(
tmq_t
*
tmq
,
tmq_list_t
*
topic_list
);
DLL_EXPORT
TAOS_RES
*
tmq_subscribe
(
tmq_t
*
tmq
,
tmq_list_t
*
topic_list
);
DLL_EXPORT
tmq_message_t
*
tmq_consume_poll
(
tmq_t
*
tmq
,
int64_t
blocking_time
);
DLL_EXPORT
tmq_message_t
*
tmq_consumer_poll
(
tmq_t
*
tmq
,
int64_t
blocking_time
);
DLL_EXPORT
tmq_resp_err_t
*
tmq_commit
(
tmq_t
*
tmq
,
tmq_topic_vgroup_list_t
*
tmq_topic_vgroup_list
,
int32_t
async
);
DLL_EXPORT
int32_t
tmq_topic_num
(
tmq_message_t
*
msg
);
DLL_EXPORT
char
*
tmq_get_topic
(
tmq_message_topic_t
*
msg
);
DLL_EXPORT
int32_t
tmq_get_vgId
(
tmq_message_topic_t
*
msg
);
DLL_EXPORT
tmq_message_tb_t
*
tmq_get_next_tb
(
tmq_message_topic_t
*
msg
,
tmq_tb_iter_t
*
iter
);
DLL_EXPORT
tmq_message_col_t
*
tmq_get_next_col
(
tmq_message_tb_t
*
msg
,
tmq_col_iter_t
*
iter
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/common/common.h
浏览文件 @
244b552f
...
@@ -38,6 +38,10 @@
...
@@ -38,6 +38,10 @@
// int16_t bytes;
// int16_t bytes;
//} SSchema;
//} SSchema;
#define TMQ_REQ_TYPE_COMMIT_ONLY 0
#define TMQ_REQ_TYPE_CONSUME_ONLY 1
#define TMQ_REQ_TYPE_CONSUME_AND_COMMIT 2
typedef
struct
{
typedef
struct
{
uint32_t
numOfTables
;
uint32_t
numOfTables
;
SArray
*
pGroupList
;
SArray
*
pGroupList
;
...
...
include/libs/executor/executor.h
浏览文件 @
244b552f
...
@@ -27,6 +27,10 @@ typedef void* DataSinkHandle;
...
@@ -27,6 +27,10 @@ typedef void* DataSinkHandle;
struct
SRpcMsg
;
struct
SRpcMsg
;
struct
SSubplan
;
struct
SSubplan
;
typedef
struct
SReadHandle
{
void
*
reader
;
void
*
meta
;
}
SReadHandle
;
/**
/**
* Create the exec task for streaming mode
* Create the exec task for streaming mode
* @param pMsg
* @param pMsg
...
@@ -35,7 +39,13 @@ struct SSubplan;
...
@@ -35,7 +39,13 @@ struct SSubplan;
*/
*/
qTaskInfo_t
qCreateStreamExecTaskInfo
(
void
*
msg
,
void
*
streamReadHandle
);
qTaskInfo_t
qCreateStreamExecTaskInfo
(
void
*
msg
,
void
*
streamReadHandle
);
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
void
*
input
);
/**
*
* @param tinfo
* @param input
* @return
*/
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
);
/**
/**
* Create the exec task object according to task json
* Create the exec task object according to task json
...
@@ -46,7 +56,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, void* input);
...
@@ -46,7 +56,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, void* input);
* @param qId
* @param qId
* @return
* @return
*/
*/
int32_t
qCreateExecTask
(
void
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
struct
SSubplan
*
pPlan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
);
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
struct
SSubplan
*
pPlan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
);
/**
/**
* The main task execution function, including query on both table and multiple tables,
* The main task execution function, including query on both table and multiple tables,
...
...
include/libs/function/function.h
浏览文件 @
244b552f
...
@@ -107,14 +107,14 @@ typedef struct SPoint1 {
...
@@ -107,14 +107,14 @@ typedef struct SPoint1 {
union
{
double
val
;
char
*
ptr
;};
union
{
double
val
;
char
*
ptr
;};
}
SPoint1
;
}
SPoint1
;
struct
S
QL
FunctionCtx
;
struct
S
ql
FunctionCtx
;
struct
SResultRowEntryInfo
;
struct
SResultRowEntryInfo
;
//for selectivity query, the corresponding tag value is assigned if the data is qualified
//for selectivity query, the corresponding tag value is assigned if the data is qualified
typedef
struct
SExtTagsInfo
{
typedef
struct
SExtTagsInfo
{
int16_t
tagsLen
;
// keep the tags data for top/bottom query result
int16_t
tagsLen
;
// keep the tags data for top/bottom query result
int16_t
numOfTagCols
;
int16_t
numOfTagCols
;
struct
S
QL
FunctionCtx
**
pTagCtxList
;
struct
S
ql
FunctionCtx
**
pTagCtxList
;
}
SExtTagsInfo
;
}
SExtTagsInfo
;
typedef
struct
SResultDataInfo
{
typedef
struct
SResultDataInfo
{
...
@@ -126,18 +126,18 @@ typedef struct SResultDataInfo {
...
@@ -126,18 +126,18 @@ typedef struct SResultDataInfo {
#define GET_RES_INFO(ctx) ((ctx)->resultInfo)
#define GET_RES_INFO(ctx) ((ctx)->resultInfo)
typedef
struct
SFunctionFpSet
{
typedef
struct
SFunctionFpSet
{
bool
(
*
init
)(
struct
S
QL
FunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
// setup the execute environment
bool
(
*
init
)(
struct
S
ql
FunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
// setup the execute environment
void
(
*
addInput
)(
struct
S
QL
FunctionCtx
*
pCtx
);
void
(
*
addInput
)(
struct
S
ql
FunctionCtx
*
pCtx
);
// finalizer must be called after all exec has been executed to generated final result.
// finalizer must be called after all exec has been executed to generated final result.
void
(
*
finalize
)(
struct
S
QL
FunctionCtx
*
pCtx
);
void
(
*
finalize
)(
struct
S
ql
FunctionCtx
*
pCtx
);
void
(
*
combine
)(
struct
S
QL
FunctionCtx
*
pCtx
);
void
(
*
combine
)(
struct
S
ql
FunctionCtx
*
pCtx
);
}
SFunctionFpSet
;
}
SFunctionFpSet
;
extern
SFunctionFpSet
fpSet
[
1
];
extern
SFunctionFpSet
fpSet
[
1
];
// sql function runtime context
// sql function runtime context
typedef
struct
S
QL
FunctionCtx
{
typedef
struct
S
ql
FunctionCtx
{
int32_t
size
;
// number of rows
int32_t
size
;
// number of rows
void
*
pInput
;
// input data buffer
void
*
pInput
;
// input data buffer
uint32_t
order
;
// asc|desc
uint32_t
order
;
// asc|desc
...
@@ -167,7 +167,7 @@ typedef struct SQLFunctionCtx {
...
@@ -167,7 +167,7 @@ typedef struct SQLFunctionCtx {
int32_t
columnIndex
;
int32_t
columnIndex
;
SFunctionFpSet
*
fpSet
;
SFunctionFpSet
*
fpSet
;
}
S
QL
FunctionCtx
;
}
S
ql
FunctionCtx
;
enum
{
enum
{
TEXPR_NODE_DUMMY
=
0x0
,
TEXPR_NODE_DUMMY
=
0x0
,
...
@@ -216,14 +216,14 @@ typedef struct SAggFunctionInfo {
...
@@ -216,14 +216,14 @@ typedef struct SAggFunctionInfo {
int8_t
sFunctionId
;
// Transfer function for super table query
int8_t
sFunctionId
;
// Transfer function for super table query
uint16_t
status
;
uint16_t
status
;
bool
(
*
init
)(
S
QL
FunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
// setup the execute environment
bool
(
*
init
)(
S
ql
FunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
// setup the execute environment
void
(
*
addInput
)(
S
QL
FunctionCtx
*
pCtx
);
void
(
*
addInput
)(
S
ql
FunctionCtx
*
pCtx
);
// finalizer must be called after all exec has been executed to generated final result.
// finalizer must be called after all exec has been executed to generated final result.
void
(
*
finalize
)(
S
QL
FunctionCtx
*
pCtx
);
void
(
*
finalize
)(
S
ql
FunctionCtx
*
pCtx
);
void
(
*
combine
)(
S
QL
FunctionCtx
*
pCtx
);
void
(
*
combine
)(
S
ql
FunctionCtx
*
pCtx
);
int32_t
(
*
dataReqFunc
)(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
);
int32_t
(
*
dataReqFunc
)(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
);
}
SAggFunctionInfo
;
}
SAggFunctionInfo
;
struct
SScalarFuncParam
;
struct
SScalarFuncParam
;
...
@@ -279,9 +279,9 @@ void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc);
...
@@ -279,9 +279,9 @@ void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc);
tExprNode
*
exprdup
(
tExprNode
*
pTree
);
tExprNode
*
exprdup
(
tExprNode
*
pTree
);
void
resetResultRowEntryResult
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
num
);
void
resetResultRowEntryResult
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
num
);
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
);
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
);
int32_t
getNumOfResult
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
num
);
int32_t
getNumOfResult
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
num
);
bool
isRowEntryCompleted
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryCompleted
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
);
...
...
include/libs/function/functionMgt.h
浏览文件 @
244b552f
...
@@ -22,7 +22,7 @@ extern "C" {
...
@@ -22,7 +22,7 @@ extern "C" {
#include "nodes.h"
#include "nodes.h"
struct
S
QL
FunctionCtx
;
struct
S
ql
FunctionCtx
;
struct
SResultRowEntryInfo
;
struct
SResultRowEntryInfo
;
struct
STimeWindow
;
struct
STimeWindow
;
...
@@ -32,9 +32,9 @@ typedef struct SFuncExecEnv {
...
@@ -32,9 +32,9 @@ typedef struct SFuncExecEnv {
typedef
void
*
FuncMgtHandle
;
typedef
void
*
FuncMgtHandle
;
typedef
bool
(
*
FExecGetEnv
)(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
typedef
bool
(
*
FExecGetEnv
)(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
typedef
bool
(
*
FExecInit
)(
struct
S
QL
FunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
typedef
bool
(
*
FExecInit
)(
struct
S
ql
FunctionCtx
*
pCtx
,
struct
SResultRowEntryInfo
*
pResultCellInfo
);
typedef
void
(
*
FExecProcess
)(
struct
S
QL
FunctionCtx
*
pCtx
);
typedef
void
(
*
FExecProcess
)(
struct
S
ql
FunctionCtx
*
pCtx
);
typedef
void
(
*
FExecFinalize
)(
struct
S
QL
FunctionCtx
*
pCtx
);
typedef
void
(
*
FExecFinalize
)(
struct
S
ql
FunctionCtx
*
pCtx
);
typedef
struct
SFuncExecFuncs
{
typedef
struct
SFuncExecFuncs
{
FExecGetEnv
getEnv
;
FExecGetEnv
getEnv
;
...
...
include/libs/planner/plannerOp.h
浏览文件 @
244b552f
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#endif
#endif
OP_ENUM_MACRO
(
StreamScan
)
OP_ENUM_MACRO
(
StreamScan
)
OP_ENUM_MACRO
(
TableScan
)
OP_ENUM_MACRO
(
DataBlocksOptScan
)
OP_ENUM_MACRO
(
DataBlocksOptScan
)
OP_ENUM_MACRO
(
TableSeqScan
)
OP_ENUM_MACRO
(
TableSeqScan
)
OP_ENUM_MACRO
(
TagScan
)
OP_ENUM_MACRO
(
TagScan
)
...
@@ -48,3 +47,5 @@ OP_ENUM_MACRO(AllTimeWindow)
...
@@ -48,3 +47,5 @@ OP_ENUM_MACRO(AllTimeWindow)
OP_ENUM_MACRO
(
AllMultiTableTimeInterval
)
OP_ENUM_MACRO
(
AllMultiTableTimeInterval
)
OP_ENUM_MACRO
(
Order
)
OP_ENUM_MACRO
(
Order
)
OP_ENUM_MACRO
(
Exchange
)
OP_ENUM_MACRO
(
Exchange
)
//OP_ENUM_MACRO(TableScan)
include/util/taoserror.h
浏览文件 @
244b552f
...
@@ -254,6 +254,7 @@ int32_t* taosGetErrno();
...
@@ -254,6 +254,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_TOPIC_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03E5)
#define TSDB_CODE_MND_TOPIC_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03E5)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_STB TAOS_DEF_ERROR_CODE(0, 0x03E6)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_STB TAOS_DEF_ERROR_CODE(0, 0x03E6)
#define TSDB_CODE_MND_CONSUMER_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E7)
#define TSDB_CODE_MND_CONSUMER_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E7)
#define TSDB_CODE_MND_UNSUPPORTED_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03E7)
// dnode
// dnode
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
...
...
source/client/src/clientImpl.c
浏览文件 @
244b552f
#include "../../libs/scheduler/inc/schedulerInt.h"
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "clientLog.h"
#include "parser.h"
#include "parser.h"
...
@@ -22,6 +21,93 @@
...
@@ -22,6 +21,93 @@
} \
} \
} while (0)
} while (0)
typedef
struct
SMqClientVg
{
// statistics
int64_t
pollCnt
;
// offset
int64_t
committedOffset
;
int64_t
currentOffset
;
//connection info
int32_t
vgId
;
SEpSet
epSet
;
}
SMqClientVg
;
typedef
struct
SMqClientTopic
{
// subscribe info
int32_t
sqlLen
;
char
*
sql
;
char
*
topicName
;
int64_t
topicId
;
int32_t
nextVgIdx
;
SArray
*
vgs
;
//SArray<SMqClientVg>
}
SMqClientTopic
;
struct
tmq_resp_err_t
{
int32_t
code
;
};
struct
tmq_topic_vgroup_t
{
char
*
topic
;
int32_t
vgId
;
int64_t
commitOffset
;
};
struct
tmq_topic_vgroup_list_t
{
int32_t
cnt
;
int32_t
size
;
tmq_topic_vgroup_t
*
elems
;
};
typedef
struct
SMqConsumeCbParam
{
tmq_t
*
tmq
;
SMqClientVg
*
pVg
;
tmq_message_t
**
retMsg
;
}
SMqConsumeCbParam
;
struct
tmq_conf_t
{
char
clientId
[
256
];
char
groupId
[
256
];
char
*
ip
;
uint16_t
port
;
tmq_commit_cb
*
commit_cb
;
};
struct
tmq_message_t
{
SMqConsumeRsp
rsp
;
};
tmq_conf_t
*
tmq_conf_new
()
{
tmq_conf_t
*
conf
=
calloc
(
1
,
sizeof
(
tmq_conf_t
));
return
conf
;
}
int32_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
)
{
if
(
strcmp
(
key
,
"group.id"
)
==
0
)
{
strcpy
(
conf
->
groupId
,
value
);
}
if
(
strcmp
(
key
,
"client.id"
)
==
0
)
{
strcpy
(
conf
->
clientId
,
value
);
}
return
0
;
}
struct
tmq_t
{
char
groupId
[
256
];
char
clientId
[
256
];
SRWLatch
lock
;
int64_t
consumerId
;
int64_t
epoch
;
int64_t
status
;
tsem_t
rspSem
;
STscObj
*
pTscObj
;
tmq_commit_cb
*
commit_cb
;
int32_t
nextTopicIdx
;
SArray
*
clientTopics
;
//SArray<SMqClientTopic>
//stat
int64_t
pollCnt
;
};
static
int32_t
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
);
static
int32_t
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
);
static
SMsgSendInfo
*
buildConnectMsg
(
SRequestObj
*
pRequest
);
static
SMsgSendInfo
*
buildConnectMsg
(
SRequestObj
*
pRequest
);
static
void
destroySendMsgInfo
(
SMsgSendInfo
*
pMsgBody
);
static
void
destroySendMsgInfo
(
SMsgSendInfo
*
pMsgBody
);
...
@@ -260,83 +346,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, SArray* pNodeList)
...
@@ -260,83 +346,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, SArray* pNodeList)
}
}
typedef
struct
SMqClientVg
{
// statistics
int64_t
pollCnt
;
// offset
int64_t
committedOffset
;
int64_t
currentOffset
;
//connection info
int32_t
vgId
;
SEpSet
epSet
;
}
SMqClientVg
;
typedef
struct
SMqClientTopic
{
// subscribe info
int32_t
sqlLen
;
char
*
sql
;
char
*
topicName
;
int64_t
topicId
;
int32_t
nextVgIdx
;
SArray
*
vgs
;
//SArray<SMqClientVg>
}
SMqClientTopic
;
typedef
struct
tmq_resp_err_t
{
int32_t
code
;
}
tmq_resp_err_t
;
typedef
struct
tmq_topic_vgroup_t
{
char
*
topic
;
int32_t
vgId
;
int64_t
commitOffset
;
}
tmq_topic_vgroup_t
;
typedef
struct
tmq_topic_vgroup_list_t
{
int32_t
cnt
;
int32_t
size
;
tmq_topic_vgroup_t
*
elems
;
}
tmq_topic_vgroup_list_t
;
typedef
void
(
tmq_commit_cb
(
tmq_t
*
,
tmq_resp_err_t
,
tmq_topic_vgroup_list_t
*
,
void
*
param
));
struct
tmq_conf_t
{
char
clientId
[
256
];
char
groupId
[
256
];
char
*
ip
;
uint16_t
port
;
tmq_commit_cb
*
commit_cb
;
};
tmq_conf_t
*
tmq_conf_new
()
{
tmq_conf_t
*
conf
=
calloc
(
1
,
sizeof
(
tmq_conf_t
));
return
conf
;
}
int32_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
)
{
if
(
strcmp
(
key
,
"group.id"
)
==
0
)
{
strcpy
(
conf
->
groupId
,
value
);
}
if
(
strcmp
(
key
,
"client.id"
)
==
0
)
{
strcpy
(
conf
->
clientId
,
value
);
}
return
0
;
}
struct
tmq_t
{
char
groupId
[
256
];
char
clientId
[
256
];
SRWLatch
lock
;
int64_t
consumerId
;
int64_t
epoch
;
int64_t
status
;
tsem_t
rspSem
;
STscObj
*
pTscObj
;
tmq_commit_cb
*
commit_cb
;
int32_t
nextTopicIdx
;
SArray
*
clientTopics
;
//SArray<SMqClientTopic>
//stat
int64_t
pollCnt
;
};
tmq_t
*
taos_consumer_new
(
void
*
conn
,
tmq_conf_t
*
conf
,
char
*
errstr
,
int32_t
errstrLen
)
{
tmq_t
*
taos_consumer_new
(
void
*
conn
,
tmq_conf_t
*
conf
,
char
*
errstr
,
int32_t
errstrLen
)
{
tmq_t
*
pTmq
=
calloc
(
sizeof
(
tmq_t
),
1
);
tmq_t
*
pTmq
=
calloc
(
sizeof
(
tmq_t
),
1
);
...
@@ -583,7 +592,7 @@ TAOS_RES *taos_create_topic(TAOS* taos, const char* topicName, const char* sql,
...
@@ -583,7 +592,7 @@ TAOS_RES *taos_create_topic(TAOS* taos, const char* topicName, const char* sql,
int
tlen
=
tSerializeSCMCreateTopicReq
(
NULL
,
&
req
);
int
tlen
=
tSerializeSCMCreateTopicReq
(
NULL
,
&
req
);
void
*
buf
=
malloc
(
tlen
);
void
*
buf
=
malloc
(
tlen
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
goto
_return
;
goto
_return
;
}
}
...
@@ -615,18 +624,64 @@ _return:
...
@@ -615,18 +624,64 @@ _return:
return
pRequest
;
return
pRequest
;
}
}
/*typedef SMqConsumeRsp tmq_message_t;*/
static
char
*
formatTimestamp
(
char
*
buf
,
int64_t
val
,
int
precision
)
{
time_t
tt
;
int32_t
ms
=
0
;
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
tt
=
(
time_t
)(
val
/
1000000000
);
ms
=
val
%
1000000000
;
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
tt
=
(
time_t
)(
val
/
1000000
);
ms
=
val
%
1000000
;
}
else
{
tt
=
(
time_t
)(
val
/
1000
);
ms
=
val
%
1000
;
}
struct
tmq_message_t
{
/* comment out as it make testcases like select_with_tags.sim fail.
SMqConsumeRsp
rsp
;
but in windows, this may cause the call to localtime crash if tt < 0,
};
need to find a better solution.
if (tt < 0) {
tt = 0;
}
*/
#ifdef WINDOWS
if
(
tt
<
0
)
tt
=
0
;
#endif
if
(
tt
<=
0
&&
ms
<
0
)
{
tt
--
;
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
ms
+=
1000000000
;
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
ms
+=
1000000
;
}
else
{
ms
+=
1000
;
}
}
struct
tm
*
ptm
=
localtime
(
&
tt
);
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
sprintf
(
buf
+
pos
,
".%06d"
,
ms
);
}
else
{
sprintf
(
buf
+
pos
,
".%03d"
,
ms
);
}
return
buf
;
}
int32_t
tmq_poll_cb_inner
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
int32_t
tmq_poll_cb_inner
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
if
(
code
==
-
1
)
{
if
(
code
==
-
1
)
{
printf
(
"discard
\n
"
);
printf
(
"
msg
discard
\n
"
);
return
0
;
return
0
;
}
}
SMqClientVg
*
pVg
=
(
SMqClientVg
*
)
param
;
char
pBuf
[
128
];
SMqConsumeCbParam
*
pParam
=
(
SMqConsumeCbParam
*
)
param
;
SMqClientVg
*
pVg
=
pParam
->
pVg
;
SMqConsumeRsp
rsp
;
SMqConsumeRsp
rsp
;
tDecodeSMqConsumeRsp
(
pMsg
->
pData
,
&
rsp
);
tDecodeSMqConsumeRsp
(
pMsg
->
pData
,
&
rsp
);
if
(
rsp
.
numOfTopics
==
0
)
{
if
(
rsp
.
numOfTopics
==
0
)
{
...
@@ -639,10 +694,11 @@ int32_t tmq_poll_cb_inner(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -639,10 +694,11 @@ int32_t tmq_poll_cb_inner(void* param, const SDataBuf* pMsg, int32_t code) {
/*printf("-----msg begin----\n");*/
/*printf("-----msg begin----\n");*/
printf
(
"|"
);
printf
(
"|"
);
for
(
int32_t
i
=
0
;
i
<
colNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
colNum
;
i
++
)
{
printf
(
" %15s |"
,
rsp
.
schemas
->
pSchema
[
i
].
name
);
if
(
i
==
0
)
printf
(
" %25s |"
,
rsp
.
schemas
->
pSchema
[
i
].
name
);
else
printf
(
" %15s |"
,
rsp
.
schemas
->
pSchema
[
i
].
name
);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
printf
(
"=====================================
\n
"
);
printf
(
"=====================================
==========
\n
"
);
int32_t
sz
=
taosArrayGetSize
(
rsp
.
pBlockData
);
int32_t
sz
=
taosArrayGetSize
(
rsp
.
pBlockData
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
rsp
.
pBlockData
,
i
);
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
rsp
.
pBlockData
,
i
);
...
@@ -654,7 +710,8 @@ int32_t tmq_poll_cb_inner(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -654,7 +710,8 @@ int32_t tmq_poll_cb_inner(void* param, const SDataBuf* pMsg, int32_t code) {
void
*
var
=
POINTER_SHIFT
(
pColInfoData
->
pData
,
j
*
pColInfoData
->
info
.
bytes
);
void
*
var
=
POINTER_SHIFT
(
pColInfoData
->
pData
,
j
*
pColInfoData
->
info
.
bytes
);
switch
(
pColInfoData
->
info
.
type
)
{
switch
(
pColInfoData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
printf
(
" %15lu |"
,
*
(
uint64_t
*
)
var
);
formatTimestamp
(
pBuf
,
*
(
uint64_t
*
)
var
,
TSDB_TIME_PRECISION_MILLI
);
printf
(
" %25s |"
,
pBuf
);
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UINT
:
...
@@ -678,8 +735,7 @@ int32_t tmq_ask_ep_cb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -678,8 +735,7 @@ int32_t tmq_ask_ep_cb(void* param, const SDataBuf* pMsg, int32_t code) {
SMqAskEpCbParam
*
pParam
=
(
SMqAskEpCbParam
*
)
param
;
SMqAskEpCbParam
*
pParam
=
(
SMqAskEpCbParam
*
)
param
;
tmq_t
*
tmq
=
pParam
->
tmq
;
tmq_t
*
tmq
=
pParam
->
tmq
;
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"get topic endpoint error, not ready, wait:%d
\n
"
,
pParam
->
wait
);
printf
(
"exit wait %d
\n
"
,
pParam
->
wait
);
if
(
pParam
->
wait
)
{
if
(
pParam
->
wait
)
{
tsem_post
(
&
tmq
->
rspSem
);
tsem_post
(
&
tmq
->
rspSem
);
}
}
...
@@ -770,47 +826,70 @@ END:
...
@@ -770,47 +826,70 @@ END:
return
0
;
return
0
;
}
}
tmq_message_t
*
tmq_consume_poll
(
tmq_t
*
tmq
,
int64_t
blocking_time
)
{
SMqConsumeReq
*
tmqBuildConsumeReqImpl
(
tmq_t
*
tmq
,
int64_t
blocking_time
,
int32_t
type
,
SMqClientTopic
*
pTopic
,
SMqClientVg
**
ppVg
)
{
SMqConsumeReq
*
pReq
=
malloc
(
sizeof
(
SMqConsumeReq
));
if
(
pReq
==
NULL
)
{
return
NULL
;
}
pReq
->
reqType
=
type
;
pReq
->
blockingTime
=
blocking_time
;
pReq
->
consumerId
=
tmq
->
consumerId
;
strcpy
(
pReq
->
cgroup
,
tmq
->
groupId
);
tmq
->
nextTopicIdx
=
(
tmq
->
nextTopicIdx
+
1
)
%
taosArrayGetSize
(
tmq
->
clientTopics
);
strcpy
(
pReq
->
topic
,
pTopic
->
topicName
);
pTopic
->
nextVgIdx
=
(
pTopic
->
nextVgIdx
+
1
%
taosArrayGetSize
(
pTopic
->
vgs
));
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
pTopic
->
nextVgIdx
);
pReq
->
offset
=
pVg
->
currentOffset
+
1
;
*
ppVg
=
pVg
;
pReq
->
head
.
vgId
=
htonl
(
pVg
->
vgId
);
pReq
->
head
.
contLen
=
htonl
(
sizeof
(
SMqConsumeReq
));
return
pReq
;
}
tmq_message_t
*
tmq_consumer_poll
(
tmq_t
*
tmq
,
int64_t
blocking_time
)
{
tmq_message_t
*
tmq_message
=
NULL
;
int64_t
status
=
atomic_load_64
(
&
tmq
->
status
);
int64_t
status
=
atomic_load_64
(
&
tmq
->
status
);
tmqAsyncAskEp
(
tmq
,
status
==
0
||
taosArrayGetSize
(
tmq
->
clientTopics
));
tmqAsyncAskEp
(
tmq
,
status
==
0
||
taosArrayGetSize
(
tmq
->
clientTopics
));
if
(
blocking_time
<
0
)
blocking_time
=
500
;
/*if (blocking_time < 0) blocking_time = 500;*/
blocking_time
=
1000
;
if
(
taosArrayGetSize
(
tmq
->
clientTopics
)
==
0
)
{
if
(
taosArrayGetSize
(
tmq
->
clientTopics
)
==
0
)
{
tscDebug
(
"consumer:%ld poll but not assigned"
,
tmq
->
consumerId
);
tscDebug
(
"consumer:%ld poll but not assigned"
,
tmq
->
consumerId
);
usleep
(
blocking_time
*
1000
);
usleep
(
blocking_time
*
1000
);
return
NULL
;
return
NULL
;
}
}
SMqConsumeReq
*
pReq
=
malloc
(
sizeof
(
SMqConsumeReq
));
pReq
->
reqType
=
1
;
pReq
->
blockingTime
=
blocking_time
;
pReq
->
consumerId
=
tmq
->
consumerId
;
tmq_message_t
*
tmq_message
=
NULL
;
strcpy
(
pReq
->
cgroup
,
tmq
->
groupId
);
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
tmq
->
nextTopicIdx
);
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
tmq
->
nextTopicIdx
);
tmq
->
nextTopicIdx
=
(
tmq
->
nextTopicIdx
+
1
)
%
taosArrayGetSize
(
tmq
->
clientTopics
);
if
(
taosArrayGetSize
(
pTopic
->
vgs
)
==
0
)
{
strcpy
(
pReq
->
topic
,
pTopic
->
topicName
);
int32_t
vgSz
=
taosArrayGetSize
(
pTopic
->
vgs
);
if
(
vgSz
==
0
)
{
free
(
pReq
);
usleep
(
blocking_time
*
1000
);
usleep
(
blocking_time
*
1000
);
return
NULL
;
return
NULL
;
}
}
pTopic
->
nextVgIdx
=
(
pTopic
->
nextVgIdx
+
1
%
vgSz
);
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
pTopic
->
nextVgIdx
);
pReq
->
offset
=
pVg
->
currentOffset
+
1
;
pReq
->
head
.
vgId
=
htonl
(
pVg
->
vgId
);
SMqClientVg
*
pVg
=
NULL
;
pReq
->
head
.
contLen
=
htonl
(
sizeof
(
SMqConsumeReq
));
SMqConsumeReq
*
pReq
=
tmqBuildConsumeReqImpl
(
tmq
,
blocking_time
,
TMQ_REQ_TYPE_CONSUME_ONLY
,
pTopic
,
&
pVg
);
if
(
pReq
==
NULL
)
{
usleep
(
blocking_time
*
1000
);
return
NULL
;
}
SMqConsumeCbParam
*
param
=
malloc
(
sizeof
(
SMqConsumeCbParam
));
if
(
param
==
NULL
)
{
usleep
(
blocking_time
*
1000
);
return
NULL
;
}
param
->
tmq
=
tmq
;
param
->
retMsg
=
&
tmq_message
;
param
->
pVg
=
pVg
;
SRequestObj
*
pRequest
=
createRequest
(
tmq
->
pTscObj
,
NULL
,
NULL
,
TDMT_VND_CONSUME
);
SRequestObj
*
pRequest
=
createRequest
(
tmq
->
pTscObj
,
NULL
,
NULL
,
TDMT_VND_CONSUME
);
pRequest
->
body
.
requestMsg
=
(
SDataBuf
){
.
pData
=
pReq
,
.
len
=
sizeof
(
SMqConsumeReq
)
};
pRequest
->
body
.
requestMsg
=
(
SDataBuf
){
.
pData
=
pReq
,
.
len
=
sizeof
(
SMqConsumeReq
)
};
SMsgSendInfo
*
sendInfo
=
buildMsgInfoImpl
(
pRequest
);
SMsgSendInfo
*
sendInfo
=
buildMsgInfoImpl
(
pRequest
);
sendInfo
->
requestObjRefId
=
0
;
sendInfo
->
requestObjRefId
=
0
;
sendInfo
->
param
=
p
Vg
;
sendInfo
->
param
=
p
aram
;
sendInfo
->
fp
=
tmq_poll_cb_inner
;
sendInfo
->
fp
=
tmq_poll_cb_inner
;
/*printf("req offset: %ld\n", pReq->offset);*/
/*printf("req offset: %ld\n", pReq->offset);*/
...
...
source/client/test/clientTests.cpp
浏览文件 @
244b552f
...
@@ -562,9 +562,9 @@ TEST(testCase, insert_test) {
...
@@ -562,9 +562,9 @@ TEST(testCase, insert_test) {
taos_free_result(pRes);
taos_free_result(pRes);
taos_close(pConn);
taos_close(pConn);
}
}
#endif
#endif
TEST
(
testCase
,
create_topic_Test
)
{
TEST
(
testCase
,
create_topic_ctb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
assert
(
pConn
!=
NULL
);
...
@@ -583,13 +583,37 @@ TEST(testCase, create_topic_Test) {
...
@@ -583,13 +583,37 @@ TEST(testCase, create_topic_Test) {
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
char
*
sql
=
"select * from tu"
;
char
*
sql
=
"select * from tu"
;
pRes
=
taos_create_topic
(
pConn
,
"test_topic_1"
,
sql
,
strlen
(
sql
));
pRes
=
taos_create_topic
(
pConn
,
"test_
ctb_
topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
TEST
(
testCase
,
create_topic_stb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
//taos_free_result(pRes);
TEST
(
testCase
,
tmq_subscribe_Test
)
{
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
nullptr
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
char
*
sql
=
"select ts, k from st1"
;
pRes
=
taos_create_topic
(
pConn
,
"test_stb_topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
#if 0
TEST(testCase, tmq_subscribe_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
assert(pConn != NULL);
...
@@ -604,11 +628,36 @@ TEST(testCase, tmq_subscribe_Test) {
...
@@ -604,11 +628,36 @@ TEST(testCase, tmq_subscribe_Test) {
tmq_t* tmq = taos_consumer_new(pConn, conf, NULL, 0);
tmq_t* tmq = taos_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append
(
topic_list
,
"test_topic_1"
);
tmq_list_append(topic_list, "test_
ctb_
topic_1");
tmq_subscribe(tmq, topic_list);
tmq_subscribe(tmq, topic_list);
while (1) {
while (1) {
tmq_message_t
*
msg
=
tmq_consume_poll
(
tmq
,
1000
);
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
//printf("get msg\n");
//if (msg == NULL) break;
}
}
TEST(testCase, tmq_subscribe_stb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg2");
tmq_t* tmq = taos_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_stb_topic_1");
tmq_subscribe(tmq, topic_list);
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
//printf("get msg\n");
//printf("get msg\n");
//if (msg == NULL) break;
//if (msg == NULL) break;
}
}
...
@@ -619,6 +668,7 @@ TEST(testCase, tmq_consume_Test) {
...
@@ -619,6 +668,7 @@ TEST(testCase, tmq_consume_Test) {
TEST(testCase, tmq_commit_TEST) {
TEST(testCase, tmq_commit_TEST) {
}
}
#endif
#if 0
#if 0
TEST(testCase, projection_query_tables) {
TEST(testCase, projection_query_tables) {
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
244b552f
...
@@ -96,7 +96,7 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
...
@@ -96,7 +96,7 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
bool
found
=
0
;
bool
found
=
0
;
bool
changed
=
0
;
bool
changed
=
0
;
for
(
int32_t
j
=
0
;
j
<
taosArrayGetSize
(
pSub
->
availConsumer
);
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
taosArrayGetSize
(
pSub
->
availConsumer
);
j
++
)
{
if
(
*
(
int64_t
*
)
taosArrayGet
(
pSub
->
availConsumer
,
j
)
==
consumerId
)
{
if
(
*
(
int64_t
*
)
taosArrayGet
(
pSub
->
availConsumer
,
j
)
==
consumerId
)
{
found
=
1
;
found
=
1
;
break
;
break
;
}
}
...
@@ -105,16 +105,13 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
...
@@ -105,16 +105,13 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
taosArrayPush
(
pSub
->
availConsumer
,
&
consumerId
);
taosArrayPush
(
pSub
->
availConsumer
,
&
consumerId
);
}
}
int32_t
assignedSz
=
taosArrayGetSize
(
pSub
->
assigned
);
int32_t
assignedSz
=
taosArrayGetSize
(
pSub
->
assigned
);
topicEp
.
vgs
=
taosArrayInit
(
assignedSz
,
sizeof
(
SMqSubVgEp
));
topicEp
.
vgs
=
taosArrayInit
(
assignedSz
,
sizeof
(
SMqSubVgEp
));
for
(
int32_t
j
=
0
;
j
<
assignedSz
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
assignedSz
;
j
++
)
{
SMqConsumerEp
*
pCEp
=
taosArrayGet
(
pSub
->
assigned
,
j
);
SMqConsumerEp
*
pCEp
=
taosArrayGet
(
pSub
->
assigned
,
j
);
if
(
pCEp
->
consumerId
==
consumerId
)
{
if
(
pCEp
->
consumerId
==
consumerId
)
{
pCEp
->
lastConsumerHbTs
=
currentTs
;
pCEp
->
lastConsumerHbTs
=
currentTs
;
SMqSubVgEp
vgEp
=
{
SMqSubVgEp
vgEp
=
{.
epSet
=
pCEp
->
epSet
,
.
vgId
=
pCEp
->
vgId
};
.
epSet
=
pCEp
->
epSet
,
.
vgId
=
pCEp
->
vgId
};
taosArrayPush
(
topicEp
.
vgs
,
&
vgEp
);
taosArrayPush
(
topicEp
.
vgs
,
&
vgEp
);
changed
=
1
;
changed
=
1
;
}
}
...
@@ -123,7 +120,7 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
...
@@ -123,7 +120,7 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
taosArrayPush
(
rsp
.
topics
,
&
topicEp
);
taosArrayPush
(
rsp
.
topics
,
&
topicEp
);
}
}
if
(
changed
||
found
)
{
if
(
changed
||
found
)
{
SSdbRaw
*
pRaw
=
mndSubActionEncode
(
pSub
);
SSdbRaw
*
pRaw
=
mndSubActionEncode
(
pSub
);
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
sdbWriteNotFree
(
pMnode
->
pSdb
,
pRaw
);
sdbWriteNotFree
(
pMnode
->
pSdb
,
pRaw
);
}
}
...
@@ -137,7 +134,7 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
...
@@ -137,7 +134,7 @@ static int32_t mndProcessGetSubEpReq(SMnodeMsg *pMsg) {
}
}
void
*
abuf
=
buf
;
void
*
abuf
=
buf
;
tEncodeSMqCMGetSubEpRsp
(
&
abuf
,
&
rsp
);
tEncodeSMqCMGetSubEpRsp
(
&
abuf
,
&
rsp
);
//TODO: free rsp
//
TODO: free rsp
pMsg
->
pCont
=
buf
;
pMsg
->
pCont
=
buf
;
pMsg
->
contLen
=
tlen
;
pMsg
->
contLen
=
tlen
;
return
0
;
return
0
;
...
@@ -164,9 +161,9 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
...
@@ -164,9 +161,9 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
int32_t
sz
;
int32_t
sz
;
while
(
pIter
!=
NULL
)
{
while
(
pIter
!=
NULL
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pSub
->
assigned
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pSub
->
assigned
);
i
++
)
{
SMqConsumerEp
*
pCEp
=
taosArrayGet
(
pSub
->
assigned
,
i
);
SMqConsumerEp
*
pCEp
=
taosArrayGet
(
pSub
->
assigned
,
i
);
int64_t
consumerId
=
pCEp
->
consumerId
;
int64_t
consumerId
=
pCEp
->
consumerId
;
if
(
pCEp
->
lastConsumerHbTs
!=
-
1
&&
currentTs
-
pCEp
->
lastConsumerHbTs
>
MND_SUBSCRIBE_REBALANCE_MS
)
{
if
(
pCEp
->
lastConsumerHbTs
!=
-
1
&&
currentTs
-
pCEp
->
lastConsumerHbTs
>
MND_SUBSCRIBE_REBALANCE_MS
)
{
// put consumer into lostConsumer
// put consumer into lostConsumer
taosArrayPush
(
pSub
->
lostConsumer
,
pCEp
);
taosArrayPush
(
pSub
->
lostConsumer
,
pCEp
);
// put vg into unassgined
// put vg into unassgined
...
@@ -176,7 +173,7 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
...
@@ -176,7 +173,7 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
taosArrayRemove
(
pSub
->
assigned
,
i
);
taosArrayRemove
(
pSub
->
assigned
,
i
);
// remove from available consumer
// remove from available consumer
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
pSub
->
availConsumer
);
j
++
)
{
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
pSub
->
availConsumer
);
j
++
)
{
if
(
*
(
int64_t
*
)
taosArrayGet
(
pSub
->
availConsumer
,
i
)
==
pCEp
->
consumerId
)
{
if
(
*
(
int64_t
*
)
taosArrayGet
(
pSub
->
availConsumer
,
i
)
==
pCEp
->
consumerId
)
{
taosArrayRemove
(
pSub
->
availConsumer
,
j
);
taosArrayRemove
(
pSub
->
availConsumer
,
j
);
break
;
break
;
}
}
...
@@ -209,7 +206,7 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
...
@@ -209,7 +206,7 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
taosArrayPush
(
pSub
->
assigned
,
pCEp
);
taosArrayPush
(
pSub
->
assigned
,
pCEp
);
pSub
->
nextConsumerIdx
=
(
pSub
->
nextConsumerIdx
+
1
)
%
taosArrayGetSize
(
pSub
->
availConsumer
);
pSub
->
nextConsumerIdx
=
(
pSub
->
nextConsumerIdx
+
1
)
%
taosArrayGetSize
(
pSub
->
availConsumer
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
pConsumer
->
epoch
++
;
pConsumer
->
epoch
++
;
/*SSdbRaw* pConsumerRaw = mndConsumerActionEncode(pConsumer);*/
/*SSdbRaw* pConsumerRaw = mndConsumerActionEncode(pConsumer);*/
/*sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY);*/
/*sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY);*/
...
@@ -269,33 +266,50 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
...
@@ -269,33 +266,50 @@ static int32_t mndProcessMqTimerMsg(SMnodeMsg *pMsg) {
static
int
mndInitUnassignedVg
(
SMnode
*
pMnode
,
SMqTopicObj
*
pTopic
,
SArray
*
unassignedVg
)
{
static
int
mndInitUnassignedVg
(
SMnode
*
pMnode
,
SMqTopicObj
*
pTopic
,
SArray
*
unassignedVg
)
{
// convert phyplan to dag
// convert phyplan to dag
SQueryDag
*
pDag
=
qStringToDag
(
pTopic
->
physicalPlan
);
SQueryDag
*
pDag
=
qStringToDag
(
pTopic
->
physicalPlan
);
SArray
*
pArray
;
SArray
*
pArray
=
NULL
;
SArray
*
inner
=
taosArrayGet
(
pDag
->
pSubplans
,
0
);
SArray
*
inner
=
taosArrayGet
(
pDag
->
pSubplans
,
0
);
SSubplan
*
plan
=
taosArrayGetP
(
inner
,
0
);
SSubplan
*
plan
=
taosArrayGetP
(
inner
,
0
);
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
plan
->
execNode
.
nodeId
=
2
;
void
*
pIter
=
NULL
;
SEpSet
*
pEpSet
=
&
plan
->
execNode
.
epset
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pTopic
->
dbUid
)
continue
;
plan
->
execNode
.
nodeId
=
pVgroup
->
vgId
;
plan
->
execNode
.
epset
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
if
(
schedulerConvertDagToTaskList
(
pDag
,
&
pArray
)
<
0
)
{
terrno
=
TSDB_CODE_MND_UNSUPPORTED_TOPIC
;
mError
(
"unsupport topic: %s, sql: %s"
,
pTopic
->
name
,
pTopic
->
sql
);
return
-
1
;
}
if
(
pArray
&&
taosArrayGetSize
(
pArray
)
!=
1
)
{
terrno
=
TSDB_CODE_MND_UNSUPPORTED_TOPIC
;
mError
(
"unsupport topic: %s, sql: %s, plan level: %ld"
,
pTopic
->
name
,
pTopic
->
sql
,
taosArrayGetSize
(
pArray
));
return
-
1
;
}
pEpSet
->
inUse
=
0
;
addEpIntoEpSet
(
pEpSet
,
"localhost"
,
6030
);
if
(
schedulerConvertDagToTaskList
(
pDag
,
&
pArray
)
<
0
)
{
return
-
1
;
}
int32_t
sz
=
taosArrayGetSize
(
pArray
);
// convert dag to msg
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
CEp
;
SMqConsumerEp
CEp
;
CEp
.
status
=
0
;
CEp
.
status
=
0
;
CEp
.
consumerId
=
-
1
;
CEp
.
consumerId
=
-
1
;
CEp
.
lastConsumerHbTs
=
CEp
.
lastVgHbTs
=
-
1
;
CEp
.
lastConsumerHbTs
=
CEp
.
lastVgHbTs
=
-
1
;
STaskInfo
*
pTaskInfo
=
taosArrayGet
(
pArray
,
i
);
STaskInfo
*
pTaskInfo
=
taosArrayGet
(
pArray
,
0
);
CEp
.
epSet
=
pTaskInfo
->
addr
.
epset
;
CEp
.
epSet
=
pTaskInfo
->
addr
.
epset
;
/*mDebug("subscribe convert ep %d %s %s %s %s %s\n", CEp.epSet.numOfEps, CEp.epSet.fqdn[0], CEp.epSet.fqdn[1],
* CEp.epSet.fqdn[2], CEp.epSet.fqdn[3], CEp.epSet.fqdn[4]);*/
CEp
.
vgId
=
pTaskInfo
->
addr
.
nodeId
;
CEp
.
vgId
=
pTaskInfo
->
addr
.
nodeId
;
ASSERT
(
CEp
.
vgId
==
pVgroup
->
vgId
);
CEp
.
qmsg
=
strdup
(
pTaskInfo
->
msg
->
msg
);
CEp
.
qmsg
=
strdup
(
pTaskInfo
->
msg
->
msg
);
taosArrayPush
(
unassignedVg
,
&
CEp
);
taosArrayPush
(
unassignedVg
,
&
CEp
);
//TODO: free taskInfo
taosArrayDestroy
(
pArray
);
/*SEpSet *pEpSet = &plan->execNode.epset;*/
/*pEpSet->inUse = 0;*/
/*addEpIntoEpSet(pEpSet, "localhost", 6030);*/
}
}
/*qDestroyQueryDag(pDag);*/
/*qDestroyQueryDag(pDag);*/
...
@@ -608,7 +622,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -608,7 +622,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
}
}
SMqSubscribeObj
*
pSub
=
mndAcquireSubscribe
(
pMnode
,
consumerGroup
,
newTopicName
);
SMqSubscribeObj
*
pSub
=
mndAcquireSubscribe
(
pMnode
,
consumerGroup
,
newTopicName
);
bool
create
=
false
;
bool
create
=
false
;
if
(
pSub
==
NULL
)
{
if
(
pSub
==
NULL
)
{
mDebug
(
"create new subscription, group: %s, topic %s"
,
consumerGroup
,
newTopicName
);
mDebug
(
"create new subscription, group: %s, topic %s"
,
consumerGroup
,
newTopicName
);
pSub
=
tNewSubscribeObj
();
pSub
=
tNewSubscribeObj
();
...
@@ -624,7 +638,10 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
...
@@ -624,7 +638,10 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) {
strcpy
(
pSub
->
key
,
key
);
strcpy
(
pSub
->
key
,
key
);
free
(
key
);
free
(
key
);
// set unassigned vg
// set unassigned vg
mndInitUnassignedVg
(
pMnode
,
pTopic
,
pSub
->
unassignedVg
);
if
(
mndInitUnassignedVg
(
pMnode
,
pTopic
,
pSub
->
unassignedVg
)
<
0
)
{
//TODO: free memory
return
-
1
;
}
// TODO: disable alter
// TODO: disable alter
create
=
true
;
create
=
true
;
}
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
244b552f
...
@@ -103,6 +103,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
...
@@ -103,6 +103,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
goto
WAL_RESTORE_OVER
;
goto
WAL_RESTORE_OVER
;
}
}
}
}
code
=
0
;
code
=
0
;
...
...
source/dnode/vnode/inc/tsdb.h
浏览文件 @
244b552f
...
@@ -91,7 +91,7 @@ int tsdbCommit(STsdb *pTsdb);
...
@@ -91,7 +91,7 @@ int tsdbCommit(STsdb *pTsdb);
int
tsdbOptionsInit
(
STsdbCfg
*
);
int
tsdbOptionsInit
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
typedef
void
*
tsdbRead
Handle
T
;
typedef
void
*
tsdbRead
er
T
;
/**
/**
* Get the data block iterator, starting from position according to the query condition
* Get the data block iterator, starting from position according to the query condition
...
@@ -103,7 +103,7 @@ typedef void* tsdbReadHandleT;
...
@@ -103,7 +103,7 @@ typedef void* tsdbReadHandleT;
* @param qinfo query info handle from query processor
* @param qinfo query info handle from query processor
* @return
* @return
*/
*/
tsdbRead
Handle
T
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
tsdbRead
er
T
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
/**
/**
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
...
@@ -115,13 +115,13 @@ tsdbReadHandleT *tsdbQueryTables(STsdb *tsdb, STsdbQueryCond *pCond, STableGroup
...
@@ -115,13 +115,13 @@ tsdbReadHandleT *tsdbQueryTables(STsdb *tsdb, STsdbQueryCond *pCond, STableGroup
* @param tableInfo table list.
* @param tableInfo table list.
* @return
* @return
*/
*/
//tsdbRead
Handle
T tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId,
//tsdbRead
er
T tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId,
// SMemRef *pRef);
// SMemRef *pRef);
tsdbRead
Handle
T
tsdbQueryCacheLast
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
tsdbRead
er
T
tsdbQueryCacheLast
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
bool
isTsdbCacheLastRow
(
tsdbRead
Handle
T
*
pTsdbReadHandle
);
bool
isTsdbCacheLastRow
(
tsdbRead
er
T
*
pTsdbReadHandle
);
/**
/**
*
*
...
@@ -138,7 +138,7 @@ bool isTsdbCacheLastRow(tsdbReadHandleT* pTsdbReadHandle);
...
@@ -138,7 +138,7 @@ bool isTsdbCacheLastRow(tsdbReadHandleT* pTsdbReadHandle);
* @param reqId
* @param reqId
* @return
* @return
*/
*/
int32_t
tsdbQuerySTableByTagCond
(
STsdb
*
tsdb
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
);
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
);
/**
/**
...
@@ -148,7 +148,7 @@ int32_t tsdbQuerySTableByTagCond(STsdb* tsdb, uint64_t uid, TSKEY skey, const ch
...
@@ -148,7 +148,7 @@ int32_t tsdbQuerySTableByTagCond(STsdb* tsdb, uint64_t uid, TSKEY skey, const ch
* @return row size
* @return row size
*/
*/
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbRead
Handle
T
*
pHandle
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbRead
er
T
*
pHandle
);
/**
/**
* move to next block if exists
* move to next block if exists
...
@@ -156,7 +156,7 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReadHandleT* pHandle);
...
@@ -156,7 +156,7 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReadHandleT* pHandle);
* @param pTsdbReadHandle
* @param pTsdbReadHandle
* @return
* @return
*/
*/
bool
tsdbNextDataBlock
(
tsdbRead
Handle
T
pTsdbReadHandle
);
bool
tsdbNextDataBlock
(
tsdbRead
er
T
pTsdbReadHandle
);
/**
/**
* Get current data block information
* Get current data block information
...
@@ -165,7 +165,7 @@ bool tsdbNextDataBlock(tsdbReadHandleT pTsdbReadHandle);
...
@@ -165,7 +165,7 @@ bool tsdbNextDataBlock(tsdbReadHandleT pTsdbReadHandle);
* @param pBlockInfo
* @param pBlockInfo
* @return
* @return
*/
*/
void
tsdbRetrieveDataBlockInfo
(
tsdbRead
Handle
T
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
void
tsdbRetrieveDataBlockInfo
(
tsdbRead
er
T
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
/**
/**
*
*
...
@@ -177,7 +177,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReadHandleT *pTsdbReadHandle, SDataBlockInfo
...
@@ -177,7 +177,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReadHandleT *pTsdbReadHandle, SDataBlockInfo
* @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0
* @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0
* @return
* @return
*/
*/
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbRead
Handle
T
*
pTsdbReadHandle
,
SDataStatis
**
pBlockStatis
);
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbRead
er
T
*
pTsdbReadHandle
,
SDataStatis
**
pBlockStatis
);
/**
/**
*
*
...
@@ -189,7 +189,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReadHandleT *pTsdbReadHandle, SDataS
...
@@ -189,7 +189,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReadHandleT *pTsdbReadHandle, SDataS
* @param pColumnIdList required data columns id list
* @param pColumnIdList required data columns id list
* @return
* @return
*/
*/
SArray
*
tsdbRetrieveDataBlock
(
tsdbRead
Handle
T
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
SArray
*
tsdbRetrieveDataBlock
(
tsdbRead
er
T
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
/**
/**
* destroy the created table group list, which is generated by tag query
* destroy the created table group list, which is generated by tag query
...
@@ -205,7 +205,7 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
...
@@ -205,7 +205,7 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
* @param pGroupInfo the generated result
* @param pGroupInfo the generated result
* @return
* @return
*/
*/
int32_t
tsdbGetOneTableGroup
(
STsdb
*
tsdb
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
/**
/**
*
*
...
@@ -220,7 +220,7 @@ int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGro
...
@@ -220,7 +220,7 @@ int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGro
* clean up the query handle
* clean up the query handle
* @param queryHandle
* @param queryHandle
*/
*/
void
tsdbCleanup
QueryHandle
(
tsdbReadHandle
T
queryHandle
);
void
tsdbCleanup
ReadHandle
(
tsdbReader
T
queryHandle
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
244b552f
...
@@ -72,7 +72,7 @@ typedef struct STqReadHandle {
...
@@ -72,7 +72,7 @@ typedef struct STqReadHandle {
int64_t
ver
;
int64_t
ver
;
uint64_t
tbUid
;
uint64_t
tbUid
;
SHashObj
*
tbIdHash
;
SHashObj
*
tbIdHash
;
SSubmitMsg
*
pMsg
;
const
SSubmitMsg
*
pMsg
;
SSubmitBlk
*
pBlock
;
SSubmitBlk
*
pBlock
;
SSubmitMsgIter
msgIter
;
SSubmitMsgIter
msgIter
;
SSubmitBlkIter
blkIter
;
SSubmitBlkIter
blkIter
;
...
@@ -208,11 +208,11 @@ static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle* pReadHandle, SA
...
@@ -208,11 +208,11 @@ static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle* pReadHandle, SA
pReadHandle
->
pColIdList
=
pColIdList
;
pReadHandle
->
pColIdList
=
pColIdList
;
}
}
static
FORCE_INLINE
void
tqReadHandleSetTbUid
(
STqReadHandle
*
pHandle
,
uint64_t
tbUid
)
{
//static FORCE_INLINE void tqReadHandleSetTbUid(STqReadHandle* pHandle, const SArray* pTableIdList
) {
pHandle
->
tbUid
=
tbUid
;
//pHandle->tbUid = pTableIdList
;
}
//
}
static
FORCE_INLINE
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
SArray
*
tbUidList
)
{
static
FORCE_INLINE
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_NO_LOCK
);
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
if
(
pHandle
->
tbIdHash
==
NULL
)
{
return
-
1
;
return
-
1
;
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
244b552f
...
@@ -824,8 +824,9 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
...
@@ -824,8 +824,9 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
for
(
int
i
=
0
;
i
<
TQ_BUFFER_SIZE
;
i
++
)
{
for
(
int
i
=
0
;
i
<
TQ_BUFFER_SIZE
;
i
++
)
{
pTopic
->
buffer
.
output
[
i
].
status
=
0
;
pTopic
->
buffer
.
output
[
i
].
status
=
0
;
STqReadHandle
*
pReadHandle
=
tqInitSubmitMsgScanner
(
pTq
->
pMeta
);
STqReadHandle
*
pReadHandle
=
tqInitSubmitMsgScanner
(
pTq
->
pMeta
);
SReadHandle
handle
=
{
.
reader
=
pReadHandle
,
.
meta
=
pTq
->
pMeta
};
pTopic
->
buffer
.
output
[
i
].
pReadHandle
=
pReadHandle
;
pTopic
->
buffer
.
output
[
i
].
pReadHandle
=
pReadHandle
;
pTopic
->
buffer
.
output
[
i
].
task
=
qCreateStreamExecTaskInfo
(
req
.
qmsg
,
pReadH
andle
);
pTopic
->
buffer
.
output
[
i
].
task
=
qCreateStreamExecTaskInfo
(
req
.
qmsg
,
&
h
andle
);
}
}
taosArrayPush
(
pConsumer
->
topics
,
pTopic
);
taosArrayPush
(
pConsumer
->
topics
,
pTopic
);
tqHandleMovePut
(
pTq
->
tqMeta
,
req
.
newConsumerId
,
pConsumer
);
tqHandleMovePut
(
pTq
->
tqMeta
,
req
.
newConsumerId
,
pConsumer
);
...
@@ -866,18 +867,16 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
...
@@ -866,18 +867,16 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
if
(
pHandle
->
pBlock
==
NULL
)
return
false
;
if
(
pHandle
->
pBlock
==
NULL
)
return
false
;
pHandle
->
pBlock
->
uid
=
htobe64
(
pHandle
->
pBlock
->
uid
);
pHandle
->
pBlock
->
uid
=
htobe64
(
pHandle
->
pBlock
->
uid
);
if
(
pHandle
->
tbUid
==
pHandle
->
pBlock
->
uid
)
{
/*if (pHandle->tbUid == pHandle->pBlock->uid) {*/
ASSERT
(
pHandle
->
tbIdHash
);
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
pBlock
->
uid
,
sizeof
(
int64_t
));
if
(
ret
!=
NULL
)
{
pHandle
->
pBlock
->
tid
=
htonl
(
pHandle
->
pBlock
->
tid
);
pHandle
->
pBlock
->
tid
=
htonl
(
pHandle
->
pBlock
->
tid
);
pHandle
->
pBlock
->
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
pHandle
->
pBlock
->
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
pHandle
->
pBlock
->
dataLen
=
htonl
(
pHandle
->
pBlock
->
dataLen
);
pHandle
->
pBlock
->
dataLen
=
htonl
(
pHandle
->
pBlock
->
dataLen
);
pHandle
->
pBlock
->
schemaLen
=
htonl
(
pHandle
->
pBlock
->
schemaLen
);
pHandle
->
pBlock
->
schemaLen
=
htonl
(
pHandle
->
pBlock
->
schemaLen
);
pHandle
->
pBlock
->
numOfRows
=
htons
(
pHandle
->
pBlock
->
numOfRows
);
pHandle
->
pBlock
->
numOfRows
=
htons
(
pHandle
->
pBlock
->
numOfRows
);
return
true
;
return
true
;
}
else
if
(
pHandle
->
tbIdHash
!=
NULL
)
{
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
pBlock
->
uid
,
sizeof
(
int64_t
));
if
(
ret
!=
NULL
)
{
return
true
;
}
}
}
}
}
return
false
;
return
false
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
244b552f
...
@@ -159,7 +159,7 @@ static int32_t checkForCachedLastRow(STsdbReadHandle* pTsdbReadHandle, STableGro
...
@@ -159,7 +159,7 @@ static int32_t checkForCachedLastRow(STsdbReadHandle* pTsdbReadHandle, STableGro
static
int32_t
checkForCachedLast
(
STsdbReadHandle
*
pTsdbReadHandle
);
static
int32_t
checkForCachedLast
(
STsdbReadHandle
*
pTsdbReadHandle
);
//static int32_t tsdbGetCachedLastRow(STable* pTable, SMemRow* pRes, TSKEY* lastKey);
//static int32_t tsdbGetCachedLastRow(STable* pTable, SMemRow* pRes, TSKEY* lastKey);
static
void
changeQueryHandleForInterpQuery
(
tsdbRead
Handle
T
pHandle
);
static
void
changeQueryHandleForInterpQuery
(
tsdbRead
er
T
pHandle
);
static
void
doMergeTwoLevelData
(
STsdbReadHandle
*
pTsdbReadHandle
,
STableCheckInfo
*
pCheckInfo
,
SBlock
*
pBlock
);
static
void
doMergeTwoLevelData
(
STsdbReadHandle
*
pTsdbReadHandle
,
STableCheckInfo
*
pCheckInfo
,
SBlock
*
pBlock
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int32_t
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbReadHandle
*
pTsdbReadHandle
);
static
int32_t
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbReadHandle
*
pTsdbReadHandle
);
...
@@ -167,7 +167,7 @@ static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2);
...
@@ -167,7 +167,7 @@ static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2);
//static int32_t doGetExternalRow(STsdbReadHandle* pTsdbReadHandle, int16_t type, void* pMemRef);
//static int32_t doGetExternalRow(STsdbReadHandle* pTsdbReadHandle, int16_t type, void* pMemRef);
//static void* doFreeColumnInfoData(SArray* pColumnInfoData);
//static void* doFreeColumnInfoData(SArray* pColumnInfoData);
//static void* destroyTableCheckInfo(SArray* pTableCheckInfo);
//static void* destroyTableCheckInfo(SArray* pTableCheckInfo);
static
bool
tsdbGetExternalRow
(
tsdbRead
Handle
T
pHandle
);
static
bool
tsdbGetExternalRow
(
tsdbRead
er
T
pHandle
);
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
pBlockLoadInfo
->
slot
=
-
1
;
pBlockLoadInfo
->
slot
=
-
1
;
...
@@ -208,7 +208,7 @@ static SArray* getDefaultLoadColumns(STsdbReadHandle* pTsdbReadHandle, bool load
...
@@ -208,7 +208,7 @@ static SArray* getDefaultLoadColumns(STsdbReadHandle* pTsdbReadHandle, bool load
return
pLocalIdList
;
return
pLocalIdList
;
}
}
//int64_t tsdbGetNumOfRowsInMemTable(tsdbRead
Handle
T* pHandle) {
//int64_t tsdbGetNumOfRowsInMemTable(tsdbRead
er
T* pHandle) {
// STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) pHandle;
// STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) pHandle;
//
//
// int64_t rows = 0;
// int64_t rows = 0;
...
@@ -424,28 +424,28 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond,
...
@@ -424,28 +424,28 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond,
tsdbInitDataBlockLoadInfo
(
&
pReadHandle
->
dataBlockLoadInfo
);
tsdbInitDataBlockLoadInfo
(
&
pReadHandle
->
dataBlockLoadInfo
);
tsdbInitCompBlockLoadInfo
(
&
pReadHandle
->
compBlockLoadInfo
);
tsdbInitCompBlockLoadInfo
(
&
pReadHandle
->
compBlockLoadInfo
);
return
(
tsdbRead
Handle
T
)
pReadHandle
;
return
(
tsdbRead
er
T
)
pReadHandle
;
_end:
_end:
tsdbCleanup
Query
Handle
(
pReadHandle
);
tsdbCleanup
Read
Handle
(
pReadHandle
);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
tsdbRead
Handle
T
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
tsdbRead
er
T
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
tsdb
,
pCond
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
tsdb
,
pCond
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
return
(
tsdbRead
Handle
T
*
)
pTsdbReadHandle
;
return
(
tsdbRead
er
T
*
)
pTsdbReadHandle
;
}
}
// todo apply the lastkey of table check to avoid to load header file
// todo apply the lastkey of table check to avoid to load header file
pTsdbReadHandle
->
pTableCheckInfo
=
createCheckInfoFromTableGroup
(
pTsdbReadHandle
,
groupList
);
pTsdbReadHandle
->
pTableCheckInfo
=
createCheckInfoFromTableGroup
(
pTsdbReadHandle
,
groupList
);
if
(
pTsdbReadHandle
->
pTableCheckInfo
==
NULL
)
{
if
(
pTsdbReadHandle
->
pTableCheckInfo
==
NULL
)
{
// tsdbCleanup
Query
Handle(pTsdbReadHandle);
// tsdbCleanup
Read
Handle(pTsdbReadHandle);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
...
@@ -453,10 +453,10 @@ tsdbReadHandleT* tsdbQueryTables(STsdb* tsdb, STsdbQueryCond* pCond, STableGroup
...
@@ -453,10 +453,10 @@ tsdbReadHandleT* tsdbQueryTables(STsdb* tsdb, STsdbQueryCond* pCond, STableGroup
tsdbDebug
(
"%p total numOfTable:%"
PRIzu
" in this query, group %"
PRIzu
" %s"
,
pTsdbReadHandle
,
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
tsdbDebug
(
"%p total numOfTable:%"
PRIzu
" in this query, group %"
PRIzu
" %s"
,
pTsdbReadHandle
,
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
taosArrayGetSize
(
groupList
->
pGroupList
),
pTsdbReadHandle
->
idStr
);
taosArrayGetSize
(
groupList
->
pGroupList
),
pTsdbReadHandle
->
idStr
);
return
(
tsdbRead
Handle
T
)
pTsdbReadHandle
;
return
(
tsdbRead
er
T
)
pTsdbReadHandle
;
}
}
void
tsdbResetQueryHandle
(
tsdbRead
Handle
T
queryHandle
,
STsdbQueryCond
*
pCond
)
{
void
tsdbResetQueryHandle
(
tsdbRead
er
T
queryHandle
,
STsdbQueryCond
*
pCond
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
queryHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
queryHandle
;
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
...
@@ -493,7 +493,7 @@ void tsdbResetQueryHandle(tsdbReadHandleT queryHandle, STsdbQueryCond *pCond) {
...
@@ -493,7 +493,7 @@ void tsdbResetQueryHandle(tsdbReadHandleT queryHandle, STsdbQueryCond *pCond) {
resetCheckInfo
(
pTsdbReadHandle
);
resetCheckInfo
(
pTsdbReadHandle
);
}
}
void
tsdbResetQueryHandleForNewTable
(
tsdbRead
Handle
T
queryHandle
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
)
{
void
tsdbResetQueryHandleForNewTable
(
tsdbRead
er
T
queryHandle
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
queryHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
queryHandle
;
pTsdbReadHandle
->
order
=
pCond
->
order
;
pTsdbReadHandle
->
order
=
pCond
->
order
;
...
@@ -525,7 +525,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReadHandleT queryHandle, STsdbQueryCond
...
@@ -525,7 +525,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReadHandleT queryHandle, STsdbQueryCond
pTsdbReadHandle
->
pTableCheckInfo
=
NULL
;
//createCheckInfoFromTableGroup(pTsdbReadHandle, groupList, pMeta, &pTable);
pTsdbReadHandle
->
pTableCheckInfo
=
NULL
;
//createCheckInfoFromTableGroup(pTsdbReadHandle, groupList, pMeta, &pTable);
if
(
pTsdbReadHandle
->
pTableCheckInfo
==
NULL
)
{
if
(
pTsdbReadHandle
->
pTableCheckInfo
==
NULL
)
{
// tsdbCleanup
Query
Handle(pTsdbReadHandle);
// tsdbCleanup
Read
Handle(pTsdbReadHandle);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
}
}
...
@@ -533,7 +533,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReadHandleT queryHandle, STsdbQueryCond
...
@@ -533,7 +533,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReadHandleT queryHandle, STsdbQueryCond
// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next);
// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next);
}
}
tsdbRead
Handle
T
tsdbQueryLastRow
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
tsdbRead
er
T
tsdbQueryLastRow
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
pCond
->
twindow
=
updateLastrowForEachGroup
(
groupList
);
pCond
->
twindow
=
updateLastrowForEachGroup
(
groupList
);
// no qualified table
// no qualified table
...
@@ -561,7 +561,7 @@ tsdbReadHandleT tsdbQueryLastRow(STsdb *tsdb, STsdbQueryCond *pCond, STableGroup
...
@@ -561,7 +561,7 @@ tsdbReadHandleT tsdbQueryLastRow(STsdb *tsdb, STsdbQueryCond *pCond, STableGroup
}
}
#if 0
#if 0
tsdbRead
Handle
T tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, STsdbMemTable* pMemRef) {
tsdbRead
er
T tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, STsdbMemTable* pMemRef) {
STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef);
STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef);
if (pTsdbReadHandle == NULL) {
if (pTsdbReadHandle == NULL) {
return NULL;
return NULL;
...
@@ -581,7 +581,7 @@ tsdbReadHandleT tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGro
...
@@ -581,7 +581,7 @@ tsdbReadHandleT tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGro
}
}
#endif
#endif
SArray
*
tsdbGetQueriedTableList
(
tsdbRead
Handle
T
*
pHandle
)
{
SArray
*
tsdbGetQueriedTableList
(
tsdbRead
er
T
*
pHandle
)
{
assert
(
pHandle
!=
NULL
);
assert
(
pHandle
!=
NULL
);
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
...
@@ -624,7 +624,7 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr
...
@@ -624,7 +624,7 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr
return
pNew
;
return
pNew
;
}
}
tsdbRead
Handle
T
tsdbQueryRowsInExternalWindow
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
tsdbRead
er
T
tsdbQueryRowsInExternalWindow
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
uint64_t
taskId
)
{
STableGroupInfo
*
pNew
=
trimTableGroup
(
&
pCond
->
twindow
,
groupList
);
STableGroupInfo
*
pNew
=
trimTableGroup
(
&
pCond
->
twindow
,
groupList
);
if
(
pNew
->
numOfTables
==
0
)
{
if
(
pNew
->
numOfTables
==
0
)
{
...
@@ -2338,7 +2338,7 @@ static void moveToNextDataBlockInCurrentFile(STsdbReadHandle* pTsdbReadHandle) {
...
@@ -2338,7 +2338,7 @@ static void moveToNextDataBlockInCurrentFile(STsdbReadHandle* pTsdbReadHandle) {
cur
->
blockCompleted
=
false
;
cur
->
blockCompleted
=
false
;
}
}
#if 0
#if 0
int32_t tsdbGetFileBlocksDistInfo(tsdbRead
Handle
T* queryHandle, STableBlockDist* pTableBlockInfo) {
int32_t tsdbGetFileBlocksDistInfo(tsdbRead
er
T* queryHandle, STableBlockDist* pTableBlockInfo) {
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) queryHandle;
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) queryHandle;
pTableBlockInfo->totalSize = 0;
pTableBlockInfo->totalSize = 0;
...
@@ -2494,7 +2494,7 @@ static bool doHasDataInBuffer(STsdbReadHandle* pTsdbReadHandle) {
...
@@ -2494,7 +2494,7 @@ static bool doHasDataInBuffer(STsdbReadHandle* pTsdbReadHandle) {
}
}
//todo not unref yet, since it is not support multi-group interpolation query
//todo not unref yet, since it is not support multi-group interpolation query
static
UNUSED_FUNC
void
changeQueryHandleForInterpQuery
(
tsdbRead
Handle
T
pHandle
)
{
static
UNUSED_FUNC
void
changeQueryHandleForInterpQuery
(
tsdbRead
er
T
pHandle
)
{
// filter the queried time stamp in the first place
// filter the queried time stamp in the first place
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
...
@@ -2635,7 +2635,7 @@ static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) {
...
@@ -2635,7 +2635,7 @@ static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) {
}
}
if
(
exists
)
{
if
(
exists
)
{
tsdbRetrieveDataBlock
((
tsdbRead
Handle
T
*
)
pTsdbReadHandle
,
NULL
);
tsdbRetrieveDataBlock
((
tsdbRead
er
T
*
)
pTsdbReadHandle
,
NULL
);
if
(
pTsdbReadHandle
->
currentLoadExternalRows
&&
pTsdbReadHandle
->
window
.
skey
==
pTsdbReadHandle
->
window
.
ekey
)
{
if
(
pTsdbReadHandle
->
currentLoadExternalRows
&&
pTsdbReadHandle
->
window
.
skey
==
pTsdbReadHandle
->
window
.
ekey
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
0
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
0
);
assert
(
*
(
int64_t
*
)
pColInfo
->
pData
==
pTsdbReadHandle
->
window
.
skey
);
assert
(
*
(
int64_t
*
)
pColInfo
->
pData
==
pTsdbReadHandle
->
window
.
skey
);
...
@@ -2891,7 +2891,7 @@ static bool loadDataBlockFromTableSeq(STsdbReadHandle* pTsdbReadHandle) {
...
@@ -2891,7 +2891,7 @@ static bool loadDataBlockFromTableSeq(STsdbReadHandle* pTsdbReadHandle) {
}
}
// handle data in cache situation
// handle data in cache situation
bool
tsdbNextDataBlock
(
tsdbRead
Handle
T
pHandle
)
{
bool
tsdbNextDataBlock
(
tsdbRead
er
T
pHandle
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
...
@@ -3051,11 +3051,11 @@ bool tsdbNextDataBlock(tsdbReadHandleT pHandle) {
...
@@ -3051,11 +3051,11 @@ bool tsdbNextDataBlock(tsdbReadHandleT pHandle) {
// }
// }
//
//
//out_of_memory:
//out_of_memory:
// tsdbCleanup
Query
Handle(pSecQueryHandle);
// tsdbCleanup
Read
Handle(pSecQueryHandle);
// return terrno;
// return terrno;
//}
//}
bool
tsdbGetExternalRow
(
tsdbRead
Handle
T
pHandle
)
{
bool
tsdbGetExternalRow
(
tsdbRead
er
T
pHandle
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
pHandle
;
SQueryFilePos
*
cur
=
&
pTsdbReadHandle
->
cur
;
SQueryFilePos
*
cur
=
&
pTsdbReadHandle
->
cur
;
...
@@ -3112,7 +3112,7 @@ bool tsdbGetExternalRow(tsdbReadHandleT pHandle) {
...
@@ -3112,7 +3112,7 @@ bool tsdbGetExternalRow(tsdbReadHandleT pHandle) {
// return code;
// return code;
//}
//}
bool
isTsdbCacheLastRow
(
tsdbRead
Handle
T
*
pTsdbReadHandle
)
{
bool
isTsdbCacheLastRow
(
tsdbRead
er
T
*
pTsdbReadHandle
)
{
return
((
STsdbReadHandle
*
)
pTsdbReadHandle
)
->
cachelastrow
>
TSDB_CACHED_TYPE_NONE
;
return
((
STsdbReadHandle
*
)
pTsdbReadHandle
)
->
cachelastrow
>
TSDB_CACHED_TYPE_NONE
;
}
}
...
@@ -3230,7 +3230,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) {
...
@@ -3230,7 +3230,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) {
return
window
;
return
window
;
}
}
void
tsdbRetrieveDataBlockInfo
(
tsdbRead
Handle
T
*
pTsdbReadHandle
,
SDataBlockInfo
*
pDataBlockInfo
)
{
void
tsdbRetrieveDataBlockInfo
(
tsdbRead
er
T
*
pTsdbReadHandle
,
SDataBlockInfo
*
pDataBlockInfo
)
{
STsdbReadHandle
*
pHandle
=
(
STsdbReadHandle
*
)
pTsdbReadHandle
;
STsdbReadHandle
*
pHandle
=
(
STsdbReadHandle
*
)
pTsdbReadHandle
;
SQueryFilePos
*
cur
=
&
pHandle
->
cur
;
SQueryFilePos
*
cur
=
&
pHandle
->
cur
;
...
@@ -3254,7 +3254,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReadHandleT* pTsdbReadHandle, SDataBlockInfo*
...
@@ -3254,7 +3254,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReadHandleT* pTsdbReadHandle, SDataBlockInfo*
/*
/*
* return null for mixed data block, if not a complete file data block, the statistics value will always return NULL
* return null for mixed data block, if not a complete file data block, the statistics value will always return NULL
*/
*/
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbRead
Handle
T
*
pTsdbReadHandle
,
SDataStatis
**
pBlockStatis
)
{
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbRead
er
T
*
pTsdbReadHandle
,
SDataStatis
**
pBlockStatis
)
{
STsdbReadHandle
*
pHandle
=
(
STsdbReadHandle
*
)
pTsdbReadHandle
;
STsdbReadHandle
*
pHandle
=
(
STsdbReadHandle
*
)
pTsdbReadHandle
;
SQueryFilePos
*
c
=
&
pHandle
->
cur
;
SQueryFilePos
*
c
=
&
pHandle
->
cur
;
...
@@ -3309,7 +3309,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReadHandleT* pTsdbReadHandle, SDataS
...
@@ -3309,7 +3309,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReadHandleT* pTsdbReadHandle, SDataS
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SArray
*
tsdbRetrieveDataBlock
(
tsdbRead
Handle
T
*
pTsdbReadHandle
,
SArray
*
pIdList
)
{
SArray
*
tsdbRetrieveDataBlock
(
tsdbRead
er
T
*
pTsdbReadHandle
,
SArray
*
pIdList
)
{
/**
/**
* In the following two cases, the data has been loaded to SColumnInfoData.
* In the following two cases, the data has been loaded to SColumnInfoData.
* 1. data is from cache, 2. data block is not completed qualified to query time range
* 1. data is from cache, 2. data block is not completed qualified to query time range
...
@@ -3635,29 +3635,29 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd
...
@@ -3635,29 +3635,29 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd
// return TSDB_CODE_SUCCESS;
// return TSDB_CODE_SUCCESS;
//}
//}
int32_t
tsdbQuerySTableByTagCond
(
STsdb
*
tsdb
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
)
{
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
)
{
STbCfg
*
pTbCfg
=
metaGetTbInfoByUid
(
tsdb
->
pMeta
,
uid
);
STbCfg
*
pTbCfg
=
metaGetTbInfoByUid
(
pMeta
,
uid
);
if
(
pTbCfg
==
NULL
)
{
if
(
pTbCfg
==
NULL
)
{
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
tsdb
,
uid
,
taskId
,
reqId
);
//
tsdbError("%p failed to get stable, uid:%"PRIu64", TID:0x%"PRIx64" QID:0x%"PRIx64, tsdb, uid, taskId, reqId);
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
goto
_error
;
goto
_error
;
}
}
if
(
pTbCfg
->
type
!=
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
!=
META_SUPER_TABLE
)
{
tsdbError
(
"%p query normal tag not allowed, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
tsdb
,
uid
,
taskId
,
reqId
);
//
tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", TID:0x%"PRIx64" QID:0x%"PRIx64, tsdb, uid, taskId, reqId);
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
//basically, this error is caused by invalid sql issued by client
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
//basically, this error is caused by invalid sql issued by client
goto
_error
;
goto
_error
;
}
}
//NOTE: not add ref count for super table
//NOTE: not add ref count for super table
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
SSchemaWrapper
*
pTagSchema
=
metaGetTableSchema
(
tsdb
->
pMeta
,
uid
,
0
,
true
);
SSchemaWrapper
*
pTagSchema
=
metaGetTableSchema
(
pMeta
,
uid
,
0
,
true
);
// no tags and tbname condition, all child tables of this stable are involved
// no tags and tbname condition, all child tables of this stable are involved
if
(
tbnameCond
==
NULL
&&
(
pTagCond
==
NULL
||
len
==
0
))
{
if
(
tbnameCond
==
NULL
&&
(
pTagCond
==
NULL
||
len
==
0
))
{
int32_t
ret
=
getAllTableList
(
tsdb
->
pMeta
,
uid
,
res
);
int32_t
ret
=
getAllTableList
(
pMeta
,
uid
,
res
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
...
@@ -3665,8 +3665,8 @@ int32_t tsdbQuerySTableByTagCond(STsdb* tsdb, uint64_t uid, TSKEY skey, const ch
...
@@ -3665,8 +3665,8 @@ int32_t tsdbQuerySTableByTagCond(STsdb* tsdb, uint64_t uid, TSKEY skey, const ch
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
,
skey
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
,
skey
);
tsdbDebug
(
"%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu, TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
tsdb
,
//
tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu, TID:0x%"PRIx64" QID:0x%"PRIx64, tsdb,
pGroupInfo
->
numOfTables
,
taosArrayGetSize
(
pGroupInfo
->
pGroupList
),
taskId
,
reqId
);
//
pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList), taskId, reqId);
taosArrayDestroy
(
res
);
taosArrayDestroy
(
res
);
return
ret
;
return
ret
;
...
@@ -3722,26 +3722,19 @@ int32_t tsdbQuerySTableByTagCond(STsdb* tsdb, uint64_t uid, TSKEY skey, const ch
...
@@ -3722,26 +3722,19 @@ int32_t tsdbQuerySTableByTagCond(STsdb* tsdb, uint64_t uid, TSKEY skey, const ch
return
terrno
;
return
terrno
;
}
}
#if 0
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
)
{
int32_t tsdbGetOneTableGroup(STsdb* tsdb, uint64_t uid, TSKEY startKey, STableGroupInfo* pGroupInfo) {
STbCfg
*
pTbCfg
=
metaGetTbInfoByUid
(
pMeta
,
uid
);
if (tsdbRLockRepoMeta(tsdb) < 0) goto _error;
if
(
pTbCfg
==
NULL
)
{
STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid);
if (pTable == NULL) {
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
tsdbUnlockRepoMeta(tsdb);
goto
_error
;
goto
_error
;
}
}
assert(pTable->type == TSDB_CHILD_TABLE || pTable->type == TSDB_NORMAL_TABLE || pTable->type == TSDB_STREAM_TABLE);
if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error;
pGroupInfo
->
numOfTables
=
1
;
pGroupInfo
->
numOfTables
=
1
;
pGroupInfo
->
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
pGroupInfo
->
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
group
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
SArray
*
group
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
STableKeyInfo info = {.
pTable = pTable, .lastKey = startKey
};
STableKeyInfo
info
=
{.
lastKey
=
startKey
,
.
uid
=
uid
};
taosArrayPush
(
group
,
&
info
);
taosArrayPush
(
group
,
&
info
);
taosArrayPush
(
pGroupInfo
->
pGroupList
,
&
group
);
taosArrayPush
(
pGroupInfo
->
pGroupList
,
&
group
);
...
@@ -3751,6 +3744,7 @@ int32_t tsdbGetOneTableGroup(STsdb* tsdb, uint64_t uid, TSKEY startKey, STableGr
...
@@ -3751,6 +3744,7 @@ int32_t tsdbGetOneTableGroup(STsdb* tsdb, uint64_t uid, TSKEY startKey, STableGr
return
terrno
;
return
terrno
;
}
}
#if 0
int32_t tsdbGetTableGroupFromIdList(STsdb* tsdb, SArray* pTableIdList, STableGroupInfo* pGroupInfo) {
int32_t tsdbGetTableGroupFromIdList(STsdb* tsdb, SArray* pTableIdList, STableGroupInfo* pGroupInfo) {
if (tsdbRLockRepoMeta(tsdb) < 0) {
if (tsdbRLockRepoMeta(tsdb) < 0) {
return terrno;
return terrno;
...
@@ -3826,7 +3820,7 @@ static void* destroyTableCheckInfo(SArray* pTableCheckInfo) {
...
@@ -3826,7 +3820,7 @@ static void* destroyTableCheckInfo(SArray* pTableCheckInfo) {
}
}
void
tsdbCleanup
QueryHandle
(
tsdbReadHandle
T
queryHandle
)
{
void
tsdbCleanup
ReadHandle
(
tsdbReader
T
queryHandle
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
queryHandle
;
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
queryHandle
;
if
(
pTsdbReadHandle
==
NULL
)
{
if
(
pTsdbReadHandle
==
NULL
)
{
return
;
return
;
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
244b552f
...
@@ -26,12 +26,14 @@ int vnodeQueryOpen(SVnode *pVnode) {
...
@@ -26,12 +26,14 @@ int vnodeQueryOpen(SVnode *pVnode) {
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
vTrace
(
"message in query queue is processing"
);
vTrace
(
"message in query queue is processing"
);
SReadHandle
handle
=
{.
reader
=
pVnode
->
pTsdb
,
.
meta
=
pVnode
->
pMeta
};
switch
(
pMsg
->
msgType
)
{
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_QUERY
:
case
TDMT_VND_QUERY
:{
return
qWorkerProcessQueryMsg
(
pVnode
->
pTsdb
,
pVnode
->
pQuery
,
pMsg
);
return
qWorkerProcessQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
);
}
case
TDMT_VND_QUERY_CONTINUE
:
case
TDMT_VND_QUERY_CONTINUE
:
return
qWorkerProcessCQueryMsg
(
pVnode
->
pTsdb
,
pVnode
->
pQuery
,
pMsg
);
return
qWorkerProcessCQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
);
default:
default:
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
return
TSDB_CODE_VND_APP_ERROR
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
244b552f
...
@@ -224,12 +224,12 @@ typedef struct STaskAttr {
...
@@ -224,12 +224,12 @@ typedef struct STaskAttr {
// SFilterInfo *pFilters;
// SFilterInfo *pFilters;
void
*
tsdb
;
void
*
tsdb
;
// SMemRef memRef;
STableGroupInfo
tableGroupInfo
;
// table <tid, last_key> list SArray<STableKeyInfo>
STableGroupInfo
tableGroupInfo
;
// table <tid, last_key> list SArray<STableKeyInfo>
int32_t
vgId
;
int32_t
vgId
;
SArray
*
pUdfInfo
;
// no need to free
SArray
*
pUdfInfo
;
// no need to free
}
STaskAttr
;
}
STaskAttr
;
typedef
int32_t
(
*
__optr_prepare_fn_t
)(
void
*
param
);
typedef
SSDataBlock
*
(
*
__operator_fn_t
)(
void
*
param
,
bool
*
newgroup
);
typedef
SSDataBlock
*
(
*
__operator_fn_t
)(
void
*
param
,
bool
*
newgroup
);
typedef
void
(
*
__optr_cleanup_fn_t
)(
void
*
param
,
int32_t
num
);
typedef
void
(
*
__optr_cleanup_fn_t
)(
void
*
param
,
int32_t
num
);
...
@@ -313,8 +313,9 @@ typedef struct SOperatorInfo {
...
@@ -313,8 +313,9 @@ typedef struct SOperatorInfo {
struct
SOperatorInfo
**
pDownstream
;
// downstram pointer list
struct
SOperatorInfo
**
pDownstream
;
// downstram pointer list
int32_t
numOfDownstream
;
// number of downstream. The value is always ONE expect for join operator
int32_t
numOfDownstream
;
// number of downstream. The value is always ONE expect for join operator
__optr_prepare_fn_t
prepareFn
;
__operator_fn_t
exec
;
__operator_fn_t
exec
;
__optr_cleanup_fn_t
cleanup
;
__optr_cleanup_fn_t
cleanup
Fn
;
}
SOperatorInfo
;
}
SOperatorInfo
;
enum
{
enum
{
...
@@ -395,7 +396,7 @@ typedef struct STableScanInfo {
...
@@ -395,7 +396,7 @@ typedef struct STableScanInfo {
int32_t
current
;
int32_t
current
;
int32_t
reverseTimes
;
// 0 by default
int32_t
reverseTimes
;
// 0 by default
S
QL
FunctionCtx
*
pCtx
;
// next operator query context
S
ql
FunctionCtx
*
pCtx
;
// next operator query context
SResultRowInfo
*
pResultRowInfo
;
SResultRowInfo
*
pResultRowInfo
;
int32_t
*
rowCellInfoOffset
;
int32_t
*
rowCellInfoOffset
;
SExprInfo
*
pExpr
;
SExprInfo
*
pExpr
;
...
@@ -425,7 +426,7 @@ typedef struct SStreamBlockScanInfo {
...
@@ -425,7 +426,7 @@ typedef struct SStreamBlockScanInfo {
typedef
struct
SOptrBasicInfo
{
typedef
struct
SOptrBasicInfo
{
SResultRowInfo
resultRowInfo
;
SResultRowInfo
resultRowInfo
;
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
S
QL
FunctionCtx
*
pCtx
;
S
ql
FunctionCtx
*
pCtx
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
}
SOptrBasicInfo
;
}
SOptrBasicInfo
;
...
@@ -564,7 +565,6 @@ typedef struct SOrderOperatorInfo {
...
@@ -564,7 +565,6 @@ typedef struct SOrderOperatorInfo {
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SArray
*
pSources
,
const
SArray
*
pSchema
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SArray
*
pSources
,
const
SArray
*
pSchema
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createSubmitBlockScanOperatorInfo
(
void
*
pSubmitBlockReadHandle
,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSubmitBlockScanOperatorInfo
(
void
*
pSubmitBlockReadHandle
,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
);
...
@@ -607,11 +607,11 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
...
@@ -607,11 +607,11 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
void
*
destroyOutputBuf
(
SSDataBlock
*
pBlock
);
void
*
destroyOutputBuf
(
SSDataBlock
*
pBlock
);
void
*
doDestroyFilterInfo
(
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
);
void
*
doDestroyFilterInfo
(
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
);
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
void
finalizeQueryResult
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
);
void
finalizeQueryResult
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
);
void
updateOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
,
int32_t
numOfInputRows
);
void
updateOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
,
int32_t
numOfInputRows
);
void
clearOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
);
void
clearOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
);
void
copyTsColoum
(
SSDataBlock
*
pRes
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
void
copyTsColoum
(
SSDataBlock
*
pRes
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
void
freeParam
(
STaskParam
*
param
);
void
freeParam
(
STaskParam
*
param
);
int32_t
createQueryFunc
(
SQueriedTableInfo
*
pTableInfo
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
int32_t
createQueryFunc
(
SQueriedTableInfo
*
pTableInfo
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
...
@@ -659,8 +659,8 @@ void freeQueryAttr(STaskAttr *pQuery);
...
@@ -659,8 +659,8 @@ void freeQueryAttr(STaskAttr *pQuery);
int32_t
getMaximumIdleDurationSec
();
int32_t
getMaximumIdleDurationSec
();
void
doInvokeUdf
(
struct
SUdfInfo
*
pUdfInfo
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
idx
,
int32_t
type
);
void
doInvokeUdf
(
struct
SUdfInfo
*
pUdfInfo
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
idx
,
int32_t
type
);
void
setTaskStatus
(
SExecTaskInfo
*
pTaskInfo
,
int8_t
status
);
void
setTaskStatus
(
SExecTaskInfo
*
pTaskInfo
,
int8_t
status
);
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
void
*
reader
Handle
,
uint64_t
taskId
);
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
p
Handle
,
uint64_t
taskId
);
#endif // TDENGINE_EXECUTORIMPL_H
#endif // TDENGINE_EXECUTORIMPL_H
source/libs/executor/src/executor.c
浏览文件 @
244b552f
...
@@ -39,7 +39,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, char* id)
...
@@ -39,7 +39,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, char* id)
}
}
}
}
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
void
*
input
)
{
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
)
{
if
(
tinfo
==
NULL
)
{
if
(
tinfo
==
NULL
)
{
return
TSDB_CODE_QRY_APP_ERROR
;
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
...
@@ -50,7 +50,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, void* input) {
...
@@ -50,7 +50,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, void* input) {
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
input
,
GET_TASKID
(
pTaskInfo
));
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
(
void
*
)
input
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s failed to set the stream block data"
,
GET_TASKID
(
pTaskInfo
));
qError
(
"%s failed to set the stream block data"
,
GET_TASKID
(
pTaskInfo
));
}
else
{
}
else
{
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
244b552f
...
@@ -51,25 +51,7 @@ static void freeqinfoFn(void *qhandle) {
...
@@ -51,25 +51,7 @@ static void freeqinfoFn(void *qhandle) {
qDestroyTask
(
*
handle
);
qDestroyTask
(
*
handle
);
}
}
void
freeParam
(
STaskParam
*
param
)
{
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
SSubplan
*
pSubplan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
)
{
tfree
(
param
->
sql
);
tfree
(
param
->
tagCond
);
tfree
(
param
->
tbnameCond
);
tfree
(
param
->
pTableIdList
);
taosArrayDestroy
(
param
->
pOperator
);
tfree
(
param
->
pExprs
);
tfree
(
param
->
pSecExprs
);
tfree
(
param
->
pExpr
);
tfree
(
param
->
pSecExpr
);
tfree
(
param
->
pGroupColIndex
);
tfree
(
param
->
pTagColumnInfo
);
tfree
(
param
->
pGroupbyExpr
);
tfree
(
param
->
prevResult
);
}
int32_t
qCreateExecTask
(
void
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
SSubplan
*
pSubplan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
)
{
assert
(
readHandle
!=
NULL
&&
pSubplan
!=
NULL
);
assert
(
readHandle
!=
NULL
&&
pSubplan
!=
NULL
);
SExecTaskInfo
**
pTask
=
(
SExecTaskInfo
**
)
pTaskInfo
;
SExecTaskInfo
**
pTask
=
(
SExecTaskInfo
**
)
pTaskInfo
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
244b552f
...
@@ -173,13 +173,13 @@ static void getNextTimeWindow(STaskAttr* pQueryAttr, STimeWindow* tw) {
...
@@ -173,13 +173,13 @@ static void getNextTimeWindow(STaskAttr* pQueryAttr, STimeWindow* tw) {
}
}
static
void
doSetTagValueToResultBuf
(
char
*
output
,
const
char
*
val
,
int16_t
type
,
int16_t
bytes
);
static
void
doSetTagValueToResultBuf
(
char
*
output
,
const
char
*
val
,
int16_t
type
,
int16_t
bytes
);
static
void
setResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
QL
FunctionCtx
*
pCtx
,
static
void
setResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfCols
,
int32_t
*
rowCellInfoOffset
);
int32_t
numOfCols
,
int32_t
*
rowCellInfoOffset
);
void
setResultRowOutputBufInitCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
void
setResultRowOutputBufInitCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
static
bool
functionNeedToExecute
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
);
static
bool
functionNeedToExecute
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
);
static
void
setBlockStatisInfo
(
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
);
static
void
setBlockStatisInfo
(
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
);
static
void
destroyTableQueryInfoImpl
(
STableQueryInfo
*
pTableQueryInfo
);
static
void
destroyTableQueryInfoImpl
(
STableQueryInfo
*
pTableQueryInfo
);
static
bool
hasMainOutput
(
STaskAttr
*
pQueryAttr
);
static
bool
hasMainOutput
(
STaskAttr
*
pQueryAttr
);
...
@@ -219,14 +219,14 @@ static int32_t doCopyToSDataBlock(STaskRuntimeEnv* pRuntimeEnv, SGroupResInfo* p
...
@@ -219,14 +219,14 @@ static int32_t doCopyToSDataBlock(STaskRuntimeEnv* pRuntimeEnv, SGroupResInfo* p
static
int32_t
getGroupbyColumnIndex
(
SGroupbyExpr
*
pGroupbyExpr
,
SSDataBlock
*
pDataBlock
);
static
int32_t
getGroupbyColumnIndex
(
SGroupbyExpr
*
pGroupbyExpr
,
SSDataBlock
*
pDataBlock
);
static
int32_t
setGroupResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
binf
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupIndex
);
static
int32_t
setGroupResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
binf
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupIndex
);
static
void
initCtxOutputBuffer
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
size
);
static
void
initCtxOutputBuffer
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
size
);
static
void
getAlignQueryTimeWindow
(
STaskAttr
*
pQueryAttr
,
int64_t
key
,
int64_t
keyFirst
,
int64_t
keyLast
,
STimeWindow
*
win
);
static
void
getAlignQueryTimeWindow
(
STaskAttr
*
pQueryAttr
,
int64_t
key
,
int64_t
keyFirst
,
int64_t
keyLast
,
STimeWindow
*
win
);
static
void
setResultBufSize
(
STaskAttr
*
pQueryAttr
,
SRspResultInfo
*
pResultInfo
);
static
void
setResultBufSize
(
STaskAttr
*
pQueryAttr
,
SRspResultInfo
*
pResultInfo
);
static
void
setCtxTagForJoin
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
);
static
void
setCtxTagForJoin
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
);
static
void
setParamForStableStddev
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
);
static
void
setParamForStableStddev
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
);
static
void
setParamForStableStddevByColData
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
);
static
void
setParamForStableStddevByColData
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
);
static
void
doSetTableGroupOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
static
void
doSetTableGroupOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
*
rowCellInfoOffset
,
int32_t
numOfOutput
,
int32_t
tableGroupId
);
S
ql
FunctionCtx
*
pCtx
,
int32_t
*
rowCellInfoOffset
,
int32_t
numOfOutput
,
int32_t
tableGroupId
);
SArray
*
getOrderCheckColumns
(
STaskAttr
*
pQuery
);
SArray
*
getOrderCheckColumns
(
STaskAttr
*
pQuery
);
...
@@ -354,7 +354,7 @@ void* destroyOutputBuf(SSDataBlock* pBlock) {
...
@@ -354,7 +354,7 @@ void* destroyOutputBuf(SSDataBlock* pBlock) {
return
NULL
;
return
NULL
;
}
}
static
bool
isSelectivityWithTagsQuery
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
static
bool
isSelectivityWithTagsQuery
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
return
true
;
return
true
;
// bool hasTags = false;
// bool hasTags = false;
// int32_t numOfSelectivity = 0;
// int32_t numOfSelectivity = 0;
...
@@ -754,14 +754,14 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf
...
@@ -754,14 +754,14 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf
}
}
static
bool
chkWindowOutputBufByKey
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
STimeWindow
*
win
,
static
bool
chkWindowOutputBufByKey
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
STimeWindow
*
win
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
groupId
,
S
QL
FunctionCtx
*
pCtx
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
groupId
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
assert
(
win
->
skey
<=
win
->
ekey
);
return
chkResultRowFromKey
(
pRuntimeEnv
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
groupId
);
return
chkResultRowFromKey
(
pRuntimeEnv
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
groupId
);
}
}
static
int32_t
setResultOutputBufByKey
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
STimeWindow
*
win
,
static
int32_t
setResultOutputBufByKey
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
STimeWindow
*
win
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
tableGroupId
,
S
QL
FunctionCtx
*
pCtx
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
tableGroupId
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
assert
(
win
->
skey
<=
win
->
ekey
);
SDiskbasedResultBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
SDiskbasedResultBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
...
@@ -940,7 +940,7 @@ static int32_t getNumOfRowsInTimeWindow(STaskRuntimeEnv* pRuntimeEnv, SDataBlock
...
@@ -940,7 +940,7 @@ static int32_t getNumOfRowsInTimeWindow(STaskRuntimeEnv* pRuntimeEnv, SDataBlock
return
num
;
return
num
;
}
}
static
void
doApplyFunctions
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
int32_t
offset
,
static
void
doApplyFunctions
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
)
{
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
bool
hasAggregates
=
pCtx
[
0
].
isAggSet
;
bool
hasAggregates
=
pCtx
[
0
].
isAggSet
;
...
@@ -1073,7 +1073,7 @@ static FORCE_INLINE TSKEY reviseWindowEkey(STaskAttr *pQueryAttr, STimeWindow *p
...
@@ -1073,7 +1073,7 @@ static FORCE_INLINE TSKEY reviseWindowEkey(STaskAttr *pQueryAttr, STimeWindow *p
return
ekey
;
return
ekey
;
}
}
static
void
setNotInterpoWindowKey
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
type
)
{
static
void
setNotInterpoWindowKey
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
type
)
{
if
(
type
==
RESULT_ROW_START_INTERP
)
{
if
(
type
==
RESULT_ROW_START_INTERP
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
pCtx
[
k
].
start
.
key
=
INT64_MIN
;
pCtx
[
k
].
start
.
key
=
INT64_MIN
;
...
@@ -1112,9 +1112,9 @@ static TSKEY getStartTsKey(STaskAttr* pQueryAttr, STimeWindow* win, const TSKEY*
...
@@ -1112,9 +1112,9 @@ static TSKEY getStartTsKey(STaskAttr* pQueryAttr, STimeWindow* win, const TSKEY*
return
ts
;
return
ts
;
}
}
static
void
doSetInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
static
void
doSetInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
static
void
doSetInputDataBlockInfo
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
static
void
doSetInputDataBlockInfo
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
pCtx
[
i
].
order
=
order
;
pCtx
[
i
].
order
=
order
;
pCtx
[
i
].
size
=
pBlock
->
info
.
rows
;
pCtx
[
i
].
size
=
pBlock
->
info
.
rows
;
...
@@ -1124,7 +1124,7 @@ static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SQLFunctionCtx* pC
...
@@ -1124,7 +1124,7 @@ static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SQLFunctionCtx* pC
}
}
}
}
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
// if (pCtx[0].functionId == FUNCTION_ARITHM) {
// if (pCtx[0].functionId == FUNCTION_ARITHM) {
// SScalar* pSupport = (SScalarFunctionSupport*) pCtx[0].param[1].pz;
// SScalar* pSupport = (SScalarFunctionSupport*) pCtx[0].param[1].pz;
// if (pSupport->colList == NULL) {
// if (pSupport->colList == NULL) {
...
@@ -1141,7 +1141,7 @@ void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlo
...
@@ -1141,7 +1141,7 @@ void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlo
// }
// }
}
}
static
void
doSetInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
static
void
doSetInputDataBlock
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
pCtx
[
i
].
order
=
order
;
pCtx
[
i
].
order
=
order
;
pCtx
[
i
].
size
=
pBlock
->
info
.
rows
;
pCtx
[
i
].
size
=
pBlock
->
info
.
rows
;
...
@@ -1205,7 +1205,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
...
@@ -1205,7 +1205,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
}
}
}
}
static
void
doAggregateImpl
(
SOperatorInfo
*
pOperator
,
TSKEY
startTs
,
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
)
{
static
void
doAggregateImpl
(
SOperatorInfo
*
pOperator
,
TSKEY
startTs
,
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
)
{
for
(
int32_t
k
=
0
;
k
<
pOperator
->
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pOperator
->
numOfOutput
;
++
k
)
{
if
(
functionNeedToExecute
(
NULL
,
&
pCtx
[
k
]))
{
if
(
functionNeedToExecute
(
NULL
,
&
pCtx
[
k
]))
{
pCtx
[
k
].
startTs
=
startTs
;
// this can be set during create the struct
pCtx
[
k
].
startTs
=
startTs
;
// this can be set during create the struct
...
@@ -1214,7 +1214,7 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SQLFunction
...
@@ -1214,7 +1214,7 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SQLFunction
}
}
}
}
static
void
projectApplyFunctions
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
static
void
projectApplyFunctions
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
...
@@ -1242,7 +1242,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo,
...
@@ -1242,7 +1242,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo,
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
SExprInfo
*
pExpr
=
pOperator
->
pExpr
;
SExprInfo
*
pExpr
=
pOperator
->
pExpr
;
S
QL
FunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
S
ql
FunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
for
(
int32_t
k
=
0
;
k
<
pOperator
->
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
pOperator
->
numOfOutput
;
++
k
)
{
int32_t
functionId
=
pCtx
[
k
].
functionId
;
int32_t
functionId
=
pCtx
[
k
].
functionId
;
...
@@ -1302,7 +1302,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo,
...
@@ -1302,7 +1302,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo,
}
}
}
}
static
bool
setTimeWindowInterpolationStartTs
(
SOperatorInfo
*
pOperatorInfo
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
pos
,
static
bool
setTimeWindowInterpolationStartTs
(
SOperatorInfo
*
pOperatorInfo
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
pos
,
int32_t
numOfRows
,
SArray
*
pDataBlock
,
const
TSKEY
*
tsCols
,
STimeWindow
*
win
)
{
int32_t
numOfRows
,
SArray
*
pDataBlock
,
const
TSKEY
*
tsCols
,
STimeWindow
*
win
)
{
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
...
@@ -1333,7 +1333,7 @@ static bool setTimeWindowInterpolationStartTs(SOperatorInfo* pOperatorInfo, SQLF
...
@@ -1333,7 +1333,7 @@ static bool setTimeWindowInterpolationStartTs(SOperatorInfo* pOperatorInfo, SQLF
return
true
;
return
true
;
}
}
static
bool
setTimeWindowInterpolationEndTs
(
SOperatorInfo
*
pOperatorInfo
,
S
QL
FunctionCtx
*
pCtx
,
static
bool
setTimeWindowInterpolationEndTs
(
SOperatorInfo
*
pOperatorInfo
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
endRowIndex
,
SArray
*
pDataBlock
,
const
TSKEY
*
tsCols
,
TSKEY
blockEkey
,
STimeWindow
*
win
)
{
int32_t
endRowIndex
,
SArray
*
pDataBlock
,
const
TSKEY
*
tsCols
,
TSKEY
blockEkey
,
STimeWindow
*
win
)
{
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
...
@@ -1365,7 +1365,7 @@ static bool setTimeWindowInterpolationEndTs(SOperatorInfo* pOperatorInfo, SQLFun
...
@@ -1365,7 +1365,7 @@ static bool setTimeWindowInterpolationEndTs(SOperatorInfo* pOperatorInfo, SQLFun
return
true
;
return
true
;
}
}
static
void
doWindowBorderInterpolation
(
SOperatorInfo
*
pOperatorInfo
,
SSDataBlock
*
pBlock
,
S
QL
FunctionCtx
*
pCtx
,
static
void
doWindowBorderInterpolation
(
SOperatorInfo
*
pOperatorInfo
,
SSDataBlock
*
pBlock
,
S
ql
FunctionCtx
*
pCtx
,
SResultRow
*
pResult
,
STimeWindow
*
win
,
int32_t
startPos
,
int32_t
forwardStep
)
{
SResultRow
*
pResult
,
STimeWindow
*
win
,
int32_t
startPos
,
int32_t
forwardStep
)
{
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
...
@@ -1775,7 +1775,7 @@ static int32_t setGroupResultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SOptrBasicI
...
@@ -1775,7 +1775,7 @@ static int32_t setGroupResultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SOptrBasicI
int32_t
*
rowCellInfoOffset
=
binfo
->
rowCellInfoOffset
;
int32_t
*
rowCellInfoOffset
=
binfo
->
rowCellInfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
S
QL
FunctionCtx
*
pCtx
=
binfo
->
pCtx
;
S
ql
FunctionCtx
*
pCtx
=
binfo
->
pCtx
;
// not assign result buffer yet, add new result buffer, TODO remove it
// not assign result buffer yet, add new result buffer, TODO remove it
char
*
d
=
pData
;
char
*
d
=
pData
;
...
@@ -1824,7 +1824,7 @@ static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pD
...
@@ -1824,7 +1824,7 @@ static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pD
return
-
1
;
return
-
1
;
}
}
static
bool
functionNeedToExecute
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
)
{
static
bool
functionNeedToExecute
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
)
{
struct
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
struct
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
// in case of timestamp column, always generated results.
// in case of timestamp column, always generated results.
...
@@ -1855,7 +1855,7 @@ static bool functionNeedToExecute(STaskRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *
...
@@ -1855,7 +1855,7 @@ static bool functionNeedToExecute(STaskRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *
return
true
;
return
true
;
}
}
void
setBlockStatisInfo
(
S
QL
FunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
)
{
void
setBlockStatisInfo
(
S
ql
FunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
)
{
SColumnDataAgg
*
pAgg
=
NULL
;
SColumnDataAgg
*
pAgg
=
NULL
;
if
(
pSDataBlock
->
pBlockAgg
!=
NULL
&&
TSDB_COL_IS_NORMAL_COL
(
pColumn
->
flag
))
{
if
(
pSDataBlock
->
pBlockAgg
!=
NULL
&&
TSDB_COL_IS_NORMAL_COL
(
pColumn
->
flag
))
{
...
@@ -1879,7 +1879,7 @@ void setBlockStatisInfo(SQLFunctionCtx *pCtx, SSDataBlock* pSDataBlock, SColumn*
...
@@ -1879,7 +1879,7 @@ void setBlockStatisInfo(SQLFunctionCtx *pCtx, SSDataBlock* pSDataBlock, SColumn*
}
}
// set the output buffer for the selectivity + tag query
// set the output buffer for the selectivity + tag query
static
int32_t
setCtxTagColumnInfo
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
static
int32_t
setCtxTagColumnInfo
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
if
(
!
isSelectivityWithTagsQuery
(
pCtx
,
numOfOutput
))
{
if
(
!
isSelectivityWithTagsQuery
(
pCtx
,
numOfOutput
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1887,8 +1887,8 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
...
@@ -1887,8 +1887,8 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
int32_t
num
=
0
;
int32_t
num
=
0
;
int16_t
tagLen
=
0
;
int16_t
tagLen
=
0
;
S
QL
FunctionCtx
*
p
=
NULL
;
S
ql
FunctionCtx
*
p
=
NULL
;
S
QL
FunctionCtx
**
pTagCtx
=
calloc
(
numOfOutput
,
POINTER_BYTES
);
S
ql
FunctionCtx
**
pTagCtx
=
calloc
(
numOfOutput
,
POINTER_BYTES
);
if
(
pTagCtx
==
NULL
)
{
if
(
pTagCtx
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
}
...
@@ -1920,11 +1920,11 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
...
@@ -1920,11 +1920,11 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
S
QL
FunctionCtx
*
createSqlFunctionCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
static
S
ql
FunctionCtx
*
createSqlFunctionCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
)
{
int32_t
**
rowCellInfoOffset
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
S
QLFunctionCtx
*
pFuncCtx
=
(
SQLFunctionCtx
*
)
calloc
(
numOfOutput
,
sizeof
(
SQL
FunctionCtx
));
S
qlFunctionCtx
*
pFuncCtx
=
(
SqlFunctionCtx
*
)
calloc
(
numOfOutput
,
sizeof
(
Sql
FunctionCtx
));
if
(
pFuncCtx
==
NULL
)
{
if
(
pFuncCtx
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -1937,7 +1937,7 @@ static SQLFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI
...
@@ -1937,7 +1937,7 @@ static SQLFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SSqlExpr
*
pSqlExpr
=
&
pExpr
[
i
].
base
;
SSqlExpr
*
pSqlExpr
=
&
pExpr
[
i
].
base
;
S
QL
FunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
S
ql
FunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
#if 0
#if 0
SColIndex *pIndex = &pSqlExpr->colInfo;
SColIndex *pIndex = &pSqlExpr->colInfo;
...
@@ -2024,10 +2024,10 @@ static SQLFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI
...
@@ -2024,10 +2024,10 @@ static SQLFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI
return
pFuncCtx
;
return
pFuncCtx
;
}
}
static
S
QL
FunctionCtx
*
createSqlFunctionCtx_rv
(
SArray
*
pExprInfo
,
int32_t
**
rowCellInfoOffset
)
{
static
S
ql
FunctionCtx
*
createSqlFunctionCtx_rv
(
SArray
*
pExprInfo
,
int32_t
**
rowCellInfoOffset
)
{
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
S
QLFunctionCtx
*
pFuncCtx
=
(
SQLFunctionCtx
*
)
calloc
(
numOfOutput
,
sizeof
(
SQL
FunctionCtx
));
S
qlFunctionCtx
*
pFuncCtx
=
(
SqlFunctionCtx
*
)
calloc
(
numOfOutput
,
sizeof
(
Sql
FunctionCtx
));
if
(
pFuncCtx
==
NULL
)
{
if
(
pFuncCtx
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -2042,7 +2042,7 @@ static SQLFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
...
@@ -2042,7 +2042,7 @@ static SQLFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
);
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
);
SSqlExpr
*
pSqlExpr
=
&
pExpr
->
base
;
SSqlExpr
*
pSqlExpr
=
&
pExpr
->
base
;
S
QL
FunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
S
ql
FunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
#if 0
#if 0
SColIndex *pIndex = &pSqlExpr->colInfo;
SColIndex *pIndex = &pSqlExpr->colInfo;
...
@@ -2128,7 +2128,7 @@ static SQLFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
...
@@ -2128,7 +2128,7 @@ static SQLFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
return
pFuncCtx
;
return
pFuncCtx
;
}
}
static
void
*
destroySQLFunctionCtx
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
static
void
*
destroySQLFunctionCtx
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
if
(
pCtx
==
NULL
)
{
if
(
pCtx
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -2371,7 +2371,7 @@ _clean:
...
@@ -2371,7 +2371,7 @@ _clean:
static
void
doFreeQueryHandle
(
STaskRuntimeEnv
*
pRuntimeEnv
)
{
static
void
doFreeQueryHandle
(
STaskRuntimeEnv
*
pRuntimeEnv
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
// tsdbCleanup
Query
Handle(pRuntimeEnv->pTsdbReadHandle);
// tsdbCleanup
Read
Handle(pRuntimeEnv->pTsdbReadHandle);
pRuntimeEnv
->
pTsdbReadHandle
=
NULL
;
pRuntimeEnv
->
pTsdbReadHandle
=
NULL
;
// SMemRef* pMemRef = &pQueryAttr->memRef;
// SMemRef* pMemRef = &pQueryAttr->memRef;
...
@@ -2773,7 +2773,7 @@ static void getIntermediateBufInfo(STaskRuntimeEnv* pRuntimeEnv, int32_t* ps, in
...
@@ -2773,7 +2773,7 @@ static void getIntermediateBufInfo(STaskRuntimeEnv* pRuntimeEnv, int32_t* ps, in
#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_BINARY && (_t) != TSDB_DATA_TYPE_NCHAR)
#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_BINARY && (_t) != TSDB_DATA_TYPE_NCHAR)
//static FORCE_INLINE bool doFilterByBlockStatistics(STaskRuntimeEnv* pRuntimeEnv, SDataStatis *pDataStatis, S
QL
FunctionCtx *pCtx, int32_t numOfRows) {
//static FORCE_INLINE bool doFilterByBlockStatistics(STaskRuntimeEnv* pRuntimeEnv, SDataStatis *pDataStatis, S
ql
FunctionCtx *pCtx, int32_t numOfRows) {
// STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
// STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
//
//
// if (pDataStatis == NULL || pQueryAttr->pFilters == NULL) {
// if (pDataStatis == NULL || pQueryAttr->pFilters == NULL) {
...
@@ -3053,7 +3053,7 @@ static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t num
...
@@ -3053,7 +3053,7 @@ static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t num
static
void
doSetTagValueInParam
(
void
*
pTable
,
int32_t
tagColId
,
SVariant
*
tag
,
int16_t
type
,
int16_t
bytes
);
static
void
doSetTagValueInParam
(
void
*
pTable
,
int32_t
tagColId
,
SVariant
*
tag
,
int16_t
type
,
int16_t
bytes
);
static
uint32_t
doFilterByBlockTimeWindow
(
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
)
{
static
uint32_t
doFilterByBlockTimeWindow
(
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
)
{
S
QL
FunctionCtx
*
pCtx
=
pTableScanInfo
->
pCtx
;
S
ql
FunctionCtx
*
pCtx
=
pTableScanInfo
->
pCtx
;
uint32_t
status
=
BLK_DATA_NO_NEEDED
;
uint32_t
status
=
BLK_DATA_NO_NEEDED
;
int32_t
numOfOutput
=
pTableScanInfo
->
numOfOutput
;
int32_t
numOfOutput
=
pTableScanInfo
->
numOfOutput
;
...
@@ -3334,7 +3334,7 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) {
...
@@ -3334,7 +3334,7 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) {
}
}
/*
/*
* set tag value in S
QL
FunctionCtx
* set tag value in S
ql
FunctionCtx
* e.g.,tag information into input buffer
* e.g.,tag information into input buffer
*/
*/
static
void
doSetTagValueInParam
(
void
*
pTable
,
int32_t
tagColId
,
SVariant
*
tag
,
int16_t
type
,
int16_t
bytes
)
{
static
void
doSetTagValueInParam
(
void
*
pTable
,
int32_t
tagColId
,
SVariant
*
tag
,
int16_t
type
,
int16_t
bytes
)
{
...
@@ -3375,7 +3375,7 @@ static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t num
...
@@ -3375,7 +3375,7 @@ static SColumnInfo* doGetTagColumnInfoById(SColumnInfo* pTagColList, int32_t num
return
NULL
;
return
NULL
;
}
}
void
setTagValue
(
SOperatorInfo
*
pOperatorInfo
,
void
*
pTable
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
void
setTagValue
(
SOperatorInfo
*
pOperatorInfo
,
void
*
pTable
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperatorInfo
->
pRuntimeEnv
;
SExprInfo
*
pExpr
=
pOperatorInfo
->
pExpr
;
SExprInfo
*
pExpr
=
pOperatorInfo
->
pExpr
;
...
@@ -3509,7 +3509,7 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) {
...
@@ -3509,7 +3509,7 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) {
}
}
void
switchCtxOrder
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
void
switchCtxOrder
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SWITCH_ORDER
(
pCtx
[
i
].
order
);
SWITCH_ORDER
(
pCtx
[
i
].
order
);
}
}
...
@@ -3531,7 +3531,7 @@ int32_t initResultRow(SResultRow *pResultRow) {
...
@@ -3531,7 +3531,7 @@ int32_t initResultRow(SResultRow *pResultRow) {
* offset[0] offset[1] offset[2]
* offset[0] offset[1] offset[2]
*/
*/
void
setDefaultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
pInfo
,
int64_t
uid
,
int32_t
stage
)
{
void
setDefaultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
pInfo
,
int64_t
uid
,
int32_t
stage
)
{
S
QL
FunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
S
ql
FunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
SSDataBlock
*
pDataBlock
=
pInfo
->
pRes
;
SSDataBlock
*
pDataBlock
=
pInfo
->
pRes
;
int32_t
*
rowCellInfoOffset
=
pInfo
->
rowCellInfoOffset
;
int32_t
*
rowCellInfoOffset
=
pInfo
->
rowCellInfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
...
@@ -3568,7 +3568,7 @@ void setDefaultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, in
...
@@ -3568,7 +3568,7 @@ void setDefaultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, in
void
setDefaultOutputBuf_rv
(
SAggOperatorInfo
*
pAggInfo
,
int64_t
uid
,
int32_t
stage
,
SExecTaskInfo
*
pTaskInfo
)
{
void
setDefaultOutputBuf_rv
(
SAggOperatorInfo
*
pAggInfo
,
int64_t
uid
,
int32_t
stage
,
SExecTaskInfo
*
pTaskInfo
)
{
SOptrBasicInfo
*
pInfo
=
&
pAggInfo
->
binfo
;
SOptrBasicInfo
*
pInfo
=
&
pAggInfo
->
binfo
;
S
QL
FunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
S
ql
FunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
SSDataBlock
*
pDataBlock
=
pInfo
->
pRes
;
SSDataBlock
*
pDataBlock
=
pInfo
->
pRes
;
int32_t
*
rowCellInfoOffset
=
pInfo
->
rowCellInfoOffset
;
int32_t
*
rowCellInfoOffset
=
pInfo
->
rowCellInfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
...
@@ -3637,7 +3637,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
...
@@ -3637,7 +3637,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf
}
}
}
}
void
copyTsColoum
(
SSDataBlock
*
pRes
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
void
copyTsColoum
(
SSDataBlock
*
pRes
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
bool
needCopyTs
=
false
;
bool
needCopyTs
=
false
;
int32_t
tsNum
=
0
;
int32_t
tsNum
=
0
;
char
*
src
=
NULL
;
char
*
src
=
NULL
;
...
@@ -3680,7 +3680,7 @@ void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity) {
...
@@ -3680,7 +3680,7 @@ void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity) {
}
}
}
}
void
initCtxOutputBuffer
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
size
)
{
void
initCtxOutputBuffer
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
size
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
struct
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
struct
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
if
(
isRowEntryInitialized
(
pResInfo
))
{
if
(
isRowEntryInitialized
(
pResInfo
))
{
...
@@ -3701,7 +3701,7 @@ void setTaskStatus(SExecTaskInfo *pTaskInfo, int8_t status) {
...
@@ -3701,7 +3701,7 @@ void setTaskStatus(SExecTaskInfo *pTaskInfo, int8_t status) {
}
}
}
}
static
void
setupEnvForReverseScan
(
STableScanInfo
*
pTableScanInfo
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
static
void
setupEnvForReverseScan
(
STableScanInfo
*
pTableScanInfo
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
// if (pRuntimeEnv->pTsBuf) {
// if (pRuntimeEnv->pTsBuf) {
// SWITCH_ORDER(pRuntimeEnv->pTsBuf->cur.order);
// SWITCH_ORDER(pRuntimeEnv->pTsBuf->cur.order);
// bool ret = tsBufNextPos(pRuntimeEnv->pTsBuf);
// bool ret = tsBufNextPos(pRuntimeEnv->pTsBuf);
...
@@ -3722,7 +3722,7 @@ static void setupEnvForReverseScan(STableScanInfo *pTableScanInfo, SQLFunctionCt
...
@@ -3722,7 +3722,7 @@ static void setupEnvForReverseScan(STableScanInfo *pTableScanInfo, SQLFunctionCt
pTableScanInfo
->
reverseTimes
=
0
;
pTableScanInfo
->
reverseTimes
=
0
;
}
}
void
finalizeQueryResult
(
SOperatorInfo
*
pOperator
,
S
QL
FunctionCtx
*
pCtx
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
)
{
void
finalizeQueryResult
(
SOperatorInfo
*
pOperator
,
S
ql
FunctionCtx
*
pCtx
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
)
{
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
...
@@ -3832,7 +3832,7 @@ void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
...
@@ -3832,7 +3832,7 @@ void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
cleanupResultRowInfo
(
&
pTableQueryInfo
->
resInfo
);
cleanupResultRowInfo
(
&
pTableQueryInfo
->
resInfo
);
}
}
void
setResultRowOutputBufInitCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
QL
FunctionCtx
*
pCtx
,
void
setResultRowOutputBufInitCtx
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
SFilePage
*
bufPage
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
SFilePage
*
bufPage
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
...
@@ -3865,7 +3865,7 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pRes
...
@@ -3865,7 +3865,7 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pRes
}
}
}
}
void
doSetTableGroupOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
S
QL
FunctionCtx
*
pCtx
,
void
doSetTableGroupOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
*
rowCellInfoOffset
,
int32_t
numOfOutput
,
int32_t
tableGroupId
)
{
int32_t
*
rowCellInfoOffset
,
int32_t
numOfOutput
,
int32_t
tableGroupId
)
{
// for simple group by query without interval, all the tables belong to one group result.
// for simple group by query without interval, all the tables belong to one group result.
int64_t
uid
=
0
;
int64_t
uid
=
0
;
...
@@ -3905,7 +3905,7 @@ void setExecutionContext(STaskRuntimeEnv* pRuntimeEnv, SOptrBasicInfo* pInfo, in
...
@@ -3905,7 +3905,7 @@ void setExecutionContext(STaskRuntimeEnv* pRuntimeEnv, SOptrBasicInfo* pInfo, in
pRuntimeEnv
->
prevGroupId
=
tableGroupId
;
pRuntimeEnv
->
prevGroupId
=
tableGroupId
;
}
}
void
setResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
QL
FunctionCtx
*
pCtx
,
void
setResultOutputBuf
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResult
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfCols
,
int32_t
*
rowCellInfoOffset
)
{
int32_t
numOfCols
,
int32_t
*
rowCellInfoOffset
)
{
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
SFilePage
*
page
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
SFilePage
*
page
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pResult
->
pageId
);
...
@@ -3928,7 +3928,7 @@ void setResultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLFu
...
@@ -3928,7 +3928,7 @@ void setResultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLFu
}
}
}
}
void
setCtxTagForJoin
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
)
{
void
setCtxTagForJoin
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
SSqlExpr
*
pExpr
=
&
pExprInfo
->
base
;
SSqlExpr
*
pExpr
=
&
pExprInfo
->
base
;
...
@@ -3996,7 +3996,7 @@ int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, S
...
@@ -3996,7 +3996,7 @@ int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, S
}
}
// TODO refactor: this funciton should be merged with setparamForStableStddevColumnData function.
// TODO refactor: this funciton should be merged with setparamForStableStddevColumnData function.
void
setParamForStableStddev
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExprInfo
)
{
void
setParamForStableStddev
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExprInfo
)
{
#if 0
#if 0
STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
...
@@ -4031,7 +4031,7 @@ void setParamForStableStddev(STaskRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx,
...
@@ -4031,7 +4031,7 @@ void setParamForStableStddev(STaskRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx,
#endif
#endif
}
}
void
setParamForStableStddevByColData
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
)
{
void
setParamForStableStddevByColData
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
#if 0
#if 0
int32_t numOfExprs = pQueryAttr->numOfOutput;
int32_t numOfExprs = pQueryAttr->numOfOutput;
...
@@ -4199,7 +4199,7 @@ static void toSSDataBlock(SGroupResInfo *pGroupResInfo, STaskRuntimeEnv* pRuntim
...
@@ -4199,7 +4199,7 @@ static void toSSDataBlock(SGroupResInfo *pGroupResInfo, STaskRuntimeEnv* pRuntim
}
}
}
}
static
void
updateNumOfRowsInResultRows
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
QL
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
static
void
updateNumOfRowsInResultRows
(
STaskRuntimeEnv
*
pRuntimeEnv
,
S
ql
FunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
)
{
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
...
@@ -4953,6 +4953,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
...
@@ -4953,6 +4953,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
// The read handle is not initialized yet, since no qualified tables exists
if
(
pTableScanInfo
->
pTsdbReadHandle
==
NULL
)
{
if
(
pTableScanInfo
->
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -5071,6 +5072,7 @@ static SSDataBlock* doStreamBlockScan(void* param, bool* newgroup) {
...
@@ -5071,6 +5072,7 @@ static SSDataBlock* doStreamBlockScan(void* param, bool* newgroup) {
SDataBlockInfo
*
pBlockInfo
=
&
pInfo
->
pRes
->
info
;
SDataBlockInfo
*
pBlockInfo
=
&
pInfo
->
pRes
->
info
;
pBlockInfo
->
rows
=
0
;
pBlockInfo
->
rows
=
0
;
while
(
tqNextDataBlock
(
pInfo
->
readerHandle
))
{
while
(
tqNextDataBlock
(
pInfo
->
readerHandle
))
{
pTaskInfo
->
code
=
tqRetrieveDataBlockInfo
(
pInfo
->
readerHandle
,
pBlockInfo
);
pTaskInfo
->
code
=
tqRetrieveDataBlockInfo
(
pInfo
->
readerHandle
,
pBlockInfo
);
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -5342,37 +5344,6 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
...
@@ -5342,37 +5344,6 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
return
pResBlock
;
return
pResBlock
;
}
}
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
repeatTime
>
0
&&
numOfOutput
>
0
);
STableScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableScanInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
tfree
(
pInfo
);
tfree
(
pOperator
);
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
}
pInfo
->
pTsdbReadHandle
=
pTsdbReadHandle
;
pInfo
->
times
=
repeatTime
;
pInfo
->
reverseTimes
=
0
;
pInfo
->
order
=
order
;
pInfo
->
current
=
0
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pOperator
->
name
=
"TableScanOperator"
;
pOperator
->
operatorType
=
OP_TableScan
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
exec
=
doTableScan
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
return
pOperator
;
}
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createDataBlocksOptScanInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
repeatTime
>
0
);
assert
(
repeatTime
>
0
);
...
@@ -5447,14 +5418,13 @@ SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbReadHandle, STaskRunt
...
@@ -5447,14 +5418,13 @@ SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbReadHandle, STaskRunt
pOperator
->
blockingOptr
=
false
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
// pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols;
pOperator
->
numOfOutput
=
pRuntimeEnv
->
pQueryAttr
->
numOfCols
;
pOperator
->
exec
=
doBlockInfoScan
;
pOperator
->
exec
=
doBlockInfoScan
;
return
pOperator
;
return
pOperator
;
}
}
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
streamReadHandle
,
SArray
*
pExprInfo
,
uint64_t
uid
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
streamReadHandle
,
SArray
*
pExprInfo
,
SArray
*
pTableIdList
,
SExecTaskInfo
*
pTaskInfo
)
{
SStreamBlockScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SStreamBlockScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
@@ -5477,7 +5447,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void *streamReadHandle, SArray* pExp
...
@@ -5477,7 +5447,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void *streamReadHandle, SArray* pExp
// set the extract column id to streamHandle
// set the extract column id to streamHandle
tqReadHandleSetColIdList
((
STqReadHandle
*
)
streamReadHandle
,
pColList
);
tqReadHandleSetColIdList
((
STqReadHandle
*
)
streamReadHandle
,
pColList
);
tqReadHandleSetTbUid
(
streamReadHandle
,
uid
);
tqReadHandleSetTbUid
List
(
streamReadHandle
,
pTableIdList
);
pInfo
->
readerHandle
=
streamReadHandle
;
pInfo
->
readerHandle
=
streamReadHandle
;
...
@@ -5701,9 +5671,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
...
@@ -5701,9 +5671,8 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
// pOperator->exec = doGlobalAggregate;
// pOperator->exec = doGlobalAggregate;
pOperator
->
cleanup
=
destroyGlobalAggOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyGlobalAggOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -5746,7 +5715,7 @@ SOperatorInfo *createMultiwaySortOperatorInfo(STaskRuntimeEnv *pRuntimeEnv, SExp
...
@@ -5746,7 +5715,7 @@ SOperatorInfo *createMultiwaySortOperatorInfo(STaskRuntimeEnv *pRuntimeEnv, SExp
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
// pOperator->exec = doMultiwayMergeSort;
// pOperator->exec = doMultiwayMergeSort;
pOperator
->
cleanup
=
destroyGlobalAggOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyGlobalAggOperatorInfo
;
return
pOperator
;
return
pOperator
;
}
}
...
@@ -5850,7 +5819,7 @@ SOperatorInfo *createOrderOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorIn
...
@@ -5850,7 +5819,7 @@ SOperatorInfo *createOrderOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorIn
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
exec
=
doSort
;
pOperator
->
exec
=
doSort
;
pOperator
->
cleanup
=
destroyOrderOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyOrderOperatorInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
...
@@ -6759,8 +6728,8 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
...
@@ -6759,8 +6728,8 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
return
;
return
;
}
}
if
(
pOperator
->
cleanup
!=
NULL
)
{
if
(
pOperator
->
cleanup
Fn
!=
NULL
)
{
pOperator
->
cleanup
(
pOperator
->
info
,
pOperator
->
numOfOutput
);
pOperator
->
cleanup
Fn
(
pOperator
->
info
,
pOperator
->
numOfOutput
);
}
}
if
(
pOperator
->
pDownstream
!=
NULL
)
{
if
(
pOperator
->
pDownstream
!=
NULL
)
{
...
@@ -6814,7 +6783,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pE
...
@@ -6814,7 +6783,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pE
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
exec
=
doAggregate
;
pOperator
->
exec
=
doAggregate
;
pOperator
->
cleanup
=
destroyAggOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyAggOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -6909,7 +6878,7 @@ SOperatorInfo* createMultiTableAggOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOp
...
@@ -6909,7 +6878,7 @@ SOperatorInfo* createMultiTableAggOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOp
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doSTableAggregate
;
pOperator
->
exec
=
doSTableAggregate
;
pOperator
->
cleanup
=
destroyAggOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyAggOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -6939,7 +6908,7 @@ SOperatorInfo* createProjectOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
...
@@ -6939,7 +6908,7 @@ SOperatorInfo* createProjectOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doProjectOperation
;
pOperator
->
exec
=
doProjectOperation
;
pOperator
->
cleanup
=
destroyProjectOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyProjectOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -6997,7 +6966,7 @@ SOperatorInfo* createFilterOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
...
@@ -6997,7 +6966,7 @@ SOperatorInfo* createFilterOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
pOperator
->
exec
=
doFilter
;
pOperator
->
exec
=
doFilter
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
cleanup
=
destroyConditionOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyConditionOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7039,7 +7008,7 @@ SOperatorInfo* createTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOpe
...
@@ -7039,7 +7008,7 @@ SOperatorInfo* createTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOpe
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doIntervalAgg
;
pOperator
->
exec
=
doIntervalAgg
;
pOperator
->
cleanup
=
destroyBasicOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyBasicOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7064,7 +7033,7 @@ SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
...
@@ -7064,7 +7033,7 @@ SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doAllIntervalAgg
;
pOperator
->
exec
=
doAllIntervalAgg
;
pOperator
->
cleanup
=
destroyBasicOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyBasicOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7088,7 +7057,7 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper
...
@@ -7088,7 +7057,7 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doStateWindowAgg
;
pOperator
->
exec
=
doStateWindowAgg
;
pOperator
->
cleanup
=
destroyStateWindowOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyStateWindowOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7113,7 +7082,7 @@ SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
...
@@ -7113,7 +7082,7 @@ SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doSessionWindowAgg
;
pOperator
->
exec
=
doSessionWindowAgg
;
pOperator
->
cleanup
=
destroySWindowOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroySWindowOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7137,7 +7106,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
...
@@ -7137,7 +7106,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doSTableIntervalAgg
;
pOperator
->
exec
=
doSTableIntervalAgg
;
pOperator
->
cleanup
=
destroyBasicOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyBasicOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7161,7 +7130,7 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
...
@@ -7161,7 +7130,7 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doAllSTableIntervalAgg
;
pOperator
->
exec
=
doAllSTableIntervalAgg
;
pOperator
->
cleanup
=
destroyBasicOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyBasicOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
...
@@ -7194,7 +7163,7 @@ SOperatorInfo* createGroupbyOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
...
@@ -7194,7 +7163,7 @@ SOperatorInfo* createGroupbyOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
hashGroupbyAggregate
;
pOperator
->
exec
=
hashGroupbyAggregate
;
pOperator
->
cleanup
=
destroyGroupbyOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyGroupbyOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7233,7 +7202,7 @@ SOperatorInfo* createFillOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInf
...
@@ -7233,7 +7202,7 @@ SOperatorInfo* createFillOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInf
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
doFill
;
pOperator
->
exec
=
doFill
;
pOperator
->
cleanup
=
destroySFillOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroySFillOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7281,7 +7250,7 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
...
@@ -7281,7 +7250,7 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
// pOperator->exec = doSLimit;
// pOperator->exec = doSLimit;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
cleanup
=
destroySlimitOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroySlimitOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7439,7 +7408,7 @@ SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo
...
@@ -7439,7 +7408,7 @@ SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
cleanup
=
destroyTagScanOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyTagScanOperatorInfo
;
return
pOperator
;
return
pOperator
;
}
}
...
@@ -7579,7 +7548,7 @@ SOperatorInfo* createDistinctOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperato
...
@@ -7579,7 +7548,7 @@ SOperatorInfo* createDistinctOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperato
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
exec
=
hashDistinct
;
pOperator
->
exec
=
hashDistinct
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
cleanup
=
destroyDistinctOperatorInfo
;
pOperator
->
cleanup
Fn
=
destroyDistinctOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
return
pOperator
;
...
@@ -7749,31 +7718,43 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId) {
...
@@ -7749,31 +7718,43 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId) {
return
pTaskInfo
;
return
pTaskInfo
;
}
}
static
tsdbReadHandleT
doCreateDataReadHandle
(
STableScanPhyNode
*
pTableScanNode
,
void
*
readerHandle
,
uint64_t
queryId
,
uint64_t
taskId
);
static
tsdbReaderT
doCreateDataReader
(
STableScanPhyNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
);
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhyNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
void
*
reader
Handle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhyNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
p
Handle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
taosArrayGetSize
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
taosArrayGetSize
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
info
.
type
==
OP_TableScan
)
{
if
(
pPhyNode
->
info
.
type
==
OP_DataBlocksOptScan
)
{
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
tsdbReadHandleT
tReaderHandle
=
doCreateDataReadHandle
((
STableScanPhyNode
*
)
pPhyNode
,
readerHandle
,
(
uint64_t
)
queryId
,
taskId
);
return
createTableScanOperatorInfo
(
tReaderHandle
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pTaskInfo
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhyNode
*
)
pPhyNode
,
pHandle
,
(
uint64_t
)
queryId
,
taskId
);
}
else
if
(
pPhyNode
->
info
.
type
==
OP_DataBlocksOptScan
)
{
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
tsdbReadHandleT
tReaderHandle
=
doCreateDataReadHandle
((
STableScanPhyNode
*
)
pPhyNode
,
readerHandle
,
(
uint64_t
)
queryId
,
taskId
);
return
createDataBlocksOptScanInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
return
createDataBlocksOptScanInfo
(
tReaderHandle
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
}
else
if
(
pPhyNode
->
info
.
type
==
OP_Exchange
)
{
}
else
if
(
pPhyNode
->
info
.
type
==
OP_Exchange
)
{
SExchangePhyNode
*
pEx
=
(
SExchangePhyNode
*
)
pPhyNode
;
SExchangePhyNode
*
pEx
=
(
SExchangePhyNode
*
)
pPhyNode
;
return
createExchangeOperatorInfo
(
pEx
->
pSrcEndPoints
,
pEx
->
node
.
pTargets
,
pTaskInfo
);
return
createExchangeOperatorInfo
(
pEx
->
pSrcEndPoints
,
pEx
->
node
.
pTargets
,
pTaskInfo
);
}
else
if
(
pPhyNode
->
info
.
type
==
OP_StreamScan
)
{
}
else
if
(
pPhyNode
->
info
.
type
==
OP_StreamScan
)
{
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
// simple child table.
SScanPhyNode
*
pScanPhyNode
=
(
SScanPhyNode
*
)
pPhyNode
;
// simple child table.
return
createStreamScanOperatorInfo
(
readerHandle
,
pPhyNode
->
pTargets
,
pScanPhyNode
->
uid
,
pTaskInfo
);
STableGroupInfo
groupInfo
=
{
0
};
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
&
groupInfo
,
queryId
,
taskId
);
SArray
*
pa
=
taosArrayGetP
(
groupInfo
.
pGroupList
,
0
);
ASSERT
(
taosArrayGetSize
(
groupInfo
.
pGroupList
)
==
1
);
// Transfer the Array of STableKeyInfo into uid list.
size_t
numOfTables
=
taosArrayGetSize
(
pa
);
SArray
*
idList
=
taosArrayInit
(
numOfTables
,
sizeof
(
uint64_t
));
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pkeyInfo
=
taosArrayGet
(
pa
,
i
);
taosArrayPush
(
idList
,
&
pkeyInfo
->
uid
);
}
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pHandle
->
reader
,
pPhyNode
->
pTargets
,
idList
,
pTaskInfo
);
taosArrayDestroy
(
idList
);
//TODO destroy groupInfo
return
pOperator
;
}
}
}
}
...
@@ -7783,18 +7764,23 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhyNode* pPhyNode, SExecTaskInfo* pTask
...
@@ -7783,18 +7764,23 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhyNode* pPhyNode, SExecTaskInfo* pTask
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhyNode
*
pChildNode
=
taosArrayGetP
(
pPhyNode
->
pChildren
,
i
);
SPhyNode
*
pChildNode
=
taosArrayGetP
(
pPhyNode
->
pChildren
,
i
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
reader
Handle
,
queryId
,
taskId
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
p
Handle
,
queryId
,
taskId
);
return
createAggregateOperatorInfo
(
op
,
pPhyNode
->
pTargets
,
pTaskInfo
);
return
createAggregateOperatorInfo
(
op
,
pPhyNode
->
pTargets
,
pTaskInfo
);
}
}
}
}
}
}
static
tsdbRead
HandleT
createDataReadHandle
(
STableScanPhyNode
*
pTableScanNode
,
STableGroupInfo
*
pGroupInfo
,
void
*
reader
Handle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
static
tsdbRead
erT
createDataReaderImpl
(
STableScanPhyNode
*
pTableScanNode
,
STableGroupInfo
*
pGroupInfo
,
void
*
read
Handle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
STsdbQueryCond
cond
=
{.
loadExternalRows
=
false
};
STsdbQueryCond
cond
=
{.
loadExternalRows
=
false
};
cond
.
order
=
pTableScanNode
->
scan
.
order
;
cond
.
order
=
pTableScanNode
->
scan
.
order
;
cond
.
numOfCols
=
taosArrayGetSize
(
pTableScanNode
->
scan
.
node
.
pTargets
);
cond
.
numOfCols
=
taosArrayGetSize
(
pTableScanNode
->
scan
.
node
.
pTargets
);
cond
.
colList
=
calloc
(
cond
.
numOfCols
,
sizeof
(
SColumnInfo
));
cond
.
colList
=
calloc
(
cond
.
numOfCols
,
sizeof
(
SColumnInfo
));
if
(
cond
.
colList
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
}
cond
.
twindow
=
pTableScanNode
->
window
;
cond
.
twindow
=
pTableScanNode
->
window
;
cond
.
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
cond
.
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
...
@@ -7808,32 +7794,27 @@ static tsdbReadHandleT createDataReadHandle(STableScanPhyNode* pTableScanNode, S
...
@@ -7808,32 +7794,27 @@ static tsdbReadHandleT createDataReadHandle(STableScanPhyNode* pTableScanNode, S
cond
.
colList
[
i
].
colId
=
pSchema
->
colId
;
cond
.
colList
[
i
].
colId
=
pSchema
->
colId
;
}
}
return
tsdbQueryTables
(
read
er
Handle
,
&
cond
,
pGroupInfo
,
queryId
,
taskId
);
return
tsdbQueryTables
(
readHandle
,
&
cond
,
pGroupInfo
,
queryId
,
taskId
);
}
}
static
tsdbReadHandleT
doCreateDataReadHandle
(
STableScanPhyNode
*
pTableScanNode
,
void
*
readerHandle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STableGroupInfo
groupInfo
=
{
0
};
uint64_t
uid
=
pTableScanNode
->
scan
.
uid
;
STimeWindow
window
=
pTableScanNode
->
window
;
int32_t
tableType
=
pTableScanNode
->
scan
.
tableType
;
if
(
tableType
==
TSDB_SUPER_TABLE
)
{
if
(
tableType
==
TSDB_SUPER_TABLE
)
{
code
=
code
=
tsdbQuerySTableByTagCond
(
metaHandle
,
tableUid
,
0
,
NULL
,
0
,
0
,
NULL
,
pGroupInfo
,
NULL
,
0
,
queryId
,
taskId
);
tsdbQuerySTableByTagCond
(
readerHandle
,
uid
,
window
.
skey
,
NULL
,
0
,
0
,
NULL
,
&
groupInfo
,
NULL
,
0
,
queryId
,
taskId
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
}
else
{
// Create one table group.
}
else
{
// Create one table group.
groupInfo
.
numOfTables
=
1
;
code
=
tsdbGetOneTableGroup
(
metaHandle
,
tableUid
,
0
,
pGroupInfo
)
;
groupInfo
.
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
}
SArray
*
pa
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
return
code
;
}
static
tsdbReaderT
doCreateDataReader
(
STableScanPhyNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
STableGroupInfo
groupInfo
=
{
0
};
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
uid
};
uint64_t
uid
=
pTableScanNode
->
scan
.
uid
;
taosArrayPush
(
pa
,
&
info
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pTableScanNode
->
scan
.
tableType
,
uid
,
&
groupInfo
,
queryId
,
taskId
);
taosArrayPush
(
groupInfo
.
pGroupList
,
&
pa
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
}
if
(
groupInfo
.
numOfTables
==
0
)
{
if
(
groupInfo
.
numOfTables
==
0
)
{
...
@@ -7842,14 +7823,14 @@ static tsdbReadHandleT doCreateDataReadHandle(STableScanPhyNode* pTableScanNode,
...
@@ -7842,14 +7823,14 @@ static tsdbReadHandleT doCreateDataReadHandle(STableScanPhyNode* pTableScanNode,
goto
_error
;
goto
_error
;
}
}
return
createDataRead
Handle
(
pTableScanNode
,
&
groupInfo
,
readerHandle
,
queryId
,
taskId
);
return
createDataRead
erImpl
(
pTableScanNode
,
&
groupInfo
,
pHandle
->
reader
,
queryId
,
taskId
);
_error:
_error:
terrno
=
code
;
terrno
=
code
;
return
NULL
;
return
NULL
;
}
}
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
void
*
reader
Handle
,
uint64_t
taskId
)
{
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
p
Handle
,
uint64_t
taskId
)
{
uint64_t
queryId
=
pPlan
->
id
.
queryId
;
uint64_t
queryId
=
pPlan
->
id
.
queryId
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -7859,7 +7840,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, void*
...
@@ -7859,7 +7840,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, void*
goto
_complete
;
goto
_complete
;
}
}
(
*
pTaskInfo
)
->
pRoot
=
doCreateOperatorTreeNode
(
pPlan
->
pNode
,
*
pTaskInfo
,
reader
Handle
,
queryId
,
taskId
);
(
*
pTaskInfo
)
->
pRoot
=
doCreateOperatorTreeNode
(
pPlan
->
pNode
,
*
pTaskInfo
,
p
Handle
,
queryId
,
taskId
);
if
((
*
pTaskInfo
)
->
pRoot
==
NULL
)
{
if
((
*
pTaskInfo
)
->
pRoot
==
NULL
)
{
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
goto
_complete
;
goto
_complete
;
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
244b552f
...
@@ -219,7 +219,7 @@ TEST(testCase, build_executor_tree_Test) {
...
@@ -219,7 +219,7 @@ TEST(testCase, build_executor_tree_Test) {
SExecTaskInfo
*
pTaskInfo
=
nullptr
;
SExecTaskInfo
*
pTaskInfo
=
nullptr
;
DataSinkHandle
sinkHandle
=
nullptr
;
DataSinkHandle
sinkHandle
=
nullptr
;
int32_t
code
=
qCreateExecTask
((
void
*
)
1
,
2
,
1
,
NULL
,
(
void
**
)
&
pTaskInfo
,
&
sinkHandle
);
int32_t
code
=
qCreateExecTask
((
SReadHandle
*
)
1
,
2
,
1
,
NULL
,
(
void
**
)
&
pTaskInfo
,
&
sinkHandle
);
}
}
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
\ No newline at end of file
source/libs/function/inc/taggfunction.h
浏览文件 @
244b552f
...
@@ -73,7 +73,7 @@ typedef struct STwaInfo {
...
@@ -73,7 +73,7 @@ typedef struct STwaInfo {
extern
int32_t
functionCompatList
[];
// compatible check array list
extern
int32_t
functionCompatList
[];
// compatible check array list
bool
topbot_datablock_filter
(
S
QL
FunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
bool
topbot_datablock_filter
(
S
ql
FunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
/**
/**
* the numOfRes should be kept, since it may be used later
* the numOfRes should be kept, since it may be used later
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
244b552f
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
#define DO_UPDATE_TAG_COLUMNS(ctx, ts) \
#define DO_UPDATE_TAG_COLUMNS(ctx, ts) \
do { \
do { \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
S
QL
FunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
S
ql
FunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
if (__ctx->functionId == FUNCTION_TS_DUMMY) { \
if (__ctx->functionId == FUNCTION_TS_DUMMY) { \
__ctx->tag.i = (ts); \
__ctx->tag.i = (ts); \
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \
...
@@ -71,14 +71,14 @@
...
@@ -71,14 +71,14 @@
#define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx) \
#define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx) \
do { \
do { \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \
S
QL
FunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
S
ql
FunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \
aggFunc[FUNCTION_TAG].addInput(__ctx); \
aggFunc[FUNCTION_TAG].addInput(__ctx); \
} \
} \
} while (0);
} while (0);
void
noop1
(
S
QL
FunctionCtx
*
UNUSED_PARAM
(
pCtx
))
{}
void
noop1
(
S
ql
FunctionCtx
*
UNUSED_PARAM
(
pCtx
))
{}
void
doFinalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
cleanupResultRowEntry
(
GET_RES_INFO
(
pCtx
));
}
void
doFinalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
cleanupResultRowEntry
(
GET_RES_INFO
(
pCtx
));
}
typedef
struct
tValuePair
{
typedef
struct
tValuePair
{
SVariant
v
;
SVariant
v
;
...
@@ -200,7 +200,7 @@ void cleanupResultRowEntry(struct SResultRowEntryInfo* pCell) {
...
@@ -200,7 +200,7 @@ void cleanupResultRowEntry(struct SResultRowEntryInfo* pCell) {
pCell
->
initialized
=
false
;
pCell
->
initialized
=
false
;
}
}
int32_t
getNumOfResult
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
num
)
{
int32_t
getNumOfResult
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
num
)
{
int32_t
maxOutput
=
0
;
int32_t
maxOutput
=
0
;
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
int32_t
id
=
pCtx
[
j
].
functionId
;
int32_t
id
=
pCtx
[
j
].
functionId
;
...
@@ -223,7 +223,7 @@ int32_t getNumOfResult(SQLFunctionCtx* pCtx, int32_t num) {
...
@@ -223,7 +223,7 @@ int32_t getNumOfResult(SQLFunctionCtx* pCtx, int32_t num) {
return
maxOutput
;
return
maxOutput
;
}
}
void
resetResultRowEntryResult
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
num
)
{
void
resetResultRowEntryResult
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
num
)
{
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
pResInfo
->
numOfRes
=
0
;
pResInfo
->
numOfRes
=
0
;
...
@@ -473,7 +473,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
...
@@ -473,7 +473,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
bool
function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
static
bool
function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
pResultInfo
->
initialized
)
{
if
(
pResultInfo
->
initialized
)
{
return
false
;
return
false
;
}
}
...
@@ -490,7 +490,7 @@ static bool function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResultInf
...
@@ -490,7 +490,7 @@ static bool function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResultInf
*
*
* @param pCtx
* @param pCtx
*/
*/
static
void
function_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
function_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
setNull
(
pCtx
->
pOutput
,
pCtx
->
resDataInfo
.
type
,
pCtx
->
resDataInfo
.
bytes
);
setNull
(
pCtx
->
pOutput
,
pCtx
->
resDataInfo
.
type
,
pCtx
->
resDataInfo
.
bytes
);
...
@@ -503,7 +503,7 @@ static void function_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -503,7 +503,7 @@ static void function_finalizer(SQLFunctionCtx *pCtx) {
* count function does need the finalize, if data is missing, the default value, which is 0, is used
* count function does need the finalize, if data is missing, the default value, which is 0, is used
* count function does not use the pCtx->interResBuf to keep the intermediate buffer
* count function does not use the pCtx->interResBuf to keep the intermediate buffer
*/
*/
static
void
count_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
count_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
numOfElem
=
0
;
int32_t
numOfElem
=
0
;
/*
/*
...
@@ -537,7 +537,7 @@ static void count_function(SQLFunctionCtx *pCtx) {
...
@@ -537,7 +537,7 @@ static void count_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
numOfElem
,
1
);
SET_VAL
(
pCtx
,
numOfElem
,
1
);
}
}
static
void
count_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
count_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
int64_t
*
pData
=
(
int64_t
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
int64_t
*
pData
=
(
int64_t
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
*
((
int64_t
*
)
pCtx
->
pOutput
)
+=
pData
[
i
];
*
((
int64_t
*
)
pCtx
->
pOutput
)
+=
pData
[
i
];
...
@@ -555,7 +555,7 @@ static void count_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -555,7 +555,7 @@ static void count_func_merge(SQLFunctionCtx *pCtx) {
* @param filterCols
* @param filterCols
* @return
* @return
*/
*/
int32_t
countRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
int32_t
countRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
else
{
}
else
{
...
@@ -563,7 +563,7 @@ int32_t countRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
...
@@ -563,7 +563,7 @@ int32_t countRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
}
}
}
}
int32_t
noDataRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
int32_t
noDataRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
}
#define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \
#define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \
...
@@ -635,7 +635,7 @@ int32_t noDataRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
...
@@ -635,7 +635,7 @@ int32_t noDataRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t colId) {
LOOPCHECK_N(*_data, _list, ctx, tsdbType, sign, notNullElems); \
LOOPCHECK_N(*_data, _list, ctx, tsdbType, sign, notNullElems); \
} while (0)
} while (0)
static
void
do_sum
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
do_sum
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
// Only the pre-computing information loaded and actual data does not loaded
// Only the pre-computing information loaded and actual data does not loaded
...
@@ -698,7 +698,7 @@ static void do_sum(SQLFunctionCtx *pCtx) {
...
@@ -698,7 +698,7 @@ static void do_sum(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
sum_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
sum_function
(
S
ql
FunctionCtx
*
pCtx
)
{
do_sum
(
pCtx
);
do_sum
(
pCtx
);
// keep the result data in output buffer, not in the intermediate buffer
// keep the result data in output buffer, not in the intermediate buffer
...
@@ -710,7 +710,7 @@ static void sum_function(SQLFunctionCtx *pCtx) {
...
@@ -710,7 +710,7 @@ static void sum_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
sum_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
sum_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
GET_TRUE_DATA_TYPE
();
GET_TRUE_DATA_TYPE
();
...
@@ -742,16 +742,16 @@ static void sum_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -742,16 +742,16 @@ static void sum_func_merge(SQLFunctionCtx *pCtx) {
}
}
}
}
static
int32_t
statisRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
statisRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_STATIS_NEEDED
;
return
BLK_DATA_STATIS_NEEDED
;
}
}
static
int32_t
dataBlockRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
dataBlockRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_ALL_NEEDED
;
return
BLK_DATA_ALL_NEEDED
;
}
}
// todo: if column in current data block are null, opt for this case
// todo: if column in current data block are null, opt for this case
static
int32_t
firstFuncRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
firstFuncRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
}
...
@@ -764,7 +764,7 @@ static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c
...
@@ -764,7 +764,7 @@ static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t c
}
}
}
}
static
int32_t
lastFuncRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
lastFuncRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
}
...
@@ -776,7 +776,7 @@ static int32_t lastFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t co
...
@@ -776,7 +776,7 @@ static int32_t lastFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_t co
}
}
}
}
static
int32_t
firstDistFuncRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
firstDistFuncRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
}
...
@@ -796,7 +796,7 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32
...
@@ -796,7 +796,7 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32
}
}
}
}
static
int32_t
lastDistFuncRequired
(
S
QL
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
static
int32_t
lastDistFuncRequired
(
S
ql
FunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
}
...
@@ -822,7 +822,7 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_
...
@@ -822,7 +822,7 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, STimeWindow* w, int32_
* For super table query, once the avg_function/avg_function_f is finished, copy the intermediate
* For super table query, once the avg_function/avg_function_f is finished, copy the intermediate
* result into output buffer.
* result into output buffer.
*/
*/
static
void
avg_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
avg_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
// NOTE: keep the intermediate result into the interResultBuf
// NOTE: keep the intermediate result into the interResultBuf
...
@@ -885,7 +885,7 @@ static void avg_function(SQLFunctionCtx *pCtx) {
...
@@ -885,7 +885,7 @@ static void avg_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
avg_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
avg_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
double
*
sum
=
(
double
*
)
pCtx
->
pOutput
;
double
*
sum
=
(
double
*
)
pCtx
->
pOutput
;
...
@@ -907,7 +907,7 @@ static void avg_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -907,7 +907,7 @@ static void avg_func_merge(SQLFunctionCtx *pCtx) {
/*
/*
* the average value is calculated in finalize routine, since current routine does not know the exact number of points
* the average value is calculated in finalize routine, since current routine does not know the exact number of points
*/
*/
static
void
avg_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
avg_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
...
@@ -938,7 +938,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -938,7 +938,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) {
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
static
void
minMax_function
(
S
QL
FunctionCtx
*
pCtx
,
char
*
pOutput
,
int32_t
isMin
,
int32_t
*
notNullElems
)
{
static
void
minMax_function
(
S
ql
FunctionCtx
*
pCtx
,
char
*
pOutput
,
int32_t
isMin
,
int32_t
*
notNullElems
)
{
// data in current data block are qualified to the query
// data in current data block are qualified to the query
if
(
pCtx
->
isAggSet
)
{
if
(
pCtx
->
isAggSet
)
{
*
notNullElems
=
pCtx
->
size
-
pCtx
->
agg
.
numOfNull
;
*
notNullElems
=
pCtx
->
size
-
pCtx
->
agg
.
numOfNull
;
...
@@ -994,7 +994,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
...
@@ -994,7 +994,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
if
((
*
data
<
val
)
^
isMin
)
{
if
((
*
data
<
val
)
^
isMin
)
{
*
data
=
(
int32_t
)
val
;
*
data
=
(
int32_t
)
val
;
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
tagInfo
.
numOfTagCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
(
pCtx
)
->
tagInfo
.
numOfTagCols
;
++
i
)
{
S
QL
FunctionCtx
*
__ctx
=
pCtx
->
tagInfo
.
pTagCtxList
[
i
];
S
ql
FunctionCtx
*
__ctx
=
pCtx
->
tagInfo
.
pTagCtxList
[
i
];
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
if
(
__ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
i
=
key
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
__ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
...
@@ -1089,7 +1089,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
...
@@ -1089,7 +1089,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
}
}
}
}
static
bool
min_func_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
static
bool
min_func_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
return
false
;
// not initialized since it has been initialized
return
false
;
// not initialized since it has been initialized
}
}
...
@@ -1135,7 +1135,7 @@ static bool min_func_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResultInf
...
@@ -1135,7 +1135,7 @@ static bool min_func_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResultInf
return
true
;
return
true
;
}
}
static
bool
max_func_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
static
bool
max_func_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
return
false
;
// not initialized since it has been initialized
return
false
;
// not initialized since it has been initialized
}
}
...
@@ -1184,7 +1184,7 @@ static bool max_func_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResultInf
...
@@ -1184,7 +1184,7 @@ static bool max_func_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResultInf
/*
/*
* the output result of min/max function is the final output buffer, not the intermediate result buffer
* the output result of min/max function is the final output buffer, not the intermediate result buffer
*/
*/
static
void
min_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
min_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
minMax_function
(
pCtx
,
pCtx
->
pOutput
,
1
,
&
notNullElems
);
minMax_function
(
pCtx
,
pCtx
->
pOutput
,
1
,
&
notNullElems
);
...
@@ -1201,7 +1201,7 @@ static void min_function(SQLFunctionCtx *pCtx) {
...
@@ -1201,7 +1201,7 @@ static void min_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
max_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
max_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
minMax_function
(
pCtx
,
pCtx
->
pOutput
,
0
,
&
notNullElems
);
minMax_function
(
pCtx
,
pCtx
->
pOutput
,
0
,
&
notNullElems
);
...
@@ -1218,7 +1218,7 @@ static void max_function(SQLFunctionCtx *pCtx) {
...
@@ -1218,7 +1218,7 @@ static void max_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
int32_t
minmax_merge_impl
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
bytes
,
char
*
output
,
bool
isMin
)
{
static
int32_t
minmax_merge_impl
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
bytes
,
char
*
output
,
bool
isMin
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
GET_TRUE_DATA_TYPE
();
GET_TRUE_DATA_TYPE
();
...
@@ -1247,7 +1247,7 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp
...
@@ -1247,7 +1247,7 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp
*
(
int32_t
*
)
output
=
v
;
*
(
int32_t
*
)
output
=
v
;
for
(
int32_t
j
=
0
;
j
<
pCtx
->
tagInfo
.
numOfTagCols
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pCtx
->
tagInfo
.
numOfTagCols
;
++
j
)
{
S
QL
FunctionCtx
*
__ctx
=
pCtx
->
tagInfo
.
pTagCtxList
[
j
];
S
ql
FunctionCtx
*
__ctx
=
pCtx
->
tagInfo
.
pTagCtxList
[
j
];
aggFunc
[
FUNCTION_TAG
].
addInput
(
__ctx
);
aggFunc
[
FUNCTION_TAG
].
addInput
(
__ctx
);
}
}
...
@@ -1303,7 +1303,7 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp
...
@@ -1303,7 +1303,7 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp
return
notNullElems
;
return
notNullElems
;
}
}
static
void
min_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
min_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
minmax_merge_impl
(
pCtx
,
pCtx
->
resDataInfo
.
bytes
,
pCtx
->
pOutput
,
1
);
int32_t
notNullElems
=
minmax_merge_impl
(
pCtx
,
pCtx
->
resDataInfo
.
bytes
,
pCtx
->
pOutput
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
...
@@ -1314,7 +1314,7 @@ static void min_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -1314,7 +1314,7 @@ static void min_func_merge(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
max_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
max_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
numOfElem
=
minmax_merge_impl
(
pCtx
,
pCtx
->
resDataInfo
.
bytes
,
pCtx
->
pOutput
,
0
);
int32_t
numOfElem
=
minmax_merge_impl
(
pCtx
,
pCtx
->
resDataInfo
.
bytes
,
pCtx
->
pOutput
,
0
);
SET_VAL
(
pCtx
,
numOfElem
,
1
);
SET_VAL
(
pCtx
,
numOfElem
,
1
);
...
@@ -1334,7 +1334,7 @@ static void max_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -1334,7 +1334,7 @@ static void max_func_merge(SQLFunctionCtx *pCtx) {
(r) += TPOW2(((type *)d)[i] - (delta)); \
(r) += TPOW2(((type *)d)[i] - (delta)); \
}
}
static
void
stddev_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
stddev_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -1419,7 +1419,7 @@ static void stddev_function(SQLFunctionCtx *pCtx) {
...
@@ -1419,7 +1419,7 @@ static void stddev_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
stddev_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
stddev_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
if
(
pStd
->
num
<=
0
)
{
if
(
pStd
->
num
<=
0
)
{
...
@@ -1445,7 +1445,7 @@ int32_t tsCompare(const void* p1, const void* p2) {
...
@@ -1445,7 +1445,7 @@ int32_t tsCompare(const void* p1, const void* p2) {
}
}
}
}
static
void
stddev_dst_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
stddev_dst_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SStddevdstInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SStddevdstInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
// the second stage to calculate standard deviation
// the second stage to calculate standard deviation
...
@@ -1536,7 +1536,7 @@ static void stddev_dst_function(SQLFunctionCtx *pCtx) {
...
@@ -1536,7 +1536,7 @@ static void stddev_dst_function(SQLFunctionCtx *pCtx) {
memcpy
(
pCtx
->
pOutput
,
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
)),
sizeof
(
SAvgInfo
));
memcpy
(
pCtx
->
pOutput
,
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
)),
sizeof
(
SAvgInfo
));
}
}
static
void
stddev_dst_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
stddev_dst_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SStddevdstInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SStddevdstInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -1553,7 +1553,7 @@ static void stddev_dst_merge(SQLFunctionCtx *pCtx) {
...
@@ -1553,7 +1553,7 @@ static void stddev_dst_merge(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
stddev_dst_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
stddev_dst_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SStddevdstInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SStddevdstInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
if
(
pStd
->
num
<=
0
)
{
if
(
pStd
->
num
<=
0
)
{
...
@@ -1568,7 +1568,7 @@ static void stddev_dst_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -1568,7 +1568,7 @@ static void stddev_dst_finalizer(SQLFunctionCtx *pCtx) {
}
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
static
bool
first_last_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
first_last_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -1581,7 +1581,7 @@ static bool first_last_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo*
...
@@ -1581,7 +1581,7 @@ static bool first_last_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo*
}
}
// todo opt for null block
// todo opt for null block
static
void
first_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
first_function
(
S
ql
FunctionCtx
*
pCtx
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
;
return
;
}
}
...
@@ -1612,7 +1612,7 @@ static void first_function(SQLFunctionCtx *pCtx) {
...
@@ -1612,7 +1612,7 @@ static void first_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
}
}
static
void
first_data_assign_impl
(
S
QL
FunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
index
)
{
static
void
first_data_assign_impl
(
S
ql
FunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
index
)
{
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
...
@@ -1630,7 +1630,7 @@ static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t in
...
@@ -1630,7 +1630,7 @@ static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t in
* format of intermediate result: "timestamp,value" need to compare the timestamp in the first part (before the comma)
* format of intermediate result: "timestamp,value" need to compare the timestamp in the first part (before the comma)
* to decide if the value is earlier than current intermediate result
* to decide if the value is earlier than current intermediate result
*/
*/
static
void
first_dist_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
first_dist_function
(
S
ql
FunctionCtx
*
pCtx
)
{
/*
/*
* do not to check data in the following cases:
* do not to check data in the following cases:
* 1. data block that are not loaded
* 1. data block that are not loaded
...
@@ -1661,7 +1661,7 @@ static void first_dist_function(SQLFunctionCtx *pCtx) {
...
@@ -1661,7 +1661,7 @@ static void first_dist_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
}
}
static
void
first_dist_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
first_dist_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
assert
(
pCtx
->
stableQuery
);
assert
(
pCtx
->
stableQuery
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
...
@@ -1691,7 +1691,7 @@ static void first_dist_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -1691,7 +1691,7 @@ static void first_dist_func_merge(SQLFunctionCtx *pCtx) {
* 2. If numOfNull == pBlock->numOfBlocks, the whole block is empty. Otherwise, there is at
* 2. If numOfNull == pBlock->numOfBlocks, the whole block is empty. Otherwise, there is at
* least one data in this block that is not null.(TODO opt for this case)
* least one data in this block that is not null.(TODO opt for this case)
*/
*/
static
void
last_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
last_function
(
S
ql
FunctionCtx
*
pCtx
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
return
;
return
;
}
}
...
@@ -1743,7 +1743,7 @@ static void last_function(SQLFunctionCtx *pCtx) {
...
@@ -1743,7 +1743,7 @@ static void last_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
}
}
static
void
last_data_assign_impl
(
S
QL
FunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
index
)
{
static
void
last_data_assign_impl
(
S
ql
FunctionCtx
*
pCtx
,
char
*
pData
,
int32_t
index
)
{
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
int64_t
*
timestamp
=
GET_TS_LIST
(
pCtx
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
...
@@ -1761,7 +1761,7 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind
...
@@ -1761,7 +1761,7 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind
}
}
}
}
static
void
last_dist_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
last_dist_function
(
S
ql
FunctionCtx
*
pCtx
)
{
/*
/*
* 1. for scan data is not the required order
* 1. for scan data is not the required order
* 2. for data blocks that are not loaded, no need to check data
* 2. for data blocks that are not loaded, no need to check data
...
@@ -1796,7 +1796,7 @@ static void last_dist_function(SQLFunctionCtx *pCtx) {
...
@@ -1796,7 +1796,7 @@ static void last_dist_function(SQLFunctionCtx *pCtx) {
* final output size, so the main difference between last_dist_func_merge and second_merge
* final output size, so the main difference between last_dist_func_merge and second_merge
* is: the output data format in computing
* is: the output data format in computing
*/
*/
static
void
last_dist_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
last_dist_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
SFirstLastInfo
*
pInput
=
(
SFirstLastInfo
*
)
(
pData
+
pCtx
->
resDataInfo
.
bytes
);
SFirstLastInfo
*
pInput
=
(
SFirstLastInfo
*
)
(
pData
+
pCtx
->
resDataInfo
.
bytes
);
...
@@ -1824,7 +1824,7 @@ static void last_dist_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -1824,7 +1824,7 @@ static void last_dist_func_merge(SQLFunctionCtx *pCtx) {
/*
/*
* NOTE: last_row does not use the interResultBuf to keep the result
* NOTE: last_row does not use the interResultBuf to keep the result
*/
*/
static
void
last_row_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
last_row_function
(
S
ql
FunctionCtx
*
pCtx
)
{
assert
(
pCtx
->
size
>=
1
);
assert
(
pCtx
->
size
>=
1
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
...
@@ -1849,7 +1849,7 @@ static void last_row_function(SQLFunctionCtx *pCtx) {
...
@@ -1849,7 +1849,7 @@ static void last_row_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
}
}
static
void
last_row_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
last_row_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
// do nothing at the first stage
// do nothing at the first stage
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
...
@@ -1873,7 +1873,7 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6
...
@@ -1873,7 +1873,7 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6
memcpy
(
dst
->
pTags
,
pTags
,
(
size_t
)
pTagInfo
->
tagsLen
);
memcpy
(
dst
->
pTags
,
pTags
,
(
size_t
)
pTagInfo
->
tagsLen
);
}
else
{
// the tags are dumped from the ctx tag fields
}
else
{
// the tags are dumped from the ctx tag fields
for
(
int32_t
i
=
0
;
i
<
pTagInfo
->
numOfTagCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pTagInfo
->
numOfTagCols
;
++
i
)
{
S
QL
FunctionCtx
*
ctx
=
pTagInfo
->
pTagCtxList
[
i
];
S
ql
FunctionCtx
*
ctx
=
pTagInfo
->
pTagCtxList
[
i
];
if
(
ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
if
(
ctx
->
functionId
==
FUNCTION_TS_DUMMY
)
{
ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
ctx
->
tag
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
ctx
->
tag
.
i
=
tsKey
;
ctx
->
tag
.
i
=
tsKey
;
...
@@ -2023,7 +2023,7 @@ static int32_t resDataAscComparFn(const void *pLeft, const void *pRight) {
...
@@ -2023,7 +2023,7 @@ static int32_t resDataAscComparFn(const void *pLeft, const void *pRight) {
static
int32_t
resDataDescComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
-
resDataAscComparFn
(
pLeft
,
pRight
);
}
static
int32_t
resDataDescComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
return
-
resDataAscComparFn
(
pLeft
,
pRight
);
}
static
void
copyTopBotRes
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
type
)
{
static
void
copyTopBotRes
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
type
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STopBotInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
STopBotInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -2118,7 +2118,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
...
@@ -2118,7 +2118,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
*
*
* top/bottom use the intermediate result buffer to keep the intermediate result
* top/bottom use the intermediate result buffer to keep the intermediate result
*/
*/
static
STopBotInfo
*
getTopBotOutputInfo
(
S
QL
FunctionCtx
*
pCtx
)
{
static
STopBotInfo
*
getTopBotOutputInfo
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
// only the first_stage_merge is directly written data into final output buffer
// only the first_stage_merge is directly written data into final output buffer
...
@@ -2136,7 +2136,7 @@ static STopBotInfo *getTopBotOutputInfo(SQLFunctionCtx *pCtx) {
...
@@ -2136,7 +2136,7 @@ static STopBotInfo *getTopBotOutputInfo(SQLFunctionCtx *pCtx) {
* |-------------pointer area----------|----ts---+-----+-----n tags-----------|----ts---+-----+-----n tags-----------|
* |-------------pointer area----------|----ts---+-----+-----n tags-----------|----ts---+-----+-----n tags-----------|
* +..[Value Pointer1][Value Pointer2].|timestamp|value|tags1|tags2|....|tagsn|timestamp|value|tags1|tags2|....|tagsn+
* +..[Value Pointer1][Value Pointer2].|timestamp|value|tags1|tags2|....|tagsn|timestamp|value|tags1|tags2|....|tagsn+
*/
*/
static
void
buildTopBotStruct
(
STopBotInfo
*
pTopBotInfo
,
S
QL
FunctionCtx
*
pCtx
)
{
static
void
buildTopBotStruct
(
STopBotInfo
*
pTopBotInfo
,
S
ql
FunctionCtx
*
pCtx
)
{
char
*
tmp
=
(
char
*
)
pTopBotInfo
+
sizeof
(
STopBotInfo
);
char
*
tmp
=
(
char
*
)
pTopBotInfo
+
sizeof
(
STopBotInfo
);
pTopBotInfo
->
res
=
(
tValuePair
**
)
tmp
;
pTopBotInfo
->
res
=
(
tValuePair
**
)
tmp
;
tmp
+=
POINTER_BYTES
*
pCtx
->
param
[
0
].
i
;
tmp
+=
POINTER_BYTES
*
pCtx
->
param
[
0
].
i
;
...
@@ -2150,7 +2150,7 @@ static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) {
...
@@ -2150,7 +2150,7 @@ static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) {
}
}
}
}
bool
topbot_datablock_filter
(
S
QL
FunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
)
{
bool
topbot_datablock_filter
(
S
ql
FunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
==
NULL
)
{
if
(
pResInfo
==
NULL
)
{
return
true
;
return
true
;
...
@@ -2206,7 +2206,7 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha
...
@@ -2206,7 +2206,7 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha
}
}
}
}
static
bool
top_bottom_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
top_bottom_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -2216,7 +2216,7 @@ static bool top_bottom_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo*
...
@@ -2216,7 +2216,7 @@ static bool top_bottom_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo*
return
true
;
return
true
;
}
}
static
void
top_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
top_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
STopBotInfo
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
STopBotInfo
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
...
@@ -2252,7 +2252,7 @@ static void top_function(SQLFunctionCtx *pCtx) {
...
@@ -2252,7 +2252,7 @@ static void top_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
top_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
top_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
STopBotInfo
*
pInput
=
(
STopBotInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
STopBotInfo
*
pInput
=
(
STopBotInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
// construct the input data struct from binary data
// construct the input data struct from binary data
...
@@ -2275,7 +2275,7 @@ static void top_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -2275,7 +2275,7 @@ static void top_func_merge(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
bottom_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
bottom_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
STopBotInfo
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
STopBotInfo
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
...
@@ -2309,7 +2309,7 @@ static void bottom_function(SQLFunctionCtx *pCtx) {
...
@@ -2309,7 +2309,7 @@ static void bottom_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
bottom_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
bottom_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
STopBotInfo
*
pInput
=
(
STopBotInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
STopBotInfo
*
pInput
=
(
STopBotInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
// construct the input data struct from binary data
// construct the input data struct from binary data
...
@@ -2332,7 +2332,7 @@ static void bottom_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -2332,7 +2332,7 @@ static void bottom_func_merge(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
top_bottom_func_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
top_bottom_func_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
// data in temporary list is less than the required number of results, not enough qualified number of results
// data in temporary list is less than the required number of results, not enough qualified number of results
...
@@ -2361,7 +2361,7 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -2361,7 +2361,7 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
static
bool
percentile_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
static
bool
percentile_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -2375,7 +2375,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo*
...
@@ -2375,7 +2375,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo*
return
true
;
return
true
;
}
}
static
void
percentile_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
percentile_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -2460,7 +2460,7 @@ static void percentile_function(SQLFunctionCtx *pCtx) {
...
@@ -2460,7 +2460,7 @@ static void percentile_function(SQLFunctionCtx *pCtx) {
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
}
}
static
void
percentile_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
percentile_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
double
v
=
pCtx
->
param
[
0
].
nType
==
TSDB_DATA_TYPE_INT
?
pCtx
->
param
[
0
].
i
:
pCtx
->
param
[
0
].
d
;
double
v
=
pCtx
->
param
[
0
].
nType
==
TSDB_DATA_TYPE_INT
?
pCtx
->
param
[
0
].
i
:
pCtx
->
param
[
0
].
d
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -2484,7 +2484,7 @@ static void buildHistogramInfo(SAPercentileInfo* pInfo) {
...
@@ -2484,7 +2484,7 @@ static void buildHistogramInfo(SAPercentileInfo* pInfo) {
pInfo
->
pHisto
->
elems
=
(
SHistBin
*
)
((
char
*
)
pInfo
->
pHisto
+
sizeof
(
SHistogramInfo
));
pInfo
->
pHisto
->
elems
=
(
SHistBin
*
)
((
char
*
)
pInfo
->
pHisto
+
sizeof
(
SHistogramInfo
));
}
}
static
SAPercentileInfo
*
getAPerctInfo
(
S
QL
FunctionCtx
*
pCtx
)
{
static
SAPercentileInfo
*
getAPerctInfo
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SAPercentileInfo
*
pInfo
=
NULL
;
SAPercentileInfo
*
pInfo
=
NULL
;
...
@@ -2498,7 +2498,7 @@ static SAPercentileInfo *getAPerctInfo(SQLFunctionCtx *pCtx) {
...
@@ -2498,7 +2498,7 @@ static SAPercentileInfo *getAPerctInfo(SQLFunctionCtx *pCtx) {
return
pInfo
;
return
pInfo
;
}
}
static
bool
apercentile_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
static
bool
apercentile_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -2510,7 +2510,7 @@ static bool apercentile_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo
...
@@ -2510,7 +2510,7 @@ static bool apercentile_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo
return
true
;
return
true
;
}
}
static
void
apercentile_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
apercentile_function
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -2542,7 +2542,7 @@ static void apercentile_function(SQLFunctionCtx *pCtx) {
...
@@ -2542,7 +2542,7 @@ static void apercentile_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
apercentile_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
apercentile_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
SAPercentileInfo
*
pInput
=
(
SAPercentileInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
SAPercentileInfo
*
pInput
=
(
SAPercentileInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
pInput
->
pHisto
=
(
SHistogramInfo
*
)
((
char
*
)
pInput
+
sizeof
(
SAPercentileInfo
));
pInput
->
pHisto
=
(
SHistogramInfo
*
)
((
char
*
)
pInput
+
sizeof
(
SAPercentileInfo
));
...
@@ -2572,7 +2572,7 @@ static void apercentile_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -2572,7 +2572,7 @@ static void apercentile_func_merge(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
1
,
1
);
SET_VAL
(
pCtx
,
1
,
1
);
}
}
static
void
apercentile_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
apercentile_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
double
v
=
(
pCtx
->
param
[
0
].
nType
==
TSDB_DATA_TYPE_INT
)
?
pCtx
->
param
[
0
].
i
:
pCtx
->
param
[
0
].
d
;
double
v
=
(
pCtx
->
param
[
0
].
nType
==
TSDB_DATA_TYPE_INT
)
?
pCtx
->
param
[
0
].
i
:
pCtx
->
param
[
0
].
d
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -2608,7 +2608,7 @@ static void apercentile_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -2608,7 +2608,7 @@ static void apercentile_finalizer(SQLFunctionCtx *pCtx) {
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
static
bool
leastsquares_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
leastsquares_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -2638,7 +2638,7 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInf
...
@@ -2638,7 +2638,7 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInf
LEASTSQR_CAL(param, x, y, i, step); \
LEASTSQR_CAL(param, x, y, i, step); \
}
}
static
void
leastsquares_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
leastsquares_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SLeastsquaresInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SLeastsquaresInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -2724,7 +2724,7 @@ static void leastsquares_function(SQLFunctionCtx *pCtx) {
...
@@ -2724,7 +2724,7 @@ static void leastsquares_function(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
numOfElem
,
1
);
SET_VAL
(
pCtx
,
numOfElem
,
1
);
}
}
static
void
leastsquares_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
leastsquares_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
// no data in query
// no data in query
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SLeastsquaresInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SLeastsquaresInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -2756,12 +2756,12 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -2756,12 +2756,12 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
doFinalizer
(
pCtx
);
doFinalizer
(
pCtx
);
}
}
static
void
date_col_output_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
date_col_output_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
pCtx
->
startTs
;
*
(
int64_t
*
)(
pCtx
->
pOutput
)
=
pCtx
->
startTs
;
}
}
static
void
col_project_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
col_project_function
(
S
ql
FunctionCtx
*
pCtx
)
{
// the number of output rows should not affect the final number of rows, so set it to be 0
// the number of output rows should not affect the final number of rows, so set it to be 0
if
(
pCtx
->
numOfParams
==
2
)
{
if
(
pCtx
->
numOfParams
==
2
)
{
return
;
return
;
...
@@ -2791,7 +2791,7 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
...
@@ -2791,7 +2791,7 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
* @param pCtx
* @param pCtx
* @return
* @return
*/
*/
static
void
tag_project_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
tag_project_function
(
S
ql
FunctionCtx
*
pCtx
)
{
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
assert
(
pCtx
->
inputBytes
==
pCtx
->
resDataInfo
.
bytes
);
assert
(
pCtx
->
inputBytes
==
pCtx
->
resDataInfo
.
bytes
);
...
@@ -2814,9 +2814,9 @@ static void tag_project_function(SQLFunctionCtx *pCtx) {
...
@@ -2814,9 +2814,9 @@ static void tag_project_function(SQLFunctionCtx *pCtx) {
* @param pCtx
* @param pCtx
* @return
* @return
*/
*/
static
void
copy_function
(
S
QL
FunctionCtx
*
pCtx
);
static
void
copy_function
(
S
ql
FunctionCtx
*
pCtx
);
static
void
tag_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
tag_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SET_VAL
(
pCtx
,
1
,
1
);
SET_VAL
(
pCtx
,
1
,
1
);
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
copy_function
(
pCtx
);
copy_function
(
pCtx
);
...
@@ -2825,7 +2825,7 @@ static void tag_function(SQLFunctionCtx *pCtx) {
...
@@ -2825,7 +2825,7 @@ static void tag_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
copy_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
copy_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
char
*
pData
=
GET_INPUT_DATA_LIST
(
pCtx
);
...
@@ -2836,7 +2836,7 @@ enum {
...
@@ -2836,7 +2836,7 @@ enum {
INITIAL_VALUE_NOT_ASSIGNED
=
0
,
INITIAL_VALUE_NOT_ASSIGNED
=
0
,
};
};
static
bool
diff_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
diff_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -2846,7 +2846,7 @@ static bool diff_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResI
...
@@ -2846,7 +2846,7 @@ static bool diff_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResI
return
false
;
return
false
;
}
}
static
bool
deriv_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
static
bool
deriv_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResultInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -2861,7 +2861,7 @@ static bool deriv_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pRes
...
@@ -2861,7 +2861,7 @@ static bool deriv_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pRes
return
false
;
return
false
;
}
}
static
void
deriv_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
deriv_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SDerivInfo
*
pDerivInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SDerivInfo
*
pDerivInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -3056,7 +3056,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
...
@@ -3056,7 +3056,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
} while (0);
} while (0);
// TODO difference in date column
// TODO difference in date column
static
void
diff_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
diff_function
(
S
ql
FunctionCtx
*
pCtx
)
{
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
bool
isFirstBlock
=
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
);
bool
isFirstBlock
=
(
pCtx
->
param
[
1
].
nType
==
INITIAL_VALUE_NOT_ASSIGNED
);
...
@@ -3236,7 +3236,7 @@ char *getArithColumnData(void *param, const char* name, int32_t colId) {
...
@@ -3236,7 +3236,7 @@ char *getArithColumnData(void *param, const char* name, int32_t colId) {
return
pSupport
->
data
[
index
]
+
pSupport
->
offset
*
pSupport
->
colList
[
index
].
bytes
;
return
pSupport
->
data
[
index
]
+
pSupport
->
offset
*
pSupport
->
colList
[
index
].
bytes
;
}
}
static
void
arithmetic_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
arithmetic_function
(
S
ql
FunctionCtx
*
pCtx
)
{
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
pCtx
->
size
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
pCtx
->
size
;
SScalarFunctionSupport
*
pSup
=
(
SScalarFunctionSupport
*
)
pCtx
->
param
[
1
].
pz
;
SScalarFunctionSupport
*
pSup
=
(
SScalarFunctionSupport
*
)
pCtx
->
param
[
1
].
pz
;
...
@@ -3264,7 +3264,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
...
@@ -3264,7 +3264,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
static
bool
spread_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
spread_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -3283,7 +3283,7 @@ static bool spread_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pRe
...
@@ -3283,7 +3283,7 @@ static bool spread_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pRe
return
true
;
return
true
;
}
}
static
void
spread_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
spread_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SSpreadInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SSpreadInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -3368,7 +3368,7 @@ static void spread_function(SQLFunctionCtx *pCtx) {
...
@@ -3368,7 +3368,7 @@ static void spread_function(SQLFunctionCtx *pCtx) {
* here we set the result value back to the intermediate buffer, to apply the finalize the function
* here we set the result value back to the intermediate buffer, to apply the finalize the function
* the final result is generated in spread_function_finalizer
* the final result is generated in spread_function_finalizer
*/
*/
void
spread_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
void
spread_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
SSpreadInfo
*
pData
=
(
SSpreadInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
SSpreadInfo
*
pData
=
(
SSpreadInfo
*
)
GET_INPUT_DATA_LIST
(
pCtx
);
if
(
pData
->
hasResult
!=
DATA_SET_FLAG
)
{
if
(
pData
->
hasResult
!=
DATA_SET_FLAG
)
{
return
;
return
;
...
@@ -3385,7 +3385,7 @@ void spread_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -3385,7 +3385,7 @@ void spread_func_merge(SQLFunctionCtx *pCtx) {
GET_RES_INFO
(
pCtx
)
->
hasResult
=
DATA_SET_FLAG
;
GET_RES_INFO
(
pCtx
)
->
hasResult
=
DATA_SET_FLAG
;
}
}
void
spread_function_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
void
spread_function_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
/*
/*
* here we do not check the input data types, because in case of metric query,
* here we do not check the input data types, because in case of metric query,
* the type of intermediate data is binary
* the type of intermediate data is binary
...
@@ -3423,7 +3423,7 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -3423,7 +3423,7 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) {
* param[2]: end time
* param[2]: end time
* @param pCtx
* @param pCtx
*/
*/
static
bool
twa_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
twa_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -3444,7 +3444,7 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
...
@@ -3444,7 +3444,7 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
return
val
;
return
val
;
}
}
static
int32_t
twa_function_impl
(
S
QL
FunctionCtx
*
pCtx
,
int32_t
index
,
int32_t
size
)
{
static
int32_t
twa_function_impl
(
S
ql
FunctionCtx
*
pCtx
,
int32_t
index
,
int32_t
size
)
{
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -3685,7 +3685,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
...
@@ -3685,7 +3685,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t index, int32_t si
return
notNullElems
;
return
notNullElems
;
}
}
static
void
twa_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
twa_function
(
S
ql
FunctionCtx
*
pCtx
)
{
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -3719,7 +3719,7 @@ static void twa_function(SQLFunctionCtx *pCtx) {
...
@@ -3719,7 +3719,7 @@ static void twa_function(SQLFunctionCtx *pCtx) {
* by next input data. The TWA function only applies to each table, so no merge procedure
* by next input data. The TWA function only applies to each table, so no merge procedure
* is required, we simply copy to the resut ot interResBuffer.
* is required, we simply copy to the resut ot interResBuffer.
*/
*/
void
twa_function_copy
(
S
QL
FunctionCtx
*
pCtx
)
{
void
twa_function_copy
(
S
ql
FunctionCtx
*
pCtx
)
{
assert
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BINARY
);
assert
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BINARY
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -3727,7 +3727,7 @@ void twa_function_copy(SQLFunctionCtx *pCtx) {
...
@@ -3727,7 +3727,7 @@ void twa_function_copy(SQLFunctionCtx *pCtx) {
pResInfo
->
hasResult
=
((
STwaInfo
*
)
pCtx
->
pInput
)
->
hasResult
;
pResInfo
->
hasResult
=
((
STwaInfo
*
)
pCtx
->
pInput
)
->
hasResult
;
}
}
void
twa_function_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
void
twa_function_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -3752,7 +3752,7 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -3752,7 +3752,7 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) {
* @param pCtx
* @param pCtx
*/
*/
static
void
interp_function_impl
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
interp_function_impl
(
S
ql
FunctionCtx
*
pCtx
)
{
int32_t
type
=
(
int32_t
)
pCtx
->
param
[
2
].
i
;
int32_t
type
=
(
int32_t
)
pCtx
->
param
[
2
].
i
;
if
(
type
==
TSDB_FILL_NONE
)
{
if
(
type
==
TSDB_FILL_NONE
)
{
return
;
return
;
...
@@ -3875,7 +3875,7 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
...
@@ -3875,7 +3875,7 @@ static void interp_function_impl(SQLFunctionCtx *pCtx) {
SET_VAL
(
pCtx
,
1
,
1
);
SET_VAL
(
pCtx
,
1
,
1
);
}
}
static
void
interp_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
interp_function
(
S
ql
FunctionCtx
*
pCtx
)
{
// at this point, the value is existed, return directly
// at this point, the value is existed, return directly
if
(
pCtx
->
size
>
0
)
{
if
(
pCtx
->
size
>
0
)
{
bool
ascQuery
=
(
pCtx
->
order
==
TSDB_ORDER_ASC
);
bool
ascQuery
=
(
pCtx
->
order
==
TSDB_ORDER_ASC
);
...
@@ -3918,7 +3918,7 @@ static void interp_function(SQLFunctionCtx *pCtx) {
...
@@ -3918,7 +3918,7 @@ static void interp_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
bool
ts_comp_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
ts_comp_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
// not initialized since it has been initialized
return
false
;
// not initialized since it has been initialized
}
}
...
@@ -3929,7 +3929,7 @@ static bool ts_comp_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pR
...
@@ -3929,7 +3929,7 @@ static bool ts_comp_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pR
return
true
;
return
true
;
}
}
static
void
ts_comp_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
ts_comp_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STSBuf
*
pTSbuf
=
((
STSCompInfo
*
)(
GET_ROWCELL_INTERBUF
(
pResInfo
)))
->
pTSBuf
;
STSBuf
*
pTSbuf
=
((
STSCompInfo
*
)(
GET_ROWCELL_INTERBUF
(
pResInfo
)))
->
pTSBuf
;
...
@@ -3949,7 +3949,7 @@ static void ts_comp_function(SQLFunctionCtx *pCtx) {
...
@@ -3949,7 +3949,7 @@ static void ts_comp_function(SQLFunctionCtx *pCtx) {
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
}
}
static
void
ts_comp_finalize
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
ts_comp_finalize
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STSCompInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
STSCompInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -4006,7 +4006,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo, double tickPerSec) {
...
@@ -4006,7 +4006,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo, double tickPerSec) {
return
(
duration
>
0
)
?
((
double
)
diff
)
/
(
duration
/
tickPerSec
)
:
0
.
0
;
return
(
duration
>
0
)
?
((
double
)
diff
)
/
(
duration
/
tickPerSec
)
:
0
.
0
;
}
}
static
bool
rate_function_setup
(
S
QL
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
static
bool
rate_function_setup
(
S
ql
FunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
)
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
if
(
!
function_setup
(
pCtx
,
pResInfo
))
{
return
false
;
return
false
;
}
}
...
@@ -4023,7 +4023,7 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResI
...
@@ -4023,7 +4023,7 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx, SResultRowEntryInfo* pResI
return
true
;
return
true
;
}
}
static
void
rate_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
rate_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
...
@@ -4076,7 +4076,7 @@ static void rate_function(SQLFunctionCtx *pCtx) {
...
@@ -4076,7 +4076,7 @@ static void rate_function(SQLFunctionCtx *pCtx) {
}
}
}
}
static
void
rate_func_copy
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
rate_func_copy
(
S
ql
FunctionCtx
*
pCtx
)
{
assert
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BINARY
);
assert
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BINARY
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -4084,7 +4084,7 @@ static void rate_func_copy(SQLFunctionCtx *pCtx) {
...
@@ -4084,7 +4084,7 @@ static void rate_func_copy(SQLFunctionCtx *pCtx) {
pResInfo
->
hasResult
=
((
SRateInfo
*
)
pCtx
->
pInput
)
->
hasResult
;
pResInfo
->
hasResult
=
((
SRateInfo
*
)
pCtx
->
pInput
)
->
hasResult
;
}
}
static
void
rate_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
rate_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SRateInfo
*
pRateInfo
=
(
SRateInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
SRateInfo
*
pRateInfo
=
(
SRateInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -4102,7 +4102,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -4102,7 +4102,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
doFinalizer
(
pCtx
);
doFinalizer
(
pCtx
);
}
}
static
void
irate_function
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
irate_function
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
int32_t
notNullElems
=
0
;
int32_t
notNullElems
=
0
;
...
@@ -4184,7 +4184,7 @@ static void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDi
...
@@ -4184,7 +4184,7 @@ static void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDi
}
}
}
}
static
void
blockInfo_func
(
S
QL
FunctionCtx
*
pCtx
)
{
static
void
blockInfo_func
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STableBlockDist
*
pDist
=
(
STableBlockDist
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
STableBlockDist
*
pDist
=
(
STableBlockDist
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -4232,7 +4232,7 @@ static void mergeTableBlockDist(SResultRowEntryInfo* pResInfo, const STableBlock
...
@@ -4232,7 +4232,7 @@ static void mergeTableBlockDist(SResultRowEntryInfo* pResInfo, const STableBlock
}
}
}
}
void
block_func_merge
(
S
QL
FunctionCtx
*
pCtx
)
{
void
block_func_merge
(
S
ql
FunctionCtx
*
pCtx
)
{
STableBlockDist
info
=
{
0
};
STableBlockDist
info
=
{
0
};
int32_t
len
=
*
(
int32_t
*
)
pCtx
->
pInput
;
int32_t
len
=
*
(
int32_t
*
)
pCtx
->
pInput
;
blockDistInfoFromBinary
(((
char
*
)
pCtx
->
pInput
)
+
sizeof
(
int32_t
),
len
,
&
info
);
blockDistInfoFromBinary
(((
char
*
)
pCtx
->
pInput
)
+
sizeof
(
int32_t
),
len
,
&
info
);
...
@@ -4338,7 +4338,7 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
...
@@ -4338,7 +4338,7 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
UNUSED
(
sz
);
UNUSED
(
sz
);
}
}
void
blockinfo_func_finalizer
(
S
QL
FunctionCtx
*
pCtx
)
{
void
blockinfo_func_finalizer
(
S
ql
FunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STableBlockDist
*
pDist
=
(
STableBlockDist
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
STableBlockDist
*
pDist
=
(
STableBlockDist
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -4380,12 +4380,12 @@ int32_t functionCompatList[] = {
...
@@ -4380,12 +4380,12 @@ int32_t functionCompatList[] = {
};
};
//typedef struct SFunctionFpSet {
//typedef struct SFunctionFpSet {
// bool (*init)(struct S
QL
FunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo); // setup the execute environment
// bool (*init)(struct S
ql
FunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo); // setup the execute environment
// void (*addInput)(struct S
QL
FunctionCtx *pCtx);
// void (*addInput)(struct S
ql
FunctionCtx *pCtx);
//
//
// // finalizer must be called after all exec has been executed to generated final result.
// // finalizer must be called after all exec has been executed to generated final result.
// void (*finalize)(struct S
QL
FunctionCtx *pCtx);
// void (*finalize)(struct S
ql
FunctionCtx *pCtx);
// void (*combine)(struct S
QL
FunctionCtx *pCtx);
// void (*combine)(struct S
ql
FunctionCtx *pCtx);
//} SFunctionFpSet;
//} SFunctionFpSet;
SFunctionFpSet
fpSet
[
1
]
=
{
SFunctionFpSet
fpSet
[
1
]
=
{
...
...
source/libs/function/src/tudf.c
浏览文件 @
244b552f
...
@@ -121,7 +121,7 @@ void destroyUdfInfo(SUdfInfo* pUdfInfo) {
...
@@ -121,7 +121,7 @@ void destroyUdfInfo(SUdfInfo* pUdfInfo) {
tfree(pUdfInfo);
tfree(pUdfInfo);
}
}
void doInvokeUdf(struct SUdfInfo* pUdfInfo, S
QL
FunctionCtx *pCtx, int32_t idx, int32_t type) {
void doInvokeUdf(struct SUdfInfo* pUdfInfo, S
ql
FunctionCtx *pCtx, int32_t idx, int32_t type) {
int32_t output = 0;
int32_t output = 0;
if (pUdfInfo == NULL || pUdfInfo->funcs[type] == NULL) {
if (pUdfInfo == NULL || pUdfInfo->funcs[type] == NULL) {
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
244b552f
...
@@ -216,7 +216,8 @@ static SPhyNode* createMultiTableScanNode(SQueryPlanNode* pPlanNode, SQueryTable
...
@@ -216,7 +216,8 @@ static SPhyNode* createMultiTableScanNode(SQueryPlanNode* pPlanNode, SQueryTable
}
else
if
(
needSeqScan
(
pPlanNode
))
{
}
else
if
(
needSeqScan
(
pPlanNode
))
{
return
createUserTableScanNode
(
pPlanNode
,
pTable
,
OP_TableSeqScan
);
return
createUserTableScanNode
(
pPlanNode
,
pTable
,
OP_TableSeqScan
);
}
}
return
createUserTableScanNode
(
pPlanNode
,
pTable
,
OP_DataBlocksOptScan
);
int32_t
type
=
(
pPlanNode
->
info
.
type
==
QNODE_TABLESCAN
)
?
OP_DataBlocksOptScan
:
OP_StreamScan
;
return
createUserTableScanNode
(
pPlanNode
,
pTable
,
type
);
}
}
static
SSubplan
*
initSubplan
(
SPlanContext
*
pCxt
,
int32_t
type
)
{
static
SSubplan
*
initSubplan
(
SPlanContext
*
pCxt
,
int32_t
type
)
{
...
@@ -287,7 +288,7 @@ static bool needMultiNodeScan(SQueryTableInfo* pTable) {
...
@@ -287,7 +288,7 @@ static bool needMultiNodeScan(SQueryTableInfo* pTable) {
static
SPhyNode
*
createSingleTableScanNode
(
SQueryPlanNode
*
pPlanNode
,
SQueryTableInfo
*
pTableInfo
,
SSubplan
*
subplan
)
{
static
SPhyNode
*
createSingleTableScanNode
(
SQueryPlanNode
*
pPlanNode
,
SQueryTableInfo
*
pTableInfo
,
SSubplan
*
subplan
)
{
SVgroupsInfo
*
pVgroupsInfo
=
pTableInfo
->
pMeta
->
vgroupList
;
SVgroupsInfo
*
pVgroupsInfo
=
pTableInfo
->
pMeta
->
vgroupList
;
vgroupInfoToNodeAddr
(
&
(
pVgroupsInfo
->
vgroups
[
0
]),
&
subplan
->
execNode
);
vgroupInfoToNodeAddr
(
&
(
pVgroupsInfo
->
vgroups
[
0
]),
&
subplan
->
execNode
);
int32_t
type
=
(
pPlanNode
->
info
.
type
==
QNODE_TABLESCAN
)
?
OP_
Table
Scan
:
OP_StreamScan
;
int32_t
type
=
(
pPlanNode
->
info
.
type
==
QNODE_TABLESCAN
)
?
OP_
DataBlocksOpt
Scan
:
OP_StreamScan
;
return
createUserTableScanNode
(
pPlanNode
,
pTableInfo
,
type
);
return
createUserTableScanNode
(
pPlanNode
,
pTableInfo
,
type
);
}
}
...
@@ -296,6 +297,7 @@ static SPhyNode* createTableScanNode(SPlanContext* pCxt, SQueryPlanNode* pPlanNo
...
@@ -296,6 +297,7 @@ static SPhyNode* createTableScanNode(SPlanContext* pCxt, SQueryPlanNode* pPlanNo
if
(
needMultiNodeScan
(
pTable
))
{
if
(
needMultiNodeScan
(
pTable
))
{
return
createExchangeNode
(
pCxt
,
pPlanNode
,
splitSubplanByTable
(
pCxt
,
pPlanNode
,
pTable
));
return
createExchangeNode
(
pCxt
,
pPlanNode
,
splitSubplanByTable
(
pCxt
,
pPlanNode
,
pTable
));
}
}
return
createSingleTableScanNode
(
pPlanNode
,
pTable
,
pCxt
->
pCurrentSubplan
);
return
createSingleTableScanNode
(
pPlanNode
,
pTable
,
pCxt
->
pCurrentSubplan
);
}
}
...
@@ -386,6 +388,33 @@ static void createSubplanByLevel(SPlanContext* pCxt, SQueryPlanNode* pRoot) {
...
@@ -386,6 +388,33 @@ static void createSubplanByLevel(SPlanContext* pCxt, SQueryPlanNode* pRoot) {
// todo deal subquery
// todo deal subquery
}
}
static
void
postCreateDag
(
SQueryPlanNode
*
pQueryNode
,
SQueryDag
*
pDag
,
SArray
*
pNodeList
)
{
// The exchange operator is not necessary, in case of the stream scan.
// Here we need to remove it from the DAG.
if
(
pQueryNode
->
info
.
type
==
QNODE_STREAMSCAN
)
{
SArray
*
pRootLevel
=
taosArrayGetP
(
pDag
->
pSubplans
,
0
);
SSubplan
*
pSubplan
=
taosArrayGetP
(
pRootLevel
,
0
);
if
(
pSubplan
->
pNode
->
info
.
type
==
OP_Exchange
)
{
ASSERT
(
taosArrayGetSize
(
pRootLevel
)
==
1
);
taosArrayRemove
(
pDag
->
pSubplans
,
0
);
// And then update the number of the subplans.
pDag
->
numOfSubplans
-=
1
;
}
}
else
{
// Traverse the dag again to acquire the execution node.
if
(
pNodeList
!=
NULL
)
{
SArray
**
pSubLevel
=
taosArrayGetLast
(
pDag
->
pSubplans
);
size_t
num
=
taosArrayGetSize
(
*
pSubLevel
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SSubplan
*
pPlan
=
taosArrayGetP
(
*
pSubLevel
,
j
);
taosArrayPush
(
pNodeList
,
&
pPlan
->
execNode
);
}
}
}
}
int32_t
createDag
(
SQueryPlanNode
*
pQueryNode
,
struct
SCatalog
*
pCatalog
,
SQueryDag
**
pDag
,
SArray
*
pNodeList
,
uint64_t
requestId
)
{
int32_t
createDag
(
SQueryPlanNode
*
pQueryNode
,
struct
SCatalog
*
pCatalog
,
SQueryDag
**
pDag
,
SArray
*
pNodeList
,
uint64_t
requestId
)
{
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
TRY
(
TSDB_MAX_TAG_CONDITIONS
)
{
SPlanContext
context
=
{
SPlanContext
context
=
{
...
@@ -407,16 +436,7 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD
...
@@ -407,16 +436,7 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
END_TRY
}
END_TRY
// traverse the dag again to acquire the execution node.
postCreateDag
(
pQueryNode
,
*
pDag
,
pNodeList
);
if
(
pNodeList
!=
NULL
)
{
SArray
**
pSubLevel
=
taosArrayGetLast
((
*
pDag
)
->
pSubplans
);
size_t
num
=
taosArrayGetSize
(
*
pSubLevel
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SSubplan
*
pPlan
=
taosArrayGetP
(
*
pSubLevel
,
j
);
taosArrayPush
(
pNodeList
,
&
pPlan
->
execNode
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
244b552f
...
@@ -88,7 +88,6 @@ static const char* jkPnodeType = "Type";
...
@@ -88,7 +88,6 @@ static const char* jkPnodeType = "Type";
static
int32_t
getPnodeTypeSize
(
cJSON
*
json
)
{
static
int32_t
getPnodeTypeSize
(
cJSON
*
json
)
{
switch
(
getNumber
(
json
,
jkPnodeType
))
{
switch
(
getNumber
(
json
,
jkPnodeType
))
{
case
OP_StreamScan
:
case
OP_StreamScan
:
case
OP_TableScan
:
case
OP_DataBlocksOptScan
:
case
OP_DataBlocksOptScan
:
case
OP_TableSeqScan
:
case
OP_TableSeqScan
:
return
sizeof
(
STableScanPhyNode
);
return
sizeof
(
STableScanPhyNode
);
...
@@ -831,7 +830,6 @@ static bool specificPhyNodeToJson(const void* obj, cJSON* json) {
...
@@ -831,7 +830,6 @@ static bool specificPhyNodeToJson(const void* obj, cJSON* json) {
const
SPhyNode
*
phyNode
=
(
const
SPhyNode
*
)
obj
;
const
SPhyNode
*
phyNode
=
(
const
SPhyNode
*
)
obj
;
switch
(
phyNode
->
info
.
type
)
{
switch
(
phyNode
->
info
.
type
)
{
case
OP_StreamScan
:
case
OP_StreamScan
:
case
OP_TableScan
:
case
OP_DataBlocksOptScan
:
case
OP_DataBlocksOptScan
:
case
OP_TableSeqScan
:
case
OP_TableSeqScan
:
return
tableScanNodeToJson
(
obj
,
json
);
return
tableScanNodeToJson
(
obj
,
json
);
...
@@ -869,7 +867,6 @@ static bool specificPhyNodeToJson(const void* obj, cJSON* json) {
...
@@ -869,7 +867,6 @@ static bool specificPhyNodeToJson(const void* obj, cJSON* json) {
static
bool
specificPhyNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
static
bool
specificPhyNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SPhyNode
*
phyNode
=
(
SPhyNode
*
)
obj
;
SPhyNode
*
phyNode
=
(
SPhyNode
*
)
obj
;
switch
(
phyNode
->
info
.
type
)
{
switch
(
phyNode
->
info
.
type
)
{
case
OP_TableScan
:
case
OP_StreamScan
:
case
OP_StreamScan
:
case
OP_DataBlocksOptScan
:
case
OP_DataBlocksOptScan
:
case
OP_TableSeqScan
:
case
OP_TableSeqScan
:
...
...
source/util/src/terror.c
浏览文件 @
244b552f
...
@@ -254,6 +254,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_RETRIEVE, "Invalid func retriev
...
@@ -254,6 +254,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_RETRIEVE, "Invalid func retriev
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_ALREADY_EXIST
,
"Transaction already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_ALREADY_EXIST
,
"Transaction already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_NOT_EXIST
,
"Transaction not exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_NOT_EXIST
,
"Transaction not exists"
)
// mnode-topic
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_UNSUPPORTED_TOPIC
,
"Topic with STable not supported yet"
)
// dnode
// dnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_ACTION_IN_PROGRESS
,
"Action in progress"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_ACTION_IN_PROGRESS
,
"Action in progress"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_OFFLINE
,
"Dnode is offline"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_OFFLINE
,
"Dnode is offline"
)
...
...
grafanaplugin
@
4a4d7909
Subproject commit 4a4d79099b076b8ff12d5b4fdbcba54049a6866d
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录