Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
6e70d237
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6e70d237
编写于
3月 26, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '2.0' into refact/slguan
上级
6f65c5a9
6d8641f3
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
322 addition
and
339 deletion
+322
-339
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+0
-11
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+14
-8
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-8
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-6
src/client/src/tscStream.c
src/client/src/tscStream.c
+0
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+4
-20
src/dnode/src/dnodeRead.c
src/dnode/src/dnodeRead.c
+52
-29
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+17
-11
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+187
-218
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+15
-7
src/vnode/detail/src/vnodeQueryImpl.c
src/vnode/detail/src/vnodeQueryImpl.c
+2
-2
src/vnode/detail/src/vnodeQueryProcess.c
src/vnode/detail/src/vnodeQueryProcess.c
+12
-12
src/vnode/tsdb/src/tsdbRead.c
src/vnode/tsdb/src/tsdbRead.c
+13
-6
tests/examples/c/demo.c
tests/examples/c/demo.c
+3
-0
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
6e70d237
...
...
@@ -1238,22 +1238,11 @@ int doParseInsertSql(SSqlObj *pSql, char *str) {
goto
_clean
;
}
// submit to more than one vnode
if
(
pCmd
->
pDataBlocks
->
nSize
>
0
)
{
// merge according to vgId
if
((
code
=
tscMergeTableDataBlocks
(
pSql
,
pCmd
->
pDataBlocks
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
}
STableDataBlocks
*
pDataBlock
=
pCmd
->
pDataBlocks
->
pData
[
0
];
if
((
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlock
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_error_clean
;
}
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
// set the next sent data vnode index in data block arraylist
pTableMetaInfo
->
vnodeIndex
=
1
;
}
else
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
6e70d237
...
...
@@ -1489,11 +1489,9 @@ static int32_t setExprInfoForFunctions(SQueryInfo* pQueryInfo, SSchema* pSchema,
SSqlExpr
*
pExpr
=
tscSqlExprInsert
(
pQueryInfo
,
resColIdx
,
functionID
,
pColIndex
,
type
,
bytes
,
bytes
);
strncpy
(
pExpr
->
aliasName
,
columnName
,
tListLen
(
pExpr
->
aliasName
));
// for
point interpolation/last_row query, we need the timestamp column
to be loaded
// for
all querie, the timestamp column meeds
to be loaded
SColumnIndex
index
=
{.
tableIndex
=
pColIndex
->
tableIndex
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
if
(
functionID
==
TSDB_FUNC_INTERP
||
functionID
==
TSDB_FUNC_LAST_ROW
)
{
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
index
);
}
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
index
);
SColumnList
ids
=
getColumnList
(
1
,
pColIndex
->
tableIndex
,
pColIndex
->
columnIndex
);
insertResultField
(
pQueryInfo
,
resColIdx
,
&
ids
,
bytes
,
type
,
columnName
,
pExpr
);
...
...
@@ -1581,7 +1579,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
(
ids
.
ids
[
i
]));
}
}
SColumnIndex
tsCol
=
{.
tableIndex
=
index
.
tableIndex
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
tsCol
);
return
TSDB_CODE_SUCCESS
;
}
case
TK_SUM
:
...
...
@@ -1689,7 +1690,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
(
ids
.
ids
[
i
]));
}
}
SColumnIndex
tsCol
=
{.
tableIndex
=
index
.
tableIndex
,
.
columnIndex
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
tscColumnBaseInfoInsert
(
pQueryInfo
,
&
tsCol
);
return
TSDB_CODE_SUCCESS
;
}
case
TK_FIRST
:
...
...
@@ -1708,7 +1712,6 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
/* in first/last function, multiple columns can be add to resultset */
for
(
int32_t
i
=
0
;
i
<
pItem
->
pNode
->
pParam
->
nExpr
;
++
i
)
{
tSQLExprItem
*
pParamElem
=
&
(
pItem
->
pNode
->
pParam
->
a
[
i
]);
if
(
pParamElem
->
pNode
->
nSQLOptr
!=
TK_ALL
&&
pParamElem
->
pNode
->
nSQLOptr
!=
TK_ID
)
{
...
...
@@ -1753,7 +1756,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
}
}
}
return
TSDB_CODE_SUCCESS
;
}
else
{
// select * from xxx
int32_t
numOfFields
=
0
;
...
...
@@ -1773,6 +1776,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
numOfFields
+=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
}
return
TSDB_CODE_SUCCESS
;
}
}
...
...
@@ -1891,6 +1895,8 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIdx, tSQLExprIt
default:
return
TSDB_CODE_INVALID_SQL
;
}
}
// todo refactor
...
...
src/client/src/tscServer.c
浏览文件 @
6e70d237
...
...
@@ -341,14 +341,8 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
(
*
pSql
->
fp
)(
pSql
->
param
,
taosres
,
rpcMsg
->
code
);
if
(
shouldFree
)
{
// If it is failed, all objects allocated during execution taos_connect_a should be released
if
(
command
==
TSDB_SQL_CONNECT
)
{
taos_close
(
pObj
);
tscTrace
(
"%p Async sql close failed connection"
,
pSql
);
}
else
{
tscFreeSqlObj
(
pSql
);
tscTrace
(
"%p Async sql is automatically freed"
,
pSql
);
}
tscFreeSqlObj
(
pSql
);
tscTrace
(
"%p Async sql is automatically freed"
,
pSql
);
}
}
...
...
src/client/src/tscSql.c
浏览文件 @
6e70d237
...
...
@@ -594,11 +594,7 @@ static void **tscBuildResFromSubqueries(SSqlObj *pSql) {
}
if
(
numOfTableHasRes
>=
2
)
{
// do merge result
success
=
(
doSetResultRowData
(
pSql
->
pSubs
[
0
])
!=
NULL
)
&&
(
doSetResultRowData
(
pSql
->
pSubs
[
1
])
!=
NULL
);
// TSKEY key1 = *(TSKEY *)pRes1->tsrow[0];
// TSKEY key2 = *(TSKEY *)pRes2->tsrow[0];
// printf("first:%" PRId64 ", second:%" PRId64 "\n", key1, key2);
}
else
{
// only one subquery
SSqlObj
*
pSub
=
pSql
->
pSubs
[
0
];
if
(
pSub
==
NULL
)
{
...
...
@@ -674,14 +670,13 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pRes
->
qhandle
==
0
||
pRes
->
completed
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pCmd
->
command
==
TSDB_SQL_INSERT
)
{
return
NULL
;
}
// current data are exhausted, fetch more data
if
(
pRes
->
data
==
NULL
||
(
pRes
->
data
!=
NULL
&&
pRes
->
row
>=
pRes
->
numOfRows
&&
if
(
pRes
->
data
==
NULL
||
(
pRes
->
data
!=
NULL
&&
pRes
->
row
>=
pRes
->
numOfRows
&&
pRes
->
completed
!=
true
&&
(
pCmd
->
command
==
TSDB_SQL_RETRIEVE
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE_METRIC
||
pCmd
->
command
==
TSDB_SQL_FETCH
)))
{
taos_fetch_rows_a
(
res
,
asyncFetchCallback
,
pSql
->
pTscObj
);
...
...
src/client/src/tscStream.c
浏览文件 @
6e70d237
...
...
@@ -504,7 +504,6 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
}
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
tsem_init
(
&
pSql
->
emptyRspSem
,
0
,
1
);
SSqlInfo
SQLInfo
=
{
0
};
tSQLParse
(
&
SQLInfo
,
pSql
->
sqlstr
);
...
...
src/client/src/tscUtil.c
浏览文件 @
6e70d237
...
...
@@ -423,9 +423,6 @@ void tscFreeResData(SSqlObj* pSql) {
}
void
tscFreeSqlResult
(
SSqlObj
*
pSql
)
{
//TODO not free
return
;
tfree
(
pSql
->
res
.
pRsp
);
pSql
->
res
.
row
=
0
;
pSql
->
res
.
numOfRows
=
0
;
...
...
@@ -469,8 +466,6 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) {
tscFreeSqlCmdData
(
pCmd
);
tscTrace
(
"%p free sqlObj partial completed"
,
pSql
);
tscFreeSqlCmdData
(
pCmd
);
}
void
tscFreeSqlObj
(
SSqlObj
*
pSql
)
{
...
...
@@ -489,10 +484,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
pCmd
->
allocSize
=
0
;
if
(
pSql
->
fp
==
NULL
)
{
tsem_destroy
(
&
pSql
->
rspSem
);
tsem_destroy
(
&
pSql
->
emptyRspSem
);
}
tsem_destroy
(
&
pSql
->
rspSem
);
free
(
pSql
);
}
...
...
@@ -721,7 +713,7 @@ static void trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock) {
char
*
p
=
pTableDataBlock
->
pData
+
sizeof
(
SSubmitBlk
);
SSubmitBlk
*
pBlock
=
pTableDataBlock
->
pData
;
SSubmitBlk
*
pBlock
=
(
SSubmitBlk
*
)
pTableDataBlock
->
pData
;
int32_t
rows
=
htons
(
pBlock
->
numOfRows
);
for
(
int32_t
i
=
0
;
i
<
rows
;
++
i
)
{
...
...
@@ -1751,16 +1743,8 @@ bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql) {
}
int32_t
command
=
pSql
->
cmd
.
command
;
if
(
pTscObj
->
pSql
==
pSql
)
{
/*
* in case of taos_connect_a query, the object should all be released, even it is the
* master sql object. Otherwise, the master sql should not be released
*/
if
(
command
==
TSDB_SQL_CONNECT
&&
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
return
true
;
}
return
false
;
if
(
command
==
TSDB_SQL_CONNECT
)
{
return
true
;
}
if
(
command
==
TSDB_SQL_INSERT
)
{
...
...
src/dnode/src/dnodeRead.c
浏览文件 @
6e70d237
...
...
@@ -176,10 +176,10 @@ static void *dnodeProcessReadQueue(void *param) {
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
}
dnodeProcessReadResult
(
pVnode
,
pReadMsg
);
//
dnodeProcessReadResult(pVnode, pReadMsg);
taosFreeQitem
(
pReadMsg
);
dnodeReleaseVnode
(
pVnode
);
dnodeReleaseVnode
(
pVnode
);
}
return
NULL
;
...
...
@@ -220,7 +220,7 @@ static void dnodeProcessReadResult(void *pVnode, SReadMsg *pRead) {
code
=
terrno
;
}
//TODO: query handle is returned by dnodeProcessQueryMsg
//TODO: query handle is returned by dnodeProcessQueryMsg
if
(
0
)
{
SRpcMsg
rsp
;
rsp
.
handle
=
pRead
->
rpcMsg
.
handle
;
...
...
@@ -232,47 +232,67 @@ static void dnodeProcessReadResult(void *pVnode, SReadMsg *pRead) {
rpcFreeCont
(
pRead
->
rpcMsg
.
pCont
);
// free the received message
}
static
void
dnodeContinueExecuteQuery
(
void
*
pVnode
,
void
*
qhandle
,
SReadMsg
*
pMsg
)
{
SReadMsg
*
pRead
=
(
SReadMsg
*
)
taosAllocateQitem
(
sizeof
(
SReadMsg
));
pRead
->
rpcMsg
=
pMsg
->
rpcMsg
;
pRead
->
pCont
=
qhandle
;
pRead
->
contLen
=
0
;
pRead
->
pRpcContext
=
pMsg
->
pRpcContext
;
pRead
->
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_QUERY
;
taos_queue
queue
=
dnodeGetVnodeRworker
(
pVnode
);
taosWriteQitem
(
queue
,
TAOS_QTYPE_RPC
,
pRead
);
// SReadMsg readMsg = {
// .rpcMsg = {0},
// .pCont = qhandle,
// .contLen = 0,
// .pRpcContext = pMsg->pRpcContext,
// };
//
// taos_queue queue = dnodeGetVnodeRworker(pVnode);
// taosWriteQitem(queue, TSDB_MSG_TYPE_QUERY, &readMsg);
}
static
void
dnodeProcessQueryMsg
(
void
*
pVnode
,
SReadMsg
*
pMsg
)
{
SQueryTableMsg
*
pQueryTableMsg
=
(
SQueryTableMsg
*
)
pMsg
->
pCont
;
SQInfo
*
pQInfo
=
NULL
;
void
*
tsdb
=
dnodeGetVnodeTsdb
(
pVnode
);
int32_t
code
=
qCreateQueryInfo
(
tsdb
,
pQueryTableMsg
,
&
pQInfo
);
if
(
pMsg
->
contLen
!=
0
)
{
void
*
tsdb
=
dnodeGetVnodeTsdb
(
pVnode
);
int32_t
code
=
qCreateQueryInfo
(
tsdb
,
pQueryTableMsg
,
NULL
,
&
pQInfo
);
SQueryTableRsp
*
pRsp
=
(
SQueryTableRsp
*
)
rpcMallocCont
(
sizeof
(
SQueryTableRsp
));
pRsp
->
code
=
code
;
pRsp
->
qhandle
=
htobe64
((
uint64_t
)
(
pQInfo
));
SRpcMsg
rpcRsp
=
{
.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
pRsp
,
.
contLen
=
sizeof
(
SQueryTableRsp
),
.
code
=
code
,
.
msgType
=
0
};
SQueryTableRsp
*
pRsp
=
(
SQueryTableRsp
*
)
rpcMallocCont
(
sizeof
(
SQueryTableRsp
));
pRsp
->
code
=
code
;
pRsp
->
qhandle
=
htobe64
((
uint64_t
)
(
pQInfo
));
rpcSendResponse
(
&
rpcRsp
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
pRsp
,
.
contLen
=
sizeof
(
SQueryTableRsp
),
.
code
=
code
,
.
msgType
=
0
};
// do execute query
qTableQuery
(
pQInfo
);
rpcSendResponse
(
&
rpcRsp
);
}
else
{
pQInfo
=
pMsg
->
pCont
;
}
qTableQuery
(
pQInfo
);
// do execute query
}
static
int32_t
c
=
0
;
static
void
dnodeProcessRetrieveMsg
(
void
*
pVnode
,
SReadMsg
*
pMsg
)
{
SRetrieveTableMsg
*
pRetrieve
=
pMsg
->
pCont
;
void
*
pQInfo
=
(
void
*
)
htobe64
(
pRetrieve
->
qhandle
);
dTrace
(
"QInfo:%p vgId:%d, retrieve msg is received"
,
pQInfo
,
pRetrieve
->
header
.
vgId
);
if
((
++
c
)
%
2
==
0
)
{
int32_t
k
=
1
;
}
int32_t
rowSize
=
0
;
int32_t
numOfRows
=
0
;
int32_t
contLen
=
0
;
SRetrieveTableRsp
*
pRsp
=
NULL
;
int32_t
code
=
qRetrieveQueryResultInfo
(
pQInfo
,
&
numOfRows
,
&
rowSize
);
int32_t
code
=
qRetrieveQueryResultInfo
(
pQInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
contLen
=
sizeof
(
SRetrieveTableRsp
);
...
...
@@ -281,6 +301,12 @@ static void dnodeProcessRetrieveMsg(void *pVnode, SReadMsg *pMsg) {
}
else
{
// todo check code and handle error in build result set
code
=
qDumpRetrieveResult
(
pQInfo
,
&
pRsp
,
&
contLen
);
if
(
qHasMoreResultsToRetrieve
(
pQInfo
))
{
dnodeContinueExecuteQuery
(
pVnode
,
pQInfo
,
pMsg
);
}
else
{
// no further execution invoked, release the ref to vnode
dnodeProcessReadResult
(
pVnode
,
pMsg
);
}
}
SRpcMsg
rpcRsp
=
(
SRpcMsg
)
{
...
...
@@ -292,7 +318,4 @@ static void dnodeProcessRetrieveMsg(void *pVnode, SReadMsg *pMsg) {
};
rpcSendResponse
(
&
rpcRsp
);
//todo merge result should be done here
//dnodeProcessReadResult(&readMsg);
}
src/query/inc/queryExecutor.h
浏览文件 @
6e70d237
...
...
@@ -68,8 +68,10 @@ typedef struct SWindowResult {
}
SWindowResult
;
typedef
struct
SResultRec
{
int64_t
pointsTotal
;
int64_t
pointsRead
;
int64_t
total
;
int64_t
size
;
int64_t
capacity
;
int32_t
threshold
;
// the threshold size, when the number of rows in result buffer, return to client
}
SResultRec
;
typedef
struct
SWindowResInfo
{
...
...
@@ -112,7 +114,7 @@ typedef struct STableQueryInfo {
typedef
struct
STableDataInfo
{
int32_t
numOfBlocks
;
int32_t
start
;
// start block index
int32_t
start
;
// start block index
int32_t
tableIndex
;
void
*
pMeterObj
;
int32_t
groupIdx
;
// group id in table list
...
...
@@ -143,7 +145,6 @@ typedef struct SQuery {
int32_t
pos
;
int64_t
pointsOffset
;
// the number of points offset to save read data
SData
**
sdata
;
int32_t
capacity
;
SSingleColumnFilterInfo
*
pFilterInfo
;
}
SQuery
;
...
...
@@ -171,15 +172,13 @@ typedef struct SQueryRuntimeEnv {
typedef
struct
SQInfo
{
void
*
signature
;
void
*
pVnode
;
// void* param; // pointer to the RpcReadMsg
TSKEY
startTime
;
TSKEY
elapsedTime
;
SResultRec
rec
;
int32_t
pointsInterpo
;
int32_t
code
;
// error code to returned to client
// int32_t killed; // denotes if current query is killed
int32_t
code
;
// error code to returned to client
sem_t
dataReady
;
SArray
*
pTableIdList
;
// table list
SArray
*
pTableIdList
;
// table
id
list
SQueryRuntimeEnv
runtimeEnv
;
int32_t
subgroupIdx
;
int32_t
offset
;
/* offset in group result set of subgroup */
...
...
@@ -204,7 +203,7 @@ typedef struct SQInfo {
* @param pQInfo
* @return
*/
int32_t
qCreateQueryInfo
(
void
*
pVnode
,
SQueryTableMsg
*
pQueryTableMsg
,
SQInfo
**
pQInfo
);
int32_t
qCreateQueryInfo
(
void
*
pVnode
,
SQueryTableMsg
*
pQueryTableMsg
,
void
*
param
,
SQInfo
**
pQInfo
);
/**
* query on single table
...
...
@@ -222,7 +221,7 @@ void qSuperTableQuery(void* pReadMsg);
* wait for the query completed, and retrieve final results to client
* @param pQInfo
*/
int32_t
qRetrieveQueryResultInfo
(
SQInfo
*
pQInfo
,
int32_t
*
numOfRows
,
int32_t
*
rowsize
);
int32_t
qRetrieveQueryResultInfo
(
SQInfo
*
pQInfo
);
/**
*
...
...
@@ -232,4 +231,11 @@ int32_t qRetrieveQueryResultInfo(SQInfo* pQInfo, int32_t *numOfRows, int32_t* ro
*/
int32_t
qDumpRetrieveResult
(
SQInfo
*
pQInfo
,
SRetrieveTableRsp
**
pRsp
,
int32_t
*
contLen
);
/**
*
* @param pQInfo
* @return
*/
bool
qHasMoreResultsToRetrieve
(
SQInfo
*
pQInfo
);
#endif // TDENGINE_QUERYEXECUTOR_H
src/query/src/queryExecutor.c
浏览文件 @
6e70d237
此差异已折叠。
点击以展开。
src/rpc/src/rpcMain.c
浏览文件 @
6e70d237
...
...
@@ -32,6 +32,7 @@
#include "rpcServer.h"
#include "rpcHead.h"
#include "trpc.h"
#include "hash.h"
#define RPC_MSG_OVERHEAD (sizeof(SRpcReqContext) + sizeof(SRpcHead) + sizeof(SRpcDigest))
#define rpcHeadFromCont(cont) ((SRpcHead *) (cont - sizeof(SRpcHead)))
...
...
@@ -258,7 +259,8 @@ void *rpcOpen(SRpcInit *pInit) {
}
if
(
pRpc
->
connType
==
TAOS_CONN_SERVER
)
{
pRpc
->
hash
=
taosInitStrHash
(
pRpc
->
sessions
,
sizeof
(
pRpc
),
taosHashString
);
// pRpc->hash = taosInitStrHash(pRpc->sessions, sizeof(pRpc), taosHashString);
pRpc
->
hash
=
taosHashInit
(
pRpc
->
sessions
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
);
if
(
pRpc
->
hash
==
NULL
)
{
tError
(
"%s failed to init string hash"
,
pRpc
->
label
);
rpcClose
(
pRpc
);
...
...
@@ -292,7 +294,8 @@ void rpcClose(void *param) {
}
}
taosCleanUpStrHash
(
pRpc
->
hash
);
// taosCleanUpStrHash(pRpc->hash);
taosHashCleanup
(
pRpc
->
hash
);
taosTmrCleanUp
(
pRpc
->
tmrCtrl
);
taosIdPoolCleanUp
(
pRpc
->
idPool
);
rpcCloseConnCache
(
pRpc
->
pCache
);
...
...
@@ -507,8 +510,10 @@ static void rpcCloseConn(void *thandle) {
if
(
pRpc
->
connType
==
TAOS_CONN_SERVER
)
{
char
hashstr
[
40
]
=
{
0
};
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
linkUid
,
pConn
->
peerId
,
pConn
->
connType
);
taosDeleteStrHash
(
pRpc
->
hash
,
hashstr
);
size_t
size
=
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
linkUid
,
pConn
->
peerId
,
pConn
->
connType
);
// taosDeleteStrHash(pRpc->hash, hashstr);
// taosHashRemove(pRpc->hash, hashstr, size);
rpcFreeMsg
(
pConn
->
pRspMsg
);
// it may have a response msg saved, but not request msg
pConn
->
pRspMsg
=
NULL
;
pConn
->
inType
=
0
;
...
...
@@ -556,10 +561,11 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
char
hashstr
[
40
]
=
{
0
};
SRpcHead
*
pHead
=
(
SRpcHead
*
)
pRecv
->
msg
;
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
linkUid
,
pHead
->
sourceId
,
pRecv
->
connType
);
s
ize_t
size
=
s
printf
(
hashstr
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
linkUid
,
pHead
->
sourceId
,
pRecv
->
connType
);
// check if it is already allocated
SRpcConn
**
ppConn
=
(
SRpcConn
**
)(
taosGetStrHashData
(
pRpc
->
hash
,
hashstr
));
// SRpcConn **ppConn = (SRpcConn **)(taosGetStrHashData(pRpc->hash, hashstr));
SRpcConn
**
ppConn
=
(
SRpcConn
**
)(
taosHashGet
(
pRpc
->
hash
,
hashstr
,
size
));
if
(
ppConn
)
pConn
=
*
ppConn
;
if
(
pConn
)
return
pConn
;
...
...
@@ -591,7 +597,9 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn
->
localPort
=
(
pRpc
->
localPort
+
pRpc
->
index
);
}
taosAddStrHash
(
pRpc
->
hash
,
hashstr
,
(
char
*
)
&
pConn
);
// taosAddStrHash(pRpc->hash, hashstr, (char *)&pConn);
taosHashPut
(
pRpc
->
hash
,
hashstr
,
size
,
(
char
*
)
&
pConn
,
POINTER_BYTES
);
tTrace
(
"%s %p, rpc connection is allocated, sid:%d id:%s port:%u"
,
pRpc
->
label
,
pConn
,
sid
,
pConn
->
user
,
pConn
->
localPort
);
}
...
...
src/vnode/detail/src/vnodeQueryImpl.c
浏览文件 @
6e70d237
...
...
@@ -5312,7 +5312,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
while
(
1
)
{
// check if query is killed or not set the status of query to pass the status check
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
setQueryStatus
(
pQuery
,
QUERY_NO_DATA_TO_CHECK
);
return
cnt
;
}
...
...
@@ -6375,7 +6375,7 @@ void vnodeScanAllData(SQueryRuntimeEnv *pRuntimeEnv) {
pRuntimeEnv
->
scanFlag
=
REPEAT_SCAN
;
/* check if query is killed or not */
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
setQueryStatus
(
pQuery
,
QUERY_NO_DATA_TO_CHECK
);
return
;
}
...
...
src/vnode/detail/src/vnodeQueryProcess.c
浏览文件 @
6e70d237
...
...
@@ -105,7 +105,7 @@ static void queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
int32_t
start
=
pSupporter
->
pSidSet
->
starterPos
[
groupIdx
];
int32_t
end
=
pSupporter
->
pSidSet
->
starterPos
[
groupIdx
+
1
]
-
1
;
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
return
;
}
...
...
@@ -276,7 +276,7 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
int64_t
st
=
taosGetTimestampUs
();
while
(
1
)
{
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
break
;
}
...
...
@@ -363,7 +363,7 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo
int32_t
j
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
0
:
numOfBlocks
-
1
;
for
(;
j
<
numOfBlocks
&&
j
>=
0
;
j
+=
step
)
{
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
break
;
}
...
...
@@ -603,7 +603,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
pSupporter
->
meterIdx
=
start
;
for
(
int32_t
k
=
start
;
k
<=
end
;
++
k
,
pSupporter
->
meterIdx
++
)
{
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
setQueryStatus
(
pQuery
,
QUERY_NO_DATA_TO_CHECK
);
return
;
}
...
...
@@ -630,7 +630,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
pSupporter
->
subgroupIdx
);
for
(
int32_t
k
=
start
;
k
<=
end
;
++
k
)
{
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
setQueryStatus
(
pQuery
,
QUERY_NO_DATA_TO_CHECK
);
return
;
}
...
...
@@ -681,7 +681,7 @@ static void vnodeSTableSeqProcessor(SQInfo *pQInfo) {
while
(
pSupporter
->
meterIdx
<
pSupporter
->
numOfMeters
)
{
int32_t
k
=
pSupporter
->
meterIdx
;
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
setQueryStatus
(
pQuery
,
QUERY_NO_DATA_TO_CHECK
);
return
;
}
...
...
@@ -958,7 +958,7 @@ static void vnodeMultiMeterQueryProcessor(SQInfo *pQInfo) {
doMultiMeterSupplementaryScan
(
pQInfo
);
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
dTrace
(
"QInfo:%p query killed, abort"
,
pQInfo
);
return
;
}
...
...
@@ -998,7 +998,7 @@ static void vnodeSingleTableFixedOutputProcessor(SQInfo *pQInfo) {
vnodeScanAllData
(
pRuntimeEnv
);
doFinalizeResult
(
pRuntimeEnv
);
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
return
;
}
...
...
@@ -1033,7 +1033,7 @@ static void vnodeSingleTableMultiOutputProcessor(SQInfo *pQInfo) {
vnodeScanAllData
(
pRuntimeEnv
);
doFinalizeResult
(
pRuntimeEnv
);
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
return
;
}
...
...
@@ -1087,7 +1087,7 @@ static void vnodeSingleMeterIntervalMainLooper(STableQuerySupportObj *pSupporter
initCtxOutputBuf
(
pRuntimeEnv
);
vnodeScanAllData
(
pRuntimeEnv
);
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
return
;
}
...
...
@@ -1301,7 +1301,7 @@ void vnodeSingleTableQuery(SSchedMsg *pMsg) {
pQInfo
->
useconds
+=
(
taosGetTimestampUs
()
-
st
);
/* check if query is killed or not */
if
(
isQueryKilled
(
pQ
uery
))
{
if
(
isQueryKilled
(
pQ
Info
))
{
dTrace
(
"QInfo:%p query is killed"
,
pQInfo
);
pQInfo
->
over
=
1
;
}
else
{
...
...
@@ -1345,7 +1345,7 @@ void vnodeMultiMeterQuery(SSchedMsg *pMsg) {
/* record the total elapsed time */
pQInfo
->
useconds
+=
(
taosGetTimestampUs
()
-
st
);
pQInfo
->
over
=
isQueryKilled
(
pQ
uery
)
?
1
:
0
;
pQInfo
->
over
=
isQueryKilled
(
pQ
Info
)
?
1
:
0
;
taosInterpoSetStartInfo
(
&
pQInfo
->
pTableQuerySupporter
->
runtimeEnv
.
interpoInfo
,
pQuery
->
pointsRead
,
pQInfo
->
query
.
interpoType
);
...
...
src/vnode/tsdb/src/tsdbRead.c
浏览文件 @
6e70d237
...
...
@@ -124,6 +124,7 @@ typedef struct STsdbQueryHandle {
int32_t
tableIndex
;
bool
isFirstSlot
;
void
*
qinfo
;
// query info handle, for debug purpose
SSkipListIterator
*
memIter
;
}
STsdbQueryHandle
;
int32_t
doAllocateBuf
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
rowsPerFileBlock
)
{
...
...
@@ -335,7 +336,6 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
if
(
dataRowKey
(
row
)
>
maxKey
)
break
;
// Convert row data to column data
if
(
*
skey
==
INT64_MIN
)
{
*
skey
=
dataRowKey
(
row
);
...
...
@@ -345,13 +345,13 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoEx
*
pColInfo
=
taosArrayGet
(
pHandle
->
pColumns
,
0
);
SColumnInfoEx
*
pColInfo
=
taosArrayGet
(
pHandle
->
pColumns
,
i
);
memcpy
(
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
,
dataRowTuple
(
row
)
+
offset
,
pColInfo
->
info
.
bytes
);
offset
+=
pColInfo
->
info
.
bytes
;
}
numOfRows
++
;
if
(
numOfRows
>
maxRowsToRead
)
break
;
if
(
numOfRows
>
=
maxRowsToRead
)
break
;
};
return
numOfRows
;
...
...
@@ -368,8 +368,13 @@ SDataBlockInfo tsdbRetrieveDataBlockInfo(tsdb_query_handle_t *pQueryHandle) {
int32_t
rows
=
0
;
if
(
pTable
->
mem
!=
NULL
)
{
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pTable
->
mem
->
pData
);
rows
=
tsdbReadRowsFromCache
(
iter
,
INT64_MAX
,
4000
,
&
skey
,
&
ekey
,
pHandle
);
// create mem table iterator if it is not created yet
if
(
pHandle
->
memIter
==
NULL
)
{
pHandle
->
memIter
=
tSkipListCreateIter
(
pTable
->
mem
->
pData
);
}
rows
=
tsdbReadRowsFromCache
(
pHandle
->
memIter
,
INT64_MAX
,
2
,
&
skey
,
&
ekey
,
pHandle
);
}
SDataBlockInfo
blockInfo
=
{
...
...
@@ -392,7 +397,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdb_query_handle_t *pQueryHandle, SData
}
SArray
*
tsdbRetrieveDataBlock
(
tsdb_query_handle_t
*
pQueryHandle
,
SArray
*
pIdList
)
{
// in case of data in cache, all data has been kept in column info object.
STsdbQueryHandle
*
pHandle
=
(
STsdbQueryHandle
*
)
pQueryHandle
;
return
pHandle
->
pColumns
;
}
int32_t
tsdbResetQuery
(
tsdb_query_handle_t
*
pQueryHandle
,
STimeWindow
*
window
,
tsdbpos_t
position
,
int16_t
order
)
{}
...
...
tests/examples/c/demo.c
浏览文件 @
6e70d237
...
...
@@ -64,6 +64,9 @@ int main(int argc, char *argv[]) {
memset
(
buf
,
0
,
512
);
}
taos_close
(
taos
);
getchar
();
return
0
;
taos_query
(
taos
,
"drop database demo"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录