Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
adb62142
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
adb62142
编写于
6月 05, 2020
作者:
S
Steven Li
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/crash_gen
上级
db033460
8b993116
变更
75
展开全部
显示空白变更内容
内联
并排
Showing
75 changed file
with
2325 addition
and
1553 deletion
+2325
-1553
src/client/inc/tscProfile.h
src/client/inc/tscProfile.h
+1
-1
src/client/inc/tscSecondaryMerge.h
src/client/inc/tscSecondaryMerge.h
+6
-4
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-2
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+0
-12
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+1
-2
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+41
-41
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+48
-24
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+54
-55
src/client/src/tscServer.c
src/client/src/tscServer.c
+17
-36
src/client/src/tscSql.c
src/client/src/tscSql.c
+0
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+9
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-3
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+1
-1
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+7
-6
src/common/src/tglobal.c
src/common/src/tglobal.c
+2
-2
src/connector/python/linux/python2/taos/cinterface.py
src/connector/python/linux/python2/taos/cinterface.py
+1
-0
src/connector/python/linux/python3/taos/cinterface.py
src/connector/python/linux/python3/taos/cinterface.py
+1
-0
src/connector/python/windows/python2/taos/cinterface.py
src/connector/python/windows/python2/taos/cinterface.py
+1
-0
src/connector/python/windows/python3/taos/cinterface.py
src/connector/python/windows/python3/taos/cinterface.py
+1
-0
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+5
-5
src/inc/taosdef.h
src/inc/taosdef.h
+2
-1
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+9
-10
src/inc/tsdb.h
src/inc/tsdb.h
+4
-3
src/inc/ttokendef.h
src/inc/ttokendef.h
+2
-2
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+0
-2
src/mnode/inc/mnodeProfile.h
src/mnode/inc/mnodeProfile.h
+21
-0
src/mnode/inc/mnodeShow.h
src/mnode/inc/mnodeShow.h
+1
-0
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+43
-63
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+432
-485
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+51
-9
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+40
-41
src/plugins/monitor/src/monitorMain.c
src/plugins/monitor/src/monitorMain.c
+1
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-1
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+2
-1
src/query/inc/qextbuffer.h
src/query/inc/qextbuffer.h
+2
-2
src/query/inc/qresultBuf.h
src/query/inc/qresultBuf.h
+1
-1
src/query/inc/sql.y
src/query/inc/sql.y
+3
-3
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+10
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+190
-149
src/query/src/qUtil.c
src/query/src/qUtil.c
+0
-5
src/query/src/qextbuffer.c
src/query/src/qextbuffer.c
+13
-17
src/query/src/qresultBuf.c
src/query/src/qresultBuf.c
+1
-7
src/query/src/sql.c
src/query/src/sql.c
+171
-172
src/rpc/src/rpcCache.c
src/rpc/src/rpcCache.c
+1
-1
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+7
-7
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+3
-3
src/rpc/src/rpcUdp.c
src/rpc/src/rpcUdp.c
+2
-2
src/rpc/test/rclient.c
src/rpc/test/rclient.c
+3
-2
src/rpc/test/rsclient.c
src/rpc/test/rsclient.c
+2
-1
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+2
-49
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+176
-69
src/util/inc/tcache.h
src/util/inc/tcache.h
+9
-0
src/util/inc/tutil.h
src/util/inc/tutil.h
+2
-0
src/util/src/tarray.c
src/util/src/tarray.c
+5
-3
src/util/src/tcache.c
src/util/src/tcache.c
+29
-0
src/util/src/tsocket.c
src/util/src/tsocket.c
+11
-8
src/util/src/tutil.c
src/util/src/tutil.c
+15
-5
src/wal/src/walMain.c
src/wal/src/walMain.c
+60
-37
tests/pytest/query/filter.py
tests/pytest/query/filter.py
+2
-2
tests/pytest/query/filterCombo.py
tests/pytest/query/filterCombo.py
+6
-3
tests/pytest/query/queryError.py
tests/pytest/query/queryError.py
+4
-5
tests/pytest/query/queryNormal.py
tests/pytest/query/queryNormal.py
+15
-12
tests/pytest/random-test/random-test-multi-threading-3.py
tests/pytest/random-test/random-test-multi-threading-3.py
+1
-4
tests/pytest/random-test/random-test-multi-threading.py
tests/pytest/random-test/random-test-multi-threading.py
+1
-4
tests/pytest/random-test/random-test.py
tests/pytest/random-test/random-test.py
+9
-3
tests/pytest/valgrind-test.sh
tests/pytest/valgrind-test.sh
+34
-34
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim
+26
-60
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim
...ript/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim
+52
-0
tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
...t/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
+94
-16
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
+2
-9
tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
+202
-0
tests/script/unique/arbitrator/insert_duplicationTs.sim
tests/script/unique/arbitrator/insert_duplicationTs.sim
+194
-0
tests/script/unique/arbitrator/replica_changeWithArbitrator.sim
...script/unique/arbitrator/replica_changeWithArbitrator.sim
+155
-39
未找到文件。
src/client/inc/tscProfile.h
浏览文件 @
adb62142
...
@@ -26,7 +26,7 @@ void tscAddIntoSqlList(SSqlObj *pSql);
...
@@ -26,7 +26,7 @@ void tscAddIntoSqlList(SSqlObj *pSql);
void
tscRemoveFromSqlList
(
SSqlObj
*
pSql
);
void
tscRemoveFromSqlList
(
SSqlObj
*
pSql
);
void
tscAddIntoStreamList
(
SSqlStream
*
pStream
);
void
tscAddIntoStreamList
(
SSqlStream
*
pStream
);
void
tscRemoveFromStreamList
(
SSqlStream
*
pStream
,
SSqlObj
*
pSqlObj
);
void
tscRemoveFromStreamList
(
SSqlStream
*
pStream
,
SSqlObj
*
pSqlObj
);
char
*
tscBuildQueryStreamDesc
(
char
*
pMsg
,
STscObj
*
pObj
);
int
tscBuildQueryStreamDesc
(
void
*
pMsg
,
STscObj
*
pObj
);
void
tscKillQuery
(
STscObj
*
pObj
,
uint32_t
killId
);
void
tscKillQuery
(
STscObj
*
pObj
,
uint32_t
killId
);
void
tscKillStream
(
STscObj
*
pObj
,
uint32_t
killId
);
void
tscKillStream
(
STscObj
*
pObj
,
uint32_t
killId
);
void
tscKillConnection
(
STscObj
*
pObj
);
void
tscKillConnection
(
STscObj
*
pObj
);
...
...
src/client/inc/tscSecondaryMerge.h
浏览文件 @
adb62142
...
@@ -64,6 +64,7 @@ typedef struct SLocalReducer {
...
@@ -64,6 +64,7 @@ typedef struct SLocalReducer {
tFilePage
*
pTempBuffer
;
tFilePage
*
pTempBuffer
;
struct
SQLFunctionCtx
*
pCtx
;
struct
SQLFunctionCtx
*
pCtx
;
int32_t
rowSize
;
// size of each intermediate result.
int32_t
rowSize
;
// size of each intermediate result.
int32_t
finalRowSize
;
// final result row size
int32_t
status
;
// denote it is in reduce process, in reduce process, it
int32_t
status
;
// denote it is in reduce process, in reduce process, it
bool
hasPrevRow
;
// cannot be released
bool
hasPrevRow
;
// cannot be released
bool
hasUnprocessedRow
;
bool
hasUnprocessedRow
;
...
@@ -76,6 +77,7 @@ typedef struct SLocalReducer {
...
@@ -76,6 +77,7 @@ typedef struct SLocalReducer {
SResultInfo
*
pResInfo
;
SResultInfo
*
pResInfo
;
bool
discard
;
bool
discard
;
int32_t
offset
;
// limit offset value
int32_t
offset
;
// limit offset value
bool
orderPrjOnSTable
;
// projection query on stable
}
SLocalReducer
;
}
SLocalReducer
;
typedef
struct
SSubqueryState
{
typedef
struct
SSubqueryState
{
...
...
src/client/inc/tsclient.h
浏览文件 @
adb62142
...
@@ -285,8 +285,6 @@ typedef struct {
...
@@ -285,8 +285,6 @@ typedef struct {
typedef
struct
STscObj
{
typedef
struct
STscObj
{
void
*
signature
;
void
*
signature
;
void
*
pTimer
;
void
*
pTimer
;
char
mnodeIp
[
TSDB_USER_LEN
];
uint16_t
mnodePort
;
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
acctId
[
TSDB_DB_NAME_LEN
];
char
acctId
[
TSDB_DB_NAME_LEN
];
...
@@ -294,6 +292,7 @@ typedef struct STscObj {
...
@@ -294,6 +292,7 @@ typedef struct STscObj {
char
sversion
[
TSDB_VERSION_LEN
];
char
sversion
[
TSDB_VERSION_LEN
];
char
writeAuth
:
1
;
char
writeAuth
:
1
;
char
superAuth
:
1
;
char
superAuth
:
1
;
uint32_t
connId
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
sqlList
;
struct
SSqlObj
*
sqlList
;
struct
SSqlStream
*
streamList
;
struct
SSqlStream
*
streamList
;
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
adb62142
...
@@ -341,16 +341,6 @@ bool stableQueryFunctChanged(int32_t funcId) {
...
@@ -341,16 +341,6 @@ bool stableQueryFunctChanged(int32_t funcId) {
*/
*/
void
resetResultInfo
(
SResultInfo
*
pResInfo
)
{
pResInfo
->
initialized
=
false
;
}
void
resetResultInfo
(
SResultInfo
*
pResInfo
)
{
pResInfo
->
initialized
=
false
;
}
void
initResultInfo
(
SResultInfo
*
pResInfo
)
{
pResInfo
->
initialized
=
true
;
// the this struct has been initialized flag
pResInfo
->
complete
=
false
;
pResInfo
->
hasResult
=
false
;
pResInfo
->
numOfRes
=
0
;
memset
(
pResInfo
->
interResultBuf
,
0
,
(
size_t
)
pResInfo
->
bufLen
);
}
void
setResultInfoBuf
(
SResultInfo
*
pResInfo
,
int32_t
size
,
bool
superTable
)
{
void
setResultInfoBuf
(
SResultInfo
*
pResInfo
,
int32_t
size
,
bool
superTable
)
{
assert
(
pResInfo
->
interResultBuf
==
NULL
);
assert
(
pResInfo
->
interResultBuf
==
NULL
);
...
@@ -387,9 +377,7 @@ static bool function_setup(SQLFunctionCtx *pCtx) {
...
@@ -387,9 +377,7 @@ static bool function_setup(SQLFunctionCtx *pCtx) {
*/
*/
static
void
function_finalizer
(
SQLFunctionCtx
*
pCtx
)
{
static
void
function_finalizer
(
SQLFunctionCtx
*
pCtx
)
{
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
tscTrace
(
"no result generated, result is set to NULL"
);
if
(
pCtx
->
outputType
==
TSDB_DATA_TYPE_BINARY
||
pCtx
->
outputType
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pCtx
->
outputType
==
TSDB_DATA_TYPE_BINARY
||
pCtx
->
outputType
==
TSDB_DATA_TYPE_NCHAR
)
{
setVardataNull
(
pCtx
->
aOutputBuf
,
pCtx
->
outputType
);
setVardataNull
(
pCtx
->
aOutputBuf
,
pCtx
->
outputType
);
}
else
{
}
else
{
...
...
src/client/src/tscParseInsert.c
浏览文件 @
adb62142
...
@@ -48,7 +48,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
...
@@ -48,7 +48,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
int32_t
radix
=
10
;
int32_t
radix
=
10
;
int32_t
radixList
[
3
]
=
{
16
,
8
,
2
};
int32_t
radixList
[
3
]
=
{
16
,
8
,
2
};
// the integer number with different radix: hex, oct, bin
if
(
pToken
->
type
==
TK_HEX
||
pToken
->
type
==
TK_OCT
||
pToken
->
type
==
TK_BIN
)
{
if
(
pToken
->
type
==
TK_HEX
||
pToken
->
type
==
TK_OCT
||
pToken
->
type
==
TK_BIN
)
{
radix
=
radixList
[
pToken
->
type
-
TK_HEX
];
radix
=
radixList
[
pToken
->
type
-
TK_HEX
];
}
}
...
...
src/client/src/tscPrepare.c
浏览文件 @
adb62142
...
@@ -494,7 +494,6 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
...
@@ -494,7 +494,6 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
pSql
->
signature
=
pSql
;
pSql
->
signature
=
pSql
;
pSql
->
pTscObj
=
pObj
;
pSql
->
pTscObj
=
pObj
;
//pSql->pTscObj->pSql = pSql;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA_NUM
;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA_NUM
;
pStmt
->
pSql
=
pSql
;
pStmt
->
pSql
=
pSql
;
...
@@ -515,7 +514,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
...
@@ -515,7 +514,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
//doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen);
//doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen);
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
pSql
->
param
=
(
void
*
)
pSql
;
pSql
->
param
=
(
void
*
)
pSql
;
pSql
->
fp
=
waitForQueryRsp
;
pSql
->
fp
=
waitForQueryRsp
;
pSql
->
insertType
=
TSDB_QUERY_TYPE_STMT_INSERT
;
pSql
->
insertType
=
TSDB_QUERY_TYPE_STMT_INSERT
;
...
...
src/client/src/tscProfile.c
浏览文件 @
adb62142
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "ttime.h"
#include "ttime.h"
#include "ttimer.h"
#include "ttimer.h"
#include "tutil.h"
#include "tutil.h"
#include "taosmsg.h"
void
tscSaveSlowQueryFp
(
void
*
handle
,
void
*
tmrId
);
void
tscSaveSlowQueryFp
(
void
*
handle
,
void
*
tmrId
);
void
*
tscSlowQueryConn
=
NULL
;
void
*
tscSlowQueryConn
=
NULL
;
...
@@ -96,7 +97,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
...
@@ -96,7 +97,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
}
}
tscTrace
(
"%p query time:%"
PRId64
" sql:%s"
,
pSql
,
pSql
->
res
.
useconds
,
pSql
->
sqlstr
);
tscTrace
(
"%p query time:%"
PRId64
" sql:%s"
,
pSql
,
pSql
->
res
.
useconds
,
pSql
->
sqlstr
);
int32_t
sqlSize
=
TSDB_S
HOW
_SQL_LEN
+
size
;
int32_t
sqlSize
=
TSDB_S
LOW_QUERY
_SQL_LEN
+
size
;
char
*
sql
=
malloc
(
sqlSize
);
char
*
sql
=
malloc
(
sqlSize
);
if
(
sql
==
NULL
)
{
if
(
sql
==
NULL
)
{
...
@@ -106,9 +107,9 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
...
@@ -106,9 +107,9 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
int
len
=
snprintf
(
sql
,
size
,
"insert into %s.slowquery values(now, '%s', %"
PRId64
", %"
PRId64
", '"
,
tsMonitorDbName
,
int
len
=
snprintf
(
sql
,
size
,
"insert into %s.slowquery values(now, '%s', %"
PRId64
", %"
PRId64
", '"
,
tsMonitorDbName
,
pSql
->
pTscObj
->
user
,
pSql
->
stime
,
pSql
->
res
.
useconds
);
pSql
->
pTscObj
->
user
,
pSql
->
stime
,
pSql
->
res
.
useconds
);
int
sqlLen
=
snprintf
(
sql
+
len
,
TSDB_S
HOW
_SQL_LEN
,
"%s"
,
pSql
->
sqlstr
);
int
sqlLen
=
snprintf
(
sql
+
len
,
TSDB_S
LOW_QUERY
_SQL_LEN
,
"%s"
,
pSql
->
sqlstr
);
if
(
sqlLen
>
TSDB_S
HOW
_SQL_LEN
-
1
)
{
if
(
sqlLen
>
TSDB_S
LOW_QUERY
_SQL_LEN
-
1
)
{
sqlLen
=
len
+
TSDB_S
HOW
_SQL_LEN
-
1
;
sqlLen
=
len
+
TSDB_S
LOW_QUERY
_SQL_LEN
-
1
;
}
else
{
}
else
{
sqlLen
+=
len
;
sqlLen
+=
len
;
}
}
...
@@ -208,25 +209,25 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
...
@@ -208,25 +209,25 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
if
(
pStream
)
{
if
(
pStream
)
{
tscTrace
(
"%p stream:%p is killed, streamId:%d"
,
pStream
->
pSql
,
pStream
,
killId
);
tscTrace
(
"%p stream:%p is killed, streamId:%d"
,
pStream
->
pSql
,
pStream
,
killId
);
}
if
(
pStream
->
callback
)
{
if
(
pStream
->
callback
)
{
pStream
->
callback
(
pStream
->
param
);
pStream
->
callback
(
pStream
->
param
);
}
}
taos_close_stream
(
pStream
);
taos_close_stream
(
pStream
);
}
else
{
tscError
(
"failed to kill stream, streamId:%d not exist"
,
killId
);
}
}
}
char
*
tscBuildQueryStreamDesc
(
char
*
pMsg
,
STscObj
*
pObj
)
{
int
tscBuildQueryStreamDesc
(
void
*
pMsg
,
STscObj
*
pObj
)
{
char
*
pMax
=
pMsg
+
TSDB_PAYLOAD_SIZE
-
256
;
SCMHeartBeatMsg
*
pHeartbeat
=
pMsg
;
int
allocedQueriesNum
=
pHeartbeat
->
numOfQueries
;
int
allocedStreamsNum
=
pHeartbeat
->
numOfStreams
;
SQqueryList
*
pQList
=
(
SQqueryList
*
)
pMsg
;
pHeartbeat
->
numOfQueries
=
0
;
pQList
->
numOfQueries
=
0
;
SQueryDesc
*
pQdesc
=
(
SQueryDesc
*
)
pHeartbeat
->
pData
;
SQueryDesc
*
pQdesc
=
(
SQueryDesc
*
)(
pMsg
+
sizeof
(
SQqueryList
));
// We extract the lock to tscBuildHeartBeatMsg function.
// We extract the lock to tscBuildHeartBeatMsg function.
/* pthread_mutex_lock (&pObj->mutex); */
pMsg
+=
sizeof
(
SQqueryList
);
SSqlObj
*
pSql
=
pObj
->
sqlList
;
SSqlObj
*
pSql
=
pObj
->
sqlList
;
while
(
pSql
)
{
while
(
pSql
)
{
/*
/*
...
@@ -240,47 +241,46 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
...
@@ -240,47 +241,46 @@ char *tscBuildQueryStreamDesc(char *pMsg, STscObj *pObj) {
strncpy
(
pQdesc
->
sql
,
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
strncpy
(
pQdesc
->
sql
,
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
pQdesc
->
sql
[
TSDB_SHOW_SQL_LEN
-
1
]
=
0
;
pQdesc
->
sql
[
TSDB_SHOW_SQL_LEN
-
1
]
=
0
;
pQdesc
->
stime
=
pSql
->
stime
;
pQdesc
->
stime
=
htobe64
(
pSql
->
stime
)
;
pQdesc
->
queryId
=
pSql
->
queryId
;
pQdesc
->
queryId
=
htonl
(
pSql
->
queryId
)
;
pQdesc
->
useconds
=
pSql
->
res
.
useconds
;
pQdesc
->
useconds
=
htobe64
(
pSql
->
res
.
useconds
)
;
p
QLis
t
->
numOfQueries
++
;
p
Heartbea
t
->
numOfQueries
++
;
pQdesc
++
;
pQdesc
++
;
pSql
=
pSql
->
next
;
pSql
=
pSql
->
next
;
pMsg
+=
sizeof
(
SQueryDesc
);
if
(
pHeartbeat
->
numOfQueries
>=
allocedQueriesNum
)
break
;
if
(
pMsg
>
pMax
)
break
;
}
}
SStreamList
*
pSList
=
(
SStreamList
*
)
pMsg
;
pHeartbeat
->
numOfStreams
=
0
;
pSList
->
numOfStreams
=
0
;
SStreamDesc
*
pSdesc
=
(
SStreamDesc
*
)
pQdesc
;
SStreamDesc
*
pSdesc
=
(
SStreamDesc
*
)
(
pMsg
+
sizeof
(
SStreamList
));
pMsg
+=
sizeof
(
SStreamList
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
while
(
pStream
)
{
strncpy
(
pSdesc
->
sql
,
pStream
->
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
strncpy
(
pSdesc
->
sql
,
pStream
->
pSql
->
sqlstr
,
TSDB_SHOW_SQL_LEN
-
1
);
pSdesc
->
sql
[
TSDB_SHOW_SQL_LEN
-
1
]
=
0
;
pSdesc
->
sql
[
TSDB_SHOW_SQL_LEN
-
1
]
=
0
;
pSdesc
->
streamId
=
pStream
->
streamId
;
pSdesc
->
streamId
=
htonl
(
pStream
->
streamId
)
;
pSdesc
->
num
=
pStream
->
num
;
pSdesc
->
num
=
htobe64
(
pStream
->
num
)
;
pSdesc
->
useconds
=
pStream
->
useconds
;
pSdesc
->
useconds
=
htobe64
(
pStream
->
useconds
)
;
pSdesc
->
stime
=
pStream
->
stime
-
pStream
->
interval
;
pSdesc
->
stime
=
htobe64
(
pStream
->
stime
-
pStream
->
interval
)
;
pSdesc
->
ctime
=
pStream
->
ctime
;
pSdesc
->
ctime
=
htobe64
(
pStream
->
ctime
)
;
pSdesc
->
slidingTime
=
pStream
->
slidingTime
;
pSdesc
->
slidingTime
=
htobe64
(
pStream
->
slidingTime
)
;
pSdesc
->
interval
=
pStream
->
interval
;
pSdesc
->
interval
=
htobe64
(
pStream
->
interval
)
;
p
SLis
t
->
numOfStreams
++
;
p
Heartbea
t
->
numOfStreams
++
;
pSdesc
++
;
pSdesc
++
;
pStream
=
pStream
->
next
;
pStream
=
pStream
->
next
;
pMsg
+=
sizeof
(
SStreamDesc
);
if
(
pHeartbeat
->
numOfStreams
>=
allocedStreamsNum
)
break
;
if
(
pMsg
>
pMax
)
break
;
}
}
/* pthread_mutex_unlock (&pObj->mutex); */
int32_t
msgLen
=
pHeartbeat
->
numOfQueries
*
sizeof
(
SQueryDesc
)
+
pHeartbeat
->
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SCMHeartBeatMsg
);
pHeartbeat
->
connId
=
htonl
(
pObj
->
connId
);
pHeartbeat
->
numOfQueries
=
htonl
(
pHeartbeat
->
numOfQueries
);
pHeartbeat
->
numOfStreams
=
htonl
(
pHeartbeat
->
numOfStreams
);
return
pMsg
;
return
msgLen
;
}
}
void
tscKillConnection
(
STscObj
*
pObj
)
{
void
tscKillConnection
(
STscObj
*
pObj
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
adb62142
...
@@ -93,7 +93,7 @@ static int32_t validateArithmeticSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo
...
@@ -93,7 +93,7 @@ static int32_t validateArithmeticSQLExpr(tSQLExpr* pExpr, SQueryInfo* pQueryInfo
static
int32_t
validateDNodeConfig
(
tDCLSQL
*
pOptions
);
static
int32_t
validateDNodeConfig
(
tDCLSQL
*
pOptions
);
static
int32_t
validateLocalConfig
(
tDCLSQL
*
pOptions
);
static
int32_t
validateLocalConfig
(
tDCLSQL
*
pOptions
);
static
int32_t
validateColumnName
(
char
*
name
);
static
int32_t
validateColumnName
(
char
*
name
);
static
int32_t
setKillInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
static
int32_t
setKillInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
,
int32_t
killType
);
static
bool
validateOneTags
(
SSqlCmd
*
pCmd
,
TAOS_FIELD
*
pTagField
);
static
bool
validateOneTags
(
SSqlCmd
*
pCmd
,
TAOS_FIELD
*
pTagField
);
static
bool
hasTimestampForPointInterpQuery
(
SQueryInfo
*
pQueryInfo
);
static
bool
hasTimestampForPointInterpQuery
(
SQueryInfo
*
pQueryInfo
);
...
@@ -531,7 +531,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -531,7 +531,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
TSDB_SQL_KILL_QUERY
:
case
TSDB_SQL_KILL_QUERY
:
case
TSDB_SQL_KILL_STREAM
:
case
TSDB_SQL_KILL_STREAM
:
case
TSDB_SQL_KILL_CONNECTION
:
{
case
TSDB_SQL_KILL_CONNECTION
:
{
if
((
code
=
setKillInfo
(
pSql
,
pInfo
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
setKillInfo
(
pSql
,
pInfo
,
pInfo
->
type
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -1881,21 +1881,37 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
...
@@ -1881,21 +1881,37 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr
// functions can not be applied to normal columns
// functions can not be applied to normal columns
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
index
.
columnIndex
<
numOfCols
)
{
if
(
index
.
columnIndex
<
numOfCols
&&
index
.
columnIndex
!=
TSDB_TBNAME_COLUMN_INDEX
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg6
);
}
}
if
(
index
.
columnIndex
>
0
)
{
index
.
columnIndex
-=
numOfCols
;
index
.
columnIndex
-=
numOfCols
;
}
// 2. valid the column type
// 2. valid the column type
int16_t
colType
=
pSchema
[
index
.
columnIndex
].
type
;
int16_t
colType
=
0
;
if
(
colType
==
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
colType
=
TSDB_DATA_TYPE_BINARY
;
}
else
{
colType
=
pSchema
[
index
.
columnIndex
].
type
;
}
if
(
colType
==
TSDB_DATA_TYPE_BOOL
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg1
);
}
}
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
&
index
);
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
&
index
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
SSchema
s
=
pTagSchema
[
index
.
columnIndex
];
SSchema
s
=
{
0
};
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
s
.
bytes
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
;
s
.
type
=
TSDB_DATA_TYPE_BINARY
;
s
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
}
else
{
s
=
pTagSchema
[
index
.
columnIndex
];
}
int16_t
bytes
=
0
;
int16_t
bytes
=
0
;
int16_t
type
=
0
;
int16_t
type
=
0
;
...
@@ -2229,35 +2245,43 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -2229,35 +2245,43 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
setKillInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
int32_t
setKillInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
,
int32_t
killType
)
{
const
char
*
msg1
=
"invalid ip address"
;
const
char
*
msg1
=
"invalid connection ID"
;
const
char
*
msg2
=
"invalid port"
;
const
char
*
msg2
=
"invalid query ID"
;
const
char
*
msg3
=
"invalid stream ID"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
command
=
pInfo
->
type
;
pCmd
->
command
=
pInfo
->
type
;
SSQLToken
*
i
p
=
&
(
pInfo
->
pDCLInfo
->
ip
);
SSQLToken
*
i
dStr
=
&
(
pInfo
->
pDCLInfo
->
ip
);
if
(
i
p
->
n
>
TSDB_KILL_MSG_LEN
)
{
if
(
i
dStr
->
n
>
TSDB_KILL_MSG_LEN
)
{
return
TSDB_CODE_INVALID_SQL
;
return
TSDB_CODE_INVALID_SQL
;
}
}
strncpy
(
pCmd
->
payload
,
i
p
->
z
,
ip
->
n
);
strncpy
(
pCmd
->
payload
,
i
dStr
->
z
,
idStr
->
n
);
const
char
delim
=
':'
;
const
char
delim
=
':'
;
char
*
connIdStr
=
strtok
(
idStr
->
z
,
&
delim
);
char
*
queryIdStr
=
strtok
(
NULL
,
&
delim
);
char
*
ipStr
=
strtok
(
ip
->
z
,
&
delim
);
int32_t
connId
=
(
int32_t
)
strtol
(
connIdStr
,
NULL
,
10
);
char
*
portStr
=
strtok
(
NULL
,
&
delim
);
if
(
connId
<=
0
)
{
if
(
!
validateIpAddress
(
ipStr
,
strlen
(
ipStr
)))
{
memset
(
pCmd
->
payload
,
0
,
strlen
(
pCmd
->
payload
));
memset
(
pCmd
->
payload
,
0
,
strlen
(
pCmd
->
payload
));
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
uint16_t
port
=
(
uint16_t
)
strtol
(
portStr
,
NULL
,
10
);
if
(
killType
==
TSDB_SQL_KILL_CONNECTION
)
{
if
(
port
<=
0
||
port
>
65535
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
queryId
=
(
int32_t
)
strtol
(
queryIdStr
,
NULL
,
10
);
if
(
queryId
<=
0
)
{
memset
(
pCmd
->
payload
,
0
,
strlen
(
pCmd
->
payload
));
memset
(
pCmd
->
payload
,
0
,
strlen
(
pCmd
->
payload
));
if
(
killType
==
TSDB_SQL_KILL_QUERY
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
else
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
adb62142
...
@@ -278,6 +278,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -278,6 +278,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
param
->
groupOrderType
=
pQueryInfo
->
groupbyExpr
.
orderType
;
param
->
groupOrderType
=
pQueryInfo
->
groupbyExpr
.
orderType
;
pReducer
->
orderPrjOnSTable
=
tscOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
);
pRes
->
code
=
tLoserTreeCreate
(
&
pReducer
->
pLoserTree
,
pReducer
->
numOfBuffer
,
param
,
treeComparator
);
pRes
->
code
=
tLoserTreeCreate
(
&
pReducer
->
pLoserTree
,
pReducer
->
numOfBuffer
,
param
,
treeComparator
);
if
(
pReducer
->
pLoserTree
==
NULL
||
pRes
->
code
!=
0
)
{
if
(
pReducer
->
pLoserTree
==
NULL
||
pRes
->
code
!=
0
)
{
...
@@ -309,10 +310,10 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -309,10 +310,10 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
int32_t
finalRowLength
=
tscGetResRowLength
(
pQueryInfo
->
exprList
);
pReducer
->
finalRowSize
=
tscGetResRowLength
(
pQueryInfo
->
exprList
);
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
/
finalRowLength
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
/
pReducer
->
finalRowSize
;
assert
(
finalRowLength
<=
pReducer
->
rowSize
);
assert
(
pReducer
->
finalRowSize
<=
pReducer
->
rowSize
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
// pReducer->pBufForInterpo = calloc(1, pReducer->nResultBufSize);
// pReducer->pBufForInterpo = calloc(1, pReducer->nResultBufSize);
...
@@ -389,7 +390,7 @@ static int32_t tscFlushTmpBufferImpl(tExtMemBuffer *pMemoryBuf, tOrderDescriptor
...
@@ -389,7 +390,7 @@ static int32_t tscFlushTmpBufferImpl(tExtMemBuffer *pMemoryBuf, tOrderDescriptor
assert
(
pPage
->
num
<=
pDesc
->
pColumnModel
->
capacity
);
assert
(
pPage
->
num
<=
pDesc
->
pColumnModel
->
capacity
);
// sort before flush to disk, the data must be consecutively put on tFilePage.
// sort before flush to disk, the data must be consecutively put on tFilePage.
if
(
pDesc
->
orderI
dx
.
numOfCols
>
0
)
{
if
(
pDesc
->
orderI
nfo
.
numOfCols
>
0
)
{
tColDataQSort
(
pDesc
,
pPage
->
num
,
0
,
pPage
->
num
-
1
,
pPage
->
data
,
orderType
);
tColDataQSort
(
pDesc
,
pPage
->
num
,
0
,
pPage
->
num
-
1
,
pPage
->
data
,
orderType
);
}
}
...
@@ -590,12 +591,10 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
...
@@ -590,12 +591,10 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
bool
isSameGroup
(
SSqlCmd
*
pCmd
,
SLocalReducer
*
pReducer
,
char
*
pPrev
,
tFilePage
*
tmpBuffer
)
{
bool
isSameGroup
(
SSqlCmd
*
pCmd
,
SLocalReducer
*
pReducer
,
char
*
pPrev
,
tFilePage
*
tmpBuffer
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
int16_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
;
// disable merge procedure for column projection query
// disable merge procedure for column projection query
int16_t
functionId
=
pReducer
->
pCtx
[
0
].
functionId
;
assert
(
functionId
!=
TSDB_FUNC_ARITHM
);
assert
(
functionId
!=
TSDB_FUNC_ARITHM
);
if
(
pReducer
->
orderPrjOnSTable
)
{
if
(
tscOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
return
true
;
return
true
;
}
}
...
@@ -604,26 +603,33 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage
...
@@ -604,26 +603,33 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage
}
}
tOrderDescriptor
*
pOrderDesc
=
pReducer
->
pDesc
;
tOrderDescriptor
*
pOrderDesc
=
pReducer
->
pDesc
;
int32_t
numOfCols
=
pOrderDesc
->
orderIdx
.
numOfCols
;
SColumnOrderInfo
*
orderInfo
=
&
pOrderDesc
->
orderInfo
;
// no group by columns, all data belongs to one group
// no group by columns, all data belongs to one group
int32_t
numOfCols
=
orderInfo
->
numOfCols
;
if
(
numOfCols
<=
0
)
{
if
(
numOfCols
<=
0
)
{
return
true
;
return
true
;
}
}
if
(
pOrderDesc
->
orderIdx
.
pData
[
numOfCols
-
1
]
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
//<= 0
if
(
orderInfo
->
pData
[
numOfCols
-
1
]
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// super table interval query
/*
* super table interval query
* if the order columns is the primary timestamp, all result data belongs to one group
*/
assert
(
pQueryInfo
->
intervalTime
>
0
);
assert
(
pQueryInfo
->
intervalTime
>
0
);
pOrderDesc
->
orderIdx
.
numOfCols
-=
1
;
if
(
numOfCols
==
1
)
{
return
true
;
}
}
else
{
// simple group by query
}
else
{
// simple group by query
assert
(
pQueryInfo
->
intervalTime
==
0
);
assert
(
pQueryInfo
->
intervalTime
==
0
);
}
}
// only one row exists
// only one row exists
int32_t
ret
=
compare_a
(
pOrderDesc
,
1
,
0
,
pPrev
,
1
,
0
,
tmpBuffer
->
data
)
;
int32_t
index
=
orderInfo
->
pData
[
0
]
;
pOrderDesc
->
orderIdx
.
numOfCols
=
numOfCols
;
int32_t
offset
=
(
pOrderDesc
->
pColumnModel
)
->
pFields
[
index
].
offset
;
return
(
ret
==
0
);
int32_t
ret
=
memcmp
(
pPrev
+
offset
,
tmpBuffer
->
data
+
offset
,
pOrderDesc
->
pColumnModel
->
rowSize
-
offset
);
return
ret
==
0
;
}
}
int32_t
tscLocalReducerEnvCreate
(
SSqlObj
*
pSql
,
tExtMemBuffer
***
pMemBuffer
,
tOrderDescriptor
**
pOrderDesc
,
int32_t
tscLocalReducerEnvCreate
(
SSqlObj
*
pSql
,
tExtMemBuffer
***
pMemBuffer
,
tOrderDescriptor
**
pOrderDesc
,
...
@@ -873,24 +879,24 @@ static void reversedCopyFromInterpolationToDstBuf(SQueryInfo *pQueryInfo, SSqlRe
...
@@ -873,24 +879,24 @@ static void reversedCopyFromInterpolationToDstBuf(SQueryInfo *pQueryInfo, SSqlRe
* Note: pRes->pLocalReducer may be null, due to the fact that "tscDestroyLocalReducer" is called
* Note: pRes->pLocalReducer may be null, due to the fact that "tscDestroyLocalReducer" is called
* by "interuptHandler" function in shell
* by "interuptHandler" function in shell
*/
*/
static
void
do
Interpolate
Result
(
SSqlObj
*
pSql
,
SLocalReducer
*
pLocalReducer
,
bool
doneOutput
)
{
static
void
do
Fill
Result
(
SSqlObj
*
pSql
,
SLocalReducer
*
pLocalReducer
,
bool
doneOutput
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
tFilePage
*
pFinalDataPage
=
pLocalReducer
->
pResultBuf
;
tFilePage
*
pFinalDataPage
=
pLocalReducer
->
pResultBuf
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
pRes
->
pLocalReducer
!=
pLocalReducer
)
{
//
if (pRes->pLocalReducer != pLocalReducer) {
/*
//
/*
* Release the SSqlObj is called, and it is int destroying function invoked by other thread.
//
* Release the SSqlObj is called, and it is int destroying function invoked by other thread.
* However, the other thread will WAIT until current process fully completes.
//
* However, the other thread will WAIT until current process fully completes.
* Since the flag of release struct is set by doLocalReduce function
//
* Since the flag of release struct is set by doLocalReduce function
*/
//
*/
assert
(
pRes
->
pLocalReducer
==
NULL
);
//
assert(pRes->pLocalReducer == NULL);
}
//
}
if
(
pQueryInfo
->
intervalTime
==
0
||
pQueryInfo
->
fillType
==
TSDB_FILL_NONE
)
{
// no interval query, no fill operation
// no interval query, no fill operation
if
(
pQueryInfo
->
intervalTime
==
0
||
pQueryInfo
->
fillType
==
TSDB_FILL_NONE
)
{
pRes
->
data
=
pLocalReducer
->
pFinalRes
;
pRes
->
data
=
pLocalReducer
->
pFinalRes
;
pRes
->
numOfRows
=
pFinalDataPage
->
num
;
pRes
->
numOfRows
=
pFinalDataPage
->
num
;
pRes
->
numOfClauseTotal
+=
pRes
->
numOfRows
;
pRes
->
numOfClauseTotal
+=
pRes
->
numOfRows
;
...
@@ -929,9 +935,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
...
@@ -929,9 +935,7 @@ static void doInterpolateResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, boo
savePrevRecordAndSetupInterpoInfo
(
pLocalReducer
,
pQueryInfo
,
pLocalReducer
->
pFillInfo
);
savePrevRecordAndSetupInterpoInfo
(
pLocalReducer
,
pQueryInfo
,
pLocalReducer
->
pFillInfo
);
}
}
int32_t
rowSize
=
tscGetResRowLength
(
pQueryInfo
->
exprList
);
memcpy
(
pRes
->
data
,
pFinalDataPage
->
data
,
pRes
->
numOfRows
*
pLocalReducer
->
finalRowSize
);
memcpy
(
pRes
->
data
,
pFinalDataPage
->
data
,
pRes
->
numOfRows
*
rowSize
);
pFinalDataPage
->
num
=
0
;
pFinalDataPage
->
num
=
0
;
return
;
return
;
}
}
...
@@ -1037,16 +1041,13 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
...
@@ -1037,16 +1041,13 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
static
void
doExecuteSecondaryMerge
(
SSqlCmd
*
pCmd
,
SLocalReducer
*
pLocalReducer
,
bool
needInit
)
{
static
void
doExecuteSecondaryMerge
(
SSqlCmd
*
pCmd
,
SLocalReducer
*
pLocalReducer
,
bool
needInit
)
{
// the tag columns need to be set before all functions execution
// the tag columns need to be set before all functions execution
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
j
);
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
j
];
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
j
];
tVariantAssign
(
&
pCtx
->
param
[
0
],
&
pExpr
->
param
[
0
]);
// tags/tags_dummy function, the tag field of SQLFunctionCtx is from the input buffer
// tags/tags_dummy function, the tag field of SQLFunctionCtx is from the input buffer
int32_t
functionId
=
p
Expr
->
functionId
;
int32_t
functionId
=
p
Ctx
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAG_DUMMY
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
if
(
functionId
==
TSDB_FUNC_TAG_DUMMY
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
tVariantDestroy
(
&
pCtx
->
tag
);
tVariantDestroy
(
&
pCtx
->
tag
);
char
*
input
=
pCtx
->
aInputElemBuf
;
char
*
input
=
pCtx
->
aInputElemBuf
;
...
@@ -1057,17 +1058,20 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer,
...
@@ -1057,17 +1058,20 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer,
}
else
{
}
else
{
tVariantCreateFromBinary
(
&
pCtx
->
tag
,
input
,
pCtx
->
inputBytes
,
pCtx
->
inputType
);
tVariantCreateFromBinary
(
&
pCtx
->
tag
,
input
,
pCtx
->
inputBytes
,
pCtx
->
inputType
);
}
}
}
else
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
j
);
pCtx
->
param
[
0
].
i64Key
=
pExpr
->
param
[
0
].
i64Key
;
}
}
pCtx
->
currentStage
=
SECONDARY_STAGE_MERGE
;
pCtx
->
currentStage
=
SECONDARY_STAGE_MERGE
;
if
(
needInit
)
{
if
(
needInit
)
{
aAggs
[
p
Expr
->
functionId
].
init
(
pCtx
);
aAggs
[
p
Ctx
->
functionId
].
init
(
pCtx
);
}
}
}
}
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
int32_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
j
)
->
functionId
;
int32_t
functionId
=
pLocalReducer
->
pCtx
[
j
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TAG_DUMMY
||
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
if
(
functionId
==
TSDB_FUNC_TAG_DUMMY
||
functionId
==
TSDB_FUNC_TS_DUMMY
)
{
continue
;
continue
;
}
}
...
@@ -1101,8 +1105,7 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
...
@@ -1101,8 +1105,7 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
* ts, tag, tagprj function can not decide the output number of current query
* ts, tag, tagprj function can not decide the output number of current query
* the number of output result is decided by main output
* the number of output result is decided by main output
*/
*/
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
j
);
int32_t
functionId
=
pCtx
[
j
].
functionId
;
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TAGPRJ
)
{
if
(
functionId
==
TSDB_FUNC_TS
||
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_TAGPRJ
)
{
continue
;
continue
;
}
}
...
@@ -1136,15 +1139,13 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
...
@@ -1136,15 +1139,13 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
char
*
buf
=
malloc
((
size_t
)
maxBufSize
);
char
*
buf
=
malloc
((
size_t
)
maxBufSize
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
S
SqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
)
;
S
QLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
]
;
if
(
p
Expr
->
functionId
!=
TSDB_FUNC_TAG
)
{
if
(
p
Ctx
->
functionId
!=
TSDB_FUNC_TAG
)
{
continue
;
continue
;
}
}
int32_t
inc
=
numOfRes
-
1
;
// tsdb_func_tag function only produce one row of result
int32_t
inc
=
numOfRes
-
1
;
// tsdb_func_tag function only produce one row of result
memset
(
buf
,
0
,
(
size_t
)
maxBufSize
);
memset
(
buf
,
0
,
(
size_t
)
maxBufSize
);
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
];
memcpy
(
buf
,
pCtx
->
aOutputBuf
,
(
size_t
)
pCtx
->
outputBytes
);
memcpy
(
buf
,
pCtx
->
aOutputBuf
,
(
size_t
)
pCtx
->
outputBytes
);
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
...
@@ -1160,8 +1161,8 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
...
@@ -1160,8 +1161,8 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
S
SqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
)
;
S
QLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
]
;
aAggs
[
p
Expr
->
functionId
].
xFinalize
(
&
pLocalReducer
->
pCtx
[
k
]
);
aAggs
[
p
Ctx
->
functionId
].
xFinalize
(
pCtx
);
}
}
pLocalReducer
->
hasPrevRow
=
false
;
pLocalReducer
->
hasPrevRow
=
false
;
...
@@ -1182,13 +1183,13 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
...
@@ -1182,13 +1183,13 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
*/
*/
bool
needToMerge
(
SQueryInfo
*
pQueryInfo
,
SLocalReducer
*
pLocalReducer
,
tFilePage
*
tmpBuffer
)
{
bool
needToMerge
(
SQueryInfo
*
pQueryInfo
,
SLocalReducer
*
pLocalReducer
,
tFilePage
*
tmpBuffer
)
{
int32_t
ret
=
0
;
// merge all result by default
int32_t
ret
=
0
;
// merge all result by default
int16_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
;
int16_t
functionId
=
pLocalReducer
->
pCtx
[
0
].
functionId
;
if
(
functionId
==
TSDB_FUNC_PRJ
||
functionId
==
TSDB_FUNC_ARITHM
)
{
// column projection query
if
(
functionId
==
TSDB_FUNC_PRJ
||
functionId
==
TSDB_FUNC_ARITHM
)
{
// column projection query
ret
=
1
;
// disable merge procedure
ret
=
1
;
// disable merge procedure
}
else
{
}
else
{
tOrderDescriptor
*
pDesc
=
pLocalReducer
->
pDesc
;
tOrderDescriptor
*
pDesc
=
pLocalReducer
->
pDesc
;
if
(
pDesc
->
orderI
dx
.
numOfCols
>
0
)
{
if
(
pDesc
->
orderI
nfo
.
numOfCols
>
0
)
{
if
(
pDesc
->
tsOrder
==
TSDB_ORDER_ASC
)
{
// asc
if
(
pDesc
->
tsOrder
==
TSDB_ORDER_ASC
)
{
// asc
// todo refactor comparator
// todo refactor comparator
ret
=
compare_a
(
pLocalReducer
->
pDesc
,
1
,
0
,
pLocalReducer
->
prevRowOfInput
,
1
,
0
,
tmpBuffer
->
data
);
ret
=
compare_a
(
pLocalReducer
->
pDesc
,
1
,
0
,
pLocalReducer
->
prevRowOfInput
,
1
,
0
,
tmpBuffer
->
data
);
...
@@ -1274,7 +1275,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
...
@@ -1274,7 +1275,7 @@ bool doGenerateFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool no
taosFillCopyInputDataFromOneFilePage
(
pFillInfo
,
pResBuf
);
taosFillCopyInputDataFromOneFilePage
(
pFillInfo
,
pResBuf
);
}
}
do
Interpolate
Result
(
pSql
,
pLocalReducer
,
noMoreCurrentGroupRes
);
do
Fill
Result
(
pSql
,
pLocalReducer
,
noMoreCurrentGroupRes
);
return
true
;
return
true
;
}
}
...
@@ -1341,7 +1342,7 @@ static bool doBuildFilledResultForGroup(SSqlObj *pSql) {
...
@@ -1341,7 +1342,7 @@ static bool doBuildFilledResultForGroup(SSqlObj *pSql) {
// the first column must be the timestamp column
// the first column must be the timestamp column
int32_t
rows
=
taosGetNumOfResultWithFill
(
pFillInfo
,
remain
,
ekey
,
pLocalReducer
->
resColModel
->
capacity
);
int32_t
rows
=
taosGetNumOfResultWithFill
(
pFillInfo
,
remain
,
ekey
,
pLocalReducer
->
resColModel
->
capacity
);
if
(
rows
>
0
)
{
// do interpo
if
(
rows
>
0
)
{
// do interpo
do
Interpolate
Result
(
pSql
,
pLocalReducer
,
false
);
do
Fill
Result
(
pSql
,
pLocalReducer
,
false
);
}
}
return
true
;
return
true
;
...
@@ -1374,7 +1375,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
...
@@ -1374,7 +1375,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
pQueryInfo
->
slidingTimeUnit
,
tinfo
.
precision
);
pQueryInfo
->
slidingTimeUnit
,
tinfo
.
precision
);
int32_t
rows
=
taosGetNumOfResultWithFill
(
pFillInfo
,
0
,
etime
,
pLocalReducer
->
resColModel
->
capacity
);
int32_t
rows
=
taosGetNumOfResultWithFill
(
pFillInfo
,
0
,
etime
,
pLocalReducer
->
resColModel
->
capacity
);
if
(
rows
>
0
)
{
// do interpo
if
(
rows
>
0
)
{
// do interpo
do
Interpolate
Result
(
pSql
,
pLocalReducer
,
true
);
do
Fill
Result
(
pSql
,
pLocalReducer
,
true
);
}
}
}
}
...
@@ -1408,13 +1409,11 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
...
@@ -1408,13 +1409,11 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
];
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
k
];
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
*
numOfRes
;
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
*
numOfRes
;
// set the correct output timestamp column position
// set the correct output timestamp column position
if
(
p
Expr
->
functionId
==
TSDB_FUNC_TOP
||
pExpr
->
functionId
==
TSDB_FUNC_BOTTOM
)
{
if
(
p
Ctx
->
functionId
==
TSDB_FUNC_TOP
||
pCtx
->
functionId
==
TSDB_FUNC_BOTTOM
)
{
pCtx
->
ptsOutputBuf
=
((
char
*
)
pCtx
->
ptsOutputBuf
+
TSDB_KEYSIZE
*
numOfRes
);
pCtx
->
ptsOutputBuf
=
((
char
*
)
pCtx
->
ptsOutputBuf
+
TSDB_KEYSIZE
*
numOfRes
);
}
}
}
}
...
...
src/client/src/tscServer.c
浏览文件 @
adb62142
...
@@ -114,6 +114,8 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
...
@@ -114,6 +114,8 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
if
(
pIpList
->
numOfIps
>
0
)
if
(
pIpList
->
numOfIps
>
0
)
tscSetMgmtIpList
(
pIpList
);
tscSetMgmtIpList
(
pIpList
);
pSql
->
pTscObj
->
connId
=
htonl
(
pRsp
->
connId
);
if
(
pRsp
->
killConnection
)
{
if
(
pRsp
->
killConnection
)
{
tscKillConnection
(
pObj
);
tscKillConnection
(
pObj
);
}
else
{
}
else
{
...
@@ -332,9 +334,8 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
...
@@ -332,9 +334,8 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
rpcMsg
->
code
=
(
*
tscProcessMsgRsp
[
pCmd
->
command
])(
pSql
);
rpcMsg
->
code
=
(
*
tscProcessMsgRsp
[
pCmd
->
command
])(
pSql
);
if
(
rpcMsg
->
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
if
(
rpcMsg
->
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
rpcMsg
->
code
=
pRes
->
code
?
pRes
->
code
:
pRes
->
numOfRows
;
rpcMsg
->
code
=
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
?
pRes
->
numOfRows
:
pRes
->
code
;
tscTrace
(
"%p SQL result:%s res:%p"
,
pSql
,
tstrerror
(
pRes
->
code
),
pSql
);
bool
shouldFree
=
tscShouldBeFreed
(
pSql
);
bool
shouldFree
=
tscShouldBeFreed
(
pSql
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
rpcMsg
->
code
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
rpcMsg
->
code
);
...
@@ -1129,13 +1130,6 @@ int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1129,13 +1130,6 @@ int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCMKillQueryMsg
);
pCmd
->
payloadLen
=
sizeof
(
SCMKillQueryMsg
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
SCMKillQueryMsg
*
pKill
=
(
SCMKillQueryMsg
*
)
pCmd
->
payload
;
strncpy
(
pKill
->
queryId
,
pInfo
->
pDCLInfo
->
ip
.
z
,
pInfo
->
pDCLInfo
->
ip
.
n
);
switch
(
pCmd
->
command
)
{
switch
(
pCmd
->
command
)
{
case
TSDB_SQL_KILL_QUERY
:
case
TSDB_SQL_KILL_QUERY
:
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_KILL_QUERY
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_KILL_QUERY
;
...
@@ -1743,57 +1737,43 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1743,57 +1737,43 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int
tsc
EstimateHeartBeatMsgLength
(
SSqlObj
*
pSql
)
{
int
tsc
BuildHeartBeatMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
int
size
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
size
+=
tsRpcHeadSize
;
pthread_mutex_lock
(
&
pObj
->
mutex
);
size
+=
sizeof
(
SQqueryList
);
int32_t
numOfQueries
=
2
;
SSqlObj
*
tpSql
=
pObj
->
sqlList
;
SSqlObj
*
tpSql
=
pObj
->
sqlList
;
while
(
tpSql
)
{
while
(
tpSql
)
{
size
+=
sizeof
(
SQueryDesc
);
tpSql
=
tpSql
->
next
;
tpSql
=
tpSql
->
next
;
numOfQueries
++
;
}
}
size
+=
sizeof
(
SStreamList
)
;
int32_t
numOfStreams
=
2
;
SSqlStream
*
pStream
=
pObj
->
streamList
;
SSqlStream
*
pStream
=
pObj
->
streamList
;
while
(
pStream
)
{
while
(
pStream
)
{
size
+=
sizeof
(
SStreamDesc
);
pStream
=
pStream
->
next
;
pStream
=
pStream
->
next
;
numOfStreams
++
;
}
}
return
size
+
TSDB_EXTRA_PAYLOAD_SIZE
;
int
size
=
numOfQueries
*
sizeof
(
SQueryDesc
)
+
numOfStreams
*
sizeof
(
SStreamDesc
)
+
sizeof
(
SCMHeartBeatMsg
)
+
100
;
}
int
tscBuildHeartBeatMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
char
*
pMsg
,
*
pStart
;
int
msgLen
=
0
;
int
size
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
pthread_mutex_lock
(
&
pObj
->
mutex
);
size
=
tscEstimateHeartBeatMsgLength
(
pSql
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
pthread_mutex_unlock
(
&
pObj
->
mutex
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tscError
(
"%p failed to malloc for heartbeat msg"
,
pSql
);
tscError
(
"%p failed to malloc for heartbeat msg"
,
pSql
);
return
-
1
;
return
-
1
;
}
}
pMsg
=
pCmd
->
payload
;
SCMHeartBeatMsg
*
pHeartbeat
=
(
SCMHeartBeatMsg
*
)
pCmd
->
payload
;
pStart
=
pMsg
;
pHeartbeat
->
numOfQueries
=
numOfQueries
;
pHeartbeat
->
numOfStreams
=
numOfStreams
;
int
msgLen
=
tscBuildQueryStreamDesc
(
pHeartbeat
,
pObj
);
pMsg
=
tscBuildQueryStreamDesc
(
pMsg
,
pObj
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
pthread_mutex_unlock
(
&
pObj
->
mutex
);
msgLen
=
pMsg
-
pStart
;
pCmd
->
payloadLen
=
msgLen
;
pCmd
->
payloadLen
=
msgLen
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_HEARTBEAT
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_HEARTBEAT
;
assert
(
msgLen
+
minMsgSize
()
<=
size
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2204,6 +2184,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
...
@@ -2204,6 +2184,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
strcpy
(
pObj
->
sversion
,
pConnect
->
serverVersion
);
strcpy
(
pObj
->
sversion
,
pConnect
->
serverVersion
);
pObj
->
writeAuth
=
pConnect
->
writeAuth
;
pObj
->
writeAuth
=
pConnect
->
writeAuth
;
pObj
->
superAuth
=
pConnect
->
superAuth
;
pObj
->
superAuth
=
pConnect
->
superAuth
;
pObj
->
connId
=
htonl
(
pConnect
->
connId
);
taosTmrReset
(
tscProcessActivityTimer
,
tsShellActivityTimer
*
500
,
pObj
,
tscTmr
,
&
pObj
->
pTimer
);
taosTmrReset
(
tscProcessActivityTimer
,
tsShellActivityTimer
*
500
,
pObj
,
tscTmr
,
&
pObj
->
pTimer
);
return
0
;
return
0
;
...
@@ -2330,7 +2311,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
...
@@ -2330,7 +2311,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
}
}
pRes
->
row
=
0
;
pRes
->
row
=
0
;
tscTrace
(
"%p numOfRows:%d, offset:%d
"
,
pSql
,
pRes
->
numOfRows
,
pRes
->
offset
);
tscTrace
(
"%p numOfRows:%d, offset:%d
, complete:%d"
,
pSql
,
pRes
->
numOfRows
,
pRes
->
offset
,
pRes
->
completed
);
return
0
;
return
0
;
}
}
...
...
src/client/src/tscSql.c
浏览文件 @
adb62142
...
@@ -88,7 +88,6 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
...
@@ -88,7 +88,6 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
strncpy
(
pObj
->
user
,
user
,
TSDB_USER_LEN
);
strncpy
(
pObj
->
user
,
user
,
TSDB_USER_LEN
);
taosEncryptPass
((
uint8_t
*
)
pass
,
strlen
(
pass
),
pObj
->
pass
);
taosEncryptPass
((
uint8_t
*
)
pass
,
strlen
(
pass
),
pObj
->
pass
);
pObj
->
mnodePort
=
port
?
port
:
tsDnodeShellPort
;
if
(
db
)
{
if
(
db
)
{
int32_t
len
=
strlen
(
db
);
int32_t
len
=
strlen
(
db
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
adb62142
...
@@ -1557,8 +1557,8 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
...
@@ -1557,8 +1557,8 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
assert
(
pRes
->
numOfRows
==
numOfRows
);
assert
(
pRes
->
numOfRows
==
numOfRows
);
int64_t
num
=
atomic_add_fetch_64
(
&
pState
->
numOfRetrievedRows
,
numOfRows
);
int64_t
num
=
atomic_add_fetch_64
(
&
pState
->
numOfRetrievedRows
,
numOfRows
);
// tscTrace("%p sub:%p retrieve numOfRows:%d totalNumOfRows:%d from ip:%u,vid:%d,
orderOfSub:%d", pPObj, pSql,
tscTrace
(
"%p sub:%p retrieve numOfRows:%d totalNumOfRows:%d from ip:%s,
orderOfSub:%d"
,
pPObj
,
pSql
,
// pRes->numOfRows, pState->numOfRetrievedRows, pSvd->ip, pSvd->vnode
, idx);
pRes
->
numOfRows
,
pState
->
numOfRetrievedRows
,
pSql
->
ipList
.
fqdn
[
pSql
->
ipList
.
inUse
]
,
idx
);
if
(
num
>
tsMaxNumOfOrderedResults
&&
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
num
>
tsMaxNumOfOrderedResults
&&
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
tscError
(
"%p sub:%p num of OrderedRes is too many, max allowed:%"
PRId64
" , current:%"
PRId64
,
tscError
(
"%p sub:%p num of OrderedRes is too many, max allowed:%"
PRId64
" , current:%"
PRId64
,
...
@@ -1713,6 +1713,11 @@ static void multiVnodeInsertMerge(void* param, TAOS_RES* tres, int numOfRows) {
...
@@ -1713,6 +1713,11 @@ static void multiVnodeInsertMerge(void* param, TAOS_RES* tres, int numOfRows) {
// increase the total inserted rows
// increase the total inserted rows
if
(
numOfRows
>
0
)
{
if
(
numOfRows
>
0
)
{
pParentObj
->
res
.
numOfRows
+=
numOfRows
;
pParentObj
->
res
.
numOfRows
+=
numOfRows
;
}
else
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
assert
(
pSql
!=
NULL
&&
pSql
->
res
.
code
==
numOfRows
);
pParentObj
->
res
.
code
=
pSql
->
res
.
code
;
}
}
taos_free_result
(
tres
);
taos_free_result
(
tres
);
...
@@ -1947,7 +1952,8 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
...
@@ -1947,7 +1952,8 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
SFieldSupInfo
*
pSup
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
i
);
SFieldSupInfo
*
pSup
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
...
...
src/client/src/tscUtil.c
浏览文件 @
adb62142
...
@@ -404,8 +404,6 @@ void tscPartiallyFreeSqlObj(SSqlObj* pSql) {
...
@@ -404,8 +404,6 @@ void tscPartiallyFreeSqlObj(SSqlObj* pSql) {
pSql
->
numOfSubs
=
0
;
pSql
->
numOfSubs
=
0
;
tscResetSqlCmdObj
(
pCmd
);
tscResetSqlCmdObj
(
pCmd
);
tscTrace
(
"%p partially free sqlObj completed"
,
pSql
);
}
}
void
tscFreeSqlObj
(
SSqlObj
*
pSql
)
{
void
tscFreeSqlObj
(
SSqlObj
*
pSql
)
{
...
@@ -2104,7 +2102,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) {
...
@@ -2104,7 +2102,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) {
}
}
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
)
{
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
)
{
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
pFieldInfo
,
columnIndex
);
SFieldSupInfo
*
pInfo
=
t
aosArrayGet
(
pFieldInfo
->
pSupportInfo
,
columnIndex
);
//t
scFieldInfoGetSupp(pFieldInfo, columnIndex);
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
int32_t
type
=
pInfo
->
pSqlExpr
->
resType
;
int32_t
type
=
pInfo
->
pSqlExpr
->
resType
;
...
...
src/common/inc/tdataformat.h
浏览文件 @
adb62142
...
@@ -251,7 +251,7 @@ void tdFreeDataCols(SDataCols *pCols);
...
@@ -251,7 +251,7 @@ void tdFreeDataCols(SDataCols *pCols);
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
STSchema
*
pSchema
,
SDataCols
*
pCols
);
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
STSchema
*
pSchema
,
SDataCols
*
pCols
);
void
tdPopDataColsPoints
(
SDataCols
*
pCols
,
int
pointsToPop
);
//!!!!
void
tdPopDataColsPoints
(
SDataCols
*
pCols
,
int
pointsToPop
);
//!!!!
int
tdMergeDataCols
(
SDataCols
*
target
,
SDataCols
*
src
,
int
rowsToMerge
);
int
tdMergeDataCols
(
SDataCols
*
target
,
SDataCols
*
src
,
int
rowsToMerge
);
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
SDataCols
*
src2
,
int
*
iter
2
,
int
tRows
);
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
int
limit1
,
SDataCols
*
src2
,
int
*
iter2
,
int
limit
2
,
int
tRows
);
// ----------------- K-V data row structure
// ----------------- K-V data row structure
/*
/*
...
...
src/common/src/tdataformat.c
浏览文件 @
adb62142
...
@@ -450,7 +450,8 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
...
@@ -450,7 +450,8 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
int
iter1
=
0
;
int
iter1
=
0
;
int
iter2
=
0
;
int
iter2
=
0
;
tdMergeTwoDataCols
(
target
,
pTarget
,
&
iter1
,
source
,
&
iter2
,
pTarget
->
numOfRows
+
rowsToMerge
);
tdMergeTwoDataCols
(
target
,
pTarget
,
&
iter1
,
pTarget
->
numOfRows
,
source
,
&
iter2
,
source
->
numOfRows
,
pTarget
->
numOfRows
+
rowsToMerge
);
}
}
tdFreeDataCols
(
pTarget
);
tdFreeDataCols
(
pTarget
);
...
@@ -461,15 +462,15 @@ _err:
...
@@ -461,15 +462,15 @@ _err:
return
-
1
;
return
-
1
;
}
}
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
SDataCols
*
src2
,
int
*
iter2
,
int
tRows
)
{
void
tdMergeTwoDataCols
(
SDataCols
*
target
,
SDataCols
*
src1
,
int
*
iter1
,
int
limit1
,
SDataCols
*
src2
,
int
*
iter2
,
int
limit2
,
int
tRows
)
{
// TODO: add resolve duplicate key here
tdResetDataCols
(
target
);
tdResetDataCols
(
target
);
ASSERT
(
limit1
<=
src1
->
numOfRows
&&
limit2
<=
src2
->
numOfRows
);
while
(
target
->
numOfRows
<
tRows
)
{
while
(
target
->
numOfRows
<
tRows
)
{
if
(
*
iter1
>=
src1
->
numOfRows
&&
*
iter2
>=
src2
->
numOfRows
)
break
;
if
(
*
iter1
>=
limit1
&&
*
iter2
>=
limit2
)
break
;
TSKEY
key1
=
(
*
iter1
>=
src1
->
numOfRows
)
?
INT64_MAX
:
((
TSKEY
*
)(
src1
->
cols
[
0
].
pData
))[
*
iter1
];
TSKEY
key1
=
(
*
iter1
>=
limit1
)
?
INT64_MAX
:
((
TSKEY
*
)(
src1
->
cols
[
0
].
pData
))[
*
iter1
];
TSKEY
key2
=
(
*
iter2
>=
src2
->
numOfRows
)
?
INT64_MAX
:
((
TSKEY
*
)(
src2
->
cols
[
0
].
pData
))[
*
iter2
];
TSKEY
key2
=
(
*
iter2
>=
limit2
)
?
INT64_MAX
:
((
TSKEY
*
)(
src2
->
cols
[
0
].
pData
))[
*
iter2
];
if
(
key1
<=
key2
)
{
if
(
key1
<=
key2
)
{
for
(
int
i
=
0
;
i
<
src1
->
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
src1
->
numOfCols
;
i
++
)
{
...
...
src/common/src/tglobal.c
浏览文件 @
adb62142
...
@@ -112,7 +112,7 @@ int32_t tsMaxShellConns = 5000;
...
@@ -112,7 +112,7 @@ int32_t tsMaxShellConns = 5000;
char
tsDefaultDB
[
TSDB_DB_NAME_LEN
]
=
{
0
};
char
tsDefaultDB
[
TSDB_DB_NAME_LEN
]
=
{
0
};
char
tsDefaultUser
[
64
]
=
"root"
;
char
tsDefaultUser
[
64
]
=
"root"
;
char
tsDefaultPass
[
64
]
=
"taosdata"
;
char
tsDefaultPass
[
64
]
=
"taosdata"
;
int32_t
tsMaxConnections
=
50
;
int32_t
tsMaxConnections
=
50
00
;
int32_t
tsBalanceInterval
=
300
;
// seconds
int32_t
tsBalanceInterval
=
300
;
// seconds
int32_t
tsOfflineThreshold
=
86400
*
100
;
// seconds 10days
int32_t
tsOfflineThreshold
=
86400
*
100
;
// seconds 10days
...
@@ -840,7 +840,7 @@ static void doInitGlobalConfig() {
...
@@ -840,7 +840,7 @@ static void doInitGlobalConfig() {
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
1
;
cfg
.
minValue
=
1
;
cfg
.
maxValue
=
100
;
cfg
.
maxValue
=
100
000
;
cfg
.
ptrLength
=
0
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
taosInitConfigOption
(
cfg
);
...
...
src/connector/python/linux/python2/taos/cinterface.py
浏览文件 @
adb62142
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_query
.
restype
=
ctypes
.
POINTER
(
ctypes
.
c_void_p
)
def
__init__
(
self
,
config
=
None
):
def
__init__
(
self
,
config
=
None
):
'''
'''
...
...
src/connector/python/linux/python3/taos/cinterface.py
浏览文件 @
adb62142
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_query
.
restype
=
ctypes
.
POINTER
(
ctypes
.
c_void_p
)
def
__init__
(
self
,
config
=
None
):
def
__init__
(
self
,
config
=
None
):
'''
'''
...
...
src/connector/python/windows/python2/taos/cinterface.py
浏览文件 @
adb62142
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_query
.
restype
=
ctypes
.
POINTER
(
ctypes
.
c_void_p
)
def
__init__
(
self
,
config
=
None
):
def
__init__
(
self
,
config
=
None
):
'''
'''
...
...
src/connector/python/windows/python3/taos/cinterface.py
浏览文件 @
adb62142
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
...
@@ -150,6 +150,7 @@ class CTaosInterface(object):
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_fetch_lengths
.
restype
=
ctypes
.
c_void_p
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_free_result
.
restype
=
None
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_errno
.
restype
=
ctypes
.
c_int
libtaos
.
taos_query
.
restype
=
ctypes
.
POINTER
(
ctypes
.
c_void_p
)
def
__init__
(
self
,
config
=
None
):
def
__init__
(
self
,
config
=
None
):
'''
'''
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
adb62142
...
@@ -46,7 +46,7 @@ typedef struct {
...
@@ -46,7 +46,7 @@ typedef struct {
void
(
*
cleanup
)();
void
(
*
cleanup
)();
}
SDnodeComponent
;
}
SDnodeComponent
;
static
const
SDnodeComponent
S
DnodeComponents
[]
=
{
static
const
SDnodeComponent
ts
DnodeComponents
[]
=
{
{
"storage"
,
dnodeInitStorage
,
dnodeCleanupStorage
},
{
"storage"
,
dnodeInitStorage
,
dnodeCleanupStorage
},
{
"vread"
,
dnodeInitVnodeRead
,
dnodeCleanupVnodeRead
},
{
"vread"
,
dnodeInitVnodeRead
,
dnodeCleanupVnodeRead
},
{
"vwrite"
,
dnodeInitVnodeWrite
,
dnodeCleanupVnodeWrite
},
{
"vwrite"
,
dnodeInitVnodeWrite
,
dnodeCleanupVnodeWrite
},
...
@@ -72,14 +72,14 @@ static int dnodeCreateDir(const char *dir) {
...
@@ -72,14 +72,14 @@ static int dnodeCreateDir(const char *dir) {
static
void
dnodeCleanupComponents
(
int32_t
stepId
)
{
static
void
dnodeCleanupComponents
(
int32_t
stepId
)
{
for
(
int32_t
i
=
stepId
;
i
>=
0
;
i
--
)
{
for
(
int32_t
i
=
stepId
;
i
>=
0
;
i
--
)
{
S
DnodeComponents
[
i
].
cleanup
();
ts
DnodeComponents
[
i
].
cleanup
();
}
}
}
}
static
int32_t
dnodeInitComponents
()
{
static
int32_t
dnodeInitComponents
()
{
int32_t
code
=
0
;
int32_t
code
=
0
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
SDnodeComponents
)
/
sizeof
(
S
DnodeComponents
[
0
]);
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sizeof
(
tsDnodeComponents
)
/
sizeof
(
ts
DnodeComponents
[
0
]);
i
++
)
{
if
(
S
DnodeComponents
[
i
].
init
()
!=
0
)
{
if
(
ts
DnodeComponents
[
i
].
init
()
!=
0
)
{
dnodeCleanupComponents
(
i
);
dnodeCleanupComponents
(
i
);
code
=
-
1
;
code
=
-
1
;
break
;
break
;
...
@@ -133,7 +133,7 @@ int32_t dnodeInitSystem() {
...
@@ -133,7 +133,7 @@ int32_t dnodeInitSystem() {
void
dnodeCleanUpSystem
()
{
void
dnodeCleanUpSystem
()
{
if
(
dnodeGetRunStatus
()
!=
TSDB_DNODE_RUN_STATUS_STOPPED
)
{
if
(
dnodeGetRunStatus
()
!=
TSDB_DNODE_RUN_STATUS_STOPPED
)
{
dnodeSetRunStatus
(
TSDB_DNODE_RUN_STATUS_STOPPED
);
dnodeSetRunStatus
(
TSDB_DNODE_RUN_STATUS_STOPPED
);
dnodeCleanupComponents
(
sizeof
(
SDnodeComponents
)
/
sizeof
(
S
DnodeComponents
[
0
])
-
1
);
dnodeCleanupComponents
(
sizeof
(
tsDnodeComponents
)
/
sizeof
(
ts
DnodeComponents
[
0
])
-
1
);
taos_cleanup
();
taos_cleanup
();
taosCloseLog
();
taosCloseLog
();
}
}
...
...
src/inc/taosdef.h
浏览文件 @
adb62142
...
@@ -231,7 +231,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
...
@@ -231,7 +231,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_SHELL_VNODE_BITS 24
#define TSDB_SHELL_VNODE_BITS 24
#define TSDB_SHELL_SID_MASK 0xFF
#define TSDB_SHELL_SID_MASK 0xFF
#define TSDB_HTTP_TOKEN_LEN 20
#define TSDB_HTTP_TOKEN_LEN 20
#define TSDB_SHOW_SQL_LEN 512
#define TSDB_SHOW_SQL_LEN 64
#define TSDB_SLOW_QUERY_SQL_LEN 512
#define TSDB_METER_STATE_OFFLINE 0
#define TSDB_METER_STATE_OFFLINE 0
#define TSDB_METER_STATE_ONLLINE 1
#define TSDB_METER_STATE_ONLLINE 1
...
...
src/inc/taoserror.h
浏览文件 @
adb62142
...
@@ -150,6 +150,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 0x0405, "no disk perm
...
@@ -150,6 +150,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 0x0405, "no disk perm
TAOS_DEFINE_ERROR
(
TSDB_CODE_FILE_CORRUPTED
,
0
,
0x0406
,
"file corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FILE_CORRUPTED
,
0
,
0x0406
,
"file corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MEMORY_CORRUPTED
,
0
,
0x0407
,
"memory corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MEMORY_CORRUPTED
,
0
,
0x0407
,
"memory corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NOT_SUCH_FILE_OR_DIR
,
0
,
0x0408
,
"no such file or directory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NOT_SUCH_FILE_OR_DIR
,
0
,
0x0408
,
"no such file or directory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TOO_MANY_SHELL_CONNS
,
0
,
0x0409
,
"too many shell conns"
)
// client
// client
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CLIENT_VERSION
,
0
,
0x0481
,
"invalid client version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CLIENT_VERSION
,
0
,
0x0481
,
"invalid client version"
)
...
...
src/inc/taosmsg.h
浏览文件 @
adb62142
...
@@ -137,6 +137,7 @@ enum _mgmt_table {
...
@@ -137,6 +137,7 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_SCORES
,
TSDB_MGMT_TABLE_SCORES
,
TSDB_MGMT_TABLE_GRANTS
,
TSDB_MGMT_TABLE_GRANTS
,
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_VNODES
,
TSDB_MGMT_TABLE_STREAMTABLES
,
TSDB_MGMT_TABLE_MAX
,
TSDB_MGMT_TABLE_MAX
,
};
};
...
@@ -299,6 +300,9 @@ typedef struct {
...
@@ -299,6 +300,9 @@ typedef struct {
char
serverVersion
[
TSDB_VERSION_LEN
];
char
serverVersion
[
TSDB_VERSION_LEN
];
int8_t
writeAuth
;
int8_t
writeAuth
;
int8_t
superAuth
;
int8_t
superAuth
;
int8_t
reserved1
;
int8_t
reserved2
;
int32_t
connId
;
SRpcIpSet
ipList
;
SRpcIpSet
ipList
;
}
SCMConnectRsp
;
}
SCMConnectRsp
;
...
@@ -716,16 +720,10 @@ typedef struct {
...
@@ -716,16 +720,10 @@ typedef struct {
}
SStreamDesc
;
}
SStreamDesc
;
typedef
struct
{
typedef
struct
{
uint32_t
connId
;
int32_t
numOfQueries
;
int32_t
numOfQueries
;
}
SQqueryList
;
typedef
struct
{
int32_t
numOfStreams
;
int32_t
numOfStreams
;
}
SStreamList
;
char
pData
[];
typedef
struct
{
SQqueryList
qlist
;
SStreamList
slist
;
}
SCMHeartBeatMsg
;
}
SCMHeartBeatMsg
;
typedef
struct
{
typedef
struct
{
...
@@ -733,6 +731,7 @@ typedef struct {
...
@@ -733,6 +731,7 @@ typedef struct {
uint32_t
streamId
;
uint32_t
streamId
;
uint32_t
totalDnodes
;
uint32_t
totalDnodes
;
uint32_t
onlineDnodes
;
uint32_t
onlineDnodes
;
uint32_t
connId
;
int8_t
killConnection
;
int8_t
killConnection
;
SRpcIpSet
ipList
;
SRpcIpSet
ipList
;
}
SCMHeartBeatRsp
;
}
SCMHeartBeatRsp
;
...
...
src/inc/tsdb.h
浏览文件 @
adb62142
...
@@ -188,9 +188,10 @@ typedef void *TsdbPosT;
...
@@ -188,9 +188,10 @@ typedef void *TsdbPosT;
* @param tsdb tsdb handle
* @param tsdb tsdb handle
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param groupInfo tableId list in the form of set, seperated into different groups according to group by condition
* @param groupInfo tableId list in the form of set, seperated into different groups according to group by condition
* @param qinfo query info handle from query processor
* @return
* @return
*/
*/
TsdbQueryHandleT
*
tsdbQueryTables
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
);
TsdbQueryHandleT
*
tsdbQueryTables
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
,
void
*
qinfo
);
/**
/**
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
...
@@ -202,11 +203,11 @@ TsdbQueryHandleT *tsdbQueryTables(TsdbRepoT *tsdb, STsdbQueryCond *pCond, STable
...
@@ -202,11 +203,11 @@ TsdbQueryHandleT *tsdbQueryTables(TsdbRepoT *tsdb, STsdbQueryCond *pCond, STable
* @param groupInfo tableId list.
* @param groupInfo tableId list.
* @return
* @return
*/
*/
TsdbQueryHandleT
tsdbQueryLastRow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
);
TsdbQueryHandleT
tsdbQueryLastRow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
,
void
*
qinfo
);
SArray
*
tsdbGetQueriedTableIdList
(
TsdbQueryHandleT
*
pHandle
);
SArray
*
tsdbGetQueriedTableIdList
(
TsdbQueryHandleT
*
pHandle
);
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
);
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
);
/**
/**
* move to next block if exists
* move to next block if exists
...
...
src/inc/ttokendef.h
浏览文件 @
adb62142
...
@@ -148,8 +148,8 @@
...
@@ -148,8 +148,8 @@
#define TK_SET 130
#define TK_SET 130
#define TK_KILL 131
#define TK_KILL 131
#define TK_CONNECTION 132
#define TK_CONNECTION 132
#define TK_
COLON
133
#define TK_
STREAM
133
#define TK_
STREAM
134
#define TK_
COLON
134
#define TK_ABORT 135
#define TK_ABORT 135
#define TK_AFTER 136
#define TK_AFTER 136
#define TK_ATTACH 137
#define TK_ATTACH 137
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
adb62142
...
@@ -182,8 +182,6 @@ typedef struct SUserObj {
...
@@ -182,8 +182,6 @@ typedef struct SUserObj {
int8_t
updateEnd
[
1
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
refCount
;
struct
SAcctObj
*
pAcct
;
struct
SAcctObj
*
pAcct
;
SQqueryList
*
pQList
;
// query list
SStreamList
*
pSList
;
// stream list
}
SUserObj
;
}
SUserObj
;
typedef
struct
{
typedef
struct
{
...
...
src/mnode/inc/mnodeProfile.h
浏览文件 @
adb62142
...
@@ -21,9 +21,30 @@ extern "C" {
...
@@ -21,9 +21,30 @@ extern "C" {
#endif
#endif
#include "mnodeDef.h"
#include "mnodeDef.h"
typedef
struct
{
char
user
[
TSDB_USER_LEN
+
1
];
int8_t
killed
;
uint16_t
port
;
uint32_t
ip
;
uint32_t
connId
;
uint64_t
stime
;
uint64_t
lastAccess
;
uint32_t
queryId
;
uint32_t
streamId
;
int32_t
numOfQueries
;
int32_t
numOfStreams
;
SStreamDesc
*
pStreams
;
SQueryDesc
*
pQueries
;
}
SConnObj
;
int32_t
mnodeInitProfile
();
int32_t
mnodeInitProfile
();
void
mnodeCleanupProfile
();
void
mnodeCleanupProfile
();
SConnObj
*
mnodeCreateConn
(
char
*
user
,
uint32_t
ip
,
uint16_t
port
);
SConnObj
*
mnodeAccquireConn
(
uint32_t
connId
,
char
*
user
,
uint32_t
ip
,
uint16_t
port
);
void
mnodeReleaseConn
(
SConnObj
*
pConn
);
int32_t
mnodeSaveQueryStreamList
(
SConnObj
*
pConn
,
SCMHeartBeatMsg
*
pHBMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/inc/mnodeShow.h
浏览文件 @
adb62142
...
@@ -28,6 +28,7 @@ typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pCon
...
@@ -28,6 +28,7 @@ typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pCon
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
void
mnodeAddShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
fp
);
void
mnodeAddShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
fp
);
void
mnodeAddShowRetrieveHandle
(
uint8_t
showType
,
SShowRetrieveFp
fp
);
void
mnodeAddShowRetrieveHandle
(
uint8_t
showType
,
SShowRetrieveFp
fp
);
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/mnode/src/mnodeMain.c
浏览文件 @
adb62142
...
@@ -33,14 +33,54 @@
...
@@ -33,14 +33,54 @@
#include "mnodeUser.h"
#include "mnodeUser.h"
#include "mnodeTable.h"
#include "mnodeTable.h"
#include "mnodeShow.h"
#include "mnodeShow.h"
#include "mnodeProfile.h"
typedef
struct
{
const
char
*
const
name
;
int
(
*
init
)();
void
(
*
cleanup
)();
}
SMnodeComponent
;
void
*
tsMnodeTmr
;
void
*
tsMnodeTmr
;
static
bool
tsMgmtIsRunning
=
false
;
static
bool
tsMgmtIsRunning
=
false
;
static
const
SMnodeComponent
tsMnodeComponents
[]
=
{
{
"profile"
,
mnodeInitProfile
,
mnodeCleanupProfile
},
{
"accts"
,
mnodeInitAccts
,
mnodeCleanupAccts
},
{
"users"
,
mnodeInitUsers
,
mnodeCleanupUsers
},
{
"dnodes"
,
mnodeInitDnodes
,
mnodeCleanupDnodes
},
{
"dbs"
,
mnodeInitDbs
,
mnodeCleanupDbs
},
{
"vgroups"
,
mnodeInitVgroups
,
mnodeCleanupVgroups
},
{
"tables"
,
mnodeInitTables
,
mnodeCleanupTables
},
{
"mnodes"
,
mnodeInitMnodes
,
mnodeCleanupMnodes
},
{
"sdb"
,
sdbInit
,
sdbCleanUp
},
{
"balance"
,
balanceInit
,
balanceCleanUp
},
{
"grant"
,
grantInit
,
grantCleanUp
},
{
"show"
,
mnodeInitShow
,
mnodeCleanUpShow
}
};
static
void
mnodeInitTimer
();
static
void
mnodeInitTimer
();
static
void
mnodeCleanupTimer
();
static
void
mnodeCleanupTimer
();
static
bool
mnodeNeedStart
()
;
static
bool
mnodeNeedStart
()
;
static
void
mnodeCleanupComponents
(
int32_t
stepId
)
{
for
(
int32_t
i
=
stepId
;
i
>=
0
;
i
--
)
{
tsMnodeComponents
[
i
].
cleanup
();
}
}
static
int32_t
mnodeInitComponents
()
{
int32_t
code
=
0
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
tsMnodeComponents
)
/
sizeof
(
tsMnodeComponents
[
0
]);
i
++
)
{
if
(
tsMnodeComponents
[
i
].
init
()
!=
0
)
{
mnodeCleanupComponents
(
i
);
code
=
-
1
;
break
;
}
}
return
code
;
}
int32_t
mnodeStartSystem
()
{
int32_t
mnodeStartSystem
()
{
if
(
tsMgmtIsRunning
)
{
if
(
tsMgmtIsRunning
)
{
mPrint
(
"mnode module already started..."
);
mPrint
(
"mnode module already started..."
);
...
@@ -57,57 +97,7 @@ int32_t mnodeStartSystem() {
...
@@ -57,57 +97,7 @@ int32_t mnodeStartSystem() {
dnodeAllocateMnodeRqueue
();
dnodeAllocateMnodeRqueue
();
dnodeAllocateMnodePqueue
();
dnodeAllocateMnodePqueue
();
if
(
mnodeInitAccts
()
<
0
)
{
if
(
mnodeInitComponents
()
!=
0
)
{
mError
(
"failed to init accts"
);
return
-
1
;
}
if
(
mnodeInitUsers
()
<
0
)
{
mError
(
"failed to init users"
);
return
-
1
;
}
if
(
mnodeInitDnodes
()
<
0
)
{
mError
(
"failed to init dnodes"
);
return
-
1
;
}
if
(
mnodeInitDbs
()
<
0
)
{
mError
(
"failed to init dbs"
);
return
-
1
;
}
if
(
mnodeInitVgroups
()
<
0
)
{
mError
(
"failed to init vgroups"
);
return
-
1
;
}
if
(
mnodeInitTables
()
<
0
)
{
mError
(
"failed to init tables"
);
return
-
1
;
}
if
(
mnodeInitMnodes
()
<
0
)
{
mError
(
"failed to init mnodes"
);
return
-
1
;
}
if
(
sdbInit
()
<
0
)
{
mError
(
"failed to init sdb"
);
return
-
1
;
}
if
(
balanceInit
()
<
0
)
{
mError
(
"failed to init balance"
)
}
if
(
grantInit
()
<
0
)
{
mError
(
"failed to init grant"
);
return
-
1
;
}
if
(
mnodeInitShow
()
<
0
)
{
mError
(
"failed to init show"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -115,7 +105,6 @@ int32_t mnodeStartSystem() {
...
@@ -115,7 +105,6 @@ int32_t mnodeStartSystem() {
tsMgmtIsRunning
=
true
;
tsMgmtIsRunning
=
true
;
mPrint
(
"mnode is initialized successfully"
);
mPrint
(
"mnode is initialized successfully"
);
return
0
;
return
0
;
}
}
...
@@ -133,17 +122,8 @@ void mnodeCleanupSystem() {
...
@@ -133,17 +122,8 @@ void mnodeCleanupSystem() {
dnodeFreeMnodeRqueue
();
dnodeFreeMnodeRqueue
();
dnodeFreeMnodePqueue
();
dnodeFreeMnodePqueue
();
mnodeCleanupTimer
();
mnodeCleanupTimer
();
mnodeCleanUpShow
();
mnodeCleanupComponents
(
sizeof
(
tsMnodeComponents
)
/
sizeof
(
tsMnodeComponents
[
0
])
-
1
);
grantCleanUp
();
balanceCleanUp
();
sdbCleanUp
();
mnodeCleanupMnodes
();
mnodeCleanupTables
();
mnodeCleanupVgroups
();
mnodeCleanupDbs
();
mnodeCleanupDnodes
();
mnodeCleanupUsers
();
mnodeCleanupAccts
();
mPrint
(
"mnode is cleaned up"
);
mPrint
(
"mnode is cleaned up"
);
}
}
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
src/mnode/src/mnodeShow.c
浏览文件 @
adb62142
...
@@ -227,21 +227,47 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
...
@@ -227,21 +227,47 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
}
SCMHeartBeatMsg
*
pHBMsg
=
pMsg
->
rpcMsg
.
pCont
;
SRpcConnInfo
connInfo
;
rpcGetConnInfo
(
pMsg
->
rpcMsg
.
handle
,
&
connInfo
);
int32_t
connId
=
htonl
(
pHBMsg
->
connId
);
SConnObj
*
pConn
=
mnodeAccquireConn
(
connId
,
connInfo
.
user
,
connInfo
.
clientIp
,
connInfo
.
clientPort
);
if
(
pConn
==
NULL
)
{
pConn
=
mnodeCreateConn
(
connInfo
.
user
,
connInfo
.
clientIp
,
connInfo
.
clientPort
);
}
if
(
pConn
==
NULL
)
{
// do not close existing links, otherwise
// mError("failed to create connId, close connect");
// pHBRsp->killConnection = 1;
}
else
{
pHBRsp
->
connId
=
htonl
(
pConn
->
connId
);
mnodeSaveQueryStreamList
(
pConn
,
pHBMsg
);
if
(
pConn
->
killed
!=
0
)
{
pHBRsp
->
killConnection
=
1
;
}
if
(
pConn
->
streamId
!=
0
)
{
pHBRsp
->
streamId
=
htonl
(
pConn
->
streamId
);
pConn
->
streamId
=
0
;
}
if
(
pConn
->
queryId
!=
0
)
{
pHBRsp
->
queryId
=
htonl
(
pConn
->
queryId
);
pConn
->
queryId
=
0
;
}
}
pHBRsp
->
onlineDnodes
=
htonl
(
mnodeGetOnlinDnodesNum
());
pHBRsp
->
onlineDnodes
=
htonl
(
mnodeGetOnlinDnodesNum
());
pHBRsp
->
totalDnodes
=
htonl
(
mnodeGetDnodesNum
());
pHBRsp
->
totalDnodes
=
htonl
(
mnodeGetDnodesNum
());
mnodeGetMnodeIpSetForShell
(
&
pHBRsp
->
ipList
);
mnodeGetMnodeIpSetForShell
(
&
pHBRsp
->
ipList
);
/*
* TODO
* Dispose kill stream or kill query message
*/
pHBRsp
->
queryId
=
0
;
pHBRsp
->
streamId
=
0
;
pHBRsp
->
killConnection
=
0
;
pMsg
->
rpcRsp
.
rsp
=
pHBRsp
;
pMsg
->
rpcRsp
.
rsp
=
pHBRsp
;
pMsg
->
rpcRsp
.
len
=
sizeof
(
SCMHeartBeatRsp
);
pMsg
->
rpcRsp
.
len
=
sizeof
(
SCMHeartBeatRsp
);
mnodeReleaseConn
(
pConn
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -281,6 +307,14 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
...
@@ -281,6 +307,14 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) {
goto
connect_over
;
goto
connect_over
;
}
}
SConnObj
*
pConn
=
mnodeCreateConn
(
connInfo
.
user
,
connInfo
.
clientIp
,
connInfo
.
clientPort
);
if
(
pConn
==
NULL
)
{
code
=
terrno
;
}
else
{
pConnectRsp
->
connId
=
htonl
(
pConn
->
connId
);
mnodeReleaseConn
(
pConn
);
}
sprintf
(
pConnectRsp
->
acctId
,
"%x"
,
pAcct
->
acctId
);
sprintf
(
pConnectRsp
->
acctId
,
"%x"
,
pAcct
->
acctId
);
strcpy
(
pConnectRsp
->
serverVersion
,
version
);
strcpy
(
pConnectRsp
->
serverVersion
,
version
);
pConnectRsp
->
writeAuth
=
pUser
->
writeAuth
;
pConnectRsp
->
writeAuth
=
pUser
->
writeAuth
;
...
@@ -358,3 +392,11 @@ static void mnodeReleaseShowObj(void *pShow, bool forceRemove) {
...
@@ -358,3 +392,11 @@ static void mnodeReleaseShowObj(void *pShow, bool forceRemove) {
mTrace
(
"%p, show is released, force:%s"
,
pShow
,
forceRemove
?
"true"
:
"false"
);
mTrace
(
"%p, show is released, force:%s"
,
pShow
,
forceRemove
?
"true"
:
"false"
);
taosCacheRelease
(
tsMnodeShowCache
,
&
pShow
,
forceRemove
);
taosCacheRelease
(
tsMnodeShowCache
,
&
pShow
,
forceRemove
);
}
}
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
)
{
if
(
rows
<
capacity
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
memmove
(
data
+
pShow
->
offset
[
i
]
*
rows
,
data
+
pShow
->
offset
[
i
]
*
capacity
,
pShow
->
bytes
[
i
]
*
rows
);
}
}
}
\ No newline at end of file
src/mnode/src/mnodeTable.c
浏览文件 @
adb62142
...
@@ -61,8 +61,8 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
...
@@ -61,8 +61,8 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
static
int32_t
mnodeRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeGetShowSuperTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetShowSuperTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveShowSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveShowSuperTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeGetStreamMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetStream
Table
Meta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStream
Table
s
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeProcessCreateTableMsg
(
SMnodeMsg
*
mnodeMsg
);
static
int32_t
mnodeProcessCreateTableMsg
(
SMnodeMsg
*
mnodeMsg
);
static
int32_t
mnodeProcessCreateSuperTableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessCreateSuperTableMsg
(
SMnodeMsg
*
pMsg
);
...
@@ -568,8 +568,8 @@ int32_t mnodeInitTables() {
...
@@ -568,8 +568,8 @@ int32_t mnodeInitTables() {
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeRetrieveShowTables
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeRetrieveShowTables
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeGetShowSuperTableMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeGetShowSuperTableMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeRetrieveShowSuperTables
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeRetrieveShowSuperTables
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_STREAM
S
,
mnodeGetStream
Meta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_STREAM
TABLES
,
mnodeGetStreamTable
Meta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_STREAM
S
,
mnodeRetrieveStream
s
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_STREAM
TABLES
,
mnodeRetrieveStreamTable
s
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1284,7 +1284,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1284,7 +1284,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
char
*
msg
=
(
char
*
)
pRsp
+
sizeof
(
SCMSTableVgroupRspMsg
);
char
*
msg
=
(
char
*
)
pRsp
+
sizeof
(
SCMSTableVgroupRspMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_ID_LEN
)
*
i
;
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_ID_LEN
)
*
i
;
SSuperTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
SSuperTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"stable:%s, not exist while get stable vgroup info"
,
stableName
);
mError
(
"stable:%s, not exist while get stable vgroup info"
,
stableName
);
...
@@ -1294,9 +1294,15 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1294,9 +1294,15 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
if
(
pTable
->
vgHash
==
NULL
)
{
if
(
pTable
->
vgHash
==
NULL
)
{
mError
(
"stable:%s, not vgroup exist while get stable vgroup info"
,
stableName
);
mError
(
"stable:%s, not vgroup exist while get stable vgroup info"
,
stableName
);
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
continue
;
}
// even this super table has no corresponding table, still return
pRsp
->
numOfTables
++
;
SVgroupsInfo
*
pVgroupInfo
=
(
SVgroupsInfo
*
)
msg
;
pVgroupInfo
->
numOfVgroups
=
0
;
msg
+=
sizeof
(
SVgroupsInfo
);
}
else
{
SVgroupsInfo
*
pVgroupInfo
=
(
SVgroupsInfo
*
)
msg
;
SVgroupsInfo
*
pVgroupInfo
=
(
SVgroupsInfo
*
)
msg
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
vgHash
);
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
vgHash
);
...
@@ -1330,6 +1336,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1330,6 +1336,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
msg
+=
sizeof
(
SVgroupsInfo
)
+
vgSize
*
sizeof
(
SCMVgroupInfo
);
msg
+=
sizeof
(
SVgroupsInfo
)
+
vgSize
*
sizeof
(
SCMVgroupInfo
);
pRsp
->
numOfTables
++
;
pRsp
->
numOfTables
++
;
}
}
}
if
(
pRsp
->
numOfTables
!=
numOfTable
)
{
if
(
pRsp
->
numOfTables
!=
numOfTable
)
{
rpcFreeCont
(
pRsp
);
rpcFreeCont
(
pRsp
);
...
@@ -2111,14 +2118,6 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
...
@@ -2111,14 +2118,6 @@ static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void
return
0
;
return
0
;
}
}
static
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
)
{
if
(
rows
<
capacity
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
memmove
(
data
+
pShow
->
offset
[
i
]
*
rows
,
data
+
pShow
->
offset
[
i
]
*
capacity
,
pShow
->
bytes
[
i
]
*
rows
);
}
}
}
static
int32_t
mnodeRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
static
int32_t
mnodeRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
if
(
pDb
==
NULL
)
return
0
;
...
@@ -2262,7 +2261,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
...
@@ -2262,7 +2261,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
return
code
;
return
code
;
}
}
static
int32_t
mnodeGetStreamMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mnodeGetStream
Table
Meta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
...
@@ -2308,7 +2307,7 @@ static int32_t mnodeGetStreamMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
...
@@ -2308,7 +2307,7 @@ static int32_t mnodeGetStreamMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
return
0
;
return
0
;
}
}
static
int32_t
mnodeRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
static
int32_t
mnodeRetrieveStream
Table
s
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
SDbObj
*
pDb
=
mnodeGetDb
(
pShow
->
db
);
if
(
pDb
==
NULL
)
return
0
;
if
(
pDb
==
NULL
)
return
0
;
...
...
src/plugins/monitor/src/monitorMain.c
浏览文件 @
adb62142
...
@@ -183,7 +183,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
...
@@ -183,7 +183,7 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
snprintf
(
sql
,
SQL_LENGTH
,
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists %s.slowquery(ts timestamp, username "
"create table if not exists %s.slowquery(ts timestamp, username "
"binary(%d), created_time timestamp, time bigint, sql binary(%d))"
,
"binary(%d), created_time timestamp, time bigint, sql binary(%d))"
,
tsMonitorDbName
,
TSDB_TABLE_ID_LEN
,
TSDB_S
HOW
_SQL_LEN
);
tsMonitorDbName
,
TSDB_TABLE_ID_LEN
,
TSDB_S
LOW_QUERY
_SQL_LEN
);
}
else
if
(
cmd
==
MONITOR_CMD_CREATE_TB_LOG
)
{
}
else
if
(
cmd
==
MONITOR_CMD_CREATE_TB_LOG
)
{
snprintf
(
sql
,
SQL_LENGTH
,
snprintf
(
sql
,
SQL_LENGTH
,
"create table if not exists %s.log(ts timestamp, level tinyint, "
"create table if not exists %s.log(ts timestamp, level tinyint, "
...
...
src/query/inc/qExecutor.h
浏览文件 @
adb62142
...
@@ -176,6 +176,7 @@ typedef struct SQueryRuntimeEnv {
...
@@ -176,6 +176,7 @@ typedef struct SQueryRuntimeEnv {
void
*
pQueryHandle
;
void
*
pQueryHandle
;
void
*
pSecQueryHandle
;
// another thread for
void
*
pSecQueryHandle
;
// another thread for
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
bool
topBotQuery
;
// false;
}
SQueryRuntimeEnv
;
}
SQueryRuntimeEnv
;
typedef
struct
SQInfo
{
typedef
struct
SQInfo
{
...
...
src/query/inc/qUtil.h
浏览文件 @
adb62142
...
@@ -31,7 +31,8 @@ void closeTimeWindow(SWindowResInfo* pWindowResInfo, int32_t slot);
...
@@ -31,7 +31,8 @@ void closeTimeWindow(SWindowResInfo* pWindowResInfo, int32_t slot);
void
closeAllTimeWindow
(
SWindowResInfo
*
pWindowResInfo
);
void
closeAllTimeWindow
(
SWindowResInfo
*
pWindowResInfo
);
void
removeRedundantWindow
(
SWindowResInfo
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
);
void
removeRedundantWindow
(
SWindowResInfo
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
);
SWindowResult
*
getWindowResult
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
SWindowResult
*
getWindowResult
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
int32_t
curTimeWindow
(
SWindowResInfo
*
pWindowResInfo
);
#define curTimeWindow(_winres) ((_winres)->curIndex)
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
void
createQueryResultInfo
(
SQuery
*
pQuery
,
SWindowResult
*
pResultRow
,
bool
isSTableQuery
,
SPosInfo
*
posInfo
);
void
createQueryResultInfo
(
SQuery
*
pQuery
,
SWindowResult
*
pResultRow
,
bool
isSTableQuery
,
SPosInfo
*
posInfo
);
...
...
src/query/inc/qextbuffer.h
浏览文件 @
adb62142
...
@@ -28,7 +28,7 @@ extern "C" {
...
@@ -28,7 +28,7 @@ extern "C" {
#include "tdataformat.h"
#include "tdataformat.h"
#include "talgo.h"
#include "talgo.h"
#define DEFAULT_PAGE_SIZE (1024L*
56
) // 16k larger than the SHistoInfo
#define DEFAULT_PAGE_SIZE (1024L*
64
) // 16k larger than the SHistoInfo
#define MAX_TMPFILE_PATH_LENGTH PATH_MAX
#define MAX_TMPFILE_PATH_LENGTH PATH_MAX
#define INITIAL_ALLOCATION_BUFFER_SIZE 64
#define INITIAL_ALLOCATION_BUFFER_SIZE 64
...
@@ -96,7 +96,7 @@ typedef struct SColumnOrderInfo {
...
@@ -96,7 +96,7 @@ typedef struct SColumnOrderInfo {
typedef
struct
tOrderDescriptor
{
typedef
struct
tOrderDescriptor
{
SColumnModel
*
pColumnModel
;
SColumnModel
*
pColumnModel
;
int32_t
tsOrder
;
// timestamp order type if exists
int32_t
tsOrder
;
// timestamp order type if exists
SColumnOrderInfo
orderI
dx
;
SColumnOrderInfo
orderI
nfo
;
}
tOrderDescriptor
;
}
tOrderDescriptor
;
typedef
struct
tExtMemBuffer
{
typedef
struct
tExtMemBuffer
{
...
...
src/query/inc/qresultBuf.h
浏览文件 @
adb62142
...
@@ -85,7 +85,7 @@ SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId);
...
@@ -85,7 +85,7 @@ SIDList getDataBufPagesIdList(SDiskbasedResultBuf* pResultBuf, int32_t groupId);
* @param id
* @param id
* @return
* @return
*/
*/
tFilePage
*
getResultBufferPageById
(
SDiskbasedResultBuf
*
pResultBuf
,
int32_t
id
);
#define GET_RES_BUF_PAGE_BY_ID(buf, id) ((tFilePage*)((buf)->pBuf + DEFAULT_INTERN_BUF_PAGE_SIZE*(id)))
/**
/**
* get the total buffer size in the format of disk file
* get the total buffer size in the format of disk file
...
...
src/query/inc/sql.y
浏览文件 @
adb62142
...
@@ -647,9 +647,9 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
...
@@ -647,9 +647,9 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
}
}
////////////////////////////////////////kill statement///////////////////////////////////////
////////////////////////////////////////kill statement///////////////////////////////////////
cmd ::= KILL CONNECTION I
PTOKEN(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &X
);}
cmd ::= KILL CONNECTION I
NTEGER(Y). {setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &Y
);}
cmd ::= KILL STREAM I
PTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F
.n); setKillSQL(pInfo, TSDB_SQL_KILL_STREAM, &X);}
cmd ::= KILL STREAM I
NTEGER(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y
.n); setKillSQL(pInfo, TSDB_SQL_KILL_STREAM, &X);}
cmd ::= KILL QUERY I
PTOKEN(X) COLON(Z) INTEGER(Y) COLON(K) INTEGER(F). {X.n += (Z.n + Y.n + K.n + F
.n); setKillSQL(pInfo, TSDB_SQL_KILL_QUERY, &X);}
cmd ::= KILL QUERY I
NTEGER(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y
.n); setKillSQL(pInfo, TSDB_SQL_KILL_QUERY, &X);}
%fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED
%fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED
DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD
DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
adb62142
...
@@ -272,9 +272,18 @@ bool top_bot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, char *mi
...
@@ -272,9 +272,18 @@ bool top_bot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, char *mi
bool
stableQueryFunctChanged
(
int32_t
funcId
);
bool
stableQueryFunctChanged
(
int32_t
funcId
);
void
resetResultInfo
(
SResultInfo
*
pResInfo
);
void
resetResultInfo
(
SResultInfo
*
pResInfo
);
void
initResultInfo
(
SResultInfo
*
pResInfo
);
void
setResultInfoBuf
(
SResultInfo
*
pResInfo
,
int32_t
size
,
bool
superTable
);
void
setResultInfoBuf
(
SResultInfo
*
pResInfo
,
int32_t
size
,
bool
superTable
);
static
FORCE_INLINE
void
initResultInfo
(
SResultInfo
*
pResInfo
)
{
pResInfo
->
initialized
=
true
;
// the this struct has been initialized flag
pResInfo
->
complete
=
false
;
pResInfo
->
hasResult
=
false
;
pResInfo
->
numOfRes
=
0
;
memset
(
pResInfo
->
interResultBuf
,
0
,
(
size_t
)
pResInfo
->
bufLen
);
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/query/src/qExecutor.c
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
src/query/src/qUtil.c
浏览文件 @
adb62142
...
@@ -206,11 +206,6 @@ bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot) {
...
@@ -206,11 +206,6 @@ bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot) {
return
(
getWindowResult
(
pWindowResInfo
,
slot
)
->
status
.
closed
==
true
);
return
(
getWindowResult
(
pWindowResInfo
,
slot
)
->
status
.
closed
==
true
);
}
}
int32_t
curTimeWindow
(
SWindowResInfo
*
pWindowResInfo
)
{
assert
(
pWindowResInfo
->
curIndex
>=
0
&&
pWindowResInfo
->
curIndex
<
pWindowResInfo
->
size
);
return
pWindowResInfo
->
curIndex
;
}
void
closeTimeWindow
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
void
closeTimeWindow
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
getWindowResult
(
pWindowResInfo
,
slot
)
->
status
.
closed
=
true
;
getWindowResult
(
pWindowResInfo
,
slot
)
->
status
.
closed
=
true
;
}
}
...
...
src/query/src/qextbuffer.c
浏览文件 @
adb62142
...
@@ -356,17 +356,15 @@ static FORCE_INLINE int32_t primaryKeyComparator(int64_t f1, int64_t f2, int32_t
...
@@ -356,17 +356,15 @@ static FORCE_INLINE int32_t primaryKeyComparator(int64_t f1, int64_t f2, int32_t
static
FORCE_INLINE
int32_t
columnValueAscendingComparator
(
char
*
f1
,
char
*
f2
,
int32_t
type
,
int32_t
bytes
)
{
static
FORCE_INLINE
int32_t
columnValueAscendingComparator
(
char
*
f1
,
char
*
f2
,
int32_t
type
,
int32_t
bytes
)
{
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
case
TSDB_DATA_TYPE_INT
:
{
int32_t
first
=
*
(
int32_t
*
)
f1
;
int32_t
first
=
*
(
int32_t
*
)
f1
;
int32_t
second
=
*
(
int32_t
*
)
f2
;
int32_t
second
=
*
(
int32_t
*
)
f2
;
if
(
first
==
second
)
{
if
(
first
==
second
)
{
return
0
;
return
0
;
}
}
return
(
first
<
second
)
?
-
1
:
1
;
return
(
first
<
second
)
?
-
1
:
1
;
};
};
case
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDB_DATA_TYPE_DOUBLE
:
{
//double first = *(double *)f1;
double
first
=
GET_DOUBLE_VAL
(
f1
);
double
first
=
GET_DOUBLE_VAL
(
f1
);
//double second = *(double *)f2;
double
second
=
GET_DOUBLE_VAL
(
f2
);
double
second
=
GET_DOUBLE_VAL
(
f2
);
if
(
first
==
second
)
{
if
(
first
==
second
)
{
return
0
;
return
0
;
...
@@ -374,8 +372,6 @@ static FORCE_INLINE int32_t columnValueAscendingComparator(char *f1, char *f2, i
...
@@ -374,8 +372,6 @@ static FORCE_INLINE int32_t columnValueAscendingComparator(char *f1, char *f2, i
return
(
first
<
second
)
?
-
1
:
1
;
return
(
first
<
second
)
?
-
1
:
1
;
};
};
case
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDB_DATA_TYPE_FLOAT
:
{
//float first = *(float *)f1;
//float second = *(float *)f2;
float
first
=
GET_FLOAT_VAL
(
f1
);
float
first
=
GET_FLOAT_VAL
(
f1
);
float
second
=
GET_FLOAT_VAL
(
f2
);
float
second
=
GET_FLOAT_VAL
(
f2
);
if
(
first
==
second
)
{
if
(
first
==
second
)
{
...
@@ -439,9 +435,9 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
...
@@ -439,9 +435,9 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
int32_t
s2
,
char
*
data2
)
{
int32_t
s2
,
char
*
data2
)
{
assert
(
numOfRows1
==
numOfRows2
);
assert
(
numOfRows1
==
numOfRows2
);
int32_t
cmpCnt
=
pDescriptor
->
orderI
dx
.
numOfCols
;
int32_t
cmpCnt
=
pDescriptor
->
orderI
nfo
.
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
cmpCnt
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
cmpCnt
;
++
i
)
{
int32_t
colIdx
=
pDescriptor
->
orderI
dx
.
pData
[
i
];
int32_t
colIdx
=
pDescriptor
->
orderI
nfo
.
pData
[
i
];
char
*
f1
=
COLMODEL_GET_VAL
(
data1
,
pDescriptor
->
pColumnModel
,
numOfRows1
,
s1
,
colIdx
);
char
*
f1
=
COLMODEL_GET_VAL
(
data1
,
pDescriptor
->
pColumnModel
,
numOfRows1
,
s1
,
colIdx
);
char
*
f2
=
COLMODEL_GET_VAL
(
data2
,
pDescriptor
->
pColumnModel
,
numOfRows2
,
s2
,
colIdx
);
char
*
f2
=
COLMODEL_GET_VAL
(
data2
,
pDescriptor
->
pColumnModel
,
numOfRows2
,
s2
,
colIdx
);
...
@@ -471,9 +467,9 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
...
@@ -471,9 +467,9 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
int32_t
s2
,
char
*
data2
)
{
int32_t
s2
,
char
*
data2
)
{
assert
(
numOfRows1
==
numOfRows2
);
assert
(
numOfRows1
==
numOfRows2
);
int32_t
cmpCnt
=
pDescriptor
->
orderI
dx
.
numOfCols
;
int32_t
cmpCnt
=
pDescriptor
->
orderI
nfo
.
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
cmpCnt
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
cmpCnt
;
++
i
)
{
int32_t
colIdx
=
pDescriptor
->
orderI
dx
.
pData
[
i
];
int32_t
colIdx
=
pDescriptor
->
orderI
nfo
.
pData
[
i
];
char
*
f1
=
COLMODEL_GET_VAL
(
data1
,
pDescriptor
->
pColumnModel
,
numOfRows1
,
s1
,
colIdx
);
char
*
f1
=
COLMODEL_GET_VAL
(
data1
,
pDescriptor
->
pColumnModel
,
numOfRows1
,
s1
,
colIdx
);
char
*
f2
=
COLMODEL_GET_VAL
(
data2
,
pDescriptor
->
pColumnModel
,
numOfRows2
,
s2
,
colIdx
);
char
*
f2
=
COLMODEL_GET_VAL
(
data2
,
pDescriptor
->
pColumnModel
,
numOfRows2
,
s2
,
colIdx
);
...
@@ -563,13 +559,13 @@ static void median(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
...
@@ -563,13 +559,13 @@ static void median(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
int32_t
midIdx
=
((
end
-
start
)
>>
1
)
+
start
;
int32_t
midIdx
=
((
end
-
start
)
>>
1
)
+
start
;
#if defined(_DEBUG_VIEW)
#if defined(_DEBUG_VIEW)
int32_t
f
=
pDescriptor
->
orderI
dx
.
pData
[
0
];
int32_t
f
=
pDescriptor
->
orderI
nfo
.
pData
[
0
];
char
*
midx
=
COLMODEL_GET_VAL
(
data
,
pDescriptor
->
pColumnModel
,
numOfRows
,
midIdx
,
f
);
char
*
midx
=
COLMODEL_GET_VAL
(
data
,
pDescriptor
->
pColumnModel
,
numOfRows
,
midIdx
,
f
);
char
*
startx
=
COLMODEL_GET_VAL
(
data
,
pDescriptor
->
pColumnModel
,
numOfRows
,
start
,
f
);
char
*
startx
=
COLMODEL_GET_VAL
(
data
,
pDescriptor
->
pColumnModel
,
numOfRows
,
start
,
f
);
char
*
endx
=
COLMODEL_GET_VAL
(
data
,
pDescriptor
->
pColumnModel
,
numOfRows
,
end
,
f
);
char
*
endx
=
COLMODEL_GET_VAL
(
data
,
pDescriptor
->
pColumnModel
,
numOfRows
,
end
,
f
);
int32_t
colIdx
=
pDescriptor
->
orderI
dx
.
pData
[
0
];
int32_t
colIdx
=
pDescriptor
->
orderI
nfo
.
pData
[
0
];
tSortDataPrint
(
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
].
field
.
type
,
"before"
,
startx
,
midx
,
endx
);
tSortDataPrint
(
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
].
field
.
type
,
"before"
,
startx
,
midx
,
endx
);
#endif
#endif
...
@@ -596,7 +592,7 @@ static void median(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
...
@@ -596,7 +592,7 @@ static void median(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
}
}
static
UNUSED_FUNC
void
tRowModelDisplay
(
tOrderDescriptor
*
pDescriptor
,
int32_t
numOfRows
,
char
*
d
,
int32_t
len
)
{
static
UNUSED_FUNC
void
tRowModelDisplay
(
tOrderDescriptor
*
pDescriptor
,
int32_t
numOfRows
,
char
*
d
,
int32_t
len
)
{
int32_t
colIdx
=
pDescriptor
->
orderI
dx
.
pData
[
0
];
int32_t
colIdx
=
pDescriptor
->
orderI
nfo
.
pData
[
0
];
for
(
int32_t
i
=
0
;
i
<
len
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
len
;
++
i
)
{
char
*
startx
=
COLMODEL_GET_VAL
(
d
,
pDescriptor
->
pColumnModel
,
numOfRows
,
i
,
colIdx
);
char
*
startx
=
COLMODEL_GET_VAL
(
d
,
pDescriptor
->
pColumnModel
,
numOfRows
,
i
,
colIdx
);
...
@@ -1062,9 +1058,9 @@ tOrderDescriptor *tOrderDesCreate(const int32_t *orderColIdx, int32_t numOfOrder
...
@@ -1062,9 +1058,9 @@ tOrderDescriptor *tOrderDesCreate(const int32_t *orderColIdx, int32_t numOfOrder
desc
->
pColumnModel
=
pModel
;
desc
->
pColumnModel
=
pModel
;
desc
->
tsOrder
=
tsOrderType
;
desc
->
tsOrder
=
tsOrderType
;
desc
->
orderI
dx
.
numOfCols
=
numOfOrderCols
;
desc
->
orderI
nfo
.
numOfCols
=
numOfOrderCols
;
for
(
int32_t
i
=
0
;
i
<
numOfOrderCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOrderCols
;
++
i
)
{
desc
->
orderI
dx
.
pData
[
i
]
=
orderColIdx
[
i
];
desc
->
orderI
nfo
.
pData
[
i
]
=
orderColIdx
[
i
];
}
}
return
desc
;
return
desc
;
...
...
src/query/src/qresultBuf.c
浏览文件 @
adb62142
...
@@ -50,12 +50,6 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si
...
@@ -50,12 +50,6 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
tFilePage
*
getResultBufferPageById
(
SDiskbasedResultBuf
*
pResultBuf
,
int32_t
id
)
{
assert
(
id
<
pResultBuf
->
numOfPages
&&
id
>=
0
);
return
(
tFilePage
*
)(
pResultBuf
->
pBuf
+
DEFAULT_INTERN_BUF_PAGE_SIZE
*
id
);
}
int32_t
getNumOfResultBufGroupId
(
SDiskbasedResultBuf
*
pResultBuf
)
{
return
taosHashGetSize
(
pResultBuf
->
idsTable
);
}
int32_t
getNumOfResultBufGroupId
(
SDiskbasedResultBuf
*
pResultBuf
)
{
return
taosHashGetSize
(
pResultBuf
->
idsTable
);
}
int32_t
getResBufSize
(
SDiskbasedResultBuf
*
pResultBuf
)
{
return
pResultBuf
->
totalBufSize
;
}
int32_t
getResBufSize
(
SDiskbasedResultBuf
*
pResultBuf
)
{
return
pResultBuf
->
totalBufSize
;
}
...
@@ -169,7 +163,7 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32
...
@@ -169,7 +163,7 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32
*
pageId
=
(
pResultBuf
->
allocateId
++
);
*
pageId
=
(
pResultBuf
->
allocateId
++
);
registerPageId
(
pResultBuf
,
groupId
,
*
pageId
);
registerPageId
(
pResultBuf
,
groupId
,
*
pageId
);
tFilePage
*
page
=
getResultBufferPageById
(
pResultBuf
,
*
pageId
);
tFilePage
*
page
=
GET_RES_BUF_PAGE_BY_ID
(
pResultBuf
,
*
pageId
);
// clear memory for the new page
// clear memory for the new page
memset
(
page
,
0
,
DEFAULT_INTERN_BUF_PAGE_SIZE
);
memset
(
page
,
0
,
DEFAULT_INTERN_BUF_PAGE_SIZE
);
...
...
src/query/src/sql.c
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
src/rpc/src/rpcCache.c
浏览文件 @
adb62142
...
@@ -127,7 +127,7 @@ void rpcAddConnIntoCache(void *handle, void *data, char *fqdn, uint16_t port, in
...
@@ -127,7 +127,7 @@ void rpcAddConnIntoCache(void *handle, void *data, char *fqdn, uint16_t port, in
hash
=
rpcHashConn
(
pCache
,
fqdn
,
port
,
connType
);
hash
=
rpcHashConn
(
pCache
,
fqdn
,
port
,
connType
);
pNode
=
(
SConnHash
*
)
taosMemPoolMalloc
(
pCache
->
connHashMemPool
);
pNode
=
(
SConnHash
*
)
taosMemPoolMalloc
(
pCache
->
connHashMemPool
);
strcpy
(
pNode
->
fqdn
,
fqdn
);
tstrncpy
(
pNode
->
fqdn
,
fqdn
,
sizeof
(
pNode
->
fqdn
)
);
pNode
->
port
=
port
;
pNode
->
port
=
port
;
pNode
->
connType
=
connType
;
pNode
->
connType
=
connType
;
pNode
->
data
=
data
;
pNode
->
data
=
data
;
...
...
src/rpc/src/rpcMain.c
浏览文件 @
adb62142
...
@@ -60,7 +60,7 @@ typedef struct {
...
@@ -60,7 +60,7 @@ typedef struct {
void
*
idPool
;
// handle to ID pool
void
*
idPool
;
// handle to ID pool
void
*
tmrCtrl
;
// handle to timer
void
*
tmrCtrl
;
// handle to timer
void
*
hash
;
// handle returned by hash utility
SHashObj
*
hash
;
// handle returned by hash utility
void
*
tcphandle
;
// returned handle from TCP initialization
void
*
tcphandle
;
// returned handle from TCP initialization
void
*
udphandle
;
// returned handle from UDP initialization
void
*
udphandle
;
// returned handle from UDP initialization
void
*
pCache
;
// connection cache
void
*
pCache
;
// connection cache
...
@@ -211,7 +211,7 @@ void *rpcOpen(const SRpcInit *pInit) {
...
@@ -211,7 +211,7 @@ void *rpcOpen(const SRpcInit *pInit) {
pRpc
=
(
SRpcInfo
*
)
calloc
(
1
,
sizeof
(
SRpcInfo
));
pRpc
=
(
SRpcInfo
*
)
calloc
(
1
,
sizeof
(
SRpcInfo
));
if
(
pRpc
==
NULL
)
return
NULL
;
if
(
pRpc
==
NULL
)
return
NULL
;
if
(
pInit
->
label
)
strcpy
(
pRpc
->
label
,
pInit
->
label
);
if
(
pInit
->
label
)
tstrncpy
(
pRpc
->
label
,
pInit
->
label
,
sizeof
(
pRpc
->
label
)
);
pRpc
->
connType
=
pInit
->
connType
;
pRpc
->
connType
=
pInit
->
connType
;
pRpc
->
idleTime
=
pInit
->
idleTime
;
pRpc
->
idleTime
=
pInit
->
idleTime
;
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
>
TSDB_MAX_RPC_THREADS
?
TSDB_MAX_RPC_THREADS
:
pInit
->
numOfThreads
;
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
>
TSDB_MAX_RPC_THREADS
?
TSDB_MAX_RPC_THREADS
:
pInit
->
numOfThreads
;
...
@@ -228,7 +228,7 @@ void *rpcOpen(const SRpcInit *pInit) {
...
@@ -228,7 +228,7 @@ void *rpcOpen(const SRpcInit *pInit) {
size_t
size
=
sizeof
(
SRpcConn
)
*
pRpc
->
sessions
;
size_t
size
=
sizeof
(
SRpcConn
)
*
pRpc
->
sessions
;
pRpc
->
connList
=
(
SRpcConn
*
)
calloc
(
1
,
size
);
pRpc
->
connList
=
(
SRpcConn
*
)
calloc
(
1
,
size
);
if
(
pRpc
->
connList
==
NULL
)
{
if
(
pRpc
->
connList
==
NULL
)
{
tError
(
"%s failed to allocate memory for taos connections, size:%d"
,
pRpc
->
label
,
size
);
tError
(
"%s failed to allocate memory for taos connections, size:%
l
d"
,
pRpc
->
label
,
size
);
rpcClose
(
pRpc
);
rpcClose
(
pRpc
);
return
NULL
;
return
NULL
;
}
}
...
@@ -459,7 +459,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) {
...
@@ -459,7 +459,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) {
pInfo
->
clientPort
=
pConn
->
peerPort
;
pInfo
->
clientPort
=
pConn
->
peerPort
;
// pInfo->serverIp = pConn->destIp;
// pInfo->serverIp = pConn->destIp;
str
cpy
(
pInfo
->
user
,
pConn
->
user
);
str
ncpy
(
pInfo
->
user
,
pConn
->
user
,
sizeof
(
pInfo
->
user
)
);
return
0
;
return
0
;
}
}
...
@@ -503,10 +503,10 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
...
@@ -503,10 +503,10 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
pConn
=
rpcAllocateClientConn
(
pRpc
);
pConn
=
rpcAllocateClientConn
(
pRpc
);
if
(
pConn
)
{
if
(
pConn
)
{
strcpy
(
pConn
->
peerFqdn
,
peerFqdn
);
tstrncpy
(
pConn
->
peerFqdn
,
peerFqdn
,
sizeof
(
pConn
->
peerFqdn
)
);
pConn
->
peerIp
=
peerIp
;
pConn
->
peerIp
=
peerIp
;
pConn
->
peerPort
=
peerPort
;
pConn
->
peerPort
=
peerPort
;
strcpy
(
pConn
->
user
,
pRpc
->
user
);
tstrncpy
(
pConn
->
user
,
pRpc
->
user
,
sizeof
(
pConn
->
user
)
);
pConn
->
connType
=
connType
;
pConn
->
connType
=
connType
;
if
(
taosOpenConn
[
connType
])
{
if
(
taosOpenConn
[
connType
])
{
...
@@ -804,7 +804,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
...
@@ -804,7 +804,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn
=
rpcGetConnObj
(
pRpc
,
sid
,
pRecv
);
pConn
=
rpcGetConnObj
(
pRpc
,
sid
,
pRecv
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
tTrace
(
"%s %p, failed to get connection obj(%s)"
,
pRpc
->
label
,
pHead
->
ahandle
,
tstrerror
(
terrno
));
tTrace
(
"%s %p, failed to get connection obj(%s)"
,
pRpc
->
label
,
(
void
*
)
pHead
->
ahandle
,
tstrerror
(
terrno
));
return
NULL
;
return
NULL
;
}
else
{
}
else
{
if
(
rpcIsReq
(
pHead
->
msgType
))
{
if
(
rpcIsReq
(
pHead
->
msgType
))
{
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
adb62142
...
@@ -73,7 +73,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
...
@@ -73,7 +73,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
pServerObj
=
(
SServerObj
*
)
calloc
(
sizeof
(
SServerObj
),
1
);
pServerObj
=
(
SServerObj
*
)
calloc
(
sizeof
(
SServerObj
),
1
);
pServerObj
->
ip
=
ip
;
pServerObj
->
ip
=
ip
;
pServerObj
->
port
=
port
;
pServerObj
->
port
=
port
;
strcpy
(
pServerObj
->
label
,
label
);
tstrncpy
(
pServerObj
->
label
,
label
,
sizeof
(
pServerObj
->
label
)
);
pServerObj
->
numOfThreads
=
numOfThreads
;
pServerObj
->
numOfThreads
=
numOfThreads
;
pServerObj
->
pThreadObj
=
(
SThreadObj
*
)
calloc
(
sizeof
(
SThreadObj
),
numOfThreads
);
pServerObj
->
pThreadObj
=
(
SThreadObj
*
)
calloc
(
sizeof
(
SThreadObj
),
numOfThreads
);
...
@@ -87,7 +87,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
...
@@ -87,7 +87,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
pThreadObj
=
pServerObj
->
pThreadObj
;
pThreadObj
=
pServerObj
->
pThreadObj
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
pThreadObj
->
processData
=
fp
;
pThreadObj
->
processData
=
fp
;
strcpy
(
pThreadObj
->
label
,
label
);
tstrncpy
(
pThreadObj
->
label
,
label
,
sizeof
(
pThreadObj
->
label
)
);
pThreadObj
->
shandle
=
shandle
;
pThreadObj
->
shandle
=
shandle
;
code
=
pthread_mutex_init
(
&
(
pThreadObj
->
mutex
),
NULL
);
code
=
pthread_mutex_init
(
&
(
pThreadObj
->
mutex
),
NULL
);
...
@@ -247,7 +247,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
...
@@ -247,7 +247,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
pThreadObj
=
(
SThreadObj
*
)
malloc
(
sizeof
(
SThreadObj
));
pThreadObj
=
(
SThreadObj
*
)
malloc
(
sizeof
(
SThreadObj
));
memset
(
pThreadObj
,
0
,
sizeof
(
SThreadObj
));
memset
(
pThreadObj
,
0
,
sizeof
(
SThreadObj
));
strcpy
(
pThreadObj
->
label
,
label
);
tstrncpy
(
pThreadObj
->
label
,
label
,
sizeof
(
pThreadObj
->
label
)
);
pThreadObj
->
ip
=
ip
;
pThreadObj
->
ip
=
ip
;
pThreadObj
->
shandle
=
shandle
;
pThreadObj
->
shandle
=
shandle
;
...
...
src/rpc/src/rpcUdp.c
浏览文件 @
adb62142
...
@@ -72,7 +72,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
...
@@ -72,7 +72,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
pSet
->
port
=
port
;
pSet
->
port
=
port
;
pSet
->
shandle
=
shandle
;
pSet
->
shandle
=
shandle
;
pSet
->
fp
=
fp
;
pSet
->
fp
=
fp
;
strcpy
(
pSet
->
label
,
label
);
tstrncpy
(
pSet
->
label
,
label
,
sizeof
(
pSet
->
label
)
);
uint16_t
ownPort
;
uint16_t
ownPort
;
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
...
@@ -99,7 +99,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
...
@@ -99,7 +99,7 @@ void *taosInitUdpConnection(uint32_t ip, uint16_t port, char *label, int threads
pConn
->
localPort
=
(
uint16_t
)
ntohs
(
sin
.
sin_port
);
pConn
->
localPort
=
(
uint16_t
)
ntohs
(
sin
.
sin_port
);
}
}
strcpy
(
pConn
->
label
,
label
);
tstrncpy
(
pConn
->
label
,
label
,
sizeof
(
pConn
->
label
)
);
pConn
->
shandle
=
shandle
;
pConn
->
shandle
=
shandle
;
pConn
->
processData
=
fp
;
pConn
->
processData
=
fp
;
pConn
->
index
=
i
;
pConn
->
index
=
i
;
...
...
src/rpc/test/rclient.c
浏览文件 @
adb62142
...
@@ -76,6 +76,7 @@ int main(int argc, char *argv[]) {
...
@@ -76,6 +76,7 @@ int main(int argc, char *argv[]) {
int
numOfReqs
=
0
;
int
numOfReqs
=
0
;
int
appThreads
=
1
;
int
appThreads
=
1
;
char
serverIp
[
40
]
=
"127.0.0.1"
;
char
serverIp
[
40
]
=
"127.0.0.1"
;
char
secret
[
TSDB_KEY_LEN
]
=
"mypassword"
;
struct
timeval
systemTime
;
struct
timeval
systemTime
;
int64_t
startTime
,
endTime
;
int64_t
startTime
,
endTime
;
pthread_attr_t
thattr
;
pthread_attr_t
thattr
;
...
@@ -97,7 +98,7 @@ int main(int argc, char *argv[]) {
...
@@ -97,7 +98,7 @@ int main(int argc, char *argv[]) {
rpcInit
.
sessions
=
100
;
rpcInit
.
sessions
=
100
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
user
=
"michael"
;
rpcInit
.
user
=
"michael"
;
rpcInit
.
secret
=
"mypassword"
;
rpcInit
.
secret
=
secret
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
.
spi
=
1
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
...
@@ -106,7 +107,7 @@ int main(int argc, char *argv[]) {
...
@@ -106,7 +107,7 @@ int main(int argc, char *argv[]) {
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
&&
i
<
argc
-
1
)
{
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
&&
i
<
argc
-
1
)
{
ipSet
.
port
[
0
]
=
atoi
(
argv
[
++
i
]);
ipSet
.
port
[
0
]
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
&&
i
<
argc
-
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
&&
i
<
argc
-
1
)
{
tstrncpy
(
ipSet
.
fqdn
[
0
],
argv
[
++
i
],
sizeof
(
ipSet
.
fqdn
));
tstrncpy
(
ipSet
.
fqdn
[
0
],
argv
[
++
i
],
sizeof
(
ipSet
.
fqdn
[
0
]
));
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
&&
i
<
argc
-
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
&&
i
<
argc
-
1
)
{
rpcInit
.
numOfThreads
=
atoi
(
argv
[
++
i
]);
rpcInit
.
numOfThreads
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
&&
i
<
argc
-
1
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
&&
i
<
argc
-
1
)
{
...
...
src/rpc/test/rsclient.c
浏览文件 @
adb62142
...
@@ -77,6 +77,7 @@ int main(int argc, char *argv[]) {
...
@@ -77,6 +77,7 @@ int main(int argc, char *argv[]) {
int
numOfReqs
=
0
;
int
numOfReqs
=
0
;
int
appThreads
=
1
;
int
appThreads
=
1
;
char
serverIp
[
40
]
=
"127.0.0.1"
;
char
serverIp
[
40
]
=
"127.0.0.1"
;
char
secret
[
TSDB_KEY_LEN
]
=
"mypassword"
;
struct
timeval
systemTime
;
struct
timeval
systemTime
;
int64_t
startTime
,
endTime
;
int64_t
startTime
,
endTime
;
pthread_attr_t
thattr
;
pthread_attr_t
thattr
;
...
@@ -98,7 +99,7 @@ int main(int argc, char *argv[]) {
...
@@ -98,7 +99,7 @@ int main(int argc, char *argv[]) {
rpcInit
.
sessions
=
100
;
rpcInit
.
sessions
=
100
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
user
=
"michael"
;
rpcInit
.
user
=
"michael"
;
rpcInit
.
secret
=
"mypassword"
;
rpcInit
.
secret
=
secret
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
.
spi
=
1
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
adb62142
...
@@ -977,7 +977,8 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
...
@@ -977,7 +977,8 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
// tdResetDataCols(pHelper->pDataCols[1]);
// tdResetDataCols(pHelper->pDataCols[1]);
while
(
true
)
{
while
(
true
)
{
if
(
iter1
>=
pHelper
->
pDataCols
[
0
]
->
numOfRows
&&
iter2
>=
rows3
)
break
;
if
(
iter1
>=
pHelper
->
pDataCols
[
0
]
->
numOfRows
&&
iter2
>=
rows3
)
break
;
tdMergeTwoDataCols
(
pHelper
->
pDataCols
[
1
],
pHelper
->
pDataCols
[
0
],
&
iter1
,
pDataCols
,
&
iter2
,
pHelper
->
config
.
maxRowsPerFileBlock
*
4
/
5
);
tdMergeTwoDataCols
(
pHelper
->
pDataCols
[
1
],
pHelper
->
pDataCols
[
0
],
&
iter1
,
pHelper
->
pDataCols
[
0
]
->
numOfRows
,
pDataCols
,
&
iter2
,
rowsWritten
,
pHelper
->
config
.
maxRowsPerFileBlock
*
4
/
5
);
ASSERT
(
pHelper
->
pDataCols
[
1
]
->
numOfRows
>
0
);
ASSERT
(
pHelper
->
pDataCols
[
1
]
->
numOfRows
>
0
);
if
(
tsdbWriteBlockToFile
(
pHelper
,
&
(
pHelper
->
files
.
dataF
),
pHelper
->
pDataCols
[
1
],
if
(
tsdbWriteBlockToFile
(
pHelper
,
&
(
pHelper
->
files
.
dataF
),
pHelper
->
pDataCols
[
1
],
pHelper
->
pDataCols
[
1
]
->
numOfRows
,
&
compBlock
,
false
,
true
)
<
0
)
pHelper
->
pDataCols
[
1
]
->
numOfRows
,
&
compBlock
,
false
,
true
)
<
0
)
...
@@ -989,54 +990,6 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
...
@@ -989,54 +990,6 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
}
}
round
++
;
round
++
;
blkIdx
++
;
blkIdx
++
;
// TODO: the blkIdx here is not correct
// if (iter1 >= pHelper->pDataCols[0]->numOfRows && iter2 >= rows3) {
// if (pHelper->pDataCols[1]->numOfRows > 0) {
// if (tsdbWriteBlockToFile(pHelper, &pHelper->files.dataF, pHelper->pDataCols[1],
// pHelper->pDataCols[1]->numOfRows, &compBlock, false, true) < 0)
// goto _err;
// // TODO: the blkIdx here is not correct
// tsdbAddSubBlock(pHelper, &compBlock, blkIdx, pHelper->pDataCols[1]->numOfRows);
// }
// }
// TSKEY key1 = iter1 >= pHelper->pDataCols[0]->numOfRows
// ? INT64_MAX
// : ((int64_t *)(pHelper->pDataCols[0]->cols[0].pData))[iter1];
// TSKEY key2 = iter2 >= rowsWritten ? INT64_MAX : ((int64_t *)(pDataCols->cols[0].pData))[iter2];
// if (key1 < key2) {
// for (int i = 0; i < pDataCols->numOfCols; i++) {
// SDataCol *pDataCol = pHelper->pDataCols[1]->cols + i;
// memcpy(((char *)pDataCol->pData + TYPE_BYTES[pDataCol->type] * pHelper->pDataCols[1]->numOfRows),
// ((char *)pHelper->pDataCols[0]->cols[i].pData + TYPE_BYTES[pDataCol->type] * iter1),
// TYPE_BYTES[pDataCol->type]);
// }
// pHelper->pDataCols[1]->numOfRows++;
// iter1++;
// } else if (key1 == key2) {
// // TODO: think about duplicate key cases
// ASSERT(false);
// } else {
// for (int i = 0; i < pDataCols->numOfCols; i++) {
// SDataCol *pDataCol = pHelper->pDataCols[1]->cols + i;
// memcpy(((char *)pDataCol->pData + TYPE_BYTES[pDataCol->type] * pHelper->pDataCols[1]->numOfRows),
// ((char *)pDataCols->cols[i].pData +
// TYPE_BYTES[pDataCol->type] * iter2),
// TYPE_BYTES[pDataCol->type]);
// }
// pHelper->pDataCols[1]->numOfRows++;
// iter2++;
// }
// if (pHelper->pDataCols[0]->numOfRows >= pHelper->config.maxRowsPerFileBlock * 4 / 5) {
// if (tsdbWriteBlockToFile(pHelper, &pHelper->files.dataF, pHelper->pDataCols[1], pHelper->pDataCols[1]->numOfRows, &compBlock, false, true) < 0) goto _err;
// // TODO: blkIdx here is not correct, fix it
// tsdbInsertSuperBlock(pHelper, &compBlock, blkIdx);
// tdResetDataCols(pHelper->pDataCols[1]);
// }
}
}
}
}
}
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
adb62142
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "tulog.h"
#include "tulog.h"
#include "talgo.h"
#include "talgo.h"
#include "tutil.h"
#include "tutil.h"
#include "ttime.h"
#include "tcompare.h"
#include "tcompare.h"
#include "exception.h"
#include "exception.h"
...
@@ -71,6 +72,8 @@ typedef struct STableCheckInfo {
...
@@ -71,6 +72,8 @@ typedef struct STableCheckInfo {
int32_t
compSize
;
int32_t
compSize
;
int32_t
numOfBlocks
;
// number of qualified data blocks not the original blocks
int32_t
numOfBlocks
;
// number of qualified data blocks not the original blocks
SDataCols
*
pDataCols
;
SDataCols
*
pDataCols
;
int32_t
chosen
;
// indicate which iterator should move forward
bool
initBuf
;
// whether to initialize the in-memory skip list iterator or not
bool
initBuf
;
// whether to initialize the in-memory skip list iterator or not
SSkipListIterator
*
iter
;
// mem buffer skip list iterator
SSkipListIterator
*
iter
;
// mem buffer skip list iterator
SSkipListIterator
*
iiter
;
// imem buffer skip list iterator
SSkipListIterator
*
iiter
;
// imem buffer skip list iterator
...
@@ -79,8 +82,6 @@ typedef struct STableCheckInfo {
...
@@ -79,8 +82,6 @@ typedef struct STableCheckInfo {
typedef
struct
STableBlockInfo
{
typedef
struct
STableBlockInfo
{
SCompBlock
*
compBlock
;
SCompBlock
*
compBlock
;
STableCheckInfo
*
pTableCheckInfo
;
STableCheckInfo
*
pTableCheckInfo
;
// int32_t blockIndex;
// int32_t groupIdx; /* number of group is less than the total number of tables */
}
STableBlockInfo
;
}
STableBlockInfo
;
typedef
struct
SBlockOrderSupporter
{
typedef
struct
SBlockOrderSupporter
{
...
@@ -120,7 +121,7 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle);
...
@@ -120,7 +121,7 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
,
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SCompBlock
*
pBlock
,
SArray
*
sa
);
SArray
*
sa
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int
tsdbReadRowsFromCache
(
S
SkipListIterator
*
pIter
,
STable
*
pTable
,
TSKEY
maxKey
,
int
maxRowsToRead
,
TSKEY
*
skey
,
TSKEY
*
ekey
,
static
int
tsdbReadRowsFromCache
(
S
TableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
TSKEY
*
skey
,
TSKEY
*
ekey
,
STsdbQueryHandle
*
pQueryHandle
);
STsdbQueryHandle
*
pQueryHandle
);
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
static
void
tsdbInitDataBlockLoadInfo
(
SDataBlockLoadInfo
*
pBlockLoadInfo
)
{
...
@@ -134,7 +135,7 @@ static void tsdbInitCompBlockLoadInfo(SLoadCompBlockInfo* pCompBlockLoadInfo) {
...
@@ -134,7 +135,7 @@ static void tsdbInitCompBlockLoadInfo(SLoadCompBlockInfo* pCompBlockLoadInfo) {
pCompBlockLoadInfo
->
fileId
=
-
1
;
pCompBlockLoadInfo
->
fileId
=
-
1
;
}
}
TsdbQueryHandleT
*
tsdbQueryTables
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
)
{
TsdbQueryHandleT
*
tsdbQueryTables
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
)
{
// todo 1. filter not exist table
// todo 1. filter not exist table
// todo 2. add the reference count for each table that is involved in query
// todo 2. add the reference count for each table that is involved in query
...
@@ -147,6 +148,7 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
...
@@ -147,6 +148,7 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
pQueryHandle
->
cur
.
win
=
TSWINDOW_INITIALIZER
;
pQueryHandle
->
cur
.
win
=
TSWINDOW_INITIALIZER
;
pQueryHandle
->
checkFiles
=
true
;
//ASCENDING_TRAVERSE(pQueryHandle->order);
pQueryHandle
->
checkFiles
=
true
;
//ASCENDING_TRAVERSE(pQueryHandle->order);
pQueryHandle
->
activeIndex
=
0
;
// current active table index
pQueryHandle
->
activeIndex
=
0
;
// current active table index
pQueryHandle
->
qinfo
=
qinfo
;
pQueryHandle
->
outputCapacity
=
((
STsdbRepo
*
)
tsdb
)
->
config
.
maxRowsPerFileBlock
;
pQueryHandle
->
outputCapacity
=
((
STsdbRepo
*
)
tsdb
)
->
config
.
maxRowsPerFileBlock
;
tsdbInitReadHelper
(
&
pQueryHandle
->
rhelper
,
(
STsdbRepo
*
)
tsdb
);
tsdbInitReadHelper
(
&
pQueryHandle
->
rhelper
,
(
STsdbRepo
*
)
tsdb
);
...
@@ -201,8 +203,8 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
...
@@ -201,8 +203,8 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
return
(
TsdbQueryHandleT
)
pQueryHandle
;
return
(
TsdbQueryHandleT
)
pQueryHandle
;
}
}
TsdbQueryHandleT
tsdbQueryLastRow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
)
{
TsdbQueryHandleT
tsdbQueryLastRow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
);
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
,
qinfo
);
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_LAST
;
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_LAST
;
pQueryHandle
->
order
=
TSDB_ORDER_DESC
;
pQueryHandle
->
order
=
TSDB_ORDER_DESC
;
...
@@ -227,8 +229,8 @@ SArray* tsdbGetQueriedTableIdList(TsdbQueryHandleT *pHandle) {
...
@@ -227,8 +229,8 @@ SArray* tsdbGetQueriedTableIdList(TsdbQueryHandleT *pHandle) {
return
res
;
return
res
;
}
}
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
)
{
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TsdbRepoT
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
);
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
tsdbQueryTables
(
tsdb
,
pCond
,
groupList
,
qinfo
);
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_EXTERNAL
;
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_EXTERNAL
;
// pQueryHandle->outputCapacity = 2; // only allowed two rows to be loaded
// pQueryHandle->outputCapacity = 2; // only allowed two rows to be loaded
...
@@ -303,40 +305,99 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
...
@@ -303,40 +305,99 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
return
true
;
return
true
;
}
}
static
bool
hasMoreDataInCache
(
STsdbQueryHandle
*
pHandle
)
{
SDataRow
getSDataRowInTableMem
(
STableCheckInfo
*
pCheckInfo
)
{
size_t
size
=
taosArrayGetSize
(
pHandle
->
pTableCheckInfo
);
SDataRow
rmem
=
NULL
,
rimem
=
NULL
;
assert
(
pHandle
->
activeIndex
<
size
&&
pHandle
->
activeIndex
>=
0
&&
size
>=
1
);
if
(
pCheckInfo
->
iter
)
{
pHandle
->
cur
.
fid
=
-
1
;
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
if
(
node
!=
NULL
)
{
rmem
=
SL_GET_NODE_DATA
(
node
);
}
}
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pHandle
->
pTableCheckInfo
,
pHandle
->
activeIndex
);
if
(
pCheckInfo
->
iiter
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iiter
);
if
(
node
!=
NULL
)
{
rimem
=
SL_GET_NODE_DATA
(
node
);
}
}
STable
*
pTable
=
pCheckInfo
->
pTableObj
;
if
(
rmem
!=
NULL
&&
rimem
!=
NULL
)
{
assert
(
pTable
!=
NULL
);
if
(
dataRowKey
(
rmem
)
<
dataRowKey
(
rimem
))
{
pCheckInfo
->
chosen
=
0
;
return
rmem
;
}
else
if
(
dataRowKey
(
rmem
)
==
dataRowKey
(
rimem
))
{
// data ts are duplicated, ignore the data in mem
tSkipListIterNext
(
pCheckInfo
->
iter
);
pCheckInfo
->
chosen
=
1
;
return
rimem
;
}
else
{
pCheckInfo
->
chosen
=
1
;
return
rimem
;
}
}
// no data in cache, abort
if
(
rmem
!=
NULL
)
{
if
(
pTable
->
mem
==
NULL
&&
pTable
->
imem
==
NULL
)
{
pCheckInfo
->
chosen
=
0
;
return
false
;
return
rmem
;
}
}
if
(
pCheckInfo
->
iter
==
NULL
&&
pTable
->
mem
)
{
if
(
rimem
!=
NULL
)
{
pCheckInfo
->
iter
=
tSkipListCreateIterFromVal
(
pTable
->
mem
->
pData
,
(
const
char
*
)
&
pCheckInfo
->
lastKey
,
pCheckInfo
->
chosen
=
1
;
TSDB_DATA_TYPE_TIMESTAMP
,
pHandle
->
order
);
return
rimem
;
}
if
(
pCheckInfo
->
iter
==
NULL
)
{
return
NULL
;
return
false
;
}
bool
moveToNextRow
(
STableCheckInfo
*
pCheckInfo
)
{
bool
hasNext
=
false
;
if
(
pCheckInfo
->
chosen
==
0
)
{
if
(
pCheckInfo
->
iter
!=
NULL
)
{
hasNext
=
tSkipListIterNext
(
pCheckInfo
->
iter
);
}
}
if
(
!
tSkipListIterNext
(
pCheckInfo
->
iter
))
{
// buffer is empty
if
(
hasNext
)
{
return
false
;
return
hasNext
;
}
if
(
pCheckInfo
->
iiter
!=
NULL
)
{
return
tSkipListIterGet
(
pCheckInfo
->
iiter
)
!=
NULL
;
}
}
}
else
{
if
(
pCheckInfo
->
chosen
==
1
)
{
if
(
pCheckInfo
->
iiter
!=
NULL
)
{
hasNext
=
tSkipListIterNext
(
pCheckInfo
->
iiter
);
}
}
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
if
(
hasNext
)
{
if
(
node
==
NULL
)
{
return
hasNext
;
}
if
(
pCheckInfo
->
iter
!=
NULL
)
{
return
tSkipListIterGet
(
pCheckInfo
->
iter
)
!=
NULL
;
}
}
}
return
hasNext
;
}
static
bool
hasMoreDataInCache
(
STsdbQueryHandle
*
pHandle
)
{
size_t
size
=
taosArrayGetSize
(
pHandle
->
pTableCheckInfo
);
assert
(
pHandle
->
activeIndex
<
size
&&
pHandle
->
activeIndex
>=
0
&&
size
>=
1
);
pHandle
->
cur
.
fid
=
-
1
;
STableCheckInfo
*
pCheckInfo
=
taosArrayGet
(
pHandle
->
pTableCheckInfo
,
pHandle
->
activeIndex
);
STable
*
pTable
=
pCheckInfo
->
pTableObj
;
assert
(
pTable
!=
NULL
);
initTableMemIterator
(
pHandle
,
pCheckInfo
);
SDataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
);
if
(
row
==
NULL
)
{
return
false
;
return
false
;
}
}
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
pCheckInfo
->
lastKey
=
dataRowKey
(
row
);
// first timestamp in buffer
pCheckInfo
->
lastKey
=
dataRowKey
(
row
);
// first timestamp in buffer
tsdbTrace
(
"%p uid:%"
PRId64
", tid:%d check data in buffer from skey:%"
PRId64
", order:%d, %p"
,
pHandle
,
tsdbTrace
(
"%p uid:%"
PRId64
", tid:%d check data in buffer from skey:%"
PRId64
", order:%d, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
pCheckInfo
->
lastKey
,
pHandle
->
order
,
pHandle
->
qinfo
);
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
pCheckInfo
->
lastKey
,
pHandle
->
order
,
pHandle
->
qinfo
);
...
@@ -349,7 +410,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
...
@@ -349,7 +410,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
int32_t
step
=
ASCENDING_TRAVERSE
(
pHandle
->
order
)
?
1
:-
1
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pHandle
->
order
)
?
1
:-
1
;
STimeWindow
*
win
=
&
pHandle
->
cur
.
win
;
STimeWindow
*
win
=
&
pHandle
->
cur
.
win
;
pHandle
->
cur
.
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
->
iter
,
pCheckInfo
->
pTableObj
,
pHandle
->
window
.
ekey
,
pHandle
->
cur
.
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
,
pHandle
->
window
.
ekey
,
pHandle
->
outputCapacity
,
&
win
->
skey
,
&
win
->
ekey
,
pHandle
);
// todo refactor API
pHandle
->
outputCapacity
,
&
win
->
skey
,
&
win
->
ekey
,
pHandle
);
// todo refactor API
// update the last key value
// update the last key value
...
@@ -382,7 +443,7 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio
...
@@ -382,7 +443,7 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio
return
fid
;
return
fid
;
}
}
static
int32_t
binarySearchForBlock
Impl
(
SCompBlock
*
pBlock
,
int32_t
numOfBlocks
,
TSKEY
skey
,
int32_t
order
)
{
static
int32_t
binarySearchForBlock
(
SCompBlock
*
pBlock
,
int32_t
numOfBlocks
,
TSKEY
skey
,
int32_t
order
)
{
int32_t
firstSlot
=
0
;
int32_t
firstSlot
=
0
;
int32_t
lastSlot
=
numOfBlocks
-
1
;
int32_t
lastSlot
=
numOfBlocks
-
1
;
...
@@ -448,7 +509,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
...
@@ -448,7 +509,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
TSKEY
e
=
MAX
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
TSKEY
e
=
MAX
(
pCheckInfo
->
lastKey
,
pQueryHandle
->
window
.
ekey
);
// discard the unqualified data block based on the query time window
// discard the unqualified data block based on the query time window
int32_t
start
=
binarySearchForBlock
Impl
(
pCompInfo
->
blocks
,
compIndex
->
numOfBlocks
,
s
,
TSDB_ORDER_ASC
);
int32_t
start
=
binarySearchForBlock
(
pCompInfo
->
blocks
,
compIndex
->
numOfBlocks
,
s
,
TSDB_ORDER_ASC
);
int32_t
end
=
start
;
int32_t
end
=
start
;
if
(
s
>
pCompInfo
->
blocks
[
start
].
keyLast
)
{
if
(
s
>
pCompInfo
->
blocks
[
start
].
keyLast
)
{
...
@@ -523,6 +584,8 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
...
@@ -523,6 +584,8 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
bool
blockLoaded
=
false
;
bool
blockLoaded
=
false
;
SArray
*
sa
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
SArray
*
sa
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
int64_t
st
=
taosGetTimestampUs
();
if
(
pCheckInfo
->
pDataCols
==
NULL
)
{
if
(
pCheckInfo
->
pDataCols
==
NULL
)
{
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
pRepo
);
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
pRepo
);
pCheckInfo
->
pDataCols
=
tdNewDataCols
(
pMeta
->
maxRowBytes
,
pMeta
->
maxCols
,
pRepo
->
config
.
maxRowsPerFileBlock
);
pCheckInfo
->
pDataCols
=
tdNewDataCols
(
pMeta
->
maxRowBytes
,
pMeta
->
maxCols
,
pRepo
->
config
.
maxRowsPerFileBlock
);
...
@@ -540,9 +603,15 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
...
@@ -540,9 +603,15 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
blockLoaded
=
true
;
blockLoaded
=
true
;
}
}
SDataCols
*
pCols
=
pQueryHandle
->
rhelper
.
pDataCols
[
0
];
assert
(
pCols
->
numOfRows
!=
0
);
taosArrayDestroy
(
sa
);
taosArrayDestroy
(
sa
);
tfree
(
data
);
tfree
(
data
);
int64_t
et
=
taosGetTimestampUs
()
-
st
;
tsdbTrace
(
"%p load file block into buffer, elapsed time:%"
PRId64
" us"
,
pQueryHandle
,
et
);
return
blockLoaded
;
return
blockLoaded
;
}
}
...
@@ -600,7 +669,7 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
...
@@ -600,7 +669,7 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
// do not load file block into buffer
// do not load file block into buffer
int32_t
step
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
1
:
-
1
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
?
1
:
-
1
;
cur
->
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
->
iter
,
pCheckInfo
->
pTableObj
,
binfo
.
window
.
skey
-
step
,
cur
->
rows
=
tsdbReadRowsFromCache
(
pCheckInfo
,
binfo
.
window
.
skey
-
step
,
pQueryHandle
->
outputCapacity
,
&
cur
->
win
.
skey
,
&
cur
->
win
.
ekey
,
pQueryHandle
);
pQueryHandle
->
outputCapacity
,
&
cur
->
win
.
skey
,
&
cur
->
win
.
ekey
,
pQueryHandle
);
pQueryHandle
->
realNumOfRows
=
cur
->
rows
;
pQueryHandle
->
realNumOfRows
=
cur
->
rows
;
...
@@ -1192,15 +1261,26 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
...
@@ -1192,15 +1261,26 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
pBlockInfo
->
compBlock
=
&
pBlock
[
k
];
pBlockInfo
->
compBlock
=
&
pBlock
[
k
];
pBlockInfo
->
pTableCheckInfo
=
pTableCheck
;
pBlockInfo
->
pTableCheckInfo
=
pTableCheck
;
// pBlockInfo->groupIdx = pTableCheckInfo[j]->groupIdx; // set the group index
// pBlockInfo->blockIndex = pTableCheckInfo[j]->start + k; // set the block index in original table
cnt
++
;
cnt
++
;
}
}
numOfQualTables
++
;
numOfQualTables
++
;
}
}
tsdbTrace
(
"%p create data blocks info struct completed, %d blocks in %d tables"
,
pQueryHandle
,
cnt
,
numOfQualTables
);
assert
(
numOfBlocks
==
cnt
);
// since there is only one table qualified, blocks are not sorted
if
(
numOfQualTables
==
1
)
{
memcpy
(
pQueryHandle
->
pDataBlockInfo
,
sup
.
pDataBlockInfo
[
0
],
sizeof
(
STableBlockInfo
)
*
numOfBlocks
);
cleanBlockOrderSupporter
(
&
sup
,
numOfQualTables
);
tsdbTrace
(
"%p create data blocks info struct completed for 1 table, %d blocks not sorted %p "
,
pQueryHandle
,
cnt
,
pQueryHandle
->
qinfo
);
return
TSDB_CODE_SUCCESS
;
}
tsdbTrace
(
"%p create data blocks info struct completed, %d blocks in %d tables %p"
,
pQueryHandle
,
cnt
,
numOfQualTables
,
pQueryHandle
->
qinfo
);
assert
(
cnt
<=
numOfBlocks
&&
numOfQualTables
<=
numOfTables
);
// the pTableQueryInfo[j]->numOfBlocks may be 0
assert
(
cnt
<=
numOfBlocks
&&
numOfQualTables
<=
numOfTables
);
// the pTableQueryInfo[j]->numOfBlocks may be 0
sup
.
numOfTables
=
numOfQualTables
;
sup
.
numOfTables
=
numOfQualTables
;
...
@@ -1257,8 +1337,8 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) {
...
@@ -1257,8 +1337,8 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) {
break
;
break
;
}
}
tsdbTrace
(
"%p %d blocks found in file for %d table(s), fid:%d"
,
pQueryHandle
,
numOfBlocks
,
tsdbTrace
(
"%p %d blocks found in file for %d table(s), fid:%d
, %p
"
,
pQueryHandle
,
numOfBlocks
,
numOfTables
,
pQueryHandle
->
pFileGroup
->
fileId
);
numOfTables
,
pQueryHandle
->
pFileGroup
->
fileId
,
pQueryHandle
->
qinfo
);
assert
(
numOfBlocks
>=
0
);
assert
(
numOfBlocks
>=
0
);
if
(
numOfBlocks
==
0
)
{
if
(
numOfBlocks
==
0
)
{
...
@@ -1565,19 +1645,22 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
...
@@ -1565,19 +1645,22 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
pQueryHandle
->
window
=
(
STimeWindow
)
{
info
.
lastKey
,
TSKEY_INITIAL_VAL
};
pQueryHandle
->
window
=
(
STimeWindow
)
{
info
.
lastKey
,
TSKEY_INITIAL_VAL
};
}
}
static
int
tsdbReadRowsFromCache
(
S
SkipListIterator
*
pIter
,
STable
*
pTable
,
TSKEY
maxKey
,
int
maxRowsToRead
,
TSKEY
*
skey
,
TSKEY
*
ekey
,
static
int
tsdbReadRowsFromCache
(
S
TableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
TSKEY
*
skey
,
TSKEY
*
ekey
,
STsdbQueryHandle
*
pQueryHandle
)
{
STsdbQueryHandle
*
pQueryHandle
)
{
int
numOfRows
=
0
;
int
numOfRows
=
0
;
int32_t
numOfCols
=
taosArrayGetSize
(
pQueryHandle
->
pColumns
);
int32_t
numOfCols
=
taosArrayGetSize
(
pQueryHandle
->
pColumns
);
*
skey
=
TSKEY_INITIAL_VAL
;
*
skey
=
TSKEY_INITIAL_VAL
;
int64_t
st
=
taosGetTimestampUs
();
STSchema
*
pSchema
=
tsdbGetTableSchema
(
tsdbGetMeta
(
pQueryHandle
->
pTsdb
),
pCheckInfo
->
pTableObj
);
int32_t
numOfTableCols
=
schemaNCols
(
pSchema
);
do
{
do
{
S
SkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
S
DataRow
row
=
getSDataRowInTableMem
(
pCheckInfo
);
if
(
node
==
NULL
)
{
if
(
row
==
NULL
)
{
break
;
break
;
}
}
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
TSKEY
key
=
dataRowKey
(
row
);
TSKEY
key
=
dataRowKey
(
row
);
if
((
key
>
maxKey
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
if
((
key
>
maxKey
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
...
@@ -1590,19 +1673,19 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
...
@@ -1590,19 +1673,19 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
}
}
if
(
*
skey
==
INT64_MIN
)
{
if
(
*
skey
==
INT64_MIN
)
{
*
skey
=
dataRowKey
(
row
)
;
*
skey
=
key
;
}
}
*
ekey
=
dataRowKey
(
row
);
*
ekey
=
key
;
int32_t
offset
=
-
1
;
char
*
pData
=
NULL
;
char
*
pData
=
NULL
;
STSchema
*
pSchema
=
tsdbGetTableSchema
(
tsdbGetMeta
(
pQueryHandle
->
pTsdb
),
pTable
);
int32_t
i
=
0
,
j
=
0
;
int32_t
numOfTableCols
=
schemaNCols
(
pSchema
);
while
(
i
<
numOfCols
&&
j
<
numOfTableCols
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
if
(
pSchema
->
columns
[
j
].
colId
<
pColInfo
->
info
.
colId
)
{
j
++
;
continue
;
}
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
pData
=
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
pData
=
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
...
@@ -1610,29 +1693,49 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
...
@@ -1610,29 +1693,49 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
pData
=
pColInfo
->
pData
+
(
maxRowsToRead
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
pData
=
pColInfo
->
pData
+
(
maxRowsToRead
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
}
for
(
int32_t
j
=
0
;
j
<
numOfTableCols
;
++
j
)
{
if
(
pSchema
->
columns
[
j
].
colId
==
pColInfo
->
info
.
colId
)
{
if
(
pColInfo
->
info
.
colId
==
pSchema
->
columns
[
j
].
colId
)
{
void
*
value
=
tdGetRowDataOfCol
(
row
,
pColInfo
->
info
.
type
,
TD_DATA_ROW_HEAD_SIZE
+
pSchema
->
columns
[
j
].
offset
);
offset
=
pSchema
->
columns
[
j
].
offset
;
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
break
;
memcpy
(
pData
,
value
,
varDataTLen
(
value
));
}
else
{
memcpy
(
pData
,
value
,
pColInfo
->
info
.
bytes
);
}
j
++
;
i
++
;
}
else
{
// pColInfo->info.colId < pSchema->columns[j].colId, it is a NULL data
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
setVardataNull
(
pData
,
pColInfo
->
info
.
type
);
}
else
{
setNull
(
pData
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
);
}
i
++
;
}
}
}
}
assert
(
offset
!=
-
1
);
// todo handle error
while
(
i
<
numOfCols
)
{
// the remain columns are all null data
void
*
value
=
tdGetRowDataOfCol
(
row
,
pColInfo
->
info
.
type
,
TD_DATA_ROW_HEAD_SIZE
+
offset
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
pData
=
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
}
else
{
pData
=
pColInfo
->
pData
+
(
maxRowsToRead
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
memcpy
(
pData
,
value
,
varDataTLen
(
value
)
);
setVardataNull
(
pData
,
pColInfo
->
info
.
type
);
}
else
{
}
else
{
memcpy
(
pData
,
valu
e
,
pColInfo
->
info
.
bytes
);
setNull
(
pData
,
pColInfo
->
info
.
typ
e
,
pColInfo
->
info
.
bytes
);
}
}
i
++
;
}
}
if
(
++
numOfRows
>=
maxRowsToRead
)
{
if
(
++
numOfRows
>=
maxRowsToRead
)
{
tSkipListIterNext
(
pIter
);
moveToNextRow
(
pCheckInfo
);
break
;
break
;
}
}
}
while
(
tSkipListIterNext
(
pIter
));
}
while
(
moveToNextRow
(
pCheckInfo
));
assert
(
numOfRows
<=
maxRowsToRead
);
assert
(
numOfRows
<=
maxRowsToRead
);
...
@@ -1646,6 +1749,10 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
...
@@ -1646,6 +1749,10 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
}
}
}
}
int64_t
elapsedTime
=
taosGetTimestampUs
()
-
st
;
tsdbTrace
(
"%p build data block from cache completed, elapsed time:%"
PRId64
" us, numOfRows:%d, numOfCols:%d"
,
pQueryHandle
,
elapsedTime
,
numOfRows
,
numOfCols
);
return
numOfRows
;
return
numOfRows
;
}
}
...
...
src/util/inc/tcache.h
浏览文件 @
adb62142
...
@@ -111,6 +111,15 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz
...
@@ -111,6 +111,15 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz
*/
*/
void
*
taosCacheAcquireByName
(
SCacheObj
*
pCacheObj
,
const
char
*
key
);
void
*
taosCacheAcquireByName
(
SCacheObj
*
pCacheObj
,
const
char
*
key
);
/**
* update the expire time of data in cache
* @param pCacheObj cache object
* @param key key
* @param expireTime new expire time of data
* @return
*/
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
uint64_t
expireTime
);
/**
/**
* Add one reference count for the exist data, and assign this data for a new owner.
* Add one reference count for the exist data, and assign this data for a new owner.
* The new owner needs to invoke the taosCacheRelease when it does not need this data anymore.
* The new owner needs to invoke the taosCacheRelease when it does not need this data anymore.
...
...
src/util/inc/tutil.h
浏览文件 @
adb62142
...
@@ -153,6 +153,8 @@ bool taosMbsToUcs4(char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len,
...
@@ -153,6 +153,8 @@ bool taosMbsToUcs4(char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len,
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
);
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
);
void
taosRandStr
(
char
*
str
,
int32_t
size
);
int32_t
taosUcs4ToMbs
(
void
*
ucs4
,
int32_t
ucs4_max_len
,
char
*
mbs
);
int32_t
taosUcs4ToMbs
(
void
*
ucs4
,
int32_t
ucs4_max_len
,
char
*
mbs
);
bool
taosValidateEncodec
(
const
char
*
encodec
);
bool
taosValidateEncodec
(
const
char
*
encodec
);
...
...
src/util/src/tarray.c
浏览文件 @
adb62142
...
@@ -92,12 +92,14 @@ void* taosArrayGet(const SArray* pArray, size_t index) {
...
@@ -92,12 +92,14 @@ void* taosArrayGet(const SArray* pArray, size_t index) {
}
}
void
*
taosArrayGetP
(
const
SArray
*
pArray
,
size_t
index
)
{
void
*
taosArrayGetP
(
const
SArray
*
pArray
,
size_t
index
)
{
void
*
ret
=
taosArrayGet
(
pArray
,
index
);
assert
(
index
<
pArray
->
size
);
if
(
ret
==
NULL
)
{
void
*
d
=
TARRAY_GET_ELEM
(
pArray
,
index
);
if
(
d
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
return
*
(
void
**
)
ret
;
return
*
(
void
**
)
d
;
}
}
size_t
taosArrayGetSize
(
const
SArray
*
pArray
)
{
return
pArray
->
size
;
}
size_t
taosArrayGetSize
(
const
SArray
*
pArray
)
{
return
pArray
->
size
;
}
...
...
src/util/src/tcache.c
浏览文件 @
adb62142
...
@@ -488,6 +488,35 @@ void *taosCacheAcquireByName(SCacheObj *pCacheObj, const char *key) {
...
@@ -488,6 +488,35 @@ void *taosCacheAcquireByName(SCacheObj *pCacheObj, const char *key) {
return
(
ptNode
!=
NULL
)
?
(
*
ptNode
)
->
data
:
NULL
;
return
(
ptNode
!=
NULL
)
?
(
*
ptNode
)
->
data
:
NULL
;
}
}
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
uint64_t
expireTime
)
{
if
(
pCacheObj
==
NULL
||
taosHashGetSize
(
pCacheObj
->
pHashTable
)
==
0
)
{
return
NULL
;
}
uint32_t
keyLen
=
(
uint32_t
)
strlen
(
key
);
__cache_rd_lock
(
pCacheObj
);
SCacheDataNode
**
ptNode
=
(
SCacheDataNode
**
)
taosHashGet
(
pCacheObj
->
pHashTable
,
key
,
keyLen
);
if
(
ptNode
!=
NULL
)
{
T_REF_INC
(
*
ptNode
);
(
*
ptNode
)
->
expiredTime
=
expireTime
;
}
__cache_unlock
(
pCacheObj
);
if
(
ptNode
!=
NULL
)
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
hitCount
,
1
);
uTrace
(
"key:%s expireTime is updated in cache, %p refcnt:%d"
,
key
,
(
*
ptNode
),
T_REF_VAL_GET
(
*
ptNode
));
}
else
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
missCount
,
1
);
uTrace
(
"key:%s not in cache, retrieved failed"
,
key
);
}
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
totalAccess
,
1
);
return
(
ptNode
!=
NULL
)
?
(
*
ptNode
)
->
data
:
NULL
;
}
void
*
taosCacheAcquireByData
(
SCacheObj
*
pCacheObj
,
void
*
data
)
{
void
*
taosCacheAcquireByData
(
SCacheObj
*
pCacheObj
,
void
*
data
)
{
if
(
pCacheObj
==
NULL
||
data
==
NULL
)
return
NULL
;
if
(
pCacheObj
==
NULL
||
data
==
NULL
)
return
NULL
;
...
...
src/util/src/tsocket.c
浏览文件 @
adb62142
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "tutil.h"
#include "tutil.h"
int
taosGetFqdn
(
char
*
fqdn
)
{
int
taosGetFqdn
(
char
*
fqdn
)
{
int
code
=
0
;
char
hostname
[
1024
];
char
hostname
[
1024
];
hostname
[
1023
]
=
'\0'
;
hostname
[
1023
]
=
'\0'
;
gethostname
(
hostname
,
1023
);
gethostname
(
hostname
,
1023
);
...
@@ -27,13 +28,15 @@ int taosGetFqdn(char *fqdn) {
...
@@ -27,13 +28,15 @@ int taosGetFqdn(char *fqdn) {
h
=
gethostbyname
(
hostname
);
h
=
gethostbyname
(
hostname
);
if
(
h
!=
NULL
)
{
if
(
h
!=
NULL
)
{
strcpy
(
fqdn
,
h
->
h_name
);
strcpy
(
fqdn
,
h
->
h_name
);
return
0
;
}
else
{
}
else
{
uError
(
"failed to get host name
"
);
uError
(
"failed to get host name
(%s)"
,
strerror
(
errno
)
);
return
-
1
;
code
=
-
1
;
}
}
free
(
h
);
// to do: free the resources
// free(h);
return
code
;
}
}
uint32_t
taosGetIpFromFqdn
(
const
char
*
fqdn
)
{
uint32_t
taosGetIpFromFqdn
(
const
char
*
fqdn
)
{
...
@@ -47,7 +50,7 @@ uint32_t ip2uint(const char *const ip_addr) {
...
@@ -47,7 +50,7 @@ uint32_t ip2uint(const char *const ip_addr) {
char
ip_addr_cpy
[
20
];
char
ip_addr_cpy
[
20
];
char
ip
[
5
];
char
ip
[
5
];
strcpy
(
ip_addr_cpy
,
ip_addr
);
tstrncpy
(
ip_addr_cpy
,
ip_addr
,
sizeof
(
ip_addr_cpy
)
);
char
*
s_start
,
*
s_end
;
char
*
s_start
,
*
s_end
;
s_start
=
ip_addr_cpy
;
s_start
=
ip_addr_cpy
;
...
@@ -206,7 +209,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
...
@@ -206,7 +209,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
int
reuse
,
nocheck
;
int
reuse
,
nocheck
;
int
bufSize
=
8192000
;
int
bufSize
=
8192000
;
uTrace
(
"open udp socket:
%s
:%hu"
,
ip
,
port
);
uTrace
(
"open udp socket:
0x%x
:%hu"
,
ip
,
port
);
memset
((
char
*
)
&
localAddr
,
0
,
sizeof
(
localAddr
));
memset
((
char
*
)
&
localAddr
,
0
,
sizeof
(
localAddr
));
localAddr
.
sin_family
=
AF_INET
;
localAddr
.
sin_family
=
AF_INET
;
...
@@ -257,7 +260,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
...
@@ -257,7 +260,7 @@ int taosOpenUdpSocket(uint32_t ip, uint16_t port) {
/* bind socket to local address */
/* bind socket to local address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
uError
(
"failed to bind udp socket: %d (%s),
%s
:%hu"
,
errno
,
strerror
(
errno
),
ip
,
port
);
uError
(
"failed to bind udp socket: %d (%s),
0x%x
:%hu"
,
errno
,
strerror
(
errno
),
ip
,
port
);
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -363,7 +366,7 @@ int taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -363,7 +366,7 @@ int taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
int
sockFd
;
int
sockFd
;
int
reuse
;
int
reuse
;
uTrace
(
"open tcp server socket:
%s
:%hu"
,
ip
,
port
);
uTrace
(
"open tcp server socket:
0x%x
:%hu"
,
ip
,
port
);
bzero
((
char
*
)
&
serverAdd
,
sizeof
(
serverAdd
));
bzero
((
char
*
)
&
serverAdd
,
sizeof
(
serverAdd
));
serverAdd
.
sin_family
=
AF_INET
;
serverAdd
.
sin_family
=
AF_INET
;
...
...
src/util/src/tutil.c
浏览文件 @
adb62142
...
@@ -27,8 +27,6 @@
...
@@ -27,8 +27,6 @@
#include "tulog.h"
#include "tulog.h"
#include "taoserror.h"
#include "taoserror.h"
int32_t
tmpFileSerialNum
=
0
;
int32_t
strdequote
(
char
*
z
)
{
int32_t
strdequote
(
char
*
z
)
{
if
(
z
==
NULL
)
{
if
(
z
==
NULL
)
{
return
0
;
return
0
;
...
@@ -433,12 +431,24 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
...
@@ -433,12 +431,24 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
#else
#else
char
*
tmpDir
=
"/tmp/"
;
char
*
tmpDir
=
"/tmp/"
;
#endif
#endif
int64_t
ts
=
taosGetTimestampUs
();
strcpy
(
tmpPath
,
tmpDir
);
strcpy
(
tmpPath
,
tmpDir
);
strcat
(
tmpPath
,
tdengineTmpFileNamePrefix
);
strcat
(
tmpPath
,
tdengineTmpFileNamePrefix
);
strcat
(
tmpPath
,
fileNamePrefix
);
strcat
(
tmpPath
,
fileNamePrefix
);
strcat
(
tmpPath
,
"-%d-%"
PRIu64
"-%u-%"
PRIu64
);
strcat
(
tmpPath
,
"-%d-%s"
);
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
taosGetPthreadId
(),
atomic_add_fetch_32
(
&
tmpFileSerialNum
,
1
),
ts
);
char
rand
[
8
]
=
{
0
};
taosRandStr
(
rand
,
tListLen
(
rand
)
-
1
);
snprintf
(
dstPath
,
PATH_MAX
,
tmpPath
,
getpid
(),
rand
);
}
void
taosRandStr
(
char
*
str
,
int32_t
size
)
{
const
char
*
set
=
"abcdefghijklmnopqrstuvwxyz0123456789-_."
;
int32_t
len
=
39
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
str
[
i
]
=
set
[
rand
()
%
len
];
}
}
}
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
)
{
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
)
{
...
...
src/wal/src/walMain.c
浏览文件 @
adb62142
...
@@ -68,10 +68,18 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
...
@@ -68,10 +68,18 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
pWal
->
num
=
0
;
pWal
->
num
=
0
;
pWal
->
level
=
pCfg
->
walLevel
;
pWal
->
level
=
pCfg
->
walLevel
;
pWal
->
keep
=
pCfg
->
keep
;
pWal
->
keep
=
pCfg
->
keep
;
strcpy
(
pWal
->
path
,
path
);
tstrncpy
(
pWal
->
path
,
path
,
sizeof
(
pWal
->
path
)
);
pthread_mutex_init
(
&
pWal
->
mutex
,
NULL
);
pthread_mutex_init
(
&
pWal
->
mutex
,
NULL
);
if
(
access
(
path
,
F_OK
)
!=
0
)
mkdir
(
path
,
0755
);
if
(
access
(
path
,
F_OK
)
!=
0
)
{
if
(
mkdir
(
path
,
0755
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"wal:%s, failed to create directory(%s)"
,
path
,
strerror
(
errno
));
pthread_mutex_destroy
(
&
pWal
->
mutex
);
free
(
pWal
);
pWal
=
NULL
;
}
}
if
(
pCfg
->
keep
==
1
)
return
pWal
;
if
(
pCfg
->
keep
==
1
)
return
pWal
;
...
@@ -80,7 +88,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
...
@@ -80,7 +88,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
if
(
pWal
->
fd
<
0
)
{
if
(
pWal
->
fd
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"wal:%s, failed to open
"
,
path
);
wError
(
"wal:%s, failed to open
(%s)"
,
path
,
strerror
(
errno
)
);
pthread_mutex_destroy
(
&
pWal
->
mutex
);
pthread_mutex_destroy
(
&
pWal
->
mutex
);
free
(
pWal
);
free
(
pWal
);
pWal
=
NULL
;
pWal
=
NULL
;
...
@@ -119,7 +127,8 @@ void walClose(void *handle) {
...
@@ -119,7 +127,8 @@ void walClose(void *handle) {
int
walRenew
(
void
*
handle
)
{
int
walRenew
(
void
*
handle
)
{
if
(
handle
==
NULL
)
return
0
;
if
(
handle
==
NULL
)
return
0
;
SWal
*
pWal
=
handle
;
SWal
*
pWal
=
handle
;
int
code
=
0
;
terrno
=
0
;
pthread_mutex_lock
(
&
pWal
->
mutex
);
pthread_mutex_lock
(
&
pWal
->
mutex
);
...
@@ -135,8 +144,8 @@ int walRenew(void *handle) {
...
@@ -135,8 +144,8 @@ int walRenew(void *handle) {
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
if
(
pWal
->
fd
<
0
)
{
wError
(
"wal:%
d
, failed to open(%s)"
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"wal:%
s
, failed to open(%s)"
,
pWal
->
name
,
strerror
(
errno
));
code
=
-
1
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
}
else
{
}
else
{
wTrace
(
"wal:%s, it is created"
,
pWal
->
name
);
wTrace
(
"wal:%s, it is created"
,
pWal
->
name
);
...
@@ -156,14 +165,15 @@ int walRenew(void *handle) {
...
@@ -156,14 +165,15 @@ int walRenew(void *handle) {
pthread_mutex_unlock
(
&
pWal
->
mutex
);
pthread_mutex_unlock
(
&
pWal
->
mutex
);
return
code
;
return
terrno
;
}
}
int
walWrite
(
void
*
handle
,
SWalHead
*
pHead
)
{
int
walWrite
(
void
*
handle
,
SWalHead
*
pHead
)
{
SWal
*
pWal
=
handle
;
SWal
*
pWal
=
handle
;
int
code
=
0
;
if
(
pWal
==
NULL
)
return
-
1
;
if
(
pWal
==
NULL
)
return
-
1
;
terrno
=
0
;
// no wal
// no wal
if
(
pWal
->
level
==
TAOS_WAL_NOLOG
)
return
0
;
if
(
pWal
->
level
==
TAOS_WAL_NOLOG
)
return
0
;
if
(
pHead
->
version
<=
pWal
->
version
)
return
0
;
if
(
pHead
->
version
<=
pWal
->
version
)
return
0
;
...
@@ -174,12 +184,12 @@ int walWrite(void *handle, SWalHead *pHead) {
...
@@ -174,12 +184,12 @@ int walWrite(void *handle, SWalHead *pHead) {
if
(
write
(
pWal
->
fd
,
pHead
,
contLen
)
!=
contLen
)
{
if
(
write
(
pWal
->
fd
,
pHead
,
contLen
)
!=
contLen
)
{
wError
(
"wal:%s, failed to write(%s)"
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"wal:%s, failed to write(%s)"
,
pWal
->
name
,
strerror
(
errno
));
code
=
-
1
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
}
else
{
}
else
{
pWal
->
version
=
pHead
->
version
;
pWal
->
version
=
pHead
->
version
;
}
}
return
code
;
return
terrno
;
}
}
void
walFsync
(
void
*
handle
)
{
void
walFsync
(
void
*
handle
)
{
...
@@ -196,11 +206,11 @@ void walFsync(void *handle) {
...
@@ -196,11 +206,11 @@ void walFsync(void *handle) {
int
walRestore
(
void
*
handle
,
void
*
pVnode
,
int
(
*
writeFp
)(
void
*
,
void
*
,
int
))
{
int
walRestore
(
void
*
handle
,
void
*
pVnode
,
int
(
*
writeFp
)(
void
*
,
void
*
,
int
))
{
SWal
*
pWal
=
handle
;
SWal
*
pWal
=
handle
;
int
code
=
0
;
struct
dirent
*
ent
;
struct
dirent
*
ent
;
int
count
=
0
;
int
count
=
0
;
uint32_t
maxId
=
0
,
minId
=
-
1
,
index
=
0
;
uint32_t
maxId
=
0
,
minId
=
-
1
,
index
=
0
;
terrno
=
0
;
int
plen
=
strlen
(
walPrefix
);
int
plen
=
strlen
(
walPrefix
);
char
opath
[
TSDB_FILENAME_LEN
+
5
];
char
opath
[
TSDB_FILENAME_LEN
+
5
];
...
@@ -224,30 +234,30 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
...
@@ -224,30 +234,30 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
closedir
(
dir
);
closedir
(
dir
);
if
(
count
==
0
)
{
if
(
count
==
0
)
{
if
(
pWal
->
keep
)
code
=
walRenew
(
pWal
);
if
(
pWal
->
keep
)
terrno
=
walRenew
(
pWal
);
return
code
;
return
terrno
;
}
}
if
(
count
!=
(
maxId
-
minId
+
1
)
)
{
if
(
count
!=
(
maxId
-
minId
+
1
)
)
{
wError
(
"wal:%s, messed up, count:%d max:%d min:%d"
,
opath
,
count
,
maxId
,
minId
);
wError
(
"wal:%s, messed up, count:%d max:%d min:%d"
,
opath
,
count
,
maxId
,
minId
);
code
=
-
1
;
terrno
=
TAOS_SYSTEM_ERROR
(
TSDB_CODE_APP_ERROR
)
;
}
else
{
}
else
{
wTrace
(
"wal:%s, %d files will be restored"
,
opath
,
count
);
wTrace
(
"wal:%s, %d files will be restored"
,
opath
,
count
);
for
(
index
=
minId
;
index
<=
maxId
;
++
index
)
{
for
(
index
=
minId
;
index
<=
maxId
;
++
index
)
{
sprintf
(
pWal
->
name
,
"%s/%s%d"
,
opath
,
walPrefix
,
index
);
sprintf
(
pWal
->
name
,
"%s/%s%d"
,
opath
,
walPrefix
,
index
);
code
=
walRestoreWalFile
(
pWal
,
pVnode
,
writeFp
);
terrno
=
walRestoreWalFile
(
pWal
,
pVnode
,
writeFp
);
if
(
code
<
0
)
break
;
if
(
terrno
<
0
)
break
;
}
}
}
}
if
(
code
==
0
)
{
if
(
terrno
==
0
)
{
if
(
pWal
->
keep
==
0
)
{
if
(
pWal
->
keep
==
0
)
{
code
=
walRemoveWalFiles
(
opath
);
terrno
=
walRemoveWalFiles
(
opath
);
if
(
code
==
0
)
{
if
(
terrno
==
0
)
{
if
(
remove
(
opath
)
<
0
)
{
if
(
remove
(
opath
)
<
0
)
{
wError
(
"wal:%s, failed to remove directory(%s)"
,
opath
,
strerror
(
errno
));
wError
(
"wal:%s, failed to remove directory(%s)"
,
opath
,
strerror
(
errno
));
code
=
-
1
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
}
}
}
}
}
else
{
}
else
{
...
@@ -258,12 +268,12 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
...
@@ -258,12 +268,12 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
if
(
pWal
->
fd
<
0
)
{
wError
(
"wal:%s, failed to open file(%s)"
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"wal:%s, failed to open file(%s)"
,
pWal
->
name
,
strerror
(
errno
));
code
=
-
1
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
}
}
}
}
}
}
return
code
;
return
terrno
;
}
}
int
walGetWalFile
(
void
*
handle
,
char
*
name
,
uint32_t
*
index
)
{
int
walGetWalFile
(
void
*
handle
,
char
*
name
,
uint32_t
*
index
)
{
...
@@ -292,40 +302,47 @@ int walGetWalFile(void *handle, char *name, uint32_t *index) {
...
@@ -292,40 +302,47 @@ int walGetWalFile(void *handle, char *name, uint32_t *index) {
}
}
static
int
walRestoreWalFile
(
SWal
*
pWal
,
void
*
pVnode
,
FWalWrite
writeFp
)
{
static
int
walRestoreWalFile
(
SWal
*
pWal
,
void
*
pVnode
,
FWalWrite
writeFp
)
{
int
code
=
0
;
char
*
name
=
pWal
->
name
;
char
*
name
=
pWal
->
name
;
terrno
=
0
;
char
*
buffer
=
malloc
(
1024000
);
// size for one record
char
*
buffer
=
malloc
(
1024000
);
// size for one record
if
(
buffer
==
NULL
)
return
-
1
;
if
(
buffer
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
terrno
;
}
SWalHead
*
pHead
=
(
SWalHead
*
)
buffer
;
SWalHead
*
pHead
=
(
SWalHead
*
)
buffer
;
int
fd
=
open
(
name
,
O_RDONLY
);
int
fd
=
open
(
name
,
O_RDONLY
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
wError
(
"wal:%s, failed to open for restore(%s)"
,
name
,
strerror
(
errno
));
wError
(
"wal:%s, failed to open for restore(%s)"
,
name
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
free
(
buffer
);
free
(
buffer
);
return
-
1
;
return
terrno
;
}
}
wTrace
(
"wal:%s, start to restore"
,
name
);
wTrace
(
"wal:%s, start to restore"
,
name
);
while
(
1
)
{
while
(
1
)
{
int
ret
=
read
(
fd
,
pHead
,
sizeof
(
SWalHead
));
int
ret
=
read
(
fd
,
pHead
,
sizeof
(
SWalHead
));
if
(
ret
==
0
)
{
code
=
0
;
break
;}
if
(
ret
==
0
)
break
;
if
(
ret
!=
sizeof
(
SWalHead
))
{
if
(
ret
!=
sizeof
(
SWalHead
))
{
wWarn
(
"wal:%s, failed to read head, skip, ret:%d(%s)"
,
name
,
ret
,
strerror
(
errno
));
wWarn
(
"wal:%s, failed to read head, skip, ret:%d(%s)"
,
name
,
ret
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
break
;
}
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SWalHead
)))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SWalHead
)))
{
wWarn
(
"wal:%s, cksum is messed up, skip the rest of file"
,
name
);
wWarn
(
"wal:%s, cksum is messed up, skip the rest of file"
,
name
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
break
;
}
}
ret
=
read
(
fd
,
pHead
->
cont
,
pHead
->
len
);
ret
=
read
(
fd
,
pHead
->
cont
,
pHead
->
len
);
if
(
ret
!=
pHead
->
len
)
{
if
(
ret
!=
pHead
->
len
)
{
wWarn
(
"wal:%s, failed to read body, skip, len:%d ret:%d"
,
name
,
pHead
->
len
,
ret
);
wWarn
(
"wal:%s, failed to read body, skip, len:%d ret:%d"
,
name
,
pHead
->
len
,
ret
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
break
;
}
}
...
@@ -336,11 +353,10 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
...
@@ -336,11 +353,10 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
close
(
fd
);
close
(
fd
);
free
(
buffer
);
free
(
buffer
);
return
code
;
return
terrno
;
}
}
int
walHandleExistingFiles
(
const
char
*
path
)
{
int
walHandleExistingFiles
(
const
char
*
path
)
{
int
code
=
0
;
char
oname
[
TSDB_FILENAME_LEN
*
3
];
char
oname
[
TSDB_FILENAME_LEN
*
3
];
char
nname
[
TSDB_FILENAME_LEN
*
3
];
char
nname
[
TSDB_FILENAME_LEN
*
3
];
char
opath
[
TSDB_FILENAME_LEN
];
char
opath
[
TSDB_FILENAME_LEN
];
...
@@ -350,6 +366,7 @@ int walHandleExistingFiles(const char *path) {
...
@@ -350,6 +366,7 @@ int walHandleExistingFiles(const char *path) {
struct
dirent
*
ent
;
struct
dirent
*
ent
;
DIR
*
dir
=
opendir
(
path
);
DIR
*
dir
=
opendir
(
path
);
int
plen
=
strlen
(
walPrefix
);
int
plen
=
strlen
(
walPrefix
);
terrno
=
0
;
if
(
access
(
opath
,
F_OK
)
==
0
)
{
if
(
access
(
opath
,
F_OK
)
==
0
)
{
// old directory is there, it means restore process is not finished
// old directory is there, it means restore process is not finished
...
@@ -360,13 +377,19 @@ int walHandleExistingFiles(const char *path) {
...
@@ -360,13 +377,19 @@ int walHandleExistingFiles(const char *path) {
int
count
=
0
;
int
count
=
0
;
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
ent
->
d_name
,
walPrefix
,
plen
)
==
0
)
{
if
(
strncmp
(
ent
->
d_name
,
walPrefix
,
plen
)
==
0
)
{
if
(
access
(
opath
,
F_OK
)
!=
0
)
mkdir
(
opath
,
0755
);
sprintf
(
oname
,
"%s/%s"
,
path
,
ent
->
d_name
);
sprintf
(
oname
,
"%s/%s"
,
path
,
ent
->
d_name
);
sprintf
(
nname
,
"%s/old/%s"
,
path
,
ent
->
d_name
);
sprintf
(
nname
,
"%s/old/%s"
,
path
,
ent
->
d_name
);
if
(
access
(
opath
,
F_OK
)
!=
0
)
{
if
(
mkdir
(
opath
,
0755
)
!=
0
)
{
wError
(
"wal:%s, failed to create directory:%s(%s)"
,
oname
,
opath
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
}
}
if
(
rename
(
oname
,
nname
)
<
0
)
{
if
(
rename
(
oname
,
nname
)
<
0
)
{
wError
(
"wal:%s, failed to move to new:%s"
,
oname
,
nname
);
wError
(
"wal:%s, failed to move to new:%s"
,
oname
,
nname
);
code
=
-
1
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
break
;
break
;
}
}
...
@@ -378,14 +401,14 @@ int walHandleExistingFiles(const char *path) {
...
@@ -378,14 +401,14 @@ int walHandleExistingFiles(const char *path) {
}
}
closedir
(
dir
);
closedir
(
dir
);
return
code
;
return
terrno
;
}
}
static
int
walRemoveWalFiles
(
const
char
*
path
)
{
static
int
walRemoveWalFiles
(
const
char
*
path
)
{
int
plen
=
strlen
(
walPrefix
);
int
plen
=
strlen
(
walPrefix
);
char
name
[
TSDB_FILENAME_LEN
*
3
];
char
name
[
TSDB_FILENAME_LEN
*
3
];
int
code
=
0
;
terrno
=
0
;
if
(
access
(
path
,
F_OK
)
!=
0
)
return
0
;
if
(
access
(
path
,
F_OK
)
!=
0
)
return
0
;
struct
dirent
*
ent
;
struct
dirent
*
ent
;
...
@@ -396,13 +419,13 @@ static int walRemoveWalFiles(const char *path) {
...
@@ -396,13 +419,13 @@ static int walRemoveWalFiles(const char *path) {
sprintf
(
name
,
"%s/%s"
,
path
,
ent
->
d_name
);
sprintf
(
name
,
"%s/%s"
,
path
,
ent
->
d_name
);
if
(
remove
(
name
)
<
0
)
{
if
(
remove
(
name
)
<
0
)
{
wError
(
"wal:%s, failed to remove(%s)"
,
name
,
strerror
(
errno
));
wError
(
"wal:%s, failed to remove(%s)"
,
name
,
strerror
(
errno
));
code
=
-
1
;
break
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
}
}
}
}
}
}
closedir
(
dir
);
closedir
(
dir
);
return
code
;
return
terrno
;
}
}
tests/pytest/query/filter.py
浏览文件 @
adb62142
...
@@ -87,7 +87,7 @@ class TDTestCase:
...
@@ -87,7 +87,7 @@ class TDTestCase:
# <> for timestamp type
# <> for timestamp type
tdSql
.
query
(
"select * from db.st where ts <> '2020-05-13 10:00:00.002'"
)
tdSql
.
query
(
"select * from db.st where ts <> '2020-05-13 10:00:00.002'"
)
#tdSql.checkRows(4)
#
tdSql.checkRows(4)
# <> for numeric type
# <> for numeric type
tdSql
.
query
(
"select * from db.st where tagtype <> 2"
)
tdSql
.
query
(
"select * from db.st where tagtype <> 2"
)
...
...
tests/pytest/query/filterCombo.py
浏览文件 @
adb62142
...
@@ -42,14 +42,17 @@ class TDTestCase:
...
@@ -42,14 +42,17 @@ class TDTestCase:
('2020-05-13 10:00:00.005', 3, 'third')"""
)
('2020-05-13 10:00:00.005', 3, 'third')"""
)
# query with filter condition A OR condition B
# query with filter condition A OR condition B
tdSql
.
query
(
"select * from db.st where ts > '2020-05-13 10:00:00.002' AND tagtype < 2"
)
tdSql
.
query
(
"select * from db.st where ts > '2020-05-13 10:00:00.002' AND tagtype < 2"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# query with filter condition A OR condition B, error expected
# query with filter condition A OR condition B, error expected
tdSql
.
error
(
"select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2"
)
tdSql
.
error
(
"select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2"
)
# illegal condition
# illegal condition
tdSql
.
error
(
"select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2"
)
tdSql
.
error
(
"select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2"
)
tdSql
.
error
(
"select * from db.st where tagtype <> 1 OR tagtype < 2"
)
tdSql
.
error
(
"select * from db.st where tagtype <> 1 OR tagtype < 2"
)
def
stop
(
self
):
def
stop
(
self
):
...
...
tests/pytest/query/queryError.py
浏览文件 @
adb62142
...
@@ -41,7 +41,6 @@ class TDTestCase:
...
@@ -41,7 +41,6 @@ class TDTestCase:
('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'),
('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'),
('2020-05-13 10:00:00.005', 3, 'third')"""
)
('2020-05-13 10:00:00.005', 3, 'third')"""
)
# query first .. as ..
# query first .. as ..
tdSql
.
error
(
"select first(*) as one from st"
)
tdSql
.
error
(
"select first(*) as one from st"
)
...
...
tests/pytest/query/queryNormal.py
浏览文件 @
adb62142
...
@@ -28,9 +28,12 @@ class TDTestCase:
...
@@ -28,9 +28,12 @@ class TDTestCase:
print
(
"==============step1"
)
print
(
"==============step1"
)
tdSql
.
execute
(
"create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))"
)
tdSql
.
execute
(
tdSql
.
execute
(
"insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1), ('2020-04-18 15:00:01.000', 2, 0.1)"
)
"create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))"
)
tdSql
.
execute
(
"insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)"
)
tdSql
.
execute
(
"insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1), ('2020-04-18 15:00:01.000', 2, 0.1)"
)
tdSql
.
execute
(
"insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)"
)
# inner join --- bug
# inner join --- bug
tdSql
.
query
(
"select * from tb1 a, tb2 b where a.ts = b.ts"
)
tdSql
.
query
(
"select * from tb1 a, tb2 b where a.ts = b.ts"
)
...
...
tests/pytest/random-test/random-test-multi-threading-3.py
浏览文件 @
adb62142
...
@@ -111,7 +111,6 @@ class Test (threading.Thread):
...
@@ -111,7 +111,6 @@ class Test (threading.Thread):
last_tb
)
last_tb
)
written
=
written
+
1
written
=
written
+
1
def
drop_stable
(
self
):
def
drop_stable
(
self
):
tdLog
.
info
(
"drop_stable"
)
tdLog
.
info
(
"drop_stable"
)
global
last_stb
global
last_stb
...
@@ -152,7 +151,6 @@ class Test (threading.Thread):
...
@@ -152,7 +151,6 @@ class Test (threading.Thread):
last_tb
=
""
last_tb
=
""
written
=
0
written
=
0
def
query_data_from_stable
(
self
):
def
query_data_from_stable
(
self
):
tdLog
.
info
(
"query_data_from_stable"
)
tdLog
.
info
(
"query_data_from_stable"
)
global
last_stb
global
last_stb
...
@@ -164,7 +162,6 @@ class Test (threading.Thread):
...
@@ -164,7 +162,6 @@ class Test (threading.Thread):
tdLog
.
info
(
"will query data from super table"
)
tdLog
.
info
(
"will query data from super table"
)
tdSql
.
execute
(
'select * from %s'
%
last_stb
)
tdSql
.
execute
(
'select * from %s'
%
last_stb
)
def
reset_query_cache
(
self
):
def
reset_query_cache
(
self
):
tdLog
.
info
(
"reset_query_cache"
)
tdLog
.
info
(
"reset_query_cache"
)
global
last_tb
global
last_tb
...
@@ -232,7 +229,7 @@ class Test (threading.Thread):
...
@@ -232,7 +229,7 @@ class Test (threading.Thread):
self
.
threadLock
.
acquire
()
self
.
threadLock
.
acquire
()
tdLog
.
notice
(
"first thread"
)
tdLog
.
notice
(
"first thread"
)
randDataOp
=
random
.
randint
(
1
,
3
)
randDataOp
=
random
.
randint
(
1
,
3
)
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
self
.
threadLock
.
release
()
self
.
threadLock
.
release
()
elif
(
self
.
threadId
==
2
):
elif
(
self
.
threadId
==
2
):
...
...
tests/pytest/random-test/random-test-multi-threading.py
浏览文件 @
adb62142
...
@@ -111,7 +111,6 @@ class Test (threading.Thread):
...
@@ -111,7 +111,6 @@ class Test (threading.Thread):
last_tb
)
last_tb
)
written
=
written
+
1
written
=
written
+
1
def
drop_stable
(
self
):
def
drop_stable
(
self
):
tdLog
.
info
(
"drop_stable"
)
tdLog
.
info
(
"drop_stable"
)
global
last_stb
global
last_stb
...
@@ -154,7 +153,6 @@ class Test (threading.Thread):
...
@@ -154,7 +153,6 @@ class Test (threading.Thread):
last_tb
=
""
last_tb
=
""
written
=
0
written
=
0
def
query_data_from_stable
(
self
):
def
query_data_from_stable
(
self
):
tdLog
.
info
(
"query_data_from_stable"
)
tdLog
.
info
(
"query_data_from_stable"
)
global
last_stb
global
last_stb
...
@@ -166,7 +164,6 @@ class Test (threading.Thread):
...
@@ -166,7 +164,6 @@ class Test (threading.Thread):
tdLog
.
info
(
"will query data from super table"
)
tdLog
.
info
(
"will query data from super table"
)
tdSql
.
execute
(
'select * from %s'
%
last_stb
)
tdSql
.
execute
(
'select * from %s'
%
last_stb
)
def
reset_query_cache
(
self
):
def
reset_query_cache
(
self
):
tdLog
.
info
(
"reset_query_cache"
)
tdLog
.
info
(
"reset_query_cache"
)
global
last_tb
global
last_tb
...
@@ -230,7 +227,7 @@ class Test (threading.Thread):
...
@@ -230,7 +227,7 @@ class Test (threading.Thread):
self
.
threadLock
.
acquire
()
self
.
threadLock
.
acquire
()
tdLog
.
notice
(
"first thread"
)
tdLog
.
notice
(
"first thread"
)
randDataOp
=
random
.
randint
(
1
,
3
)
randDataOp
=
random
.
randint
(
1
,
3
)
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
dataOp
.
get
(
randDataOp
,
lambda
:
"ERROR"
)()
self
.
threadLock
.
release
()
self
.
threadLock
.
release
()
elif
(
self
.
threadId
==
2
):
elif
(
self
.
threadId
==
2
):
...
...
tests/pytest/random-test/random-test.py
浏览文件 @
adb62142
...
@@ -112,7 +112,6 @@ class Test:
...
@@ -112,7 +112,6 @@ class Test:
tdSql
.
execute
(
'drop table %s'
%
self
.
last_stb
)
tdSql
.
execute
(
'drop table %s'
%
self
.
last_stb
)
self
.
last_stb
=
""
self
.
last_stb
=
""
def
query_data_from_stable
(
self
):
def
query_data_from_stable
(
self
):
tdLog
.
info
(
"query_data_from_stable"
)
tdLog
.
info
(
"query_data_from_stable"
)
if
(
self
.
last_stb
==
""
):
if
(
self
.
last_stb
==
""
):
...
@@ -122,20 +121,21 @@ class Test:
...
@@ -122,20 +121,21 @@ class Test:
tdLog
.
info
(
"will query data from super table"
)
tdLog
.
info
(
"will query data from super table"
)
tdSql
.
execute
(
'select * from %s'
%
self
.
last_stb
)
tdSql
.
execute
(
'select * from %s'
%
self
.
last_stb
)
def
restart_database
(
self
):
def
restart_database
(
self
):
tdLog
.
info
(
"restart_databae"
)
tdLog
.
info
(
"restart_databae"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
tdLog
.
sleep
(
5
)
def
force_restart_database
(
self
):
def
force_restart_database
(
self
):
tdLog
.
info
(
"force_restart_database"
)
tdLog
.
info
(
"force_restart_database"
)
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
forcestop
(
1
)
tdDnodes
.
start
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
tdLog
.
sleep
(
5
)
tdSql
.
prepare
()
tdSql
.
prepare
()
self
.
last_tb
=
""
self
.
last_stb
=
""
self
.
written
=
0
def
drop_table
(
self
):
def
drop_table
(
self
):
tdLog
.
info
(
"drop_table"
)
tdLog
.
info
(
"drop_table"
)
...
@@ -159,6 +159,9 @@ class Test:
...
@@ -159,6 +159,9 @@ class Test:
tdDnodes
.
start
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
5
)
tdLog
.
sleep
(
5
)
tdSql
.
prepare
()
tdSql
.
prepare
()
self
.
last_tb
=
""
self
.
last_stb
=
""
self
.
written
=
0
def
delete_datafiles
(
self
):
def
delete_datafiles
(
self
):
tdLog
.
info
(
"delete_datafiles"
)
tdLog
.
info
(
"delete_datafiles"
)
...
@@ -173,6 +176,9 @@ class Test:
...
@@ -173,6 +176,9 @@ class Test:
tdDnodes
.
start
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
sleep
(
10
)
tdLog
.
sleep
(
10
)
tdSql
.
prepare
()
tdSql
.
prepare
()
self
.
last_tb
=
""
self
.
last_stb
=
""
self
.
written
=
0
class
TDTestCase
:
class
TDTestCase
:
...
...
tests/pytest/valgrind-test.sh
浏览文件 @
adb62142
#!/bin/bash
#!/bin/bash
# insert
# insert
python3 ./test.py
-g
-f
insert/basic.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/basic.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/int.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/int.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/float.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/float.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/bigint.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/bigint.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/bool.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/bool.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/double.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/double.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/smallint.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/smallint.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/tinyint.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/tinyint.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/binary.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/binary.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/date.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/date.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/nchar.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/nchar.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
insert/multi.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
insert/multi.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
# table
# table
python3 ./test.py
-g
-f
table/column_name.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
table/column_name.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
table/column_num.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
table/column_num.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
python3 ./test.py
-g
-f
table/db_table.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
table/db_table.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
# import
# import
python3 ./test.py
-g
-f
import_merge/importDataLastSub.py
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-f
import_merge/importDataLastSub.py
python3 ./test.py
-g
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
-g
-s
&&
sleep
1
#tag
#tag
python3 ./test.py
$1
-f
tag_lite/filter.py
PYTHONMALLOC
=
malloc
python3 ./test.py
$1
-f
tag_lite/filter.py
python3 ./test.py
$1
-s
&&
sleep
1
PYTHONMALLOC
=
malloc
python3 ./test.py
$1
-s
&&
sleep
1
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim
浏览文件 @
adb62142
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
# step 1: start dnode1
# step 1: start dnode1
# step 2: start dnode2 and dnode3, and all added into cluster (Suppose dnode2 is master-vnode)
# step 2: start dnode2 and dnode3, and all added into cluster (Suppose dnode2 is master-vnode)
# step 3: create db, table, insert data, and Falling disc into file (control only one file, e.g. 1841)
# step 3: create db, table, insert data, and Falling disc into file (control only one file, e.g. 1841)
# step 4: insert old data(now-
15d) and new data(now+15
d), control data rows in order to save in cache, not falling disc
# step 4: insert old data(now-
20d) and new data(now-40
d), control data rows in order to save in cache, not falling disc
# step 5: stop dnode2, so date rows falling disc, generate two new files 1840, 1842 in dnode2
# step 5: stop dnode2, so date rows falling disc, generate two new files 1840, 1842 in dnode2
# step 6: insert two data rows: now-
16d, now+16
d
# step 6: insert two data rows: now-
21d, now-41
d
# step 7: restart dnode2, waiting sync end
# step 7: restart dnode2, waiting sync end
# expect: in dnode2, the files 18
40 and 1842
will be removed
# expect: in dnode2, the files 18
37 and 1839
will be removed
system sh/stop_dnodes.sh
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode1 -i 1
...
@@ -14,10 +14,10 @@ system sh/deploy.sh -n dnode2 -i 2
...
@@ -14,10 +14,10 @@ system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfM
Peer
s -v 1
system sh/cfg.sh -n dnode1 -c numOfM
node
s -v 1
system sh/cfg.sh -n dnode2 -c numOfM
Peer
s -v 1
system sh/cfg.sh -n dnode2 -c numOfM
node
s -v 1
system sh/cfg.sh -n dnode3 -c numOfM
Peer
s -v 1
system sh/cfg.sh -n dnode3 -c numOfM
node
s -v 1
system sh/cfg.sh -n dnode4 -c numOfM
Peer
s -v 1
system sh/cfg.sh -n dnode4 -c numOfM
node
s -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -39,11 +39,6 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
...
@@ -39,11 +39,6 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
system sh/cfg.sh -n dnode3 -c alternativeRole -v 2
system sh/cfg.sh -n dnode3 -c alternativeRole -v 2
system sh/cfg.sh -n dnode4 -c alternativeRole -v 2
system sh/cfg.sh -n dnode4 -c alternativeRole -v 2
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
...
@@ -64,16 +59,16 @@ sql connect
...
@@ -64,16 +59,16 @@ sql connect
print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data
print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
#
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode3 -s start
sql create dnode $hostname2
sql create dnode $hostname2
#
sql create dnode $hostname3
sql create dnode $hostname3
sleep 3000
sleep 3000
$totalTableNum = 1
$totalTableNum = 1
$sleepTimer = 3000
$sleepTimer = 3000
$db = db
$db = db
sql create database $db replica
1
cache 1
sql create database $db replica
2
cache 1
sql use $db
sql use $db
# create table , insert data
# create table , insert data
...
@@ -82,7 +77,7 @@ sql create table $stb (ts timestamp, c1 double) tags(t1 int)
...
@@ -82,7 +77,7 @@ sql create table $stb (ts timestamp, c1 double) tags(t1 int)
$rowNum = 130000
$rowNum = 130000
$tblNum = $totalTableNum
$tblNum = $totalTableNum
$totalRows = 0
$totalRows = 0
#$tsStart = 1420041600
000
$tsStart = 1577808000000 # 2020-01-01 00:00:00.
000
# insert over 2M data in order to falling disc, generate one file
# insert over 2M data in order to falling disc, generate one file
$i = 0
$i = 0
...
@@ -102,19 +97,24 @@ while $i < $tblNum
...
@@ -102,19 +97,24 @@ while $i < $tblNum
endw
endw
sql select count(*) from $stb
sql select count(*) from $stb
sleep 1000
print rows:$rows data00:$data00
print data00 $data00
if $rows != 1 then
if $data00 != $totalRows then
return -1
endi
if $data00 == 0 then
return -1
return -1
endi
endi
$totalRows = $data00
print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc
print ============== step3: insert old data(now-15d) and new data(now+15d), control data rows in order to save in cache, not falling disc
sql insert into $tb values ( now -
15d , -15
)
sql insert into $tb values ( now -
20d , -20
)
sql insert into $tb values ( now
+ 15d , 15
)
sql insert into $tb values ( now
- 40d , -40
)
$totalRows = $totalRows + 2
$totalRows = $totalRows + 2
print ============== step4: stop dnode2, so date rows falling disc, generate two new files in dnode2
print ============== step4: stop dnode2, so date rows falling disc, generate two new files in dnode2
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode2 -s stop
-x SIGINT
sleep $sleepTimer
sleep $sleepTimer
wait_dnode2_offline:
wait_dnode2_offline:
...
@@ -153,48 +153,14 @@ if $data00 != $totalRows then
...
@@ -153,48 +153,14 @@ if $data00 != $totalRows then
endi
endi
print ============== step5: insert two data rows: now-16d, now+16d,
print ============== step5: insert two data rows: now-16d, now+16d,
sql insert into $tb values ( now -
16d , -16
)
sql insert into $tb values ( now -
21d , -21
)
sql insert into $tb values ( now
+ 16d , 16
)
sql insert into $tb values ( now
- 41d , -41
)
$totalRows = $totalRows + 2
$totalRows = $totalRows + 2
return 1
print ============== step5: restart dnode2, waiting sync end
system sh/exec.sh -n dnode2 -s start
sleep 3000
wait_dnode2_ready:
sql show dnodes
if $rows != 3 then
sleep 2000
goto wait_dnode2_ready
endi
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5
#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6
#$dnode1Status = $data4_1
$dnode2Status = $data4_2
$dnode3Status = $data4_3
#$dnode4Status = $data4_4
#$dnode5Status = $data4_5
if $dnode2Status != ready then
sleep 2000
goto wait_dnode2_ready
endi
sleep $sleepTimer
# check using select
sql select count(*) from $stb
sql select count(*) from $stb
print data00 $data00
print data00 $data00
if $data00 != $totalRows then
if $data00 != $totalRows then
return -1
return -1
endi
endi
print ============== step6: in dnode2, the files 1840 and 1842 will be removed
print ============== step6: please check there should be 3 file in sim/dnode2/data/vnode/vnode2/tsdb/data/, and 1 file sim/dnode3/data/vnode/vnode2/tsdb/data/
# how check in script ???
\ No newline at end of file
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim
0 → 100644
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
浏览文件 @
adb62142
...
@@ -89,11 +89,8 @@ if $data00 != $totalRows then
...
@@ -89,11 +89,8 @@ if $data00 != $totalRows then
return -1
return -1
endi
endi
print ============== step2-1: stop dnode2 for falling disc, then restart dnode2, and check rows
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ============== step2-1: start dnode2 for falling disc, then restart dnode2, and check rows
system sh/exec.sh -n dnode2 -s stop
sleep $sleepTimer
sleep $sleepTimer
wait_dnode2_offline_0:
wait_dnode2_offline_0:
sql show dnodes
sql show dnodes
...
@@ -151,10 +148,6 @@ if $data00 != $totalRows then
...
@@ -151,10 +148,6 @@ if $data00 != $totalRows then
endi
endi
print ============== step3: start dnode3 and add into cluster , then alter replica from 1 to 2, and waiting sync
print ============== step3: start dnode3 and add into cluster , then alter replica from 1 to 2, and waiting sync
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode3 -s start
sql create dnode $hostname3
sql create dnode $hostname3
...
...
tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
0 → 100644
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/insert_duplicationTs.sim
0 → 100644
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
tests/script/unique/arbitrator/replica_changeWithArbitrator.sim
浏览文件 @
adb62142
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录