Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3bda4cf3
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看板
未验证
提交
3bda4cf3
编写于
10月 13, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
10月 13, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17332 from taosdata/refact/code_format
refact: code format
上级
7f8d2ff5
1ad11749
变更
111
展开全部
显示空白变更内容
内联
并排
Showing
111 changed file
with
8187 addition
and
7854 deletion
+8187
-7854
source/client/inc/clientLog.h
source/client/inc/clientLog.h
+2
-0
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+70
-50
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+7
-6
source/client/src/clientTmqConnector.c
source/client/src/clientTmqConnector.c
+3
-2
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+35
-36
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+400
-133
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+382
-325
source/libs/catalog/inc/ctgRemote.h
source/libs/catalog/inc/ctgRemote.h
+0
-2
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+88
-83
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+1
-1
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+65
-61
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+179
-221
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+149
-166
source/libs/command/test/commandTest.cpp
source/libs/command/test/commandTest.cpp
+2
-2
source/libs/executor/inc/dataSinkInt.h
source/libs/executor/inc/dataSinkInt.h
+11
-9
source/libs/executor/inc/executorInt.h
source/libs/executor/inc/executorInt.h
+4
-4
source/libs/executor/inc/tlinearhash.h
source/libs/executor/inc/tlinearhash.h
+5
-5
source/libs/executor/inc/tsimplehash.h
source/libs/executor/inc/tsimplehash.h
+1
-1
source/libs/executor/inc/tsort.h
source/libs/executor/inc/tsort.h
+16
-14
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+29
-27
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+16
-15
source/libs/executor/src/dataInserter.c
source/libs/executor/src/dataInserter.c
+40
-40
source/libs/executor/src/dataSinkMgt.c
source/libs/executor/src/dataSinkMgt.c
+7
-9
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+10
-9
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+2
-1
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+1
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+2
-2
source/libs/executor/src/tlinearhash.c
source/libs/executor/src/tlinearhash.c
+46
-48
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+88
-78
source/libs/executor/test/lhashTests.cpp
source/libs/executor/test/lhashTests.cpp
+11
-10
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+40
-40
source/libs/executor/test/tSimpleHashTests.cpp
source/libs/executor/test/tSimpleHashTests.cpp
+3
-7
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+81
-81
source/libs/function/inc/tfunctionInt.h
source/libs/function/inc/tfunctionInt.h
+5
-5
source/libs/function/inc/thistogram.h
source/libs/function/inc/thistogram.h
+8
-8
source/libs/function/inc/tpercentile.h
source/libs/function/inc/tpercentile.h
+3
-3
source/libs/function/inc/tscript.h
source/libs/function/inc/tscript.h
+4
-4
source/libs/function/inc/tudfInt.h
source/libs/function/inc/tudfInt.h
+16
-18
source/libs/function/inc/udfc.h
source/libs/function/inc/udfc.h
+37
-41
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+4
-3
source/libs/function/src/tfunctionInt.c
source/libs/function/src/tfunctionInt.c
+7
-11
source/libs/function/src/thistogram.c
source/libs/function/src/thistogram.c
+7
-7
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+79
-80
source/libs/function/src/tscript.c
source/libs/function/src/tscript.c
+2
-2
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+292
-322
source/libs/function/test/runUdf.c
source/libs/function/test/runUdf.c
+6
-7
source/libs/function/test/udf1.c
source/libs/function/test/udf1.c
+8
-13
source/libs/function/test/udf2.c
source/libs/function/test/udf2.c
+12
-17
source/libs/index/test/index_executor_tests.cpp
source/libs/index/test/index_executor_tests.cpp
+7
-7
source/libs/monitor/src/monMain.c
source/libs/monitor/src/monMain.c
+1
-1
source/libs/parser/inc/parInsertData.h
source/libs/parser/inc/parInsertData.h
+1
-1
source/libs/qcom/inc/queryInt.h
source/libs/qcom/inc/queryInt.h
+0
-1
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+58
-59
source/libs/qcom/test/queryTest.cpp
source/libs/qcom/test/queryTest.cpp
+6
-5
source/libs/qworker/inc/qwInt.h
source/libs/qworker/inc/qwInt.h
+63
-55
source/libs/qworker/inc/qwMsg.h
source/libs/qworker/inc/qwMsg.h
+5
-4
source/libs/qworker/src/qwDbg.c
source/libs/qworker/src/qwDbg.c
+23
-23
source/libs/qworker/src/qwMsg.c
source/libs/qworker/src/qwMsg.c
+37
-33
source/libs/qworker/src/qwUtil.c
source/libs/qworker/src/qwUtil.c
+12
-15
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+26
-26
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+246
-281
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+264
-132
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+52
-26
source/libs/scalar/inc/sclvector.h
source/libs/scalar/inc/sclvector.h
+3
-3
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+556
-558
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+142
-138
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+231
-241
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+371
-414
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+258
-276
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+3308
-3321
source/libs/stream/src/streamUpdate.c
source/libs/stream/src/streamUpdate.c
+7
-6
source/libs/stream/test/tstreamUpdateTest.cpp
source/libs/stream/test/tstreamUpdateTest.cpp
+57
-58
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+4
-4
source/libs/sync/inc/syncRaftStore.h
source/libs/sync/inc/syncRaftStore.h
+3
-3
source/libs/sync/inc/syncVoteMgr.h
source/libs/sync/inc/syncVoteMgr.h
+4
-4
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+3
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+18
-18
source/libs/sync/src/syncRaftStore.c
source/libs/sync/src/syncRaftStore.c
+1
-1
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+2
-2
source/libs/sync/src/syncVoteMgr.c
source/libs/sync/src/syncVoteMgr.c
+2
-2
source/libs/sync/test/syncAppendEntriesReplyTest.cpp
source/libs/sync/test/syncAppendEntriesReplyTest.cpp
+2
-2
source/libs/sync/test/syncAppendEntriesTest.cpp
source/libs/sync/test/syncAppendEntriesTest.cpp
+2
-2
source/libs/sync/test/syncApplyMsgTest.cpp
source/libs/sync/test/syncApplyMsgTest.cpp
+2
-2
source/libs/sync/test/syncClientRequestBatchTest.cpp
source/libs/sync/test/syncClientRequestBatchTest.cpp
+1
-1
source/libs/sync/test/syncClientRequestTest.cpp
source/libs/sync/test/syncClientRequestTest.cpp
+2
-2
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+1
-1
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+1
-1
source/libs/sync/test/syncEncodeTest.cpp
source/libs/sync/test/syncEncodeTest.cpp
+4
-4
source/libs/sync/test/syncHeartbeatReplyTest.cpp
source/libs/sync/test/syncHeartbeatReplyTest.cpp
+10
-14
source/libs/sync/test/syncHeartbeatTest.cpp
source/libs/sync/test/syncHeartbeatTest.cpp
+8
-8
source/libs/sync/test/syncIndexTest.cpp
source/libs/sync/test/syncIndexTest.cpp
+1
-1
source/libs/sync/test/syncLeaderTransferTest.cpp
source/libs/sync/test/syncLeaderTransferTest.cpp
+2
-2
source/libs/sync/test/syncPingReplyTest.cpp
source/libs/sync/test/syncPingReplyTest.cpp
+3
-3
source/libs/sync/test/syncPingTest.cpp
source/libs/sync/test/syncPingTest.cpp
+3
-3
source/libs/sync/test/syncRaftCfgIndexTest.cpp
source/libs/sync/test/syncRaftCfgIndexTest.cpp
+4
-4
source/libs/sync/test/syncReconfigFinishTest.cpp
source/libs/sync/test/syncReconfigFinishTest.cpp
+2
-2
source/libs/sync/test/syncRefTest.cpp
source/libs/sync/test/syncRefTest.cpp
+1
-1
source/libs/sync/test/syncRequestVoteReplyTest.cpp
source/libs/sync/test/syncRequestVoteReplyTest.cpp
+2
-2
source/libs/sync/test/syncRequestVoteTest.cpp
source/libs/sync/test/syncRequestVoteTest.cpp
+2
-2
source/libs/sync/test/syncSnapshotRspTest.cpp
source/libs/sync/test/syncSnapshotRspTest.cpp
+2
-2
source/libs/sync/test/syncSnapshotSendTest.cpp
source/libs/sync/test/syncSnapshotSendTest.cpp
+2
-2
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+2
-2
source/libs/sync/test/syncTimeoutTest.cpp
source/libs/sync/test/syncTimeoutTest.cpp
+3
-3
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+2
-2
source/libs/tfs/inc/tfsInt.h
source/libs/tfs/inc/tfsInt.h
+16
-14
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+2
-2
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+2
-2
source/libs/transport/test/transUT.cpp
source/libs/transport/test/transUT.cpp
+4
-4
source/libs/transport/test/uv.c
source/libs/transport/test/uv.c
+5
-5
tools/scripts/codeFormat.py
tools/scripts/codeFormat.py
+0
-0
tools/scripts/codeFormat.sh
tools/scripts/codeFormat.sh
+37
-8
未找到文件。
source/client/inc/clientLog.h
浏览文件 @
3bda4cf3
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "tlog.h"
// clang-format off
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
...
...
@@ -30,6 +31,7 @@ extern "C" {
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscPerf(...) do { taosPrintLog("TSC ", 0, cDebugFlag, __VA_ARGS__); } while(0)
// clang-format on
#ifdef __cplusplus
}
...
...
source/client/inc/clientStmt.h
浏览文件 @
3bda4cf3
...
...
@@ -42,13 +42,13 @@ typedef enum {
}
STMT_STATUS
;
typedef
struct
SStmtTableCache
{
STableDataBlocks
*
pDataBlock
;
void
*
boundTags
;
STableDataBlocks
*
pDataBlock
;
void
*
boundTags
;
}
SStmtTableCache
;
typedef
struct
SStmtQueryResInfo
{
TAOS_FIELD
*
fields
;
TAOS_FIELD
*
userFields
;
TAOS_FIELD
*
fields
;
TAOS_FIELD
*
userFields
;
uint32_t
numOfCols
;
int32_t
precision
;
}
SStmtQueryResInfo
;
...
...
@@ -62,7 +62,7 @@ typedef struct SStmtBindInfo {
int32_t
sBindLastIdx
;
int8_t
tbType
;
bool
tagsCached
;
void
*
boundTags
;
void
*
boundTags
;
char
tbName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
char
stbFName
[
TSDB_TABLE_FNAME_LEN
];
...
...
@@ -71,8 +71,8 @@ typedef struct SStmtBindInfo {
typedef
struct
SStmtExecInfo
{
int32_t
affectedRows
;
SRequestObj
*
pRequest
;
SHashObj
*
pBlockHash
;
SRequestObj
*
pRequest
;
SHashObj
*
pBlockHash
;
bool
autoCreateTbl
;
}
SStmtExecInfo
;
...
...
@@ -80,19 +80,19 @@ typedef struct SStmtSQLInfo {
STMT_TYPE
type
;
STMT_STATUS
status
;
uint64_t
runTimes
;
SHashObj
*
pTableCache
;
//
SHash<SStmtTableCache>
SQuery
*
pQuery
;
char
*
sqlStr
;
SHashObj
*
pTableCache
;
//
SHash<SStmtTableCache>
SQuery
*
pQuery
;
char
*
sqlStr
;
int32_t
sqlLen
;
SArray
*
nodeList
;
SArray
*
nodeList
;
SStmtQueryResInfo
queryRes
;
bool
autoCreateTbl
;
SHashObj
*
pVgHash
;
SHashObj
*
pVgHash
;
}
SStmtSQLInfo
;
typedef
struct
STscStmt
{
STscObj
*
taos
;
SCatalog
*
pCatalog
;
STscObj
*
taos
;
SCatalog
*
pCatalog
;
int32_t
affectedRows
;
SStmtSQLInfo
sql
;
...
...
@@ -103,11 +103,32 @@ typedef struct STscStmt {
#define STMT_STATUS_NE(S) (pStmt->sql.status != STMT_##S)
#define STMT_STATUS_EQ(S) (pStmt->sql.status == STMT_##S)
#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
TAOS_STMT
*
stmtInit
(
STscObj
*
taos
);
#define STMT_ERR_RET(c) \
do { \
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
return _code; \
} \
} while (0)
#define STMT_RET(c) \
do { \
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
} \
return _code; \
} while (0)
#define STMT_ERR_JRET(c) \
do { \
code = c; \
if (code != TSDB_CODE_SUCCESS) { \
terrno = code; \
goto _return; \
} \
} while (0)
TAOS_STMT
*
stmtInit
(
STscObj
*
taos
);
int
stmtClose
(
TAOS_STMT
*
stmt
);
int
stmtExec
(
TAOS_STMT
*
stmt
);
const
char
*
stmtErrstr
(
TAOS_STMT
*
stmt
);
...
...
@@ -116,8 +137,8 @@ int stmtAffectedRowsOnce(TAOS_STMT *stmt);
int
stmtPrepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
);
int
stmtSetTbName
(
TAOS_STMT
*
stmt
,
const
char
*
tbName
);
int
stmtSetTbTags
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
tags
);
int
stmtGetTagFields
(
TAOS_STMT
*
stmt
,
int
*
nums
,
TAOS_FIELD_E
**
fields
);
int
stmtGetColFields
(
TAOS_STMT
*
stmt
,
int
*
nums
,
TAOS_FIELD_E
**
fields
);
int
stmtGetTagFields
(
TAOS_STMT
*
stmt
,
int
*
nums
,
TAOS_FIELD_E
**
fields
);
int
stmtGetColFields
(
TAOS_STMT
*
stmt
,
int
*
nums
,
TAOS_FIELD_E
**
fields
);
int
stmtIsInsert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
int
stmtGetParamNum
(
TAOS_STMT
*
stmt
,
int
*
nums
);
int
stmtGetParam
(
TAOS_STMT
*
stmt
,
int
idx
,
int
*
type
,
int
*
bytes
);
...
...
@@ -125,7 +146,6 @@ int stmtAddBatch(TAOS_STMT *stmt);
TAOS_RES
*
stmtUseResult
(
TAOS_STMT
*
stmt
);
int
stmtBindBatch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int32_t
colIdx
);
#ifdef __cplusplus
}
#endif
...
...
source/client/src/clientStmt.c
浏览文件 @
3bda4cf3
...
...
@@ -402,7 +402,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
STMT_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
tscDebug
(
"reuse stmt block for tb %s in sqlBlock, suid:0x%"
PRIx64
,
pStmt
->
bInfo
.
tbFName
,
pStmt
->
bInfo
.
tbSuid
);
tscDebug
(
"reuse stmt block for tb %s in sqlBlock, suid:0x%"
PRIx64
,
pStmt
->
bInfo
.
tbFName
,
pStmt
->
bInfo
.
tbSuid
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -600,8 +600,9 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
}
tscDebug
(
"start to bind stmt tag values"
);
STMT_ERR_RET
(
qBindStmtTagsValue
(
*
pDataBlock
,
pStmt
->
bInfo
.
boundTags
,
pStmt
->
bInfo
.
tbSuid
,
pStmt
->
bInfo
.
stbFName
,
pStmt
->
bInfo
.
sname
.
tname
,
tags
,
pStmt
->
exec
.
pRequest
->
msgBuf
,
pStmt
->
exec
.
pRequest
->
msgBufLen
));
STMT_ERR_RET
(
qBindStmtTagsValue
(
*
pDataBlock
,
pStmt
->
bInfo
.
boundTags
,
pStmt
->
bInfo
.
tbSuid
,
pStmt
->
bInfo
.
stbFName
,
pStmt
->
bInfo
.
sname
.
tname
,
tags
,
pStmt
->
exec
.
pRequest
->
msgBuf
,
pStmt
->
exec
.
pRequest
->
msgBufLen
));
return
TSDB_CODE_SUCCESS
;
}
...
...
source/client/src/clientTmqConnector.c
浏览文件 @
3bda4cf3
...
...
@@ -212,7 +212,8 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync(JN
tmq_commit_async
(
tmq
,
res
,
commit_cb
,
consumer
);
}
JNIEXPORT
jint
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jtmq
)
{
JNIEXPORT
jint
JNICALL
Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
jtmq
)
{
tmq_t
*
tmq
=
(
tmq_t
*
)
jtmq
;
if
(
tmq
==
NULL
)
{
jniError
(
"jobj:%p, tmq is closed"
,
jobj
);
...
...
source/client/test/clientTests.cpp
浏览文件 @
3bda4cf3
...
...
@@ -13,12 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <gtest/gtest.h>
#include <iostream>
#include "clientInt.h"
#include "taoserror.h"
#include "tglobal.h"
#include "thash.h"
#include "clientInt.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
...
@@ -26,8 +26,8 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "taos.h"
#include "executor.h"
#include "taos.h"
namespace
{
void
showDB
(
TAOS
*
pConn
)
{
...
...
@@ -53,8 +53,8 @@ void printResult(TAOS_RES* pRes) {
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
*
length
=
taos_fetch_lengths
(
pRes
);
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
printf
(
"(%d):%d "
,
i
,
length
[
i
]);
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
printf
(
"(%d):%d "
,
i
,
length
[
i
]);
}
printf
(
"
\n
"
);
...
...
@@ -123,16 +123,16 @@ void createNewTable(TAOS* pConn, int32_t index) {
}
taos_free_result
(
pRes
);
for
(
int32_t
i
=
0
;
i
<
3280
;
i
+=
20
)
{
for
(
int32_t
i
=
0
;
i
<
3280
;
i
+=
20
)
{
char
sql
[
1024
]
=
{
0
};
sprintf
(
sql
,
"insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
,
index
,
i
,
i
,
i
+
1
,
i
+
1
,
i
+
2
,
i
+
2
,
i
+
3
,
i
+
3
,
i
+
4
,
i
+
4
,
i
+
5
,
i
+
5
,
i
+
6
,
i
+
6
,
i
+
7
,
i
+
7
,
i
+
8
,
i
+
8
,
i
+
9
,
i
+
9
,
i
+
10
,
i
+
10
,
i
+
11
,
i
+
11
,
i
+
12
,
i
+
12
,
i
+
13
,
i
+
13
,
i
+
14
,
i
+
14
,
i
+
15
,
i
+
15
,
i
+
16
,
i
+
16
,
i
+
17
,
i
+
17
,
i
+
18
,
i
+
18
,
i
+
19
,
i
+
19
);
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
,
i
ndex
,
i
,
i
,
i
+
1
,
i
+
1
,
i
+
2
,
i
+
2
,
i
+
3
,
i
+
3
,
i
+
4
,
i
+
4
,
i
+
5
,
i
+
5
,
i
+
6
,
i
+
6
,
i
+
7
,
i
+
7
,
i
+
8
,
i
+
8
,
i
+
9
,
i
+
9
,
i
+
10
,
i
+
10
,
i
+
11
,
i
+
11
,
i
+
12
,
i
+
12
,
i
+
13
,
i
+
13
,
i
+
14
,
i
+
1
4
,
i
+
1
5
,
i
+
15
,
i
+
16
,
i
+
16
,
i
+
17
,
i
+
17
,
i
+
18
,
i
+
18
,
i
+
19
,
i
+
19
);
TAOS_RES
*
p
=
taos_query
(
pConn
,
sql
);
if
(
taos_errno
(
p
)
!=
0
)
{
printf
(
"failed to insert data, reason:%s
\n
"
,
taos_errstr
(
p
));
...
...
@@ -150,7 +150,7 @@ int main(int argc, char** argv) {
TEST
(
testCase
,
driverInit_Test
)
{
// taosInitGlobalCfg();
// taos_init();
// taos_init();
}
TEST
(
testCase
,
connect_Test
)
{
...
...
@@ -670,11 +670,11 @@ TEST(testCase, projection_query_tables) {
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
// if (taos_errno(pRes) != 0) {
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
// if (taos_errno(pRes) != 0) {
// printf("error in create db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
taos_free_result
(
pRes
);
...
...
@@ -697,27 +697,27 @@ TEST(testCase, projection_query_tables) {
}
taos_free_result
(
pRes
);
for
(
int32_t
i
=
0
;
i
<
2
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
2
;
++
i
)
{
printf
(
"create table :%d
\n
"
,
i
);
createNewTable
(
pConn
,
i
);
}
//
// pRes = taos_query(pConn, "select * from tu");
// if (taos_errno(pRes) != 0) {
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// }
//
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// char str[512] = {0};
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// }
//
// pRes = taos_query(pConn, "select * from tu");
// if (taos_errno(pRes) != 0) {
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// }
//
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// char str[512] = {0};
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// }
taos_free_result
(
pRes
);
taos_close
(
pConn
);
...
...
@@ -860,5 +860,4 @@ TEST(testCase, update_test) {
#endif
#pragma GCC diagnostic pop
source/client/test/smlTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/catalog/inc/catalogInt.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/catalog/inc/ctgRemote.h
浏览文件 @
3bda4cf3
...
...
@@ -20,8 +20,6 @@
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
3bda4cf3
...
...
@@ -22,7 +22,8 @@
SCatalogMgmt
gCtgMgmt
=
{
0
};
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
SDBVgInfo
**
pInfo
)
{
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
SDBVgInfo
**
pInfo
)
{
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
dbCache
));
...
...
@@ -53,7 +54,7 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
int32_t
ctgRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
...
...
@@ -87,7 +88,8 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgRefreshTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMetaOutput
**
pOutput
,
bool
syncReq
)
{
int32_t
ctgRefreshTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMetaOutput
**
pOutput
,
bool
syncReq
)
{
SVgroupInfo
vgroupInfo
=
{
0
};
int32_t
code
=
0
;
...
...
@@ -105,7 +107,8 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx*
if
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
ctgDebug
(
"will refresh tbmeta, supposed in information_schema, tbName:%s"
,
tNameGetTableName
(
ctx
->
pName
));
CTG_ERR_JRET
(
ctgGetTbMetaFromMnodeImpl
(
pCtg
,
pConn
,
(
char
*
)
ctx
->
pName
->
dbname
,
(
char
*
)
ctx
->
pName
->
tname
,
output
,
NULL
));
CTG_ERR_JRET
(
ctgGetTbMetaFromMnodeImpl
(
pCtg
,
pConn
,
(
char
*
)
ctx
->
pName
->
dbname
,
(
char
*
)
ctx
->
pName
->
tname
,
output
,
NULL
));
}
else
if
(
CTG_FLAG_IS_STB
(
ctx
->
flag
))
{
ctgDebug
(
"will refresh tbmeta, supposed to be stb, tbName:%s"
,
tNameGetTableName
(
ctx
->
pName
));
...
...
@@ -182,9 +185,9 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgGetTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
ctgGetTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
0
;
STableMetaOutput
*
output
=
NULL
;
STableMetaOutput
*
output
=
NULL
;
CTG_ERR_RET
(
ctgGetTbMetaFromCache
(
pCtg
,
pConn
,
ctx
,
pTableMeta
));
if
(
*
pTableMeta
)
{
...
...
@@ -299,7 +302,8 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
int32_t
ctgChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
bool
inCache
=
false
;
int32_t
code
=
0
;
...
...
@@ -337,7 +341,7 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgGetTbType
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
int32_t
*
tbType
)
{
int32_t
ctgGetTbType
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
int32_t
*
tbType
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFName
);
CTG_ERR_RET
(
ctgReadTbTypeFromCache
(
pCtg
,
dbFName
,
pTableName
->
tname
,
tbType
));
...
...
@@ -357,13 +361,13 @@ int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName,
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgGetTbIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pRes
)
{
int32_t
ctgGetTbIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pRes
)
{
CTG_ERR_RET
(
ctgReadTbIndexFromCache
(
pCtg
,
pTableName
,
pRes
));
if
(
*
pRes
)
{
return
TSDB_CODE_SUCCESS
;
}
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
if
(
NULL
==
pIndex
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
...
...
@@ -395,7 +399,7 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgGetTbCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
ctgGetTbCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
tbType
=
0
;
CTG_ERR_RET
(
ctgGetTbType
(
pCtg
,
pConn
,
pTableName
,
&
tbType
));
...
...
@@ -410,13 +414,13 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName,
CTG_RET
(
TSDB_CODE_SUCCESS
);
}
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
STableMeta
*
tbMeta
=
NULL
;
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
STableMeta
*
tbMeta
=
NULL
;
int32_t
code
=
0
;
SVgroupInfo
vgroupInfo
=
{
0
};
SCtgDBCache
*
dbCache
=
NULL
;
SArray
*
vgList
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SArray
*
vgList
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SCtgTbMetaCtx
ctx
=
{
0
};
ctx
.
pName
=
pTableName
;
ctx
.
flag
=
CTG_FLAG_UNKNOWN_STB
;
...
...
@@ -428,7 +432,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
SHashObj
*
vgHash
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
if
(
dbCache
)
{
...
...
@@ -489,8 +493,7 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
if
(
IS_SYS_DBNAME
(
pTableName
->
dbname
))
{
ctgError
(
"no valid vgInfo for db, dbname:%s"
,
pTableName
->
dbname
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
...
@@ -501,7 +504,7 @@ int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vgCache
.
vgInfo
,
pTableName
,
pVgroup
));
...
...
@@ -539,7 +542,6 @@ _return:
CTG_RET
(
code
);
}
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
if
(
gCtgMgmt
.
pCluster
)
{
qError
(
"catalog already initialized"
);
...
...
@@ -648,7 +650,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
clusterCtg
->
userCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxUserCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
clusterCtg
->
userCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxUserCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
clusterCtg
->
userCache
)
{
qError
(
"taosHashInit %d user cache failed"
,
gCtgMgmt
.
cfg
.
maxUserCacheNum
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
...
...
@@ -714,7 +717,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
int32_t
catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
pConn
||
NULL
==
vgroupList
)
{
...
...
@@ -723,9 +726,9 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
SCtgDBCache
*
dbCache
=
NULL
;
int32_t
code
=
0
;
SArray
*
vgList
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SArray
*
vgList
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
));
if
(
dbCache
)
{
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
...
...
@@ -808,7 +811,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
)
{
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
)
{
CTG_API_ENTER
();
int32_t
code
=
0
;
...
...
@@ -831,7 +834,6 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
CTG_API_ENTER
();
...
...
@@ -860,7 +862,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
int32_t
catalogGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
...
...
@@ -870,7 +872,8 @@ int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
...
...
@@ -895,7 +898,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogChkTbMetaVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pTables
)
{
int32_t
catalogChkTbMetaVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pTables
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTables
)
{
...
...
@@ -944,7 +947,7 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo *pConn, SArray*
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
int32_t
catalogRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
int32_t
catalogRefreshDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
dbFName
)
{
...
...
@@ -954,7 +957,7 @@ int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const ch
CTG_API_LEAVE
(
ctgRefreshDBVgInfo
(
pCtg
,
pConn
,
dbFName
));
}
int32_t
catalogRefreshTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
int32_t
catalogRefreshTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
)
{
...
...
@@ -968,7 +971,8 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const S
CTG_API_LEAVE
(
ctgRefreshTbMeta
(
pCtg
,
pConn
,
&
ctx
,
NULL
,
true
));
}
int32_t
catalogRefreshGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
int32_t
catalogRefreshGetTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
...
...
@@ -978,7 +982,7 @@ int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, cons
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
int32_t
catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
int32_t
catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pVgList
)
{
...
...
@@ -993,13 +997,14 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const
CTG_API_LEAVE
(
ctgGetTbDistVgInfo
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pVgList
));
}
int32_t
catalogGetTableHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
catalogGetTableHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
pVgroup
));
}
int32_t
catalogGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
int32_t
catalogGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pReq
||
NULL
==
pRsp
)
{
...
...
@@ -1062,7 +1067,8 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogAsyncGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int64_t
*
jobId
)
{
int32_t
catalogAsyncGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int64_t
*
jobId
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pReq
||
NULL
==
fp
||
NULL
==
param
)
{
...
...
@@ -1070,7 +1076,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SC
}
int32_t
code
=
0
;
SCtgJob
*
pJob
=
NULL
;
SCtgJob
*
pJob
=
NULL
;
CTG_ERR_JRET
(
ctgInitJob
(
pCtg
,
pConn
,
&
pJob
,
pReq
,
fp
,
param
));
CTG_ERR_JRET
(
ctgLaunchJob
(
pJob
));
...
...
@@ -1091,7 +1097,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetQnodeList
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
)
{
int32_t
catalogGetQnodeList
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
)
{
CTG_API_ENTER
();
int32_t
code
=
0
;
...
...
@@ -1121,14 +1127,14 @@ _return:
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTableVersion
**
stables
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTableVersion
**
stables
,
uint32_t
*
num
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
stables
||
NULL
==
num
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableVersion
)));
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableVersion
)));
}
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
...
...
@@ -1179,7 +1185,7 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
int32_t
catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
int32_t
catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
dbFName
||
NULL
==
pDbCfg
)
{
...
...
@@ -1189,7 +1195,7 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbF
CTG_API_LEAVE
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
dbFName
,
pDbCfg
,
NULL
));
}
int32_t
catalogGetIndexMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
)
{
int32_t
catalogGetIndexMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
indexName
||
NULL
==
pInfo
)
{
...
...
@@ -1199,7 +1205,7 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
CTG_API_LEAVE
(
ctgGetIndexInfoFromMnode
(
pCtg
,
pConn
,
indexName
,
pInfo
,
NULL
));
}
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
)
{
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pRes
)
{
...
...
@@ -1214,7 +1220,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pCfg
)
{
...
...
@@ -1231,7 +1237,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
funcName
||
NULL
==
pInfo
)
{
...
...
@@ -1246,7 +1252,8 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
user
||
NULL
==
dbFName
||
NULL
==
pass
)
{
...
...
@@ -1261,7 +1268,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetServerVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
**
pVersion
)
{
int32_t
catalogGetServerVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
**
pVersion
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pVersion
)
{
...
...
@@ -1276,7 +1283,6 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogUpdateUserAuthInfo
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
)
{
CTG_API_ENTER
();
...
...
@@ -1303,7 +1309,6 @@ int32_t catalogClearCache(void) {
CTG_API_LEAVE_NOLOCK
(
code
);
}
void
catalogDestroy
(
void
)
{
qInfo
(
"start to destroy catalog"
);
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
3bda4cf3
...
...
@@ -636,7 +636,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
qDebug
(
"QID:0x%"
PRIx64
", jobId: 0x%"
PRIx64
" initialized, task num %d, forceUpdate %d, elapsed time:%.2f ms"
,
pJob
->
queryId
,
pJob
->
refId
,
taskNum
,
pReq
->
forceUpdate
,
el
);
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
3bda4cf3
...
...
@@ -13,16 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "
trpc
.h"
#include "
catalogInt
.h"
#include "query.h"
#include "tname.h"
#include "
catalogInt
.h"
#include "
trpc
.h"
extern
SCatalogMgmt
gCtgMgmt
;
SCtgDebug
gCTGDebug
=
{
0
};
void
ctgdUserCallback
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
ASSERT
(
*
(
int32_t
*
)
param
==
1
);
void
ctgdUserCallback
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
ASSERT
(
*
(
int32_t
*
)
param
==
1
);
taosMemoryFree
(
param
);
qDebug
(
"async call result: %s"
,
tstrerror
(
code
));
...
...
@@ -40,10 +40,13 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
STableComInfo
*
c
=
&
p
->
tableInfo
;
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
}
else
{
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
qDebug
(
"table meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
...
...
@@ -59,11 +62,11 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pDbVgroup
&&
taosArrayGetSize
(
pResult
->
pDbVgroup
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pDbVgroup
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SArray
*
pDb
=
*
(
SArray
**
)
taosArrayGet
(
pResult
->
pDbVgroup
,
i
);
SArray
*
pDb
=
*
(
SArray
**
)
taosArrayGet
(
pResult
->
pDbVgroup
,
i
);
int32_t
vgNum
=
taosArrayGetSize
(
pDb
);
qDebug
(
"db %d vgInfo:"
,
i
);
for
(
int32_t
j
=
0
;
j
<
vgNum
;
++
j
)
{
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pDb
,
j
);
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pDb
,
j
);
qDebug
(
"vg :%d info: vgId:%d"
,
j
,
pInfo
->
vgId
);
}
}
...
...
@@ -84,7 +87,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pTableHash
&&
taosArrayGetSize
(
pResult
->
pTableHash
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pTableHash
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pTableHash
,
i
);
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pTableHash
,
i
);
qDebug
(
"table %d vg info: vgId:%d"
,
i
,
pInfo
->
vgId
);
}
}
else
{
...
...
@@ -94,7 +97,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pUdfList
&&
taosArrayGetSize
(
pResult
->
pUdfList
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pUdfList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SFuncInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pUdfList
,
i
);
SFuncInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pUdfList
,
i
);
qDebug
(
"udf %d info: name:%s, funcType:%d"
,
i
,
pInfo
->
name
,
pInfo
->
funcType
);
}
}
else
{
...
...
@@ -104,7 +107,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pDbCfg
&&
taosArrayGetSize
(
pResult
->
pDbCfg
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pDbCfg
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SDbCfgInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pDbCfg
,
i
);
SDbCfgInfo
*
pInfo
=
taosArrayGet
(
pResult
->
pDbCfg
,
i
);
qDebug
(
"db %d info: numOFVgroups:%d, numOfStables:%d"
,
i
,
pInfo
->
numOfVgroups
,
pInfo
->
numOfStables
);
}
}
else
{
...
...
@@ -114,7 +117,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pUser
&&
taosArrayGetSize
(
pResult
->
pUser
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pUser
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
bool
*
auth
=
taosArrayGet
(
pResult
->
pUser
,
i
);
bool
*
auth
=
taosArrayGet
(
pResult
->
pUser
,
i
);
qDebug
(
"user auth %d info: %d"
,
i
,
*
auth
);
}
}
else
{
...
...
@@ -124,7 +127,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
if
(
pResult
->
pQnodeList
&&
taosArrayGetSize
(
pResult
->
pQnodeList
)
>
0
)
{
num
=
taosArrayGetSize
(
pResult
->
pQnodeList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SQueryNodeAddr
*
qaddr
=
taosArrayGet
(
pResult
->
pQnodeList
,
i
);
SQueryNodeAddr
*
qaddr
=
taosArrayGet
(
pResult
->
pQnodeList
,
i
);
qDebug
(
"qnode %d info: id:%d"
,
i
,
qaddr
->
nodeId
);
}
}
else
{
...
...
@@ -132,7 +135,6 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
}
}
/*
prepare SQL:
create database db1;
...
...
@@ -147,7 +149,7 @@ grant write on db2.* to user1;
create function udf1 as '/tmp/libudf1.so' outputtype int;
create aggregate function udf2 as '/tmp/libudf2.so' outputtype int;
*/
int32_t
ctgdLaunchAsyncCall
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
uint64_t
reqId
,
bool
forceUpdate
)
{
int32_t
ctgdLaunchAsyncCall
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
uint64_t
reqId
,
bool
forceUpdate
)
{
int32_t
code
=
0
;
SCatalogReq
req
=
{
0
};
req
.
pTableMeta
=
taosArrayInit
(
2
,
sizeof
(
SName
));
...
...
@@ -156,7 +158,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re
req
.
pTableHash
=
taosArrayInit
(
2
,
sizeof
(
SName
));
req
.
pUdf
=
taosArrayInit
(
2
,
TSDB_FUNC_NAME_LEN
);
req
.
pDbCfg
=
taosArrayInit
(
2
,
TSDB_DB_FNAME_LEN
);
req
.
pIndex
=
NULL
;
//
taosArrayInit(2, TSDB_INDEX_FNAME_LEN);
req
.
pIndex
=
NULL
;
//
taosArrayInit(2, TSDB_INDEX_FNAME_LEN);
req
.
pUser
=
taosArrayInit
(
2
,
sizeof
(
SUserAuthInfo
));
req
.
qNodeRequired
=
true
;
req
.
forceUpdate
=
forceUpdate
;
...
...
@@ -287,7 +289,7 @@ int32_t ctgdGetRentNum(SCtgRentMgmt *rent) {
return
num
;
}
int32_t
ctgdGetClusterCacheNum
(
SCatalog
*
pCtg
,
int32_t
type
)
{
int32_t
ctgdGetClusterCacheNum
(
SCatalog
*
pCtg
,
int32_t
type
)
{
if
(
NULL
==
pCtg
||
NULL
==
pCtg
->
dbCache
)
{
return
0
;
}
...
...
@@ -325,7 +327,7 @@ int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) {
return
num
;
}
void
ctgdShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
)
{
void
ctgdShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
)
{
if
(
!
gCTGDebug
.
metaEnable
)
{
return
;
}
...
...
@@ -333,11 +335,14 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
STableComInfo
*
c
=
&
p
->
tableInfo
;
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
return
;
}
else
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:0x%"
PRIx64
",suid:0x%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
...
...
@@ -347,7 +352,7 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
}
}
void
ctgdShowDBCache
(
SCatalog
*
pCtg
,
SHashObj
*
dbHash
)
{
void
ctgdShowDBCache
(
SCatalog
*
pCtg
,
SHashObj
*
dbHash
)
{
if
(
NULL
==
dbHash
||
!
gCTGDebug
.
cacheEnable
)
{
return
;
}
...
...
@@ -381,28 +386,28 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
}
}
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
hashPrefix
,
hashSuffix
,
vgNum
);
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
hashPrefix
,
hashSuffix
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
}
void
ctgdShowClusterCache
(
SCatalog
*
pCtg
)
{
void
ctgdShowClusterCache
(
SCatalog
*
pCtg
)
{
if
(
!
gCTGDebug
.
cacheEnable
||
NULL
==
pCtg
)
{
return
;
}
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info BEGIN ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info BEGIN ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgdShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info END ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"## cluster 0x%"
PRIx64
" %p cache Info END ##"
,
pCtg
->
clusterId
,
pCtg
);
}
int32_t
ctgdShowCacheInfo
(
void
)
{
...
...
@@ -428,4 +433,3 @@ int32_t ctgdShowCacheInfo(void) {
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
source/libs/catalog/src/ctgUtil.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
3bda4cf3
...
...
@@ -27,20 +27,20 @@
#ifdef WINDOWS
#define TD_USE_WINSOCK
#endif
#include "os.h"
#include "tglobal.h"
#include "catalog.h"
#include "catalogInt.h"
#include "os.h"
#include "stub.h"
#include "taos.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tglobal.h"
#include "trpc.h"
#include "tvariant.h"
namespace
{
extern
"C"
int32_t
ctgdGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgdGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgdEnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctgdGetStatNum
(
char
*
option
,
void
*
res
);
...
...
@@ -49,7 +49,7 @@ void ctgTestSetRspCTableMeta();
void
ctgTestSetRspSTableMeta
();
void
ctgTestSetRspMultiSTableMeta
();
//extern "C" SCatalogMgmt gCtgMgmt;
//
extern "C" SCatalogMgmt gCtgMgmt;
enum
{
CTGT_RSP_VGINFO
=
1
,
...
...
@@ -153,11 +153,11 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) {
}
void
ctgTestBuildCTableMetaOutput
(
STableMetaOutput
*
output
)
{
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
SName
sn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
sn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
sn
.
dbname
,
"db1"
);
strcpy
(
sn
.
tname
,
ctgTestSTablename
);
...
...
@@ -175,7 +175,8 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
output
->
ctbMeta
.
uid
=
3
;
output
->
ctbMeta
.
suid
=
2
;
output
->
tbMeta
=
(
STableMeta
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STableMeta
)
+
sizeof
(
SSchema
)
*
(
ctgTestColNum
+
ctgTestColNum
));
output
->
tbMeta
=
(
STableMeta
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STableMeta
)
+
sizeof
(
SSchema
)
*
(
ctgTestColNum
+
ctgTestColNum
));
output
->
tbMeta
->
vgId
=
9
;
output
->
tbMeta
->
tableType
=
TSDB_SUPER_TABLE
;
output
->
tbMeta
->
uid
=
2
;
...
...
@@ -364,7 +365,6 @@ void ctgTestRspTableMetaNotExist(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, S
pRsp
->
code
=
CTG_ERR_CODE_TABLE_NOT_EXIST
;
}
void
ctgTestRspCTableMeta
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
STableMetaRsp
metaRsp
=
{
0
};
strcpy
(
metaRsp
.
dbFName
,
ctgTestDbname
);
...
...
@@ -574,7 +574,7 @@ void ctgTestSetRspDbVgroups() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -594,7 +594,7 @@ void ctgTestSetRspTableMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -614,7 +614,7 @@ void ctgTestSetRspCTableMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -634,7 +634,7 @@ void ctgTestSetRspSTableMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -654,7 +654,7 @@ void ctgTestSetRspMultiSTableMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -674,7 +674,7 @@ void ctgTestSetRspByIdx() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -688,14 +688,13 @@ void ctgTestSetRspByIdx() {
}
}
void
ctgTestSetRspDbVgroupsAndNormalMeta
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendRecv
,
ctgTestRspDbVgroupsAndNormalMeta
);
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -715,7 +714,7 @@ void ctgTestSetRspDbVgroupsAndChildMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -735,7 +734,7 @@ void ctgTestSetRspDbVgroupsAndSuperMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -755,7 +754,7 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() {
{
#ifdef WINDOWS
AddrAny
any
;
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_func_addr
(
"rpcSendRecv"
,
result
);
#endif
#ifdef LINUX
...
...
@@ -854,7 +853,7 @@ void *ctgTestGetCtableMetaThread(void *param) {
STableMeta
*
tbMeta
=
NULL
;
bool
inCache
=
false
;
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
cn
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
...
...
@@ -920,7 +919,6 @@ void *ctgTestSetCtableMetaThread(void *param) {
#if 1
TEST
(
tableMeta
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
...
@@ -940,7 +938,7 @@ TEST(tableMeta, normalTable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -977,7 +975,6 @@ TEST(tableMeta, normalTable) {
}
}
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1047,7 +1044,7 @@ TEST(tableMeta, childTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
...
...
@@ -1072,7 +1069,6 @@ TEST(tableMeta, childTableCase) {
}
}
tableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1154,7 +1150,7 @@ TEST(tableMeta, superTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
...
@@ -1181,7 +1177,6 @@ TEST(tableMeta, superTableCase) {
}
}
ctgTestSetRspCTableMeta
();
tableMeta
=
NULL
;
...
...
@@ -1208,7 +1203,6 @@ TEST(tableMeta, superTableCase) {
}
}
tableMeta
=
NULL
;
code
=
catalogRefreshGetTableMeta
(
pCtg
,
mockPointer
,
&
n
,
&
tableMeta
,
0
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1279,7 +1273,7 @@ TEST(tableMeta, rmStbMeta) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
...
@@ -1306,7 +1300,6 @@ TEST(tableMeta, rmStbMeta) {
}
}
code
=
catalogRemoveStbMeta
(
pCtg
,
"1.db1"
,
ctgTestDbId
,
ctgTestSTablename
,
ctgTestSuid
-
1
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1320,7 +1313,6 @@ TEST(tableMeta, rmStbMeta) {
}
}
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
0
);
ASSERT_EQ
(
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
0
);
...
...
@@ -1349,7 +1341,7 @@ TEST(tableMeta, updateStbMeta) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
...
@@ -1376,7 +1368,6 @@ TEST(tableMeta, updateStbMeta) {
}
}
taosMemoryFreeClear
(
tableMeta
);
STableMetaRsp
rsp
=
{
0
};
...
...
@@ -1447,7 +1438,7 @@ TEST(refreshGetMeta, normal2normal) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -1526,7 +1517,7 @@ TEST(refreshGetMeta, normal2notexist) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -1570,7 +1561,6 @@ TEST(refreshGetMeta, normal2notexist) {
memset
(
&
gCtgMgmt
,
0
,
sizeof
(
gCtgMgmt
));
}
TEST
(
refreshGetMeta
,
normal2child
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
...
@@ -1598,7 +1588,7 @@ TEST(refreshGetMeta, normal2child) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentCTableName
=
ctgTestTablename
;
...
...
@@ -1682,7 +1672,7 @@ TEST(refreshGetMeta, stable2child) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentSTableName
=
ctgTestTablename
;
...
...
@@ -1768,7 +1758,7 @@ TEST(refreshGetMeta, stable2stable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentSTableName
=
ctgTestTablename
;
...
...
@@ -1826,7 +1816,6 @@ TEST(refreshGetMeta, stable2stable) {
ctgTestCurrentSTableName
=
NULL
;
}
TEST
(
refreshGetMeta
,
child2stable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
...
@@ -1855,7 +1844,7 @@ TEST(refreshGetMeta, child2stable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
ctgTestCurrentCTableName
=
ctgTestTablename
;
...
...
@@ -1913,7 +1902,6 @@ TEST(refreshGetMeta, child2stable) {
ctgTestCurrentSTableName
=
NULL
;
}
TEST
(
tableDistVgroup
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
0x1
;
...
...
@@ -1940,7 +1928,7 @@ TEST(tableDistVgroup, normalTable) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -1982,7 +1970,7 @@ TEST(tableDistVgroup, childTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestCTablename
);
...
...
@@ -2014,8 +2002,6 @@ TEST(tableDistVgroup, superTableCase) {
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
int32_t
code
=
catalogInit
(
NULL
);
...
...
@@ -2025,7 +2011,7 @@ TEST(tableDistVgroup, superTableCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestSTablename
);
...
...
@@ -2061,10 +2047,8 @@ TEST(dbVgroup, getSetDbVgroupCase) {
ctgTestRspFunc
[
0
]
=
CTGT_RSP_VGINFO
;
ctgTestRspFunc
[
1
]
=
CTGT_RSP_TBMETA
;
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
// sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet);
...
...
@@ -2075,7 +2059,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -2119,7 +2103,6 @@ TEST(dbVgroup, getSetDbVgroupCase) {
}
}
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
&
n
,
&
vgInfo
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
vgInfo
.
vgId
,
7
);
...
...
@@ -2160,7 +2143,7 @@ TEST(multiThread, getSetRmSameDbVgroup) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -2212,7 +2195,7 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -2264,7 +2247,7 @@ TEST(multiThread, ctableMeta) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
...
...
@@ -2316,7 +2299,7 @@ TEST(rentTest, allRent) {
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}
};
strcpy
(
n
.
dbname
,
"db1"
);
for
(
int32_t
i
=
1
;
i
<=
10
;
++
i
)
{
...
...
source/libs/command/test/commandTest.cpp
浏览文件 @
3bda4cf3
source/libs/executor/inc/dataSinkInt.h
浏览文件 @
3bda4cf3
...
...
@@ -20,9 +20,9 @@
extern
"C"
{
#endif
#include "tcommon.h"
#include "dataSinkMgt.h"
#include "plannodes.h"
#include "tcommon.h"
struct
SDataSink
;
struct
SDataSinkHandle
;
...
...
@@ -49,8 +49,10 @@ typedef struct SDataSinkHandle {
}
SDataSinkHandle
;
int32_t
createDataDispatcher
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
);
int32_t
createDataDeleter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
int32_t
createDataDeleter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
);
#ifdef __cplusplus
}
...
...
source/libs/executor/inc/executorInt.h
浏览文件 @
3bda4cf3
source/libs/executor/inc/tlinearhash.h
浏览文件 @
3bda4cf3
...
...
@@ -32,9 +32,9 @@ typedef struct SLHashObj SLHashObj;
SLHashObj
*
tHashInit
(
int32_t
inMemPages
,
int32_t
pageSize
,
_hash_fn_t
fn
,
int32_t
numOfTuplePerPage
);
void
*
tHashCleanup
(
SLHashObj
*
pHashObj
);
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
);
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
);
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
void
tHashPrint
(
const
SLHashObj
*
pHashObj
,
int32_t
type
);
...
...
source/libs/executor/inc/tsimplehash.h
浏览文件 @
3bda4cf3
...
...
@@ -112,7 +112,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj);
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
);
#pragma pack(push, 4)
typedef
struct
SHNode
{
typedef
struct
SHNode
{
struct
SHNode
*
next
;
uint32_t
keyLen
:
20
;
uint32_t
dataLen
:
12
;
...
...
source/libs/executor/inc/tsort.h
浏览文件 @
3bda4cf3
...
...
@@ -20,8 +20,8 @@
extern
"C"
{
#endif
#include "tcommon.h"
#include "os.h"
#include "tcommon.h"
enum
{
SORT_MULTISOURCE_MERGE
=
0x1
,
...
...
@@ -31,25 +31,25 @@ enum {
typedef
struct
SMultiMergeSource
{
int32_t
type
;
int32_t
rowIndex
;
SSDataBlock
*
pBlock
;
SSDataBlock
*
pBlock
;
}
SMultiMergeSource
;
typedef
struct
SSortSource
{
SMultiMergeSource
src
;
union
{
struct
{
union
{
struct
{
SArray
*
pageIdList
;
int32_t
pageIndex
;
};
void
*
param
;
void
*
param
;
};
}
SSortSource
;
typedef
struct
SMsortComparParam
{
void
**
pSources
;
void
**
pSources
;
int32_t
numOfSources
;
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
bool
cmpGroupId
;
}
SMsortComparParam
;
...
...
@@ -64,7 +64,8 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void*
* @param type
* @return
*/
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pOrderInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
);
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pOrderInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
);
/**
*
...
...
@@ -90,7 +91,8 @@ int32_t tsortClose(SSortHandle* pHandle);
*
* @return
*/
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
);
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
);
/**
*
...
...
source/libs/executor/src/cachescanoperator.c
浏览文件 @
3bda4cf3
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "function.h"
#include "os.h"
#include "tname.h"
#include "tdatablock.h"
...
...
@@ -43,8 +43,8 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pInfo
->
pRes
=
createResDataBlock
(
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
);
int32_t
numOfCols
=
0
;
pInfo
->
pColMatchInfo
=
extractColMatchInfo
(
pScanNode
->
scan
.
pScanCols
,
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
,
&
numOfCols
,
COL_MATCH_FROM_COL_ID
);
pInfo
->
pColMatchInfo
=
extractColMatchInfo
(
pScanNode
->
scan
.
pScanCols
,
pScanNode
->
scan
.
node
.
pOutputDataBlockDesc
,
&
numOfCols
,
COL_MATCH_FROM_COL_ID
);
code
=
extractTargetSlotId
(
pInfo
->
pColMatchInfo
,
pTaskInfo
,
&
pInfo
->
pSlotIds
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
...
...
@@ -58,7 +58,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
// partition by tbname
if
(
taosArrayGetSize
(
pTableList
->
pGroupList
)
==
taosArrayGetSize
(
pTableList
->
pTableList
))
{
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_ALL
|
CACHESCAN_RETRIEVE_LAST_ROW
;
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_ALL
|
CACHESCAN_RETRIEVE_LAST_ROW
;
code
=
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pTableList
->
pTableList
,
taosArrayGetSize
(
pInfo
->
pColMatchInfo
),
&
pInfo
->
pLastrowReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -68,14 +68,15 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pInfo
->
pBufferredRes
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
blockDataEnsureCapacity
(
pInfo
->
pBufferredRes
,
pOperator
->
resultInfo
.
capacity
);
}
else
{
// by tags
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_SINGLE
|
CACHESCAN_RETRIEVE_LAST_ROW
;
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_SINGLE
|
CACHESCAN_RETRIEVE_LAST_ROW
;
}
if
(
pScanNode
->
scan
.
pScanPseudoCols
!=
NULL
)
{
SExprSupp
*
pPseudoExpr
=
&
pInfo
->
pseudoExprSup
;
pPseudoExpr
->
pExprInfo
=
createExprInfo
(
pScanNode
->
scan
.
pScanPseudoCols
,
NULL
,
&
pPseudoExpr
->
numOfExprs
);
pPseudoExpr
->
pCtx
=
createSqlFunctionCtx
(
pPseudoExpr
->
pExprInfo
,
pPseudoExpr
->
numOfExprs
,
&
pPseudoExpr
->
rowEntryInfoOffset
);
pPseudoExpr
->
pCtx
=
createSqlFunctionCtx
(
pPseudoExpr
->
pExprInfo
,
pPseudoExpr
->
numOfExprs
,
&
pPseudoExpr
->
rowEntryInfoOffset
);
}
pOperator
->
name
=
"LastrowScanOperator"
;
...
...
@@ -92,7 +93,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pOperator
->
cost
.
openCost
=
0
;
return
pOperator
;
_error:
_error:
pTaskInfo
->
code
=
code
;
destroyLastrowScanOperator
(
pInfo
);
taosMemoryFree
(
pOperator
);
...
...
@@ -121,7 +122,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
blockDataCleanup
(
pInfo
->
pBufferredRes
);
taosArrayClear
(
pInfo
->
pUidList
);
int32_t
code
=
tsdbRetrieveCacheRows
(
pInfo
->
pLastrowReader
,
pInfo
->
pBufferredRes
,
pInfo
->
pSlotIds
,
pInfo
->
pUidList
);
int32_t
code
=
tsdbRetrieveCacheRows
(
pInfo
->
pLastrowReader
,
pInfo
->
pBufferredRes
,
pInfo
->
pSlotIds
,
pInfo
->
pUidList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
...
...
@@ -133,7 +135,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
}
if
(
pInfo
->
indexOfBufferedRes
<
pInfo
->
pBufferredRes
->
info
.
rows
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
++
i
)
{
SColMatchInfo
*
pMatchInfo
=
taosArrayGet
(
pInfo
->
pColMatchInfo
,
i
);
int32_t
slotId
=
pMatchInfo
->
targetSlotId
;
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
3bda4cf3
...
...
@@ -93,8 +93,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
blockEncode
(
pInput
->
pData
,
pEntry
->
data
,
&
pEntry
->
dataLen
,
numOfCols
,
pEntry
->
compressed
);
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
pBuf
->
useSize
+=
pEntry
->
dataLen
;
...
...
@@ -103,14 +103,14 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
}
static
bool
allocBuf
(
SDataDispatchHandle
*
pDispatcher
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
/*
/*
uint32_t capacity = pDispatcher->pManager->cfg.maxDataBlockNumPerQuery;
if (taosQueueItemSize(pDispatcher->pDataBlocks) > capacity) {
qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity,
taosQueueItemSize(pDispatcher->pDataBlocks));
return false;
}
*/
*/
pBuf
->
allocSize
=
sizeof
(
SDataCacheEntry
)
+
blockGetEncodeSize
(
pInput
->
pData
);
...
...
@@ -176,11 +176,12 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pDispatcher
->
nextOutput
.
pData
;
*
pLen
=
pEntry
->
dataLen
;
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
*
pQueryEnd
=
pDispatcher
->
queryEnd
;
qDebug
(
"got data len %"
PRId64
", row num %d in sink"
,
*
pLen
,
((
SDataCacheEntry
*
)(
pDispatcher
->
nextOutput
.
pData
))
->
numOfRows
);
qDebug
(
"got data len %"
PRId64
", row num %d in sink"
,
*
pLen
,
((
SDataCacheEntry
*
)(
pDispatcher
->
nextOutput
.
pData
))
->
numOfRows
);
}
static
int32_t
getDataBlock
(
SDataSinkHandle
*
pHandle
,
SOutputData
*
pOutput
)
{
...
...
@@ -199,8 +200,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
compressed
=
pEntry
->
compressed
;
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
...
...
source/libs/executor/src/dataInserter.c
浏览文件 @
3bda4cf3
...
...
@@ -27,7 +27,7 @@ extern SDataSinkStat gDataSinkStat;
typedef
struct
SSubmitRes
{
int64_t
affectedRows
;
int32_t
code
;
SSubmitRsp
*
pRsp
;
SSubmitRsp
*
pRsp
;
}
SSubmitRes
;
typedef
struct
SDataInserterHandle
{
...
...
@@ -70,7 +70,7 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
if
(
pInserter
->
submitRes
.
pRsp
->
nBlocks
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
pInserter
->
submitRes
.
pRsp
->
nBlocks
;
++
i
)
{
SSubmitBlkRsp
*
blk
=
pInserter
->
submitRes
.
pRsp
->
pBlocks
+
i
;
SSubmitBlkRsp
*
blk
=
pInserter
->
submitRes
.
pRsp
->
pBlocks
+
i
;
if
(
TSDB_CODE_SUCCESS
!=
blk
->
code
)
{
code
=
blk
->
code
;
tFreeSSubmitRsp
(
pInserter
->
submitRes
.
pRsp
);
...
...
@@ -81,7 +81,8 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) {
}
pInserter
->
submitRes
.
affectedRows
+=
pInserter
->
submitRes
.
pRsp
->
affectedRows
;
qDebug
(
"submit rsp received, affectedRows:%d, total:%d"
,
pInserter
->
submitRes
.
pRsp
->
affectedRows
,
pInserter
->
submitRes
.
affectedRows
);
qDebug
(
"submit rsp received, affectedRows:%d, total:%d"
,
pInserter
->
submitRes
.
pRsp
->
affectedRows
,
pInserter
->
submitRes
.
affectedRows
);
tFreeSSubmitRsp
(
pInserter
->
submitRes
.
pRsp
);
}
...
...
@@ -95,7 +96,6 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sendSubmitRequest
(
SDataInserterHandle
*
pInserter
,
SSubmitReq
*
pMsg
,
void
*
pTransporter
,
SEpSet
*
pEpset
)
{
// send the fetch remote task result reques
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
...
...
@@ -119,7 +119,6 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
return
asyncSendMsgToServer
(
pTransporter
,
pEpset
,
&
transporterId
,
pMsgSendInfo
);
}
int32_t
dataBlockToSubmit
(
SDataInserterHandle
*
pInserter
,
SSubmitReq
**
pReq
)
{
const
SArray
*
pBlocks
=
pInserter
->
pDataBlocks
;
const
STSchema
*
pTSchema
=
pInserter
->
pSchema
;
...
...
@@ -178,7 +177,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
SColumnInfoData
*
pColData
=
NULL
;
int16_t
colIdx
=
k
;
if
(
!
fullCol
)
{
int16_t
*
slotId
=
taosHashGet
(
pInserter
->
pCols
,
&
pColumn
->
colId
,
sizeof
(
pColumn
->
colId
));
int16_t
*
slotId
=
taosHashGet
(
pInserter
->
pCols
,
&
pColumn
->
colId
,
sizeof
(
pColumn
->
colId
));
if
(
NULL
==
slotId
)
{
continue
;
}
...
...
@@ -213,7 +212,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
pColumn
->
offset
,
k
);
}
}
if
(
!
fullCol
)
{
if
(
!
fullCol
)
{
rb
.
hasNone
=
true
;
}
tdSRowEnd
(
&
rb
);
...
...
@@ -242,7 +241,6 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
putDataBlock
(
SDataSinkHandle
*
pHandle
,
const
SInputData
*
pInput
,
bool
*
pContinue
)
{
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
taosArrayPush
(
pInserter
->
pDataBlocks
,
&
pInput
->
pData
);
...
...
@@ -279,10 +277,9 @@ static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) {
static
void
getDataLength
(
SDataSinkHandle
*
pHandle
,
int64_t
*
pLen
,
bool
*
pQueryEnd
)
{
SDataInserterHandle
*
pDispatcher
=
(
SDataInserterHandle
*
)
pHandle
;
*
pLen
=
pDispatcher
->
submitRes
.
affectedRows
;
qDebug
(
"got total affectedRows %"
PRId64
,
*
pLen
);
qDebug
(
"got total affectedRows %"
PRId64
,
*
pLen
);
}
static
int32_t
destroyDataSinker
(
SDataSinkHandle
*
pHandle
)
{
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pInserter
->
cachedSize
);
...
...
@@ -301,14 +298,15 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
int32_t
createDataInserter
(
SDataSinkManager
*
pManager
,
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
SDataInserterHandle
*
inserter
=
taosMemoryCalloc
(
1
,
sizeof
(
SDataInserterHandle
));
if
(
NULL
==
inserter
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
SQueryInserterNode
*
pInserterNode
=
(
SQueryInserterNode
*
)
pDataSink
;
SQueryInserterNode
*
pInserterNode
=
(
SQueryInserterNode
*
)
pDataSink
;
inserter
->
sink
.
fPut
=
putDataBlock
;
inserter
->
sink
.
fEndPut
=
endPut
;
inserter
->
sink
.
fGetLen
=
getDataLength
;
...
...
@@ -322,7 +320,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
inserter
->
queryEnd
=
false
;
int64_t
suid
=
0
;
int32_t
code
=
tsdbGetTableSchema
(
inserter
->
pParam
->
readHandle
->
vnode
,
pInserterNode
->
tableId
,
&
inserter
->
pSchema
,
&
suid
);
int32_t
code
=
tsdbGetTableSchema
(
inserter
->
pParam
->
readHandle
->
vnode
,
pInserterNode
->
tableId
,
&
inserter
->
pSchema
,
&
suid
);
if
(
code
)
{
return
code
;
}
...
...
@@ -339,7 +338,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
inserter
->
pCols
=
taosHashInit
(
pInserterNode
->
pCols
->
length
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
inserter
->
pCols
=
taosHashInit
(
pInserterNode
->
pCols
->
length
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_SMALLINT
),
false
,
HASH_NO_LOCK
);
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pInserterNode
->
pCols
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
...
...
source/libs/executor/src/dataSinkMgt.c
浏览文件 @
3bda4cf3
...
...
@@ -13,28 +13,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tarray.h"
#include "dataSinkMgt.h"
#include "dataSinkInt.h"
#include "planner.h"
#include "tarray.h"
static
SDataSinkManager
gDataSinkManager
=
{
0
};
SDataSinkStat
gDataSinkStat
=
{
0
};
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
)
{
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
)
{
gDataSinkManager
.
cfg
=
*
cfg
;
taosThreadMutexInit
(
&
gDataSinkManager
.
mutex
,
NULL
);
return
0
;
// to avoid compiler eror
}
int32_t
dsDataSinkGetCacheSize
(
SDataSinkStat
*
pStat
)
{
int32_t
dsDataSinkGetCacheSize
(
SDataSinkStat
*
pStat
)
{
pStat
->
cachedSize
=
atomic_load_64
(
&
gDataSinkStat
.
cachedSize
);
return
0
;
}
int32_t
dsCreateDataSinker
(
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
int32_t
dsCreateDataSinker
(
const
SDataSinkNode
*
pDataSink
,
DataSinkHandle
*
pHandle
,
void
*
pParam
)
{
switch
((
int
)
nodeType
(
pDataSink
))
{
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
createDataDispatcher
(
&
gDataSinkManager
,
pDataSink
,
pHandle
);
...
...
@@ -66,12 +65,11 @@ int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) {
return
pHandleImpl
->
fGetData
(
pHandleImpl
,
pOutput
);
}
int32_t
dsGetCacheSize
(
DataSinkHandle
handle
,
uint64_t
*
pSize
)
{
int32_t
dsGetCacheSize
(
DataSinkHandle
handle
,
uint64_t
*
pSize
)
{
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
return
pHandleImpl
->
fGetCacheSize
(
pHandleImpl
,
pSize
);
}
void
dsScheduleProcess
(
void
*
ahandle
,
void
*
pItem
)
{
// todo
}
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
3bda4cf3
...
...
@@ -267,13 +267,14 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t
size_t
rightNumJoin
=
taosArrayGetSize
(
rightRowLocations
);
code
=
blockDataEnsureCapacity
(
pRes
,
*
nRows
+
leftNumJoin
*
rightNumJoin
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s can not ensure block capacity for join. left: %zu, right: %zu"
,
GET_TASKID
(
pOperator
->
pTaskInfo
),
leftNumJoin
,
rightNumJoin
);
qError
(
"%s can not ensure block capacity for join. left: %zu, right: %zu"
,
GET_TASKID
(
pOperator
->
pTaskInfo
),
leftNumJoin
,
rightNumJoin
);
}
if
(
code
==
TSDB_CODE_SUCCESS
)
{
for
(
int32_t
i
=
0
;
i
<
leftNumJoin
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
rightNumJoin
;
++
j
)
{
SRowLocation
*
leftRow
=
taosArrayGet
(
leftRowLocations
,
i
);
SRowLocation
*
rightRow
=
taosArrayGet
(
rightRowLocations
,
j
);
SRowLocation
*
leftRow
=
taosArrayGet
(
leftRowLocations
,
i
);
SRowLocation
*
rightRow
=
taosArrayGet
(
rightRowLocations
,
j
);
mergeJoinJoinLeftRight
(
pOperator
,
pRes
,
*
nRows
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
rightRow
->
pDataBlock
,
rightRow
->
pos
);
++*
nRows
;
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
3bda4cf3
...
...
@@ -658,7 +658,8 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
blockDataDestroy
(
p
);
qDebug
(
"%s get sorted block, groupId:%0x"
PRIx64
" rows:%d"
,
GET_TASKID
(
pTaskInfo
),
pDataBlock
->
info
.
groupId
,
pDataBlock
->
info
.
rows
);
qDebug
(
"%s get sorted block, groupId:%0x"
PRIx64
" rows:%d"
,
GET_TASKID
(
pTaskInfo
),
pDataBlock
->
info
.
groupId
,
pDataBlock
->
info
.
rows
);
return
(
pDataBlock
->
info
.
rows
>
0
)
?
pDataBlock
:
NULL
;
}
...
...
source/libs/executor/src/tfill.c
浏览文件 @
3bda4cf3
source/libs/executor/src/timewindowoperator.c
浏览文件 @
3bda4cf3
source/libs/executor/src/tlinearhash.c
浏览文件 @
3bda4cf3
...
...
@@ -14,22 +14,22 @@
*/
#include "tlinearhash.h"
#include "tdef.h"
#include "taoserror.h"
#include "tdef.h"
#include "tpagedbuf.h"
#define LHASH_CAP_RATIO 0.85
// Always located in memory
typedef
struct
SLHashBucket
{
SArray
*
pPageIdList
;
SArray
*
pPageIdList
;
int32_t
size
;
// the number of element in this entry
}
SLHashBucket
;
struct
SLHashObj
{
SDiskbasedBuf
*
pBuf
;
SDiskbasedBuf
*
pBuf
;
_hash_fn_t
hashFn
;
SLHashBucket
**
pBucket
;
// entry list
SLHashBucket
**
pBucket
;
// entry list
int32_t
tuplesPerPage
;
int32_t
numOfAlloc
;
// number of allocated bucket ptr slot
int32_t
bits
;
// the number of bits used in hash
...
...
@@ -54,9 +54,7 @@ typedef struct SLHashNode {
static
int32_t
doAddNewBucket
(
SLHashObj
*
pHashObj
);
static
int32_t
doGetBucketIdFromHashVal
(
int32_t
hashv
,
int32_t
bits
)
{
return
hashv
&
((
1ul
<<
(
bits
))
-
1
);
}
static
int32_t
doGetBucketIdFromHashVal
(
int32_t
hashv
,
int32_t
bits
)
{
return
hashv
&
((
1ul
<<
(
bits
))
-
1
);
}
static
int32_t
doGetAlternativeBucketId
(
int32_t
bucketId
,
int32_t
bits
,
int32_t
numOfBuckets
)
{
int32_t
v
=
bucketId
-
(
1ul
<<
(
bits
-
1
));
...
...
@@ -70,9 +68,9 @@ static int32_t doGetRelatedSplitBucketId(int32_t bucketId, int32_t bits) {
}
static
void
doCopyObject
(
char
*
p
,
const
void
*
key
,
int32_t
keyLen
,
const
void
*
data
,
int32_t
size
)
{
*
(
uint16_t
*
)
p
=
keyLen
;
*
(
uint16_t
*
)
p
=
keyLen
;
p
+=
sizeof
(
uint16_t
);
*
(
uint16_t
*
)
p
=
size
;
*
(
uint16_t
*
)
p
=
size
;
p
+=
sizeof
(
uint16_t
);
memcpy
(
p
,
key
,
keyLen
);
...
...
@@ -86,7 +84,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
int32_t
pageId
=
*
(
int32_t
*
)
taosArrayGetLast
(
pBucket
->
pPageIdList
);
SFilePage
*
pPage
=
getBufPage
(
pHashObj
->
pBuf
,
pageId
);
ASSERT
(
pPage
!=
NULL
);
ASSERT
(
pPage
!=
NULL
);
// put to current buf page
size_t
nodeSize
=
sizeof
(
SLHashNode
)
+
keyLen
+
size
;
...
...
@@ -110,7 +108,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
setBufPageDirty
(
pNewPage
,
true
);
releaseBufPage
(
pHashObj
->
pBuf
,
pNewPage
);
}
else
{
char
*
p
=
(
char
*
)
pPage
+
pPage
->
num
;
char
*
p
=
(
char
*
)
pPage
+
pPage
->
num
;
doCopyObject
(
p
,
key
,
keyLen
,
data
,
size
);
pPage
->
num
+=
nodeSize
;
setBufPageDirty
(
pPage
,
true
);
...
...
@@ -118,7 +116,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
}
pBucket
->
size
+=
1
;
// printf("===> add to bucket:0x%x, num:%d, key:%d\n", index, pBucket->size, *(int*) key);
// printf("===> add to bucket:0x%x, num:%d, key:%d\n", index, pBucket->size, *(int*) key);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -127,7 +125,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
ASSERT
(
pPage
!=
NULL
&&
pNode
!=
NULL
&&
pBucket
->
size
>=
1
);
int32_t
len
=
GET_LHASH_NODE_LEN
(
pNode
);
char
*
p
=
(
char
*
)
pNode
+
len
;
char
*
p
=
(
char
*
)
pNode
+
len
;
char
*
pEnd
=
(
char
*
)
pPage
+
pPage
->
num
;
memmove
(
pNode
,
p
,
(
pEnd
-
p
));
...
...
@@ -141,7 +139,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
pBucket
->
size
-=
1
;
}
static
void
doTrimBucketPages
(
SLHashObj
*
pHashObj
,
SLHashBucket
*
pBucket
)
{
static
void
doTrimBucketPages
(
SLHashObj
*
pHashObj
,
SLHashBucket
*
pBucket
)
{
size_t
numOfPages
=
taosArrayGetSize
(
pBucket
->
pPageIdList
);
if
(
numOfPages
<=
1
)
{
return
;
...
...
@@ -214,7 +212,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
}
memset
(
p
+
POINTER_BYTES
*
pHashObj
->
numOfBuckets
,
0
,
newLen
-
pHashObj
->
numOfBuckets
);
pHashObj
->
pBucket
=
(
SLHashBucket
**
)
p
;
pHashObj
->
pBucket
=
(
SLHashBucket
**
)
p
;
pHashObj
->
numOfAlloc
=
newLen
;
}
...
...
@@ -239,7 +237,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
taosArrayPush
(
pBucket
->
pPageIdList
,
&
pageId
);
pHashObj
->
numOfBuckets
+=
1
;
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -266,8 +264,8 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
setBufPageCompressOnDisk
(
pHashObj
->
pBuf
,
false
);
/**
* The number of bits in the hash value, which is used to decide the exact bucket where the object should be located
in.
* The initial value is 0.
* The number of bits in the hash value, which is used to decide the exact bucket where the object should be located
*
in.
The initial value is 0.
*/
pHashObj
->
bits
=
0
;
pHashObj
->
hashFn
=
fn
;
...
...
@@ -289,7 +287,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
void
*
tHashCleanup
(
SLHashObj
*
pHashObj
)
{
destroyDiskbasedBuf
(
pHashObj
->
pBuf
);
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
taosArrayDestroy
(
pHashObj
->
pBucket
[
i
]
->
pPageIdList
);
taosMemoryFreeClear
(
pHashObj
->
pBucket
[
i
]);
}
...
...
@@ -299,7 +297,7 @@ void* tHashCleanup(SLHashObj* pHashObj) {
return
NULL
;
}
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
)
{
int32_t
tHashPut
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
)
{
ASSERT
(
pHashObj
!=
NULL
&&
key
!=
NULL
);
if
(
pHashObj
->
bits
==
0
)
{
...
...
@@ -311,7 +309,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
if
(
v
>=
pHashObj
->
numOfBuckets
)
{
int32_t
newBucketId
=
doGetAlternativeBucketId
(
v
,
pHashObj
->
bits
,
pHashObj
->
numOfBuckets
);
// printf("bucketId: 0x%x not exists, put it into 0x%x instead\n", v, newBucketId);
// printf("bucketId: 0x%x not exists, put it into 0x%x instead\n", v, newBucketId);
v
=
newBucketId
;
}
...
...
@@ -335,7 +333,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
int32_t
numOfBits
=
ceil
(
log
(
pHashObj
->
numOfBuckets
)
/
log
(
2
));
if
(
numOfBits
>
pHashObj
->
bits
)
{
// printf("extend the bits from %d to %d, new bucket:%d\n", pHashObj->bits, numOfBits, newBucketId);
// printf("extend the bits from %d to %d, new bucket:%d\n", pHashObj->bits, numOfBits, newBucketId);
ASSERT
(
numOfBits
==
pHashObj
->
bits
+
1
);
pHashObj
->
bits
=
numOfBits
;
}
...
...
@@ -344,14 +342,14 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
// load all data in this bucket and check if the data needs to relocated into the new bucket
SLHashBucket
*
pBucket
=
pHashObj
->
pBucket
[
splitBucketId
];
// printf("split %d items' bucket:0x%x to new bucket:0x%x\n", pBucket->size, splitBucketId, newBucketId);
// printf("split %d items' bucket:0x%x to new bucket:0x%x\n", pBucket->size, splitBucketId, newBucketId);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBucket
->
pPageIdList
);
++
i
)
{
int32_t
pageId
=
*
(
int32_t
*
)
taosArrayGet
(
pBucket
->
pPageIdList
,
i
);
SFilePage
*
p
=
getBufPage
(
pHashObj
->
pBuf
,
pageId
);
char
*
pStart
=
p
->
data
;
while
(
pStart
-
((
char
*
)
p
)
<
p
->
num
)
{
while
(
pStart
-
((
char
*
)
p
)
<
p
->
num
)
{
SLHashNode
*
pNode
=
(
SLHashNode
*
)
pStart
;
ASSERT
(
pNode
->
keyLen
>
0
&&
pNode
->
dataLen
>=
0
);
...
...
@@ -361,14 +359,14 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
if
(
v1
!=
splitBucketId
)
{
// place it into the new bucket
ASSERT
(
v1
==
newBucketId
);
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
SLHashBucket
*
pNewBucket
=
pHashObj
->
pBucket
[
newBucketId
];
doAddToBucket
(
pHashObj
,
pNewBucket
,
newBucketId
,
(
void
*
)
GET_LHASH_NODE_KEY
(
pNode
),
pNode
->
keyLen
,
GET_LHASH_NODE_KEY
(
pNode
),
pNode
->
dataLen
);
doRemoveFromBucket
(
p
,
pNode
,
pBucket
);
}
else
{
// printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1);
// printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1);
int32_t
nodeSize
=
GET_LHASH_NODE_LEN
(
pStart
);
pStart
+=
nodeSize
;
...
...
@@ -383,7 +381,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
return
TSDB_CODE_SUCCESS
;
}
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
char
*
tHashGet
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
ASSERT
(
pHashObj
!=
NULL
&&
key
!=
NULL
&&
keyLen
>
0
);
int32_t
hashv
=
pHashObj
->
hashFn
(
key
,
keyLen
);
...
...
@@ -418,7 +416,7 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) {
return
NULL
;
}
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
int32_t
tHashRemove
(
SLHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
// todo
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -431,8 +429,8 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
if
(
type
==
LINEAR_HASH_DATA
)
{
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
numOfBuckets
;
++
i
)
{
// printf("bucket: 0x%x, obj:%d, page:%d\n", i, pHashObj->pBucket[i]->size,
// (int)taosArrayGetSize(pHashObj->pBucket[i]->pPageIdList));
// printf("bucket: 0x%x, obj:%d, page:%d\n", i, pHashObj->pBucket[i]->size,
// (int)taosArrayGetSize(pHashObj->pBucket[i]->pPageIdList));
}
}
else
{
dBufPrintStatis
(
pHashObj
->
pBuf
);
...
...
source/libs/executor/src/tsort.c
浏览文件 @
3bda4cf3
...
...
@@ -13,16 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tcommon.h"
#include "query.h"
#include "tcommon.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tlosertree.h"
#include "tpagedbuf.h"
#include "tsort.h"
#include "tutil.h"
#include "tcompare.h"
struct
STupleHandle
{
SSDataBlock
*
pBlock
;
...
...
@@ -33,10 +33,10 @@ struct SSortHandle {
int32_t
type
;
int32_t
pageSize
;
int32_t
numOfPages
;
SDiskbasedBuf
*
pBuf
;
SDiskbasedBuf
*
pBuf
;
SArray
*
pSortInfo
;
SArray
*
pOrderedSource
;
SArray
*
pSortInfo
;
SArray
*
pOrderedSource
;
int32_t
loops
;
uint64_t
sortElapsed
;
...
...
@@ -44,23 +44,23 @@ struct SSortHandle {
uint64_t
totalElapsed
;
int32_t
sourceId
;
SSDataBlock
*
pDataBlock
;
SSDataBlock
*
pDataBlock
;
SMsortComparParam
cmpParam
;
int32_t
numOfCompletedSources
;
bool
opened
;
const
char
*
idStr
;
const
char
*
idStr
;
bool
inMemSort
;
bool
needAdjust
;
STupleHandle
tupleHandle
;
void
*
param
;
void
*
param
;
void
(
*
beforeFp
)(
SSDataBlock
*
pBlock
,
void
*
param
);
_sort_fetch_block_fn_t
fetchfp
;
_sort_merge_compar_fn_t
comparFn
;
SMultiwayMergeTreeInfo
*
pMergeTree
;
SMultiwayMergeTreeInfo
*
pMergeTree
;
};
static
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
);
static
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
);
SSDataBlock
*
tsortGetSortedDataBlock
(
const
SSortHandle
*
pSortHandle
)
{
return
createOneDataBlock
(
pSortHandle
->
pDataBlock
,
false
);
...
...
@@ -71,7 +71,8 @@ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) {
* @param type
* @return
*/
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pSortInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
)
{
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pSortInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
)
{
SSortHandle
*
pSortHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortHandle
));
pSortHandle
->
type
=
type
;
...
...
@@ -98,8 +99,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
}
static
int32_t
sortComparCleanup
(
SMsortComparParam
*
cmpParam
)
{
for
(
int32_t
i
=
0
;
i
<
cmpParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
// NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE
for
(
int32_t
i
=
0
;
i
<
cmpParam
->
numOfSources
;
++
i
)
{
SSortSource
*
pSource
=
cmpParam
->
pSources
[
i
];
// NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE
blockDataDestroy
(
pSource
->
src
.
pBlock
);
taosMemoryFreeClear
(
pSource
);
}
...
...
@@ -121,7 +123,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
destroyDiskbasedBuf
(
pSortHandle
->
pBuf
);
taosMemoryFreeClear
(
pSortHandle
->
idStr
);
blockDataDestroy
(
pSortHandle
->
pDataBlock
);
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pSortHandle
->
pOrderedSource
);
i
++
){
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pSortHandle
->
pOrderedSource
);
i
++
)
{
SSortSource
**
pSource
=
taosArrayGet
(
pSortHandle
->
pOrderedSource
,
i
);
taosMemoryFreeClear
(
*
pSource
);
}
...
...
@@ -134,7 +136,8 @@ int32_t tsortAddSource(SSortHandle* pSortHandle, void* pSource) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
doAddNewExternalMemSource
(
SDiskbasedBuf
*
pBuf
,
SArray
*
pAllSources
,
SSDataBlock
*
pBlock
,
int32_t
*
sourceId
,
SArray
*
pPageIdList
)
{
static
int32_t
doAddNewExternalMemSource
(
SDiskbasedBuf
*
pBuf
,
SArray
*
pAllSources
,
SSDataBlock
*
pBlock
,
int32_t
*
sourceId
,
SArray
*
pPageIdList
)
{
SSortSource
*
pSource
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortSource
));
if
(
pSource
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
...
...
@@ -149,7 +152,8 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSource
int32_t
rowSize
=
blockDataGetSerialRowSize
(
pSource
->
src
.
pBlock
);
// The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation
int32_t
numOfRows
=
(
getBufPageSize
(
pBuf
)
-
blockDataGetSerialMetaSize
(
taosArrayGetSize
(
pBlock
->
pDataBlock
)))
/
rowSize
;
int32_t
numOfRows
=
(
getBufPageSize
(
pBuf
)
-
blockDataGetSerialMetaSize
(
taosArrayGetSize
(
pBlock
->
pDataBlock
)))
/
rowSize
;
ASSERT
(
numOfRows
>
0
);
return
blockDataEnsureCapacity
(
pSource
->
src
.
pBlock
,
numOfRows
);
}
...
...
@@ -163,7 +167,8 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
qError
(
"Add to buf failed since %s"
,
terrstr
(
terrno
));
return
terrno
;
}
int32_t
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"doAddToBuf"
,
tsTempDir
);
int32_t
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"doAddToBuf"
,
tsTempDir
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -171,7 +176,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
}
SArray
*
pPageIdList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
while
(
start
<
pDataBlock
->
info
.
rows
)
{
while
(
start
<
pDataBlock
->
info
.
rows
)
{
int32_t
stop
=
0
;
blockDataSplitRows
(
pDataBlock
,
pDataBlock
->
info
.
hasVarCol
,
start
,
&
stop
,
pHandle
->
pageSize
);
SSDataBlock
*
p
=
blockDataExtractBlock
(
pDataBlock
,
start
,
stop
-
start
+
1
);
...
...
@@ -211,7 +216,8 @@ static void setCurrentSourceIsDone(SSortSource* pSource, SSortHandle* pHandle) {
++
pHandle
->
numOfCompletedSources
;
}
static
int32_t
sortComparInit
(
SMsortComparParam
*
cmpParam
,
SArray
*
pSources
,
int32_t
startIndex
,
int32_t
endIndex
,
SSortHandle
*
pHandle
)
{
static
int32_t
sortComparInit
(
SMsortComparParam
*
cmpParam
,
SArray
*
pSources
,
int32_t
startIndex
,
int32_t
endIndex
,
SSortHandle
*
pHandle
)
{
cmpParam
->
pSources
=
taosArrayGet
(
pSources
,
startIndex
);
cmpParam
->
numOfSources
=
(
endIndex
-
startIndex
+
1
);
...
...
@@ -246,7 +252,8 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
qError
(
"Sort compare init failed since %s"
,
terrstr
(
terrno
));
return
code
;
}
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"sortComparInit"
,
tsTempDir
);
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"sortComparInit"
,
tsTempDir
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -267,7 +274,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
return
code
;
}
static
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
const
SSDataBlock
*
pSource
,
int32_t
*
rowIndex
)
{
static
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
const
SSDataBlock
*
pSource
,
int32_t
*
rowIndex
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBlock
->
pDataBlock
);
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
...
...
@@ -286,7 +293,8 @@ static void appendOneRowToDataBlock(SSDataBlock *pBlock, const SSDataBlock* pSou
*
rowIndex
+=
1
;
}
static
int32_t
adjustMergeTreeForNextTuple
(
SSortSource
*
pSource
,
SMultiwayMergeTreeInfo
*
pTree
,
SSortHandle
*
pHandle
,
int32_t
*
numOfCompleted
)
{
static
int32_t
adjustMergeTreeForNextTuple
(
SSortSource
*
pSource
,
SMultiwayMergeTreeInfo
*
pTree
,
SSortHandle
*
pHandle
,
int32_t
*
numOfCompleted
)
{
/*
* load a new SDataBlock into memory of a given intermediate data-set source,
* since it's last record in buffer has been chosen to be processed, as the winner of loser-tree
...
...
@@ -295,7 +303,7 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
pSource
->
src
.
rowIndex
=
0
;
if
(
pHandle
->
type
==
SORT_SINGLESOURCE_SORT
)
{
pSource
->
pageIndex
++
;
pSource
->
pageIndex
++
;
if
(
pSource
->
pageIndex
>=
taosArrayGetSize
(
pSource
->
pageIdList
))
{
(
*
numOfCompleted
)
+=
1
;
pSource
->
src
.
rowIndex
=
-
1
;
...
...
@@ -344,14 +352,14 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
static
SSDataBlock
*
getSortedBlockDataInner
(
SSortHandle
*
pHandle
,
SMsortComparParam
*
cmpParam
,
int32_t
capacity
)
{
blockDataCleanup
(
pHandle
->
pDataBlock
);
while
(
1
)
{
while
(
1
)
{
if
(
cmpParam
->
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
break
;
}
int32_t
index
=
tMergeTreeGetChosenIndex
(
pHandle
->
pMergeTree
);
SSortSource
*
pSource
=
(
*
cmpParam
).
pSources
[
index
];
SSortSource
*
pSource
=
(
*
cmpParam
).
pSources
[
index
];
appendOneRowToDataBlock
(
pHandle
->
pDataBlock
,
pSource
->
src
.
pBlock
,
&
pSource
->
src
.
rowIndex
);
int32_t
code
=
adjustMergeTreeForNextTuple
(
pSource
,
pHandle
->
pMergeTree
,
pHandle
,
&
pHandle
->
numOfCompletedSources
);
...
...
@@ -365,16 +373,16 @@ static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparPa
}
}
return
(
pHandle
->
pDataBlock
->
info
.
rows
>
0
)
?
pHandle
->
pDataBlock
:
NULL
;
return
(
pHandle
->
pDataBlock
->
info
.
rows
>
0
)
?
pHandle
->
pDataBlock
:
NULL
;
}
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
)
{
int32_t
pLeftIdx
=
*
(
int32_t
*
)
pLeft
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
pRight
;
int32_t
msortComparFn
(
const
void
*
pLeft
,
const
void
*
pRight
,
void
*
param
)
{
int32_t
pLeftIdx
=
*
(
int32_t
*
)
pLeft
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
pRight
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SSortSource
*
pLeftSource
=
pParam
->
pSources
[
pLeftIdx
];
SSortSource
*
pRightSource
=
pParam
->
pSources
[
pRightIdx
];
...
...
@@ -397,7 +405,7 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
}
}
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
...
...
@@ -406,7 +414,8 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
leftNull
=
colDataIsNull_s
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
}
else
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
i
]);
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
i
]);
}
}
...
...
@@ -416,7 +425,8 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
rightNull
=
colDataIsNull_s
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
}
else
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
i
]);
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
i
]);
}
}
...
...
@@ -425,11 +435,11 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
}
if
(
rightNull
)
{
return
pOrder
->
nullFirst
?
1
:
-
1
;
return
pOrder
->
nullFirst
?
1
:
-
1
;
}
if
(
leftNull
)
{
return
pOrder
->
nullFirst
?
-
1
:
1
;
return
pOrder
->
nullFirst
?
-
1
:
1
;
}
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
...
...
@@ -464,7 +474,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
", sort elapsed:%"
PRId64
", total elapsed:%"
PRId64
,
pHandle
->
idStr
,
(
int32_t
)(
sortPass
+
1
),
s
,
pHandle
->
sortElapsed
,
pHandle
->
totalElapsed
);
}
else
{
qDebug
(
"%s ordered source:%"
PRIzu
", available buf:%d, no need internal sort"
,
pHandle
->
idStr
,
numOfSources
,
qDebug
(
"%s ordered source:%"
PRIzu
", available buf:%d, no need internal sort"
,
pHandle
->
idStr
,
numOfSources
,
pHandle
->
numOfPages
);
}
...
...
@@ -475,7 +485,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
pHandle
->
loops
=
sortPass
+
2
;
size_t
numOfSorted
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
for
(
int32_t
t
=
0
;
t
<
sortPass
;
++
t
)
{
for
(
int32_t
t
=
0
;
t
<
sortPass
;
++
t
)
{
int64_t
st
=
taosGetTimestampUs
();
SArray
*
pResList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
...
...
@@ -484,7 +494,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
int32_t
sortGroup
=
(
numOfSorted
+
numOfInputSources
-
1
)
/
numOfInputSources
;
// Only *numOfInputSources* can be loaded into buffer to perform the external sort.
for
(
int32_t
i
=
0
;
i
<
sortGroup
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
sortGroup
;
++
i
)
{
pHandle
->
sourceId
+=
1
;
int32_t
end
=
(
i
+
1
)
*
numOfInputSources
-
1
;
...
...
@@ -499,7 +509,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
return
code
;
}
code
=
tMergeTreeCreate
(
&
pHandle
->
pMergeTree
,
pHandle
->
cmpParam
.
numOfSources
,
&
pHandle
->
cmpParam
,
pHandle
->
comparFn
);
code
=
tMergeTreeCreate
(
&
pHandle
->
pMergeTree
,
pHandle
->
cmpParam
.
numOfSources
,
&
pHandle
->
cmpParam
,
pHandle
->
comparFn
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -519,7 +530,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
taosArrayPush
(
pPageIdList
,
&
pageId
);
int32_t
size
=
blockDataGetSize
(
pDataBlock
)
+
sizeof
(
int32_t
)
+
taosArrayGetSize
(
pDataBlock
->
pDataBlock
)
*
sizeof
(
int32_t
);
int32_t
size
=
blockDataGetSize
(
pDataBlock
)
+
sizeof
(
int32_t
)
+
taosArrayGetSize
(
pDataBlock
->
pDataBlock
)
*
sizeof
(
int32_t
);
assert
(
size
<=
getBufPageSize
(
pHandle
->
pBuf
));
blockDataToBuf
(
pPage
,
pDataBlock
);
...
...
@@ -551,8 +563,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
pHandle
->
totalElapsed
+=
el
;
SDiskbasedBufStatis
statis
=
getDBufStatis
(
pHandle
->
pBuf
);
qDebug
(
"%s %d round mergesort, elapsed:%"
PRId64
" readDisk:%.2f Kb, flushDisk:%.2f Kb"
,
pHandle
->
idStr
,
t
+
1
,
el
,
statis
.
loadBytes
/
1024
.
0
,
statis
.
flushBytes
/
1024
.
0
);
qDebug
(
"%s %d round mergesort, elapsed:%"
PRId64
" readDisk:%.2f Kb, flushDisk:%.2f Kb"
,
pHandle
->
idStr
,
t
+
1
,
el
,
statis
.
loadBytes
/
1024
.
0
,
statis
.
flushBytes
/
1024
.
0
);
if
(
pHandle
->
type
==
SORT_MULTISOURCE_MERGE
)
{
pHandle
->
type
=
SORT_SINGLESOURCE_SORT
;
...
...
@@ -701,7 +713,8 @@ int32_t tsortClose(SSortHandle* pHandle) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
)
{
int32_t
tsortSetFetchRawDataFp
(
SSortHandle
*
pHandle
,
_sort_fetch_block_fn_t
fetchFp
,
void
(
*
fp
)(
SSDataBlock
*
,
void
*
),
void
*
param
)
{
pHandle
->
fetchfp
=
fetchFp
;
pHandle
->
beforeFp
=
fp
;
pHandle
->
param
=
param
;
...
...
@@ -735,7 +748,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
}
int32_t
index
=
tMergeTreeGetChosenIndex
(
pHandle
->
pMergeTree
);
SSortSource
*
pSource
=
pHandle
->
cmpParam
.
pSources
[
index
];
SSortSource
*
pSource
=
pHandle
->
cmpParam
.
pSources
[
index
];
if
(
pHandle
->
needAdjust
)
{
int32_t
code
=
adjustMergeTreeForNextTuple
(
pSource
,
pHandle
->
pMergeTree
,
pHandle
,
&
pHandle
->
numOfCompletedSources
);
...
...
@@ -778,15 +791,13 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) {
}
}
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
)
{
return
pVHandle
->
pBlock
->
info
.
groupId
;
}
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
)
{
return
pVHandle
->
pBlock
->
info
.
groupId
;
}
SSortExecInfo
tsortGetSortExecInfo
(
SSortHandle
*
pHandle
)
{
SSortExecInfo
info
=
{
0
};
info
.
sortBuffer
=
pHandle
->
pageSize
*
pHandle
->
numOfPages
;
info
.
sortMethod
=
pHandle
->
inMemSort
?
SORT_QSORT_T
:
SORT_SPILLED_MERGE_SORT_T
;
info
.
sortMethod
=
pHandle
->
inMemSort
?
SORT_QSORT_T
:
SORT_SPILLED_MERGE_SORT_T
;
info
.
loops
=
pHandle
->
loops
;
if
(
pHandle
->
pBuf
!=
NULL
)
{
...
...
@@ -797,4 +808,3 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) {
return
info
;
}
source/libs/executor/test/lhashTests.cpp
浏览文件 @
3bda4cf3
...
...
@@ -32,41 +32,42 @@ TEST(testCase, linear_hash_Tests) {
int64_t
st
=
taosGetTimestampUs
();
SLHashObj
*
pHashObj
=
tHashInit
(
4098
*
4
*
2
,
512
,
fn
,
40
);
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
SLHashObj
*
pHashObj
=
tHashInit
(
4098
*
4
*
2
,
512
,
fn
,
40
);
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
int32_t
code
=
tHashPut
(
pHashObj
,
&
i
,
sizeof
(
i
),
&
i
,
sizeof
(
i
));
assert
(
code
==
0
);
}
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
int64_t
et
=
taosGetTimestampUs
();
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
if
(
i
==
950000
)
{
printf
(
"kf
\n
"
);
}
char
*
v
=
tHashGet
(
pHashObj
,
&
i
,
sizeof
(
i
));
if
(
v
!=
NULL
)
{
// printf("find value: %d, key:%d\n", *(int32_t*) v, i);
// printf("find value: %d, key:%d\n", *(int32_t*) v, i);
}
else
{
// printf("failed to found key:%d in hash\n", i);
// printf("failed to found key:%d in hash\n", i);
}
}
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
// tHashPrint(pHashObj, LINEAR_HASH_STATIS);
tHashCleanup
(
pHashObj
);
int64_t
et1
=
taosGetTimestampUs
();
SHashObj
*
pHashObj1
=
taosHashInit
(
1000
,
fn
,
false
,
HASH_NO_LOCK
);
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
taosHashPut
(
pHashObj1
,
&
i
,
sizeof
(
i
),
&
i
,
sizeof
(
i
));
}
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1000000
;
++
i
)
{
void
*
v
=
taosHashGet
(
pHashObj1
,
&
i
,
sizeof
(
i
));
}
taosHashCleanup
(
pHashObj1
);
int64_t
et2
=
taosGetTimestampUs
();
printf
(
"linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f
\n
"
,
(
et1
-
st
)
/
1000.0
,
(
et
-
st
)
/
1000.0
,
(
et2
-
et1
)
/
1000.0
);
printf
(
"linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f
\n
"
,
(
et1
-
st
)
/
1000.0
,
(
et
-
st
)
/
1000.0
,
(
et2
-
et1
)
/
1000.0
);
}
\ No newline at end of file
source/libs/executor/test/sortTests.cpp
浏览文件 @
3bda4cf3
...
...
@@ -25,14 +25,14 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "executorimpl.h"
#include "executor.h"
#include "executorimpl.h"
#include "taos.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdef.h"
#include "trpc.h"
#include "tvariant.h"
#include "tcompare.h"
namespace
{
typedef
struct
{
...
...
@@ -44,8 +44,7 @@ typedef struct {
int16_t
VARCOUNT
=
16
;
float
rand_f2
()
{
float
rand_f2
()
{
unsigned
r
=
taosRand
();
r
&=
0x007fffff
;
r
|=
0x40800000
;
...
...
@@ -53,10 +52,10 @@ float rand_f2()
}
static
const
int32_t
TEST_NUMBER
=
1
;
#define bigendian()
((*(char
*)&TEST_NUMBER) == 0)
#define bigendian()
((*(char
*)&TEST_NUMBER) == 0)
SSDataBlock
*
getSingleColDummyBlock
(
void
*
param
)
{
_info
*
pInfo
=
(
_info
*
)
param
;
_info
*
pInfo
=
(
_info
*
)
param
;
if
(
--
pInfo
->
count
<
0
)
{
return
NULL
;
}
...
...
@@ -65,11 +64,11 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
SColumnInfoData
colInfo
=
{
0
};
colInfo
.
info
.
type
=
pInfo
->
type
;
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
colInfo
.
info
.
bytes
=
TSDB_NCHAR_SIZE
*
VARCOUNT
+
VARSTR_HEADER_SIZE
;
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
colInfo
.
info
.
bytes
=
VARCOUNT
+
VARSTR_HEADER_SIZE
;
}
else
{
}
else
{
colInfo
.
info
.
bytes
=
tDataTypes
[
pInfo
->
type
].
bytes
;
}
colInfo
.
info
.
colId
=
1
;
...
...
@@ -80,22 +79,22 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
for
(
int32_t
i
=
0
;
i
<
pInfo
->
pageRows
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
static_cast
<
SColumnInfoData
*>
(
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
0
));
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
){
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
size
=
taosRand
()
%
VARCOUNT
;
char
str
[
128
]
=
{
0
};
char
strOri
[
128
]
=
{
0
};
taosRandStr
(
strOri
,
size
);
int32_t
len
=
0
;
bool
ret
=
taosMbsToUcs4
(
strOri
,
size
,
(
TdUcs4
*
)
varDataVal
(
str
),
size
*
TSDB_NCHAR_SIZE
,
&
len
);
if
(
!
ret
){
if
(
!
ret
)
{
printf
(
"error
\n
"
);
return
NULL
;
}
varDataSetLen
(
str
,
len
);
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
str
),
false
);
pBlock
->
info
.
hasVarCol
=
true
;
printf
(
"nchar: %s
\n
"
,
strOri
);
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
printf
(
"nchar: %s
\n
"
,
strOri
);
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
size
=
taosRand
()
%
VARCOUNT
;
char
str
[
64
]
=
{
0
};
taosRandStr
(
varDataVal
(
str
),
size
);
...
...
@@ -103,16 +102,16 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
str
),
false
);
pBlock
->
info
.
hasVarCol
=
true
;
printf
(
"binary: %s
\n
"
,
varDataVal
(
str
));
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_DOUBLE
||
pInfo
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
}
else
if
(
pInfo
->
type
==
TSDB_DATA_TYPE_DOUBLE
||
pInfo
->
type
==
TSDB_DATA_TYPE_FLOAT
)
{
double
v
=
rand_f2
();
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
&
v
),
false
);
printf
(
"float: %f
\n
"
,
v
);
}
else
{
}
else
{
int64_t
v
=
++
pInfo
->
startVal
;
char
*
result
=
static_cast
<
char
*>
(
taosMemoryCalloc
(
tDataTypes
[
pInfo
->
type
].
bytes
,
1
));
if
(
!
bigendian
()){
char
*
result
=
static_cast
<
char
*>
(
taosMemoryCalloc
(
tDataTypes
[
pInfo
->
type
].
bytes
,
1
));
if
(
!
bigendian
())
{
memcpy
(
result
,
&
v
,
tDataTypes
[
pInfo
->
type
].
bytes
);
}
else
{
}
else
{
memcpy
(
result
,
(
char
*
)(
&
v
)
+
sizeof
(
int64_t
)
-
tDataTypes
[
pInfo
->
type
].
bytes
,
tDataTypes
[
pInfo
->
type
].
bytes
);
}
...
...
@@ -126,15 +125,14 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
return
pBlock
;
}
int32_t
docomp
(
const
void
*
p1
,
const
void
*
p2
,
void
*
param
)
{
int32_t
pLeftIdx
=
*
(
int32_t
*
)
p1
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
p2
;
int32_t
pLeftIdx
=
*
(
int32_t
*
)
p1
;
int32_t
pRightIdx
=
*
(
int32_t
*
)
p2
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SMsortComparParam
*
pParam
=
(
SMsortComparParam
*
)
param
;
SSortSource
**
px
=
reinterpret_cast
<
SSortSource
**>
(
pParam
->
pSources
);
SArray
*
pInfo
=
pParam
->
orderInfo
;
SArray
*
pInfo
=
pParam
->
orderInfo
;
SSortSource
*
pLeftSource
=
px
[
pLeftIdx
];
SSortSource
*
pRightSource
=
px
[
pRightIdx
];
...
...
@@ -151,20 +149,22 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
SSDataBlock
*
pLeftBlock
=
pLeftSource
->
src
.
pBlock
;
SSDataBlock
*
pRightBlock
=
pRightSource
->
src
.
pBlock
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
(
SBlockOrderInfo
*
)
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
bool
leftNull
=
false
;
if
(
pLeftColInfoData
->
hasNull
)
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
}
SColumnInfoData
*
pRightColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
slotId
);
SColumnInfoData
*
pRightColInfoData
=
(
SColumnInfoData
*
)
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
slotId
);
bool
rightNull
=
false
;
if
(
pRightColInfoData
->
hasNull
)
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
pOrder
->
slotId
]);
}
if
(
leftNull
&&
rightNull
)
{
...
...
@@ -172,11 +172,11 @@ int32_t docomp(const void* p1, const void* p2, void* param) {
}
if
(
rightNull
)
{
return
pOrder
->
nullFirst
?
1
:
-
1
;
return
pOrder
->
nullFirst
?
1
:
-
1
;
}
if
(
leftNull
)
{
return
pOrder
->
nullFirst
?
-
1
:
1
;
return
pOrder
->
nullFirst
?
-
1
:
1
;
}
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
...
...
source/libs/executor/test/tSimpleHashTests.cpp
浏览文件 @
3bda4cf3
...
...
@@ -31,8 +31,7 @@
// }
TEST
(
testCase
,
tSimpleHashTest_intKey
)
{
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
assert
(
pHashObj
!=
nullptr
);
...
...
@@ -76,10 +75,8 @@ TEST(testCase, tSimpleHashTest_intKey) {
tSimpleHashCleanup
(
pHashObj
);
}
TEST
(
testCase
,
tSimpleHashTest_binaryKey
)
{
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
assert
(
pHashObj
!=
nullptr
);
...
...
@@ -140,5 +137,4 @@ TEST(testCase, tSimpleHashTest_binaryKey) {
tSimpleHashCleanup
(
pHashObj
);
}
#pragma GCC diagnostic pop
\ No newline at end of file
source/libs/function/inc/builtinsimpl.h
浏览文件 @
3bda4cf3
...
...
@@ -28,32 +28,32 @@ bool dummyInit(SqlFunctionCtx* UNUSED_PARAM(pCtx), SResultRowEntryInfo* UNUSED_P
int32_t
dummyProcess
(
SqlFunctionCtx
*
UNUSED_PARAM
(
pCtx
));
int32_t
dummyFinalize
(
SqlFunctionCtx
*
UNUSED_PARAM
(
pCtx
),
SSDataBlock
*
UNUSED_PARAM
(
pBlock
));
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
functionFinalizeWithResultBuf
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
char
*
finalResult
);
int32_t
combineFunction
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
EFuncDataRequired
countDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
bool
getCountFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
countFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
countInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
countFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
countInvertFunction
(
SqlFunctionCtx
*
pCtx
);
EFuncDataRequired
statisDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
bool
getSumFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
sumFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
minmaxFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
minmaxFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
getMinmaxFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
minFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
maxFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
maxFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
minmaxFunctionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
minCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
maxCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getAvgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
avgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
avgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
avgFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
@@ -63,7 +63,7 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getAvgInfoSize
();
bool
getStddevFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
stddevFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
stddevFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
stddevFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
@@ -73,20 +73,20 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getStddevInfoSize
();
bool
getLeastSQRFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
leastSQRFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
leastSQRFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
leastSQRFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
leastSQRFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
leastSQRInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
leastSQRCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getPercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
percentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
percentileFunction
(
SqlFunctionCtx
*
pCtx
);
bool
percentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
percentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getApercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
apercentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
apercentileFunction
(
SqlFunctionCtx
*
pCtx
);
bool
apercentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
apercentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
apercentilePartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
@@ -94,25 +94,25 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
int32_t
getApercentileMaxSize
();
bool
getDiffFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getDerivativeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
derivativeFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
derivativeFunction
(
SqlFunctionCtx
*
pCtx
);
bool
derivativeFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
derivativeFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getIrateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
irateFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
irateFunction
(
SqlFunctionCtx
*
pCtx
);
bool
irateFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
irateFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
irateFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
cachedLastRowFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getFirstLastFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstLastFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
firstLastPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
firstCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
...
...
@@ -120,15 +120,15 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getFirstLastInfoSize
(
int32_t
resBytes
);
EFuncDataRequired
lastDynDataReq
(
void
*
pRes
,
STimeWindow
*
pTimeWindow
);
int32_t
lastRowFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastRowFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getTopBotFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
getTopBotMergeFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
topBotFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
bool
topBotFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotMergeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
@@ -137,7 +137,7 @@ int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getTopBotInfoSize
(
int64_t
numOfItems
);
bool
getSpreadFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
spreadFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
spreadFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
spreadFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
spreadFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
spreadFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
@@ -146,7 +146,7 @@ int32_t getSpreadInfoSize();
int32_t
spreadCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getElapsedFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
elapsedFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
elapsedFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
elapsedFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
elapsedFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
elapsedFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
@@ -155,7 +155,7 @@ int32_t getElapsedInfoSize();
int32_t
elapsedCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getHistogramFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
histogramFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
histogramFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
histogramFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunctionPartial
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
...
...
@@ -173,7 +173,7 @@ int32_t getHLLInfoSize();
int32_t
hllCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getStateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
stateFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
stateFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
stateCountFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateDurationFunction
(
SqlFunctionCtx
*
pCtx
);
...
...
@@ -181,36 +181,36 @@ bool getCsumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
int32_t
csumFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getMavgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
mavgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
mavgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
mavgFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getSampleFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
sampleFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
sampleFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
sampleFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getTailFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
tailFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
tailFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
tailFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getUniqueFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
uniqueFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
uniqueFunction
(
SqlFunctionCtx
*
pCtx
);
bool
uniqueFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
uniqueFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getModeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
modeFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
modeFunction
(
SqlFunctionCtx
*
pCtx
);
bool
modeFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
modeFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
modeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getTwaFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
twaFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
twaFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
twaFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
twaFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
twaFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
twaFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
blockDistSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
blockDistFunction
(
SqlFunctionCtx
*
pCtx
);
bool
blockDistSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
blockDistFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
blockDistFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getGroupKeyFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
...
...
source/libs/function/inc/tfunctionInt.h
浏览文件 @
3bda4cf3
...
...
@@ -22,11 +22,11 @@ extern "C" {
#include "os.h"
#include "tname.h"
#include "taosdef.h"
#include "tvariant.h"
#include "function.h"
#include "taosdef.h"
#include "tname.h"
#include "tudf.h"
#include "tvariant.h"
bool
topbot_datablock_filter
(
SqlFunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
...
...
source/libs/function/inc/thistogram.h
浏览文件 @
3bda4cf3
source/libs/function/inc/tpercentile.h
浏览文件 @
3bda4cf3
...
...
@@ -61,10 +61,10 @@ typedef struct tMemBucket {
MinMaxEntry
range
;
// value range
int32_t
times
;
// count that has been checked for deciding the correct data value buckets.
__compar_fn_t
comparFn
;
tMemBucketSlot
*
pSlots
;
SDiskbasedBuf
*
pBuffer
;
tMemBucketSlot
*
pSlots
;
SDiskbasedBuf
*
pBuffer
;
__perc_hash_func_t
hashFunc
;
SHashObj
*
groupPagesMap
;
// disk page map for different groups;
SHashObj
*
groupPagesMap
;
// disk page map for different groups;
}
tMemBucket
;
tMemBucket
*
tMemBucketCreate
(
int16_t
nElemSize
,
int16_t
dataType
,
double
minval
,
double
maxval
);
...
...
source/libs/function/inc/tscript.h
浏览文件 @
3bda4cf3
...
...
@@ -17,14 +17,14 @@
#define TDENGINE_QSCRIPT_H
#if 0
#include <lua.h>
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
#include "tutil.h"
#include "hash.h"
#include "tlist.h"
#include "tudf.h"
#include "tutil.h"
#define MAX_FUNC_NAME 64
...
...
@@ -81,4 +81,4 @@ void scriptEnvPoolCleanup();
bool isValidScript(char *script, int32_t len);
#endif
#endif
//TDENGINE_QSCRIPT_H
#endif
// TDENGINE_QSCRIPT_H
source/libs/function/inc/tudfInt.h
浏览文件 @
3bda4cf3
...
...
@@ -61,12 +61,10 @@ typedef struct SUdfCallResponse {
SUdfInterBuf
resultBuf
;
}
SUdfCallResponse
;
typedef
struct
SUdfTeardownRequest
{
int64_t
udfHandle
;
}
SUdfTeardownRequest
;
typedef
struct
SUdfTeardownResponse
{
#ifdef WINDOWS
size_t
avoidCompilationErrors
;
...
...
@@ -98,20 +96,20 @@ typedef struct SUdfResponse {
};
}
SUdfResponse
;
int32_t
encodeUdfRequest
(
void
**
buf
,
const
SUdfRequest
*
request
);
void
*
decodeUdfRequest
(
const
void
*
buf
,
SUdfRequest
*
request
);
int32_t
encodeUdfRequest
(
void
**
buf
,
const
SUdfRequest
*
request
);
void
*
decodeUdfRequest
(
const
void
*
buf
,
SUdfRequest
*
request
);
int32_t
encodeUdfResponse
(
void
**
buf
,
const
SUdfResponse
*
response
);
void
*
decodeUdfResponse
(
const
void
*
buf
,
SUdfResponse
*
response
);
void
*
decodeUdfResponse
(
const
void
*
buf
,
SUdfResponse
*
response
);
void
freeUdfColumnData
(
SUdfColumnData
*
data
,
SUdfColumnMeta
*
meta
);
void
freeUdfColumn
(
SUdfColumn
*
col
);
void
freeUdfColumn
(
SUdfColumn
*
col
);
void
freeUdfDataDataBlock
(
SUdfDataBlock
*
block
);
int32_t
convertDataBlockToUdfDataBlock
(
SSDataBlock
*
block
,
SUdfDataBlock
*
udfBlock
);
int32_t
convertUdfColumnToDataBlock
(
SUdfColumn
*
udfCol
,
SSDataBlock
*
block
);
int32_t
getUdfdPipeName
(
char
*
pipeName
,
int32_t
size
);
int32_t
getUdfdPipeName
(
char
*
pipeName
,
int32_t
size
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/function/inc/udfc.h
浏览文件 @
3bda4cf3
...
...
@@ -20,7 +20,7 @@ enum {
};
typedef
struct
SSDataBlock
{
typedef
struct
SSDataBlock
{
char
*
data
;
int32_t
size
;
}
SSDataBlock
;
...
...
@@ -36,9 +36,9 @@ int32_t createUdfdProxy();
int32_t
destroyUdfdProxy
();
//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfcFuncHandle *handles);
//
int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfcFuncHandle *handles);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfcFuncHandle
*
handle
);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfcFuncHandle
*
handle
);
int32_t
callUdf
(
UdfcFuncHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SSDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SSDataBlock
*
output
);
...
...
@@ -48,7 +48,7 @@ int32_t doTeardownUdf(UdfcFuncHandle handle);
typedef
struct
SUdfSetupRequest
{
char
udfName
[
16
];
//
int8_t
scriptType
;
// 0:c, 1: lua, 2:js
int8_t
udfType
;
//
udaf, udf, udtf
int8_t
udfType
;
//
udaf, udf, udtf
int16_t
pathSize
;
char
*
path
;
}
SUdfSetupRequest
;
...
...
@@ -57,7 +57,6 @@ typedef struct SUdfSetupResponse {
int64_t
udfHandle
;
}
SUdfSetupResponse
;
typedef
struct
SUdfCallRequest
{
int64_t
udfHandle
;
int8_t
step
;
...
...
@@ -69,7 +68,6 @@ typedef struct SUdfCallRequest {
char
*
state
;
}
SUdfCallRequest
;
typedef
struct
SUdfCallResponse
{
int32_t
outputBytes
;
char
*
output
;
...
...
@@ -77,12 +75,10 @@ typedef struct SUdfCallResponse {
char
*
newState
;
}
SUdfCallResponse
;
typedef
struct
SUdfTeardownRequest
{
int64_t
udfHandle
;
}
SUdfTeardownRequest
;
typedef
struct
SUdfTeardownResponse
{
#ifdef WINDOWS
size_t
avoidCompilationErrors
;
...
...
@@ -110,4 +106,4 @@ int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest **pRequest);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
int32_t
encodeRequest
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfRequest
*
request
);
int32_t
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
**
pResponse
);
#endif
//
UDF_UDF_H
#endif
//
UDF_UDF_H
source/libs/function/src/builtinsimpl.c
浏览文件 @
3bda4cf3
...
...
@@ -2977,7 +2977,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
}
static
void
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
,
int32_t
rowIndex
)
{
static
void
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
,
int32_t
rowIndex
)
{
SInputColumnInfoData
*
pColInfo
=
&
pCtx
->
input
;
if
(
pOutput
->
hasResult
)
{
...
...
source/libs/function/src/tfunctionInt.c
浏览文件 @
3bda4cf3
...
...
@@ -15,8 +15,8 @@
#include "os.h"
#include "taosdef.h"
#include "tmsg.h"
#include "thash.h"
#include "tmsg.h"
#include "ttypes.h"
#include "function.h"
...
...
@@ -29,15 +29,13 @@
#include "ttszip.h"
#include "tudf.h"
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
)
{
pCell
->
initialized
=
false
;
}
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
)
{
pCell
->
initialized
=
false
;
}
int32_t
getNumOfResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
SSDataBlock
*
pResBlock
)
{
int32_t
maxRows
=
0
;
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
if
(
pResInfo
!=
NULL
&&
maxRows
<
pResInfo
->
numOfRes
)
{
maxRows
=
pResInfo
->
numOfRes
;
}
...
...
@@ -46,12 +44,12 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock
assert
(
maxRows
>=
0
);
blockDataEnsureCapacity
(
pResBlock
,
maxRows
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
i
]);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
i
]);
if
(
pResInfo
->
numOfRes
==
0
)
{
for
(
int32_t
j
=
0
;
j
<
pResInfo
->
numOfRes
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pResInfo
->
numOfRes
;
++
j
)
{
colDataAppend
(
pCol
,
j
,
NULL
,
true
);
// TODO add set null data api
}
}
else
{
...
...
@@ -70,6 +68,4 @@ bool isRowEntryCompleted(struct SResultRowEntryInfo* pEntry) {
return
pEntry
->
complete
;
}
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
)
{
return
pEntry
->
initialized
;
}
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
)
{
return
pEntry
->
initialized
;
}
source/libs/function/src/thistogram.c
浏览文件 @
3bda4cf3
...
...
@@ -14,10 +14,10 @@
*/
#include "os.h"
#include "thistogram.h"
#include "taosdef.h"
#include "t
msg
.h"
#include "t
histogram
.h"
#include "tlosertree.h"
#include "tmsg.h"
/**
*
...
...
@@ -54,7 +54,7 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
SHistogramInfo
*
pHisto
=
(
SHistogramInfo
*
)
pBuf
;
pHisto
->
elems
=
(
SHistBin
*
)((
char
*
)
pBuf
+
sizeof
(
SHistogramInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfBins
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBins
;
++
i
)
{
pHisto
->
elems
[
i
].
val
=
-
DBL_MAX
;
}
...
...
@@ -357,7 +357,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto) {
}
void
tHistogramPrint
(
SHistogramInfo
*
pHisto
)
{
printf
(
"total entries: %d, elements: %"
PRId64
"
\n
"
,
pHisto
->
numOfEntries
,
pHisto
->
numOfElems
);
printf
(
"total entries: %d, elements: %"
PRId64
"
\n
"
,
pHisto
->
numOfEntries
,
pHisto
->
numOfElems
);
#if defined(USE_ARRAYLIST)
for
(
int32_t
i
=
0
;
i
<
pHisto
->
numOfEntries
;
++
i
)
{
printf
(
"%d: (%f, %"
PRId64
")
\n
"
,
i
+
1
,
pHisto
->
elems
[
i
].
val
,
pHisto
->
elems
[
i
].
num
);
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
3bda4cf3
...
...
@@ -14,8 +14,8 @@
*/
#include "taoserror.h"
#include "tglobal.h"
#include "tcompare.h"
#include "tglobal.h"
#include "taosdef.h"
#include "tcompare.h"
...
...
@@ -25,21 +25,20 @@
#define DEFAULT_NUM_OF_SLOT 1024
int32_t
getGroupId
(
int32_t
numOfSlots
,
int32_t
slotIndex
,
int32_t
times
)
{
return
(
times
*
numOfSlots
)
+
slotIndex
;
}
int32_t
getGroupId
(
int32_t
numOfSlots
,
int32_t
slotIndex
,
int32_t
times
)
{
return
(
times
*
numOfSlots
)
+
slotIndex
;
}
static
SFilePage
*
loadDataFromFilePage
(
tMemBucket
*
pMemBucket
,
int32_t
slotIdx
)
{
SFilePage
*
buffer
=
(
SFilePage
*
)
taosMemoryCalloc
(
1
,
pMemBucket
->
bytes
*
pMemBucket
->
pSlots
[
slotIdx
].
info
.
size
+
sizeof
(
SFilePage
));
SFilePage
*
buffer
=
(
SFilePage
*
)
taosMemoryCalloc
(
1
,
pMemBucket
->
bytes
*
pMemBucket
->
pSlots
[
slotIdx
].
info
.
size
+
sizeof
(
SFilePage
));
int32_t
groupId
=
getGroupId
(
pMemBucket
->
numOfSlots
,
slotIdx
,
pMemBucket
->
times
);
SArray
*
pIdList
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
SArray
*
pIdList
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pIdList
);
++
i
)
{
int32_t
*
pageId
=
taosArrayGet
(
pIdList
,
i
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pIdList
);
++
i
)
{
int32_t
*
pageId
=
taosArrayGet
(
pIdList
,
i
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
memcpy
(
buffer
->
data
+
offset
,
pg
->
data
,
(
size_t
)(
pg
->
num
*
pMemBucket
->
bytes
));
offset
+=
(
int32_t
)(
pg
->
num
*
pMemBucket
->
bytes
);
...
...
@@ -49,7 +48,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
return
buffer
;
}
static
void
resetBoundingBox
(
MinMaxEntry
*
range
,
int32_t
type
)
{
static
void
resetBoundingBox
(
MinMaxEntry
*
range
,
int32_t
type
)
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
range
->
i64MaxVal
=
INT64_MIN
;
range
->
i64MinVal
=
INT64_MAX
;
...
...
@@ -62,17 +61,17 @@ static void resetBoundingBox(MinMaxEntry* range, int32_t type) {
}
}
static
int32_t
setBoundingBox
(
MinMaxEntry
*
range
,
int16_t
type
,
double
minval
,
double
maxval
)
{
static
int32_t
setBoundingBox
(
MinMaxEntry
*
range
,
int16_t
type
,
double
minval
,
double
maxval
)
{
if
(
minval
>
maxval
)
{
return
-
1
;
}
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
range
->
i64MinVal
=
(
int64_t
)
minval
;
range
->
i64MaxVal
=
(
int64_t
)
maxval
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
)){
range
->
u64MinVal
=
(
uint64_t
)
minval
;
range
->
u64MaxVal
=
(
uint64_t
)
maxval
;
range
->
i64MinVal
=
(
int64_t
)
minval
;
range
->
i64MaxVal
=
(
int64_t
)
maxval
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
range
->
u64MinVal
=
(
uint64_t
)
minval
;
range
->
u64MaxVal
=
(
uint64_t
)
maxval
;
}
else
{
range
->
dMinVal
=
minval
;
range
->
dMaxVal
=
maxval
;
...
...
@@ -81,7 +80,7 @@ static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, d
return
0
;
}
static
void
resetPosInfo
(
SSlotInfo
*
pInfo
)
{
static
void
resetPosInfo
(
SSlotInfo
*
pInfo
)
{
pInfo
->
size
=
0
;
pInfo
->
pageId
=
-
1
;
pInfo
->
data
=
NULL
;
...
...
@@ -97,11 +96,11 @@ double findOnlyResult(tMemBucket *pMemBucket) {
}
int32_t
groupId
=
getGroupId
(
pMemBucket
->
numOfSlots
,
i
,
pMemBucket
->
times
);
SArray
*
list
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
SArray
*
list
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
assert
(
list
->
size
==
1
);
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
assert
(
pPage
->
num
==
1
);
double
v
=
0
;
...
...
@@ -155,7 +154,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) {
uint64_t
span
=
pBucket
->
range
.
u64MaxVal
-
pBucket
->
range
.
u64MinVal
;
if
(
span
<
pBucket
->
numOfSlots
)
{
int64_t
delta
=
v
-
pBucket
->
range
.
u64MinVal
;
index
=
(
int32_t
)
(
delta
%
pBucket
->
numOfSlots
);
index
=
(
int32_t
)(
delta
%
pBucket
->
numOfSlots
);
}
else
{
double
slotSpan
=
(
double
)
span
/
pBucket
->
numOfSlots
;
index
=
(
int32_t
)((
v
-
pBucket
->
range
.
u64MinVal
)
/
slotSpan
);
...
...
@@ -209,9 +208,9 @@ static __perc_hash_func_t getHashFunc(int32_t type) {
}
}
static
void
resetSlotInfo
(
tMemBucket
*
pBucket
)
{
static
void
resetSlotInfo
(
tMemBucket
*
pBucket
)
{
for
(
int32_t
i
=
0
;
i
<
pBucket
->
numOfSlots
;
++
i
)
{
tMemBucketSlot
*
pSlot
=
&
pBucket
->
pSlots
[
i
];
tMemBucketSlot
*
pSlot
=
&
pBucket
->
pSlots
[
i
];
resetBoundingBox
(
&
pSlot
->
range
,
pBucket
->
type
);
resetPosInfo
(
&
pSlot
->
info
);
...
...
@@ -235,17 +234,17 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
pBucket
->
maxCapacity
=
200000
;
pBucket
->
groupPagesMap
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
if
(
setBoundingBox
(
&
pBucket
->
range
,
pBucket
->
type
,
minval
,
maxval
)
!=
0
)
{
// qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval);
// qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval);
taosMemoryFree
(
pBucket
);
return
NULL
;
}
pBucket
->
elemPerPage
=
(
pBucket
->
bufPageSize
-
sizeof
(
SFilePage
))
/
pBucket
->
bytes
;
pBucket
->
elemPerPage
=
(
pBucket
->
bufPageSize
-
sizeof
(
SFilePage
))
/
pBucket
->
bytes
;
pBucket
->
comparFn
=
getKeyComparFunc
(
pBucket
->
type
,
TSDB_ORDER_ASC
);
pBucket
->
hashFunc
=
getHashFunc
(
pBucket
->
type
);
if
(
pBucket
->
hashFunc
==
NULL
)
{
// qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type);
// qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type);
taosMemoryFree
(
pBucket
);
return
NULL
;
}
...
...
@@ -271,7 +270,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
return
NULL
;
}
// qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes);
// qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes);
return
pBucket
;
}
...
...
@@ -280,9 +279,9 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
return
;
}
void
*
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
NULL
);
while
(
p
)
{
SArray
**
p1
=
p
;
void
*
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
NULL
);
while
(
p
)
{
SArray
**
p1
=
p
;
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
p
);
taosArrayDestroy
(
*
p1
);
}
...
...
@@ -341,7 +340,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
int32_t
count
=
0
;
int32_t
bytes
=
pBucket
->
bytes
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
char
*
d
=
(
char
*
)
data
+
i
*
bytes
;
char
*
d
=
(
char
*
)
data
+
i
*
bytes
;
int32_t
index
=
(
pBucket
->
hashFunc
)(
pBucket
,
d
);
if
(
index
<
0
)
{
continue
;
...
...
@@ -365,9 +364,9 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
pSlot
->
info
.
data
=
NULL
;
}
SArray
*
pPageIdList
=
(
SArray
*
)
taosHashGet
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
SArray
*
pPageIdList
=
(
SArray
*
)
taosHashGet
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
if
(
pPageIdList
==
NULL
)
{
SArray
*
pList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
SArray
*
pList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
taosHashPut
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
),
&
pList
,
POINTER_BYTES
);
pPageIdList
=
pList
;
}
...
...
@@ -407,18 +406,18 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3
static
bool
isIdenticalData
(
tMemBucket
*
pMemBucket
,
int32_t
index
);
static
double
getIdenticalDataVal
(
tMemBucket
*
pMemBucket
,
int32_t
slotIndex
)
{
static
double
getIdenticalDataVal
(
tMemBucket
*
pMemBucket
,
int32_t
slotIndex
)
{
assert
(
isIdenticalData
(
pMemBucket
,
slotIndex
));
tMemBucketSlot
*
pSlot
=
&
pMemBucket
->
pSlots
[
slotIndex
];
double
finalResult
=
0
.
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
finalResult
=
(
double
)
pSlot
->
range
.
i64MinVal
;
finalResult
=
(
double
)
pSlot
->
range
.
i64MinVal
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
finalResult
=
(
double
)
pSlot
->
range
.
u64MinVal
;
finalResult
=
(
double
)
pSlot
->
range
.
u64MinVal
;
}
else
{
finalResult
=
(
double
)
pSlot
->
range
.
dMinVal
;
finalResult
=
(
double
)
pSlot
->
range
.
dMinVal
;
}
return
finalResult
;
...
...
@@ -445,14 +444,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
double
maxOfThisSlot
=
0
;
double
minOfNextSlot
=
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
i64MaxVal
;
minOfNextSlot
=
(
double
)
next
.
i64MinVal
;
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
i64MaxVal
;
minOfNextSlot
=
(
double
)
next
.
i64MinVal
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
u64MaxVal
;
minOfNextSlot
=
(
double
)
next
.
u64MinVal
;
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
u64MaxVal
;
minOfNextSlot
=
(
double
)
next
.
u64MinVal
;
}
else
{
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
dMaxVal
;
minOfNextSlot
=
(
double
)
next
.
dMinVal
;
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
dMaxVal
;
minOfNextSlot
=
(
double
)
next
.
dMinVal
;
}
assert
(
minOfNextSlot
>
maxOfThisSlot
);
...
...
@@ -484,7 +483,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
// try next round
pMemBucket
->
times
+=
1
;
// qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times);
// qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times);
pMemBucket
->
range
=
pSlot
->
range
;
pMemBucket
->
total
=
0
;
...
...
@@ -527,7 +526,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
// find the min/max value, no need to scan all data in bucket
if
(
fabs
(
percent
-
100
.
0
)
<
DBL_EPSILON
||
(
percent
<
DBL_EPSILON
))
{
MinMaxEntry
*
pRange
=
&
pMemBucket
->
range
;
MinMaxEntry
*
pRange
=
&
pMemBucket
->
range
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
i64MaxVal
:
pRange
->
i64MinVal
);
...
...
@@ -536,7 +535,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
u64MaxVal
:
pRange
->
u64MinVal
);
return
v
;
}
else
{
return
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
dMaxVal
:
pRange
->
dMinVal
;
return
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
dMaxVal
:
pRange
->
dMinVal
;
}
}
...
...
source/libs/function/src/tscript.c
浏览文件 @
3bda4cf3
...
...
@@ -13,10 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tscript.h"
#include "
ttype
s.h"
#include "
o
s.h"
#include "tstrbuild.h"
#include "ttypes.h"
//#include "queryLog.h"
#include "ttokendef.h"
#if 0
...
...
source/libs/function/src/tudf.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/function/test/runUdf.c
浏览文件 @
3bda4cf3
...
...
@@ -53,7 +53,7 @@ int scalarFuncTest() {
blockDataEnsureCapacity
(
pBlock
,
1024
);
pBlock
->
info
.
rows
=
1024
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
colDataAppendInt32
(
pCol
,
j
,
&
j
);
}
...
...
@@ -68,14 +68,13 @@ int scalarFuncTest() {
SColumnInfoData
*
col
=
output
.
columnData
;
for
(
int32_t
i
=
0
;
i
<
output
.
numOfRows
;
++
i
)
{
if
(
i
%
100
==
0
)
fprintf
(
stderr
,
"%d
\t
%d
\n
"
,
i
,
*
(
int32_t
*
)(
col
->
pData
+
i
*
sizeof
(
int32_t
)));
if
(
i
%
100
==
0
)
fprintf
(
stderr
,
"%d
\t
%d
\n
"
,
i
,
*
(
int32_t
*
)(
col
->
pData
+
i
*
sizeof
(
int32_t
)));
}
colDataDestroy
(
output
.
columnData
);
taosMemoryFree
(
output
.
columnData
);
}
int64_t
end
=
taosGetTimestampUs
();
fprintf
(
stderr
,
"time: %f
\n
"
,
(
end
-
beg
)
/
1000
.
0
);
fprintf
(
stderr
,
"time: %f
\n
"
,
(
end
-
beg
)
/
1000
.
0
);
doTeardownUdf
(
handle
);
return
0
;
...
...
@@ -98,7 +97,7 @@ int aggregateFuncTest() {
blockDataEnsureCapacity
(
pBlock
,
1024
);
pBlock
->
info
.
rows
=
1024
;
SColumnInfoData
*
pColInfo
=
bdGetColumnInfoData
(
pBlock
,
0
);
SColumnInfoData
*
pColInfo
=
bdGetColumnInfoData
(
pBlock
,
0
);
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
colDataAppendInt32
(
pColInfo
,
j
,
&
j
);
}
...
...
@@ -111,7 +110,7 @@ int aggregateFuncTest() {
taosArrayDestroy
(
pBlock
->
pDataBlock
);
doCallUdfAggFinalize
(
handle
,
&
newBuf
,
&
resultBuf
);
fprintf
(
stderr
,
"agg result: %f
\n
"
,
*
(
double
*
)
resultBuf
.
buf
);
fprintf
(
stderr
,
"agg result: %f
\n
"
,
*
(
double
*
)
resultBuf
.
buf
);
freeUdfInterBuf
(
&
buf
);
freeUdfInterBuf
(
&
newBuf
);
...
...
source/libs/function/test/udf1.c
浏览文件 @
3bda4cf3
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef LINUX
#include <unistd.h>
#endif
...
...
@@ -9,16 +9,11 @@
#endif
#include "taosudf.h"
DLL_EXPORT
int32_t
udf1_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
DLL_EXPORT
int32_t
udf1
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
SUdfColumnMeta
*
meta
=
&
resultCol
->
colMeta
;
meta
->
bytes
=
4
;
meta
->
type
=
TSDB_DATA_TYPE_INT
;
...
...
@@ -35,12 +30,12 @@ DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) {
break
;
}
}
if
(
j
==
block
->
numOfCols
)
{
if
(
j
==
block
->
numOfCols
)
{
int32_t
luckyNum
=
88
;
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
luckyNum
,
false
);
}
}
//to simulate actual processing delay by udf
//
to simulate actual processing delay by udf
#ifdef LINUX
usleep
(
1
*
1000
);
// usleep takes sleep time in us (1 millionth of a second)
#endif
...
...
source/libs/function/test/udf2.c
浏览文件 @
3bda4cf3
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "taosudf.h"
DLL_EXPORT
int32_t
udf2_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf2_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf2_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf2_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf2_start
(
SUdfInterBuf
*
buf
)
{
DLL_EXPORT
int32_t
udf2_start
(
SUdfInterBuf
*
buf
)
{
*
(
int64_t
*
)(
buf
->
buf
)
=
0
;
buf
->
bufLen
=
sizeof
(
double
);
buf
->
numOfResult
=
0
;
return
0
;
}
DLL_EXPORT
int32_t
udf2
(
SUdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
newInterBuf
)
{
DLL_EXPORT
int32_t
udf2
(
SUdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
newInterBuf
)
{
double
sumSquares
=
*
(
double
*
)
interBuf
->
buf
;
int8_t
numNotNull
=
0
;
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
||
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_DOUBLE
))
{
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
||
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_DOUBLE
))
{
return
TSDB_CODE_UDF_INVALID_INPUT
;
}
}
...
...
@@ -67,7 +62,7 @@ DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterB
return
0
;
}
DLL_EXPORT
int32_t
udf2_finish
(
SUdfInterBuf
*
buf
,
SUdfInterBuf
*
resultData
)
{
DLL_EXPORT
int32_t
udf2_finish
(
SUdfInterBuf
*
buf
,
SUdfInterBuf
*
resultData
)
{
if
(
buf
->
numOfResult
==
0
)
{
resultData
->
numOfResult
=
0
;
return
0
;
...
...
source/libs/index/test/index_executor_tests.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/monitor/src/monMain.c
浏览文件 @
3bda4cf3
source/libs/parser/inc/parInsertData.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qcom/inc/queryInt.h
浏览文件 @
3bda4cf3
...
...
@@ -20,7 +20,6 @@
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qcom/test/queryTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/inc/qwInt.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/inc/qwMsg.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/src/qwDbg.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/src/qwMsg.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/src/qwUtil.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/src/qworker.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/inc/filterInt.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/inc/sclInt.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/inc/sclvector.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/src/filter.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/src/scalar.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclfunc.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclvector.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/stream/src/streamUpdate.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/stream/test/tstreamUpdateTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncIO.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncRaftStore.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncVoteMgr.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/src/syncIO.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftStore.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/src/syncSnapshot.c
浏览文件 @
3bda4cf3
source/libs/sync/src/syncVoteMgr.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncAppendEntriesReplyTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncAppendEntriesTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncApplyMsgTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncClientRequestBatchTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncClientRequestTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncEncodeTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncHeartbeatReplyTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncHeartbeatTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIndexTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncLeaderTransferTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncPingReplyTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncPingTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftCfgIndexTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncReconfigFinishTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRefTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRequestVoteReplyTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRequestVoteTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncSnapshotRspTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncSnapshotSendTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTimeoutTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/tfs/inc/tfsInt.h
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/tfs/src/tfs.c
浏览文件 @
3bda4cf3
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/transport/test/transUT.cpp
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
source/libs/transport/test/uv.c
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
tools/scripts/codeFormat.py
0 → 100644
浏览文件 @
3bda4cf3
tools/scripts/codeFormat.sh
浏览文件 @
3bda4cf3
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录