Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/tsdb_snapshot

This commit is contained in:
Hongze Cheng 2022-07-10 12:25:25 +00:00
commit 3781db867e
99 changed files with 2980 additions and 2148 deletions

View File

@ -155,8 +155,8 @@ typedef struct SQueryTableDataCond {
int32_t numOfCols; int32_t numOfCols;
SColumnInfo* colList; SColumnInfo* colList;
int32_t type; // data block load type: int32_t type; // data block load type:
int32_t numOfTWindows; // int32_t numOfTWindows;
STimeWindow* twindows; STimeWindow twindows;
int64_t startVersion; int64_t startVersion;
int64_t endVersion; int64_t endVersion;
} SQueryTableDataCond; } SQueryTableDataCond;

View File

@ -36,6 +36,7 @@ typedef struct SReadHandle {
void* vnode; void* vnode;
void* mnd; void* mnd;
SMsgCb* pMsgCb; SMsgCb* pMsgCb;
int64_t version;
bool initMetaReader; bool initMetaReader;
bool initTableReader; bool initTableReader;
bool initTqReader; bool initTqReader;
@ -109,7 +110,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
* @param tversion * @param tversion
* @return * @return
*/ */
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion,
int32_t* tversion); int32_t* tversion);
/** /**

View File

@ -250,6 +250,7 @@ typedef struct SSelectStmt {
SLimitNode* pSlimit; SLimitNode* pSlimit;
char stmtName[TSDB_TABLE_NAME_LEN]; char stmtName[TSDB_TABLE_NAME_LEN];
uint8_t precision; uint8_t precision;
int32_t selectFuncNum;
bool isEmptyResult; bool isEmptyResult;
bool isTimeLineResult; bool isTimeLineResult;
bool hasAggFuncs; bool hasAggFuncs;
@ -257,6 +258,7 @@ typedef struct SSelectStmt {
bool hasIndefiniteRowsFunc; bool hasIndefiniteRowsFunc;
bool hasSelectFunc; bool hasSelectFunc;
bool hasSelectValFunc; bool hasSelectValFunc;
bool hasOtherVectorFunc;
bool hasUniqueFunc; bool hasUniqueFunc;
bool hasTailFunc; bool hasTailFunc;
bool hasInterpFunc; bool hasInterpFunc;

View File

@ -25,7 +25,7 @@ extern "C" {
typedef struct SFilterInfo SFilterInfo; typedef struct SFilterInfo SFilterInfo;
int32_t scalarGetOperatorResultType(SDataType left, SDataType right, EOperatorType op, SDataType* pRes); int32_t scalarGetOperatorResultType(SOperatorNode* pOp);
/* /*
pNode will be freed in API; pNode will be freed in API;
@ -42,7 +42,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type);
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type); int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
int32_t vectorGetConvertType(int32_t type1, int32_t type2); int32_t vectorGetConvertType(int32_t type1, int32_t type2);
int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut); int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* overflow);
/* Math functions */ /* Math functions */
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);

View File

@ -584,6 +584,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D) #define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E) #define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E)
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F) #define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x265C)
//planner //planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) #define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)

View File

@ -222,8 +222,8 @@ typedef struct SRequestObj {
SArray* tableList; SArray* tableList;
SQueryExecMetric metric; SQueryExecMetric metric;
SRequestSendRecvBody body; SRequestSendRecvBody body;
bool stableQuery; bool stableQuery; // todo refactor
bool validateOnly; bool validateOnly; // todo refactor
bool killed; bool killed;
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
@ -247,9 +247,9 @@ void doFreeReqResultInfo(SReqResultInfo* pResInfo);
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq); int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq);
void syncCatalogFn(SMetaData* pResult, void* param, int32_t code); void syncCatalogFn(SMetaData* pResult, void* param, int32_t code);
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly); SRequestObj* execQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly);
TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly); TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly);
void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly); void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly);
static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) { static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
SMqRspObj* msg = (SMqRspObj*)res; SMqRspObj* msg = (SMqRspObj*)res;
@ -297,7 +297,7 @@ int32_t releaseTscObj(int64_t rid);
uint64_t generateRequestId(); uint64_t generateRequestId();
void* createRequest(STscObj* pObj, int32_t type); void* createRequest(uint64_t connId, int32_t type);
void destroyRequest(SRequestObj* pRequest); void destroyRequest(SRequestObj* pRequest);
SRequestObj* acquireRequest(int64_t rid); SRequestObj* acquireRequest(int64_t rid);
int32_t releaseRequest(int64_t rid); int32_t releaseRequest(int64_t rid);
@ -318,13 +318,13 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
uint16_t port, int connType); uint16_t port, int connType);
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly); SRequestObj* launchQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly);
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb); int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList); int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList);
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, bool validateSql, SRequestObj** pRequest);
void taos_close_internal(void* taos); void taos_close_internal(void* taos);

View File

@ -49,13 +49,8 @@ void cleanupTscQhandle() {
// destroy handle // destroy handle
taosCleanUpScheduler(tscQhandle); taosCleanUpScheduler(tscQhandle);
} }
static int32_t registerRequest(SRequestObj *pRequest) {
STscObj *pTscObj = acquireTscObj(pRequest->pTscObj->id);
if (NULL == pTscObj) {
terrno = TSDB_CODE_TSC_DISCONNECTED;
return terrno;
}
static int32_t registerRequest(SRequestObj *pRequest, STscObj* pTscObj) {
// connection has been released already, abort creating request. // connection has been released already, abort creating request.
pRequest->self = taosAddRef(clientReqRefPool, pRequest); pRequest->self = taosAddRef(clientReqRefPool, pRequest);
@ -246,29 +241,34 @@ STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientCon
int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, rid); } int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, rid); }
void *createRequest(STscObj *pObj, int32_t type) { void *createRequest(uint64_t connId, int32_t type) {
assert(pObj != NULL);
SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj)); SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
if (NULL == pRequest) { if (NULL == pRequest) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
return NULL; return NULL;
} }
STscObj* pTscObj = acquireTscObj(connId);
if (pTscObj == NULL) {
terrno = TSDB_CODE_TSC_DISCONNECTED;
return NULL;
}
pRequest->resType = RES_TYPE__QUERY; pRequest->resType = RES_TYPE__QUERY;
pRequest->pDb = getDbOfConnection(pObj);
pRequest->requestId = generateRequestId(); pRequest->requestId = generateRequestId();
pRequest->metric.start = taosGetTimestampUs(); pRequest->metric.start = taosGetTimestampUs();
pRequest->body.resInfo.convertUcs4 = true; // convert ucs4 by default pRequest->body.resInfo.convertUcs4 = true; // convert ucs4 by default
pRequest->type = type; pRequest->type = type;
pRequest->pTscObj = pObj;
pRequest->pDb = getDbOfConnection(pTscObj);
pRequest->pTscObj = pTscObj;
pRequest->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE); pRequest->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
pRequest->msgBufLen = ERROR_MSG_BUF_DEFAULT_SIZE; pRequest->msgBufLen = ERROR_MSG_BUF_DEFAULT_SIZE;
tsem_init(&pRequest->body.rspSem, 0, 0); tsem_init(&pRequest->body.rspSem, 0, 0);
if (registerRequest(pRequest)) { if (registerRequest(pRequest, pTscObj)) {
doDestroyRequest(pRequest); doDestroyRequest(pRequest);
return NULL; return NULL;
} }
@ -327,8 +327,8 @@ void doDestroyRequest(void *p) {
if (pRequest->self) { if (pRequest->self) {
deregisterRequest(pRequest); deregisterRequest(pRequest);
} }
taosMemoryFree(pRequest);
taosMemoryFree(pRequest);
tscTrace("end to destroy request %" PRIx64 " p:%p", reqId, pRequest); tscTrace("end to destroy request %" PRIx64 " p:%p", reqId, pRequest);
} }
@ -338,7 +338,6 @@ void destroyRequest(SRequestObj *pRequest) {
} }
taos_stop_query(pRequest); taos_stop_query(pRequest);
removeRequest(pRequest->self); removeRequest(pRequest->self);
} }

View File

@ -264,14 +264,11 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) { static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
static int32_t emptyRspNum = 0; static int32_t emptyRspNum = 0;
if (code != 0) {
taosMemoryFreeClear(param);
return -1;
}
char *key = (char *)param; char *key = (char *)param;
SClientHbBatchRsp pRsp = {0}; SClientHbBatchRsp pRsp = {0};
if (TSDB_CODE_SUCCESS == code) {
tDeserializeSClientHbBatchRsp(pMsg->pData, pMsg->len, &pRsp); tDeserializeSClientHbBatchRsp(pMsg->pData, pMsg->len, &pRsp);
}
int32_t rspNum = taosArrayGetSize(pRsp.rsps); int32_t rspNum = taosArrayGetSize(pRsp.rsps);
@ -288,6 +285,10 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
taosMemoryFreeClear(param); taosMemoryFreeClear(param);
if (code != 0) {
(*pInst)->onlineDnodes = 0;
}
if (rspNum) { if (rspNum) {
tscDebug("hb got %d rsp, %d empty rsp received before", rspNum, tscDebug("hb got %d rsp, %d empty rsp received before", rspNum,
atomic_val_compare_exchange_32(&emptyRspNum, emptyRspNum, 0)); atomic_val_compare_exchange_32(&emptyRspNum, emptyRspNum, 0));

View File

@ -148,29 +148,49 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst, connType); return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst, connType);
} }
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest) { int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, bool validateSql, SRequestObj** pRequest) {
*pRequest = createRequest(pTscObj, TSDB_SQL_SELECT); *pRequest = createRequest(connId, TSDB_SQL_SELECT);
if (*pRequest == NULL) { if (*pRequest == NULL) {
tscError("failed to malloc sqlObj"); tscError("failed to malloc sqlObj, %s", sql);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
(*pRequest)->sqlstr = taosMemoryMalloc(sqlLen + 1); (*pRequest)->sqlstr = taosMemoryMalloc(sqlLen + 1);
if ((*pRequest)->sqlstr == NULL) { if ((*pRequest)->sqlstr == NULL) {
tscError("0x%" PRIx64 " failed to prepare sql string buffer", (*pRequest)->self); tscError("0x%" PRIx64 " failed to prepare sql string buffer, %s", (*pRequest)->self, sql);
(*pRequest)->msgBuf = strdup("failed to prepare sql string buffer"); destroyRequest(*pRequest);
*pRequest = NULL;
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
strntolower((*pRequest)->sqlstr, sql, (int32_t)sqlLen); strntolower((*pRequest)->sqlstr, sql, (int32_t)sqlLen);
(*pRequest)->sqlstr[sqlLen] = 0; (*pRequest)->sqlstr[sqlLen] = 0;
(*pRequest)->sqlLen = sqlLen; (*pRequest)->sqlLen = sqlLen;
(*pRequest)->validateOnly = validateSql;
if (param == NULL) {
SSyncQueryParam* pParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
if (pParam == NULL) {
destroyRequest(*pRequest);
*pRequest = NULL;
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
tsem_init(&pParam->sem, 0, 0);
pParam->pRequest = (*pRequest);
param = pParam;
}
(*pRequest)->body.param = param;
STscObj* pTscObj = (*pRequest)->pTscObj;
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
sizeof((*pRequest)->self))) {
tscError("%d failed to add to request container, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self,
(*pRequest)->requestId, pTscObj->id, sql);
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
sizeof((*pRequest)->self))) {
destroyRequest(*pRequest); destroyRequest(*pRequest);
*pRequest = NULL; *pRequest = NULL;
tscError("put request to request hash failed");
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
@ -882,18 +902,16 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
return pRequest; return pRequest;
} }
SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly) { SRequestObj* launchQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly) {
SRequestObj* pRequest = NULL; SRequestObj* pRequest = NULL;
SQuery* pQuery = NULL; SQuery* pQuery = NULL;
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); int32_t code = buildRequest(connId, sql, sqlLen, NULL, validateOnly, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
terrno = code; terrno = code;
return NULL; return NULL;
} }
pRequest->validateOnly = validateOnly;
code = parseSql(pRequest, false, &pQuery, NULL); code = parseSql(pRequest, false, &pQuery, NULL);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
pRequest->code = code; pRequest->code = code;
@ -1044,19 +1062,20 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool validateOnly) { // todo remove it soon
SRequestObj* execQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly) {
SRequestObj* pRequest = NULL; SRequestObj* pRequest = NULL;
int32_t retryNum = 0; int32_t retryNum = 0;
int32_t code = 0; int32_t code = 0;
do { do {
destroyRequest(pRequest); destroyRequest(pRequest);
pRequest = launchQuery(pTscObj, sql, sqlLen, validateOnly); pRequest = launchQuery(connId, sql, sqlLen, validateOnly);
if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) { if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) {
break; break;
} }
code = refreshMeta(pTscObj, pRequest); code = refreshMeta(pRequest->pTscObj, pRequest);
if (code) { if (code) {
pRequest->code = code; pRequest->code = code;
break; break;
@ -1064,7 +1083,7 @@ SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen, bool valid
} while (retryNum++ < REQUEST_TOTAL_EXEC_TIMES); } while (retryNum++ < REQUEST_TOTAL_EXEC_TIMES);
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) { if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) {
removeMeta(pTscObj, pRequest->tableList); removeMeta(pRequest->pTscObj, pRequest->tableList);
} }
return pRequest; return pRequest;
@ -1119,7 +1138,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
return pTscObj; return pTscObj;
} }
SRequestObj* pRequest = createRequest(pTscObj, TDMT_MND_CONNECT); SRequestObj* pRequest = createRequest(pTscObj->id, TDMT_MND_CONNECT);
if (pRequest == NULL) { if (pRequest == NULL) {
destroyTscObj(pTscObj); destroyTscObj(pTscObj);
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
@ -1446,15 +1465,10 @@ void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertU
return NULL; return NULL;
} }
SSyncQueryParam* pParam = pRequest->body.param;
if (NULL == pParam) {
pParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
tsem_init(&pParam->sem, 0, 0);
}
// convert ucs4 to native multi-bytes string // convert ucs4 to native multi-bytes string
pResultInfo->convertUcs4 = convertUcs4; pResultInfo->convertUcs4 = convertUcs4;
SSyncQueryParam* pParam = pRequest->body.param;
taos_fetch_rows_a(pRequest, syncFetchFn, pParam); taos_fetch_rows_a(pRequest, syncFetchFn, pParam);
tsem_wait(&pParam->sem); tsem_wait(&pParam->sem);
} }
@ -2026,22 +2040,9 @@ void syncQueryFn(void* param, void* res, int32_t code) {
tsem_post(&pParam->sem); tsem_post(&pParam->sem);
} }
void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) { void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) {
if (NULL == taos) { if (sql == NULL || NULL == fp) {
terrno = TSDB_CODE_TSC_DISCONNECTED;
fp(param, NULL, terrno);
return;
}
int64_t rid = *(int64_t*)taos;
STscObj* pTscObj = acquireTscObj(rid);
if (pTscObj == NULL || sql == NULL || NULL == fp) {
terrno = TSDB_CODE_INVALID_PARA; terrno = TSDB_CODE_INVALID_PARA;
if (pTscObj) {
releaseTscObj(rid);
} else {
terrno = TSDB_CODE_TSC_DISCONNECTED;
}
fp(param, NULL, terrno); fp(param, NULL, terrno);
return; return;
} }
@ -2050,26 +2051,20 @@ void taosAsyncQueryImpl(TAOS* taos, const char* sql, __taos_async_fn_t fp, void*
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
releaseTscObj(rid);
fp(param, NULL, terrno); fp(param, NULL, terrno);
return; return;
} }
SRequestObj* pRequest = NULL; SRequestObj* pRequest = NULL;
int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); int32_t code = buildRequest(connId, sql, sqlLen, param, validateOnly, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
terrno = code; terrno = code;
releaseTscObj(rid);
fp(param, NULL, terrno); fp(param, NULL, terrno);
return; return;
} }
pRequest->validateOnly = validateOnly;
pRequest->body.queryFp = fp; pRequest->body.queryFp = fp;
pRequest->body.param = param;
doAsyncQuery(pRequest, false); doAsyncQuery(pRequest, false);
releaseTscObj(rid);
} }
TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
@ -2078,36 +2073,22 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
return NULL; return NULL;
} }
int64_t rid = *(int64_t*)taos;
STscObj* pTscObj = acquireTscObj(rid);
if (pTscObj == NULL || sql == NULL) {
terrno = TSDB_CODE_TSC_DISCONNECTED;
return NULL;
}
#if SYNC_ON_TOP_OF_ASYNC #if SYNC_ON_TOP_OF_ASYNC
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
tsem_init(&param->sem, 0, 0); tsem_init(&param->sem, 0, 0);
taosAsyncQueryImpl((TAOS*)&rid, sql, syncQueryFn, param, validateOnly); taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly);
tsem_wait(&param->sem); tsem_wait(&param->sem);
releaseTscObj(rid);
return param->pRequest; return param->pRequest;
#else #else
size_t sqlLen = strlen(sql); size_t sqlLen = strlen(sql);
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
releaseTscObj(rid);
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
return NULL; return NULL;
} }
TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen, validateOnly); TAOS_RES* pRes = execQuery(connId, sql, sqlLen, validateOnly);
releaseTscObj(rid);
return pRes; return pRes;
#endif #endif
} }

View File

@ -479,7 +479,6 @@ void taos_stop_query(TAOS_RES *res) {
} }
schedulerFreeJob(&pRequest->body.queryJob, TSDB_CODE_TSC_QUERY_KILLED); schedulerFreeJob(&pRequest->body.queryJob, TSDB_CODE_TSC_QUERY_KILLED);
tscDebug("request %" PRIx64 " killed", pRequest->requestId); tscDebug("request %" PRIx64 " killed", pRequest->requestId);
} }
@ -706,7 +705,8 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
} }
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) { void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
taosAsyncQueryImpl(taos, sql, fp, param, false); int64_t connId = *(int64_t*)taos;
taosAsyncQueryImpl(connId, sql, fp, param, false);
} }
int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) {
@ -915,7 +915,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
return terrno; return terrno;
} }
int64_t rid = *(int64_t *)taos; int64_t connId = *(int64_t *)taos;
const int32_t MAX_TABLE_NAME_LENGTH = 12 * 1024 * 1024; // 12MB list const int32_t MAX_TABLE_NAME_LENGTH = 12 * 1024 * 1024; // 12MB list
int32_t code = 0; int32_t code = 0;
SRequestObj * pRequest = NULL; SRequestObj * pRequest = NULL;
@ -933,12 +933,14 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
} }
STscObj *pTscObj = acquireTscObj(rid); char *sql = "taos_load_table_info";
if (pTscObj == NULL) { code = buildRequest(connId, sql, strlen(sql), NULL, false, &pRequest);
terrno = TSDB_CODE_TSC_DISCONNECTED; if (code != TSDB_CODE_SUCCESS) {
return terrno; terrno = code;
goto _return;
} }
STscObj* pTscObj = pRequest->pTscObj;
code = transferTableNameList(tableNameList, pTscObj->acctId, pTscObj->db, &catalogReq.pTableMeta); code = transferTableNameList(tableNameList, pTscObj->acctId, pTscObj->db, &catalogReq.pTableMeta);
if (code) { if (code) {
goto _return; goto _return;
@ -950,36 +952,22 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
goto _return; goto _return;
} }
char *sql = "taos_load_table_info";
code = buildRequest(pTscObj, sql, strlen(sql), &pRequest);
if (code != TSDB_CODE_SUCCESS) {
terrno = code;
goto _return;
}
SSyncQueryParam param = {0};
tsem_init(&param.sem, 0, 0);
param.pRequest = pRequest;
SRequestConnInfo conn = { SRequestConnInfo conn = {
.pTrans = pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self}; .pTrans = pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self};
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, &param, NULL); code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, NULL, NULL);
if (code) { if (code) {
goto _return; goto _return;
} }
tsem_wait(&param.sem); SSyncQueryParam* pParam = pRequest->body.param;
tsem_wait(&pParam->sem);
_return: _return:
taosArrayDestroy(catalogReq.pTableMeta); taosArrayDestroy(catalogReq.pTableMeta);
destroyRequest(pRequest); destroyRequest(pRequest);
releaseTscObj(rid);
return code; return code;
} }

View File

@ -2442,22 +2442,15 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
return NULL; return NULL;
} }
int64_t rid = *(int64_t*)taos; SRequestObj* request = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT);
STscObj* pTscObj = acquireTscObj(rid);
if (NULL == pTscObj) {
terrno = TSDB_CODE_TSC_DISCONNECTED;
uError("SML:taos_schemaless_insert invalid taos");
return NULL;
}
SRequestObj* request = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT);
if(!request){ if(!request){
releaseTscObj(rid);
uError("SML:taos_schemaless_insert error request is null"); uError("SML:taos_schemaless_insert error request is null");
return NULL; return NULL;
} }
int batchs = 0; int batchs = 0;
STscObj* pTscObj = request->pTscObj;
pTscObj->schemalessType = 1; pTscObj->schemalessType = 1;
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf}; SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
@ -2507,7 +2500,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
batchs = ceil(((double)numLines) / LINE_BATCH); batchs = ceil(((double)numLines) / LINE_BATCH);
for (int i = 0; i < batchs; ++i) { for (int i = 0; i < batchs; ++i) {
SRequestObj* req = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT); SRequestObj* req = (SRequestObj*)createRequest(pTscObj->id, TSDB_SQL_INSERT);
if(!req){ if(!req){
request->code = TSDB_CODE_OUT_OF_MEMORY; request->code = TSDB_CODE_OUT_OF_MEMORY;
uError("SML:taos_schemaless_insert error request is null"); uError("SML:taos_schemaless_insert error request is null");
@ -2549,6 +2542,5 @@ end:
// ((STscObj *)taos)->schemalessType = 0; // ((STscObj *)taos)->schemalessType = 0;
pTscObj->schemalessType = 1; pTscObj->schemalessType = 1;
uDebug("resultend:%s", request->msgBuf); uDebug("resultend:%s", request->msgBuf);
releaseTscObj(rid);
return (TAOS_RES*)request; return (TAOS_RES*)request;
} }

View File

@ -5,6 +5,14 @@
#include "clientStmt.h" #include "clientStmt.h"
static int32_t stmtCreateRequest(STscStmt* pStmt) {
if (pStmt->exec.pRequest == NULL) {
return buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false, &pStmt->exec.pRequest);
} else {
return TSDB_CODE_SUCCESS;
}
}
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) { int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
int32_t code = 0; int32_t code = 0;
@ -217,9 +225,7 @@ int32_t stmtParseSql(STscStmt* pStmt) {
.getExecInfoFn = stmtGetExecInfo, .getExecInfoFn = stmtGetExecInfo,
}; };
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
STMT_ERR_RET(parseSql(pStmt->exec.pRequest, false, &pStmt->sql.pQuery, &stmtCb)); STMT_ERR_RET(parseSql(pStmt->exec.pRequest, false, &pStmt->sql.pQuery, &stmtCb));
@ -532,9 +538,7 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR); STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
} }
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb, STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb,
pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen)); pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
@ -625,9 +629,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
pStmt->exec.pRequest = NULL; pStmt->exec.pRequest = NULL;
} }
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
if (pStmt->bInfo.needParse) { if (pStmt->bInfo.needParse) {
STMT_ERR_RET(stmtParseSql(pStmt)); STMT_ERR_RET(stmtParseSql(pStmt));
@ -873,9 +875,7 @@ int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
pStmt->exec.pRequest = NULL; pStmt->exec.pRequest = NULL;
} }
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
if (pStmt->bInfo.needParse) { if (pStmt->bInfo.needParse) {
STMT_ERR_RET(stmtParseSql(pStmt)); STMT_ERR_RET(stmtParseSql(pStmt));
@ -905,9 +905,7 @@ int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
pStmt->exec.pRequest = NULL; pStmt->exec.pRequest = NULL;
} }
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
if (pStmt->bInfo.needParse) { if (pStmt->bInfo.needParse) {
STMT_ERR_RET(stmtParseSql(pStmt)); STMT_ERR_RET(stmtParseSql(pStmt));
@ -933,10 +931,7 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
pStmt->exec.pRequest = NULL; pStmt->exec.pRequest = NULL;
} }
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
if (pStmt->bInfo.needParse) { if (pStmt->bInfo.needParse) {
STMT_ERR_RET(stmtParseSql(pStmt)); STMT_ERR_RET(stmtParseSql(pStmt));
} }
@ -969,9 +964,7 @@ int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
pStmt->exec.pRequest = NULL; pStmt->exec.pRequest = NULL;
} }
if (NULL == pStmt->exec.pRequest) { STMT_ERR_RET(stmtCreateRequest(pStmt));
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
}
if (pStmt->bInfo.needParse) { if (pStmt->bInfo.needParse) {
STMT_ERR_RET(stmtParseSql(pStmt)); STMT_ERR_RET(stmtParseSql(pStmt));

View File

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "cJSON.h"
#include "clientInt.h" #include "clientInt.h"
#include "clientLog.h" #include "clientLog.h"
#include "parser.h" #include "parser.h"
@ -23,7 +24,6 @@
#include "tqueue.h" #include "tqueue.h"
#include "tref.h" #include "tref.h"
#include "ttimer.h" #include "ttimer.h"
#include "cJSON.h"
int32_t tmqAskEp(tmq_t* tmq, bool async); int32_t tmqAskEp(tmq_t* tmq, bool async);
@ -953,6 +953,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
goto FAIL; goto FAIL;
} }
tscInfo("consumer %ld is setup, consumer group %s", pTmq->consumerId, pTmq->groupId);
return pTmq; return pTmq;
FAIL: FAIL:
@ -1194,10 +1196,10 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
for (int32_t j = 0; j < vgNumCur; j++) { for (int32_t j = 0; j < vgNumCur; j++) {
SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j); SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j);
sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId); sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId);
char buf[50]; char buf[80];
tFormatOffset(buf, 50, &pVgCur->currentOffsetNew); tFormatOffset(buf, 80, &pVgCur->currentOffsetNew);
tscDebug("consumer:%" PRId64 ", epoch %d vgId:%d vgKey is %s, offset is %s", tmq->consumerId, epoch, pVgCur->vgId, tscDebug("consumer:%" PRId64 ", epoch %d vgId:%d vgKey is %s, offset is %s", tmq->consumerId, epoch,
vgKey, buf); pVgCur->vgId, vgKey, buf);
taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffsetNew, sizeof(STqOffsetVal)); taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffsetNew, sizeof(STqOffsetVal));
} }
} }
@ -1564,7 +1566,8 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT); int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT);
if (vgStatus != TMQ_VG_STATUS__IDLE) { if (vgStatus != TMQ_VG_STATUS__IDLE) {
int32_t vgSkipCnt = atomic_add_fetch_32(&pVg->vgSkipCnt, 1); int32_t vgSkipCnt = atomic_add_fetch_32(&pVg->vgSkipCnt, 1);
tscTrace("consumer:%" PRId64 ", epoch %d skip vgId:%d skip cnt %d", tmq->consumerId, tmq->epoch, pVg->vgId, vgSkipCnt); tscTrace("consumer:%" PRId64 ", epoch %d skip vgId:%d skip cnt %d", tmq->consumerId, tmq->epoch, pVg->vgId,
vgSkipCnt);
continue; continue;
/*if (vgSkipCnt < 10000) continue;*/ /*if (vgSkipCnt < 10000) continue;*/
#if 0 #if 0
@ -1620,8 +1623,8 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
char offsetFormatBuf[80]; char offsetFormatBuf[80];
tFormatOffset(offsetFormatBuf, 80, &pVg->currentOffsetNew); tFormatOffset(offsetFormatBuf, 80, &pVg->currentOffsetNew);
tscDebug("consumer:%" PRId64 ", send poll to %s vgId:%d, epoch %d, req offset:%s, reqId:%" PRIu64, tmq->consumerId, tscDebug("consumer:%" PRId64 ", send poll to %s vgId:%d, epoch %d, req offset:%s, reqId:%" PRIu64,
pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId); tmq->consumerId, pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId);
/*printf("send vgId:%d %" PRId64 "\n", pVg->vgId, pVg->currentOffset);*/ /*printf("send vgId:%d %" PRId64 "\n", pVg->vgId, pVg->currentOffset);*/
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
pVg->pollCnt++; pVg->pollCnt++;
@ -1669,7 +1672,8 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
int32_t consumerEpoch = atomic_load_32(&tmq->epoch); int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) {
SMqClientVg* pVg = pollRspWrapper->vgHandle; SMqClientVg* pVg = pollRspWrapper->vgHandle;
/*printf("vgId:%d offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ /*printf("vgId:%d offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset,
* rspMsg->msg.rspOffset);*/
pVg->currentOffsetNew = pollRspWrapper->dataRsp.rspOffset; pVg->currentOffsetNew = pollRspWrapper->dataRsp.rspOffset;
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
if (pollRspWrapper->dataRsp.blockNum == 0) { if (pollRspWrapper->dataRsp.blockNum == 0) {
@ -1691,7 +1695,8 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
int32_t consumerEpoch = atomic_load_32(&tmq->epoch); int32_t consumerEpoch = atomic_load_32(&tmq->epoch);
if (pollRspWrapper->metaRsp.head.epoch == consumerEpoch) { if (pollRspWrapper->metaRsp.head.epoch == consumerEpoch) {
SMqClientVg* pVg = pollRspWrapper->vgHandle; SMqClientVg* pVg = pollRspWrapper->vgHandle;
/*printf("vgId:%d offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ /*printf("vgId:%d offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset,
* rspMsg->msg.rspOffset);*/
pVg->currentOffsetNew.version = pollRspWrapper->metaRsp.rspOffset; pVg->currentOffsetNew.version = pollRspWrapper->metaRsp.rspOffset;
pVg->currentOffsetNew.type = TMQ_OFFSET__LOG; pVg->currentOffsetNew.type = TMQ_OFFSET__LOG;
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
@ -1860,7 +1865,8 @@ tmq_raw_data *tmq_get_raw_meta(TAOS_RES* res) {
return NULL; return NULL;
} }
static char *buildCreateTableJson(SSchemaWrapper *schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t){ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id,
int8_t t) {
char* string = NULL; char* string = NULL;
cJSON* json = cJSON_CreateObject(); cJSON* json = cJSON_CreateObject();
if (json == NULL) { if (json == NULL) {
@ -2049,9 +2055,11 @@ static char *processCreateTable(SMqMetaRsp *metaRsp){
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
pCreateReq = req.pReqs + iReq; pCreateReq = req.pReqs + iReq;
if (pCreateReq->type == TSDB_CHILD_TABLE) { if (pCreateReq->type == TSDB_CHILD_TABLE) {
string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.suid, pCreateReq->name, pCreateReq->uid); string =
buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.suid, pCreateReq->name, pCreateReq->uid);
} else if (pCreateReq->type == TSDB_NORMAL_TABLE) { } else if (pCreateReq->type == TSDB_NORMAL_TABLE) {
string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); string =
buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE);
} }
} }
@ -2267,13 +2275,7 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
SRequestObj* pRequest = NULL; SRequestObj* pRequest = NULL;
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest);
if (NULL == pTscObj) {
code = TSDB_CODE_TSC_DISCONNECTED;
goto end;
}
code = buildRequest(pTscObj, "", 0, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto end; goto end;
} }
@ -2313,6 +2315,8 @@ static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){
pReq.suid = req.suid; pReq.suid = req.suid;
pReq.source = 1; pReq.source = 1;
STscObj* pTscObj = pRequest->pTscObj;
SName tableName; SName tableName;
tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name);
@ -2351,13 +2355,7 @@ static int32_t taosDropStb(TAOS *taos, void *meta, int32_t metaLen){
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
SRequestObj* pRequest = NULL; SRequestObj* pRequest = NULL;
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest);
if (NULL == pTscObj) {
code = TSDB_CODE_TSC_DISCONNECTED;
goto end;
}
code = buildRequest(pTscObj, "", 0, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto end; goto end;
} }
@ -2379,6 +2377,9 @@ static int32_t taosDropStb(TAOS *taos, void *meta, int32_t metaLen){
pReq.igNotExists = true; pReq.igNotExists = true;
pReq.source = 1; pReq.source = 1;
pReq.suid = req.suid; pReq.suid = req.suid;
STscObj* pTscObj = pRequest->pTscObj;
SName tableName; SName tableName;
tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name);
@ -2427,14 +2428,8 @@ static int32_t taosCreateTable(TAOS *taos, void *meta, int32_t metaLen){
SRequestObj *pRequest = NULL; SRequestObj *pRequest = NULL;
SQuery *pQuery = NULL; SQuery *pQuery = NULL;
SHashObj *pVgroupHashmap = NULL; SHashObj *pVgroupHashmap = NULL;
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
if (NULL == pTscObj) { code = buildRequest(*(int64_t*) taos, "", 0, NULL, false, &pRequest);
code = TSDB_CODE_TSC_DISCONNECTED;
goto end;
}
code = buildRequest(pTscObj, "", 0, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto end; goto end;
} }
@ -2452,6 +2447,8 @@ static int32_t taosCreateTable(TAOS *taos, void *meta, int32_t metaLen){
goto end; goto end;
} }
STscObj* pTscObj = pRequest->pTscObj;
SVCreateTbReq *pCreateReq = NULL; SVCreateTbReq *pCreateReq = NULL;
SCatalog* pCatalog = NULL; SCatalog* pCatalog = NULL;
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
@ -2544,14 +2541,8 @@ static int32_t taosDropTable(TAOS *taos, void *meta, int32_t metaLen){
SRequestObj *pRequest = NULL; SRequestObj *pRequest = NULL;
SQuery *pQuery = NULL; SQuery *pQuery = NULL;
SHashObj *pVgroupHashmap = NULL; SHashObj *pVgroupHashmap = NULL;
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
if (NULL == pTscObj) { code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest);
code = TSDB_CODE_TSC_DISCONNECTED;
goto end;
}
code = buildRequest(pTscObj, "", 0, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto end; goto end;
} }
@ -2569,6 +2560,8 @@ static int32_t taosDropTable(TAOS *taos, void *meta, int32_t metaLen){
goto end; goto end;
} }
STscObj* pTscObj = pRequest->pTscObj;
SVDropTbReq *pDropReq = NULL; SVDropTbReq *pDropReq = NULL;
SCatalog *pCatalog = NULL; SCatalog *pCatalog = NULL;
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
@ -2649,14 +2642,9 @@ static int32_t taosAlterTable(TAOS *taos, void *meta, int32_t metaLen){
SQuery *pQuery = NULL; SQuery *pQuery = NULL;
SArray *pArray = NULL; SArray *pArray = NULL;
SVgDataBlocks *pVgData = NULL; SVgDataBlocks *pVgData = NULL;
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
if (NULL == pTscObj) {
code = TSDB_CODE_TSC_DISCONNECTED;
goto end;
}
code = buildRequest(pTscObj, "", 0, &pRequest); code = buildRequest(*(int64_t*) taos, "", 0, NULL, false, &pRequest);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto end; goto end;
} }
@ -2679,6 +2667,7 @@ static int32_t taosAlterTable(TAOS *taos, void *meta, int32_t metaLen){
goto end; goto end;
} }
STscObj* pTscObj = pRequest->pTscObj;
SCatalog* pCatalog = NULL; SCatalog* pCatalog = NULL;
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {

View File

@ -252,7 +252,7 @@ static const SSysTableMeta infosMeta[] = {
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)}, {TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)}, {TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
{TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)}, {TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)},
{TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)}, // {TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
{TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)}, {TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)},
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)}, {TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)},
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)}, {TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},

View File

@ -1746,7 +1746,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
for (int32_t k = 0; k < colNum; k++) { for (int32_t k = 0; k < colNum; k++) {
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k); SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
if (colDataIsNull(pColInfoData, rows, j, NULL)) { if (colDataIsNull(pColInfoData, rows, j, NULL) || !var) {
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL"); len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
if (len >= size -1) return dumpBuf; if (len >= size -1) return dumpBuf;
continue; continue;

View File

@ -292,15 +292,14 @@ int32_t taosAddClientLogCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "numOfLogLines", tsNumOfLogLines, 1000, 2000000000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "numOfLogLines", tsNumOfLogLines, 1000, 2000000000, 1) != 0) return -1;
if (cfgAddBool(pCfg, "asyncLog", tsAsyncLog, 1) != 0) return -1; if (cfgAddBool(pCfg, "asyncLog", tsAsyncLog, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "qDebugFlag", qDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "qDebugFlag", qDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255, 1) != 0) return -1; if (cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1) != 0) return -1;
if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 1) != 0) return -1;
return 0; return 0;
} }
@ -308,7 +307,6 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "vDebugFlag", vDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "vDebugFlag", vDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "mDebugFlag", mDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "mDebugFlag", mDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "qDebugFlag", qDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "wDebugFlag", wDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "wDebugFlag", wDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "sDebugFlag", sDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, 0) != 0) return -1;
@ -418,7 +416,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, 0) != 0) return -1; if (cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, 0) != 0) return -1;
tsNumOfVnodeQueryThreads = tsNumOfCores / 2; tsNumOfVnodeQueryThreads = tsNumOfCores / 2;
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 1); tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 2);
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, 0) != 0) return -1; if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, 0) != 0) return -1;
tsNumOfVnodeFetchThreads = TRANGE(tsNumOfVnodeFetchThreads, 1, 1); tsNumOfVnodeFetchThreads = TRANGE(tsNumOfVnodeFetchThreads, 1, 1);
@ -485,20 +483,18 @@ static void taosSetClientLogCfg(SConfig *pCfg) {
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32; tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval; tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32; tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32; tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32; jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
} }
static void taosSetServerLogCfg(SConfig *pCfg) { static void taosSetServerLogCfg(SConfig *pCfg) {
dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32; dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32;
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32; vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32; mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32;
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32; wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32;
sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32; sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32;
tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32; tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32;

View File

@ -1131,14 +1131,17 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
SSmaObj *pSma = NULL; SSmaObj *pSma = NULL;
int32_t cols = 0; int32_t cols = 0;
SDbObj *pDb = mndAcquireDb(pMnode, pShow->db); SDbObj *pDb = NULL;
if (strlen(pShow->db) > 0) {
pDb = mndAcquireDb(pMnode, pShow->db);
if (pDb == NULL) return 0; if (pDb == NULL) return 0;
}
while (numOfRows < rows) { while (numOfRows < rows) {
pShow->pIter = sdbFetch(pSdb, SDB_SMA, pShow->pIter, (void **)&pSma); pShow->pIter = sdbFetch(pSdb, SDB_SMA, pShow->pIter, (void **)&pSma);
if (pShow->pIter == NULL) break; if (pShow->pIter == NULL) break;
if (pSma->dbUid != pDb->uid) { if (NULL != pDb && pSma->dbUid != pDb->uid) {
sdbRelease(pSdb, pSma); sdbRelease(pSdb, pSma);
continue; continue;
} }
@ -1151,7 +1154,7 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
STR_TO_VARSTR(n1, (char *)tNameGetTableName(&smaName)); STR_TO_VARSTR(n1, (char *)tNameGetTableName(&smaName));
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
STR_TO_VARSTR(n2, (char *)mndGetDbStr(pDb->name)); STR_TO_VARSTR(n2, (char *)mndGetDbStr(pSma->db));
SName stbName = {0}; SName stbName = {0};
tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);

View File

@ -45,6 +45,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
static int32_t mndProcessTableCfgReq(SRpcMsg *pReq); static int32_t mndProcessTableCfgReq(SRpcMsg *pReq);
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp);
int32_t mndInitStb(SMnode *pMnode) { int32_t mndInitStb(SMnode *pMnode) {
SSdbTable table = { SSdbTable table = {
@ -854,6 +855,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
SStbObj *pStb = NULL; SStbObj *pStb = NULL;
SDbObj *pDb = NULL; SDbObj *pDb = NULL;
SMCreateStbReq createReq = {0}; SMCreateStbReq createReq = {0};
bool isAlter = false;
if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) { if (tDeserializeSMCreateStbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
terrno = TSDB_CODE_INVALID_MSG; terrno = TSDB_CODE_INVALID_MSG;
@ -889,6 +891,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
code = 0; code = 0;
goto _OVER; goto _OVER;
} else if ((tagDelta == 1 || colDelta == 1) && (verDelta == 1)) { } else if ((tagDelta == 1 || colDelta == 1) && (verDelta == 1)) {
isAlter = true;
mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name); mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name);
} else { } else {
mError("stb:%s, schema version increase more than 1 number, error is returned", createReq.name); mError("stb:%s, schema version increase more than 1 number, error is returned", createReq.name);
@ -929,7 +932,12 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
goto _OVER; goto _OVER;
} }
if (isAlter) {
bool needRsp = false;
code = mndAlterStbImp(pMnode, pReq, pDb, pStb, needRsp);
} else {
code = mndCreateStb(pMnode, pReq, &createReq, pDb); code = mndCreateStb(pMnode, pReq, &createReq, pDb);
}
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
_OVER: _OVER:
@ -1495,14 +1503,13 @@ static int32_t mndBuildStbCfg(SMnode *pMnode, const char *dbFName, const char *t
return code; return code;
} }
static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, SStbObj *pObj, void **pCont, static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, int32_t *pLen) {
int32_t *pLen) {
int32_t ret; int32_t ret;
SEncoder ec = {0}; SEncoder ec = {0};
uint32_t contLen = 0; uint32_t contLen = 0;
SMAlterStbRsp alterRsp = {0}; SMAlterStbRsp alterRsp = {0};
SName name = {0}; SName name = {0};
tNameFromString(&name, pAlter->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); tNameFromString(&name, pObj->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
alterRsp.pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp)); alterRsp.pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp));
if (NULL == alterRsp.pMeta) { if (NULL == alterRsp.pMeta) {
@ -1535,10 +1542,36 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, S
return 0; return 0;
} }
static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp) {
int32_t code = -1;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
if (pTrans == NULL) goto _OVER;
mDebug("trans:%d, used to alter stb:%s", pTrans->id, pStb->name);
mndTransSetDbName(pTrans, pDb->name, NULL);
if (needRsp) {
void *pCont = NULL;
int32_t contLen = 0;
if (mndBuildSMAlterStbRsp(pDb, pStb, &pCont, &contLen) != 0) goto _OVER;
mndTransSetRpcRsp(pTrans, pCont, contLen);
}
if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
code = 0;
_OVER:
mndTransDrop(pTrans);
return code;
}
static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *pAlter, SDbObj *pDb, SStbObj *pOld) { static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *pAlter, SDbObj *pDb, SStbObj *pOld) {
bool needRsp = true; bool needRsp = true;
int32_t code = -1; int32_t code = -1;
STrans *pTrans = NULL;
SField *pField0 = NULL; SField *pField0 = NULL;
SStbObj stbObj = {0}; SStbObj stbObj = {0};
@ -1587,30 +1620,9 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
} }
if (code != 0) goto _OVER; if (code != 0) goto _OVER;
code = mndAlterStbImp(pMnode, pReq, pDb, &stbObj, needRsp);
code = -1;
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq);
if (pTrans == NULL) goto _OVER;
mDebug("trans:%d, used to alter stb:%s", pTrans->id, pAlter->name);
mndTransSetDbName(pTrans, pDb->name, NULL);
if (needRsp) {
void *pCont = NULL;
int32_t contLen = 0;
if (mndBuildSMAlterStbRsp(pDb, pAlter, &stbObj, &pCont, &contLen) != 0) goto _OVER;
mndTransSetRpcRsp(pTrans, pCont, contLen);
}
if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER;
if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER;
if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
code = 0;
_OVER: _OVER:
mndTransDrop(pTrans);
taosMemoryFreeClear(stbObj.pTags); taosMemoryFreeClear(stbObj.pTags);
taosMemoryFreeClear(stbObj.pColumns); taosMemoryFreeClear(stbObj.pColumns);
return code; return code;

View File

@ -130,7 +130,7 @@ bool tsdbNextDataBlock(STsdbReader *pReader);
void tsdbRetrieveDataBlockInfo(STsdbReader *pReader, SDataBlockInfo *pDataBlockInfo); void tsdbRetrieveDataBlockInfo(STsdbReader *pReader, SDataBlockInfo *pDataBlockInfo);
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave); int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave);
SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond, int32_t tWinIdx); int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo); int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle); int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle);
void *tsdbGetIdx(SMeta *pMeta); void *tsdbGetIdx(SMeta *pMeta);

View File

@ -89,6 +89,8 @@ typedef struct {
STqExecTb execTb; STqExecTb execTb;
STqExecDb execDb; STqExecDb execDb;
}; };
// TODO remove it
int64_t tsdbEndVer;
} STqExecHandle; } STqExecHandle;
@ -129,7 +131,7 @@ typedef struct {
static STqMgmt tqMgmt = {0}; static STqMgmt tqMgmt = {0};
// tqRead // tqRead
int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal* offset); int64_t tqScan(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal* offset);
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum); int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum);
// tqExec // tqExec

View File

@ -112,7 +112,8 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
}; };
tmsgSendRsp(&resp); tmsgSendRsp(&resp);
tqDebug("vgId:%d from consumer:%" PRId64 ", (epoch %d) send rsp, res msg type %d, reqOffset:%" PRId64 ", rspOffset:%" PRId64, tqDebug("vgId:%d from consumer:%" PRId64 ", (epoch %d) send rsp, res msg type %d, reqOffset:%" PRId64
", rspOffset:%" PRId64,
TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->resMsgType, pRsp->reqOffset, pRsp->rspOffset); TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->resMsgType, pRsp->reqOffset, pRsp->rspOffset);
return 0; return 0;
@ -179,8 +180,8 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
tDecoderClear(&decoder); tDecoderClear(&decoder);
if (offset.val.type == TMQ_OFFSET__SNAPSHOT_DATA) { if (offset.val.type == TMQ_OFFSET__SNAPSHOT_DATA) {
tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:snapshot) uid:%" PRId64 ", ts:%" PRId64, offset.subKey, tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:snapshot) uid:%" PRId64 ", ts:%" PRId64,
TD_VID(pTq->pVnode), offset.val.uid, offset.val.ts); offset.subKey, TD_VID(pTq->pVnode), offset.val.uid, offset.val.ts);
} else if (offset.val.type == TMQ_OFFSET__LOG) { } else if (offset.val.type == TMQ_OFFSET__LOG) {
tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:log) version:%" PRId64, offset.subKey, tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:log) version:%" PRId64, offset.subKey,
TD_VID(pTq->pVnode), offset.val.version); TD_VID(pTq->pVnode), offset.val.version);
@ -316,9 +317,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
} }
// 3.query // 3.query
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN && fetchOffsetNew.type == TMQ_OFFSET__LOG) { if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
if (fetchOffsetNew.type == TMQ_OFFSET__LOG) {
fetchOffsetNew.version++; fetchOffsetNew.version++;
if (tqScanLog(pTq, &pHandle->execHandle, &dataRsp, &fetchOffsetNew) < 0) { }
if (tqScan(pTq, &pHandle->execHandle, &dataRsp, &fetchOffsetNew) < 0) {
ASSERT(0); ASSERT(0);
code = -1; code = -1;
goto OVER; goto OVER;
@ -333,7 +336,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
goto OVER; goto OVER;
} }
if (pHandle->execHandle.subType != TOPIC_SUB_TYPE__COLUMN && fetchOffsetNew.type == TMQ_OFFSET__LOG) { if (pHandle->execHandle.subType != TOPIC_SUB_TYPE__COLUMN) {
int64_t fetchVer = fetchOffsetNew.version + 1; int64_t fetchVer = fetchOffsetNew.version + 1;
SWalCkHead* pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); SWalCkHead* pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048);
if (pCkHead == NULL) { if (pCkHead == NULL) {
@ -411,6 +414,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
} }
taosMemoryFree(pCkHead); taosMemoryFree(pCkHead);
#if 0
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) { } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) {
tqInfo("retrieve using snapshot actual offset: uid %" PRId64 " ts %" PRId64, fetchOffsetNew.uid, fetchOffsetNew.ts); tqInfo("retrieve using snapshot actual offset: uid %" PRId64 " ts %" PRId64, fetchOffsetNew.uid, fetchOffsetNew.ts);
if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) { if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) {
@ -421,6 +425,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
code = -1; code = -1;
} }
#endif
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) { } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_META) {
ASSERT(0); ASSERT(0);
} }
@ -478,6 +483,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
/*for (int32_t i = 0; i < 5; i++) {*/ /*for (int32_t i = 0; i < 5; i++) {*/
/*pHandle->execHandle.pExecReader[i] = tqOpenReader(pTq->pVnode);*/ /*pHandle->execHandle.pExecReader[i] = tqOpenReader(pTq->pVnode);*/
/*}*/ /*}*/
int64_t ver = walGetCommittedVer(pTq->pVnode->pWal);
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
pHandle->execHandle.execCol.qmsg = req.qmsg; pHandle->execHandle.execCol.qmsg = req.qmsg;
req.qmsg = NULL; req.qmsg = NULL;
@ -488,6 +494,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
.vnode = pTq->pVnode, .vnode = pTq->pVnode,
.initTableReader = true, .initTableReader = true,
.initTqReader = true, .initTqReader = true,
.version = ver,
}; };
pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle); pHandle->execHandle.execCol.task[i] = qCreateStreamExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle);
ASSERT(pHandle->execHandle.execCol.task[i]); ASSERT(pHandle->execHandle.execCol.task[i]);
@ -496,6 +503,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
ASSERT(scanner); ASSERT(scanner);
pHandle->execHandle.pExecReader[i] = qExtractReaderFromStreamScanner(scanner); pHandle->execHandle.pExecReader[i] = qExtractReaderFromStreamScanner(scanner);
ASSERT(pHandle->execHandle.pExecReader[i]); ASSERT(pHandle->execHandle.pExecReader[i]);
pHandle->execHandle.tsdbEndVer = ver;
} }
} else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) { } else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) {
for (int32_t i = 0; i < 5; i++) { for (int32_t i = 0; i < 5; i++) {

View File

@ -59,15 +59,17 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
return 0; return 0;
} }
int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal* pOffset) { int64_t tqScan(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal* pOffset) {
qTaskInfo_t task = pExec->execCol.task[0]; qTaskInfo_t task = pExec->execCol.task[0];
if (qStreamPrepareScan(task, pOffset) < 0) { if (qStreamPrepareScan(task, pOffset) < 0) {
ASSERT(pOffset->type == TMQ_OFFSET__LOG);
pRsp->rspOffset = *pOffset; pRsp->rspOffset = *pOffset;
pRsp->rspOffset.version--; pRsp->rspOffset.version--;
return 0; return 0;
} }
int32_t rowCnt = 0;
while (1) { while (1) {
SSDataBlock* pDataBlock = NULL; SSDataBlock* pDataBlock = NULL;
uint64_t ts = 0; uint64_t ts = 0;
@ -77,11 +79,26 @@ int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOff
if (pDataBlock != NULL) { if (pDataBlock != NULL) {
tqAddBlockDataToRsp(pDataBlock, pRsp); tqAddBlockDataToRsp(pDataBlock, pRsp);
pRsp->blockNum++;
if (pRsp->withTbName) { if (pRsp->withTbName) {
if (pOffset->type == TMQ_OFFSET__LOG) {
int64_t uid = pExec->pExecReader[0]->msgIter.uid; int64_t uid = pExec->pExecReader[0]->msgIter.uid;
tqAddTbNameToRsp(pTq, uid, pRsp); tqAddTbNameToRsp(pTq, uid, pRsp);
} else {
pRsp->withTbName = 0;
} }
pRsp->blockNum++; }
if (pOffset->type == TMQ_OFFSET__LOG) {
continue;
} else {
rowCnt += pDataBlock->info.rows;
if (rowCnt <= 4096) continue;
}
}
if (pRsp->blockNum == 0 && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
tqOffsetResetToLog(pOffset, pExec->tsdbEndVer + 1);
qStreamPrepareScan(task, pOffset);
continue; continue;
} }
@ -94,18 +111,19 @@ int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOff
ASSERT(0); ASSERT(0);
} }
if (pRsp->rspOffset.type == TMQ_OFFSET__LOG) { ASSERT(pRsp->rspOffset.type != 0);
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
ASSERT(pRsp->rspOffset.version + 1 >= pRsp->reqOffset.version); ASSERT(pRsp->rspOffset.version + 1 >= pRsp->reqOffset.version);
} }
ASSERT(pRsp->rspOffset.type != 0);
break; break;
} }
return 0; return 0;
} }
#if 0
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) { int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) {
ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN); ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN);
qTaskInfo_t task = pExec->execCol.task[workerId]; qTaskInfo_t task = pExec->execCol.task[workerId];
@ -153,6 +171,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S
return 0; return 0;
} }
#endif
int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId) { int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp, int32_t workerId) {
if (pExec->subType == TOPIC_SUB_TYPE__COLUMN) { if (pExec->subType == TOPIC_SUB_TYPE__COLUMN) {

View File

@ -59,7 +59,6 @@ typedef struct SBlockLoadSuppInfo {
SColumnDataAgg tsColAgg; SColumnDataAgg tsColAgg;
SColumnDataAgg** plist; SColumnDataAgg** plist;
int16_t* colIds; // column ids for loading file block data int16_t* colIds; // column ids for loading file block data
int32_t* slotIds; // colId to slotId
char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated. char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated.
} SBlockLoadSuppInfo; } SBlockLoadSuppInfo;
@ -183,7 +182,6 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
return NULL; return NULL;
} }
// todo apply the lastkey of table check to avoid to load header file
for (int32_t j = 0; j < numOfTables; ++j) { for (int32_t j = 0; j < numOfTables; ++j) {
STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid}; STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid};
if (ASCENDING_TRAVERSE(pTsdbReader->order)) { if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
@ -218,6 +216,30 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) {
} }
} }
static void destroyBlockScanInfo(SHashObj* pTableMap) {
STableBlockScanInfo* p = NULL;
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
p->iterInit = false;
p->iiter.hasVal = false;
if (p->iter.iter != NULL) {
tsdbTbDataIterDestroy(p->iter.iter);
p->iter.iter = NULL;
}
if (p->iiter.iter != NULL) {
tsdbTbDataIterDestroy(p->iiter.iter);
p->iiter.iter = NULL;
}
taosArrayDestroy(p->delSkyline);
p->delSkyline = NULL;
}
taosHashCleanup(pTableMap);
}
static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) { static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) {
ASSERT(pWindow != NULL); ASSERT(pWindow != NULL);
return pWindow->skey > pWindow->ekey; return pWindow->skey > pWindow->ekey;
@ -265,6 +287,10 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, const STsdbFSState* pFSt
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static void cleanupFilesetIterator(SFilesetIter* pIter) {
taosArrayDestroy(pIter->pFileList);
}
static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) { static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
bool asc = ASCENDING_TRAVERSE(pIter->order); bool asc = ASCENDING_TRAVERSE(pIter->order);
int32_t step = asc ? 1 : -1; int32_t step = asc ? 1 : -1;
@ -313,7 +339,15 @@ static void resetDataBlockIterator(SDataBlockIter* pIter, int32_t order) {
pIter->order = order; pIter->order = order;
pIter->index = -1; pIter->index = -1;
pIter->numOfBlocks = -1; pIter->numOfBlocks = -1;
if (pIter->blockList == NULL) {
pIter->blockList = taosArrayInit(4, sizeof(SFileDataBlockInfo)); pIter->blockList = taosArrayInit(4, sizeof(SFileDataBlockInfo));
} else {
taosArrayClear(pIter->blockList);
}
}
static void cleanupDataBlockIterator(SDataBlockIter* pIter) {
taosArrayDestroy(pIter->blockList);
} }
static void initReaderStatus(SReaderStatus* pStatus) { static void initReaderStatus(SReaderStatus* pStatus) {
@ -356,14 +390,14 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
initReaderStatus(&pReader->status); initReaderStatus(&pReader->status);
pReader->pTsdb = pReader->pTsdb =
getTsdbByRetentions(pVnode, pCond->twindows[0].skey, pVnode->config.tsdbCfg.retentions, idstr, &level); getTsdbByRetentions(pVnode, pCond->twindows.skey, pVnode->config.tsdbCfg.retentions, idstr, &level);
pReader->suid = pCond->suid; pReader->suid = pCond->suid;
pReader->order = pCond->order; pReader->order = pCond->order;
pReader->capacity = 4096; pReader->capacity = 4096;
pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL; pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL;
pReader->verRange = getQueryVerRange(pVnode, pCond, level); pReader->verRange = getQueryVerRange(pVnode, pCond, level);
pReader->type = pCond->type; pReader->type = pCond->type;
pReader->window = updateQueryTimeWindow(pVnode->pTsdb, pCond->twindows); pReader->window = updateQueryTimeWindow(pVnode->pTsdb, &pCond->twindows);
ASSERT(pCond->numOfCols > 0); ASSERT(pCond->numOfCols > 0);
@ -2515,6 +2549,7 @@ void doMergeMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDe
tRowMergerInit(&merge, pRow, pReader->pSchema); tRowMergerInit(&merge, pRow, pReader->pSchema);
doMergeRowsInBuf(pIter, k.ts, pDelList, &merge, pReader); doMergeRowsInBuf(pIter, k.ts, pDelList, &merge, pReader);
tRowMergerGetRow(&merge, pTSRow); tRowMergerGetRow(&merge, pTSRow);
tRowMergerClear(&merge);
} }
void doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, void doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader,
@ -2651,6 +2686,7 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
} }
doAppendOneRow(pBlock, pReader, pTSRow); doAppendOneRow(pBlock, pReader, pTSRow);
taosMemoryFree(pTSRow);
// no data in buffer, return immediately // no data in buffer, return immediately
if (!(pBlockScanInfo->iter.hasVal || pBlockScanInfo->iiter.hasVal)) { if (!(pBlockScanInfo->iter.hasVal || pBlockScanInfo->iiter.hasVal)) {
@ -2778,11 +2814,24 @@ void tsdbReaderClose(STsdbReader* pReader) {
return; return;
} }
blockDataDestroy(pReader->pResBlock); SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
taosMemoryFreeClear(pReader->suppInfo.plist);
taosMemoryFreeClear(pSupInfo->plist);
taosMemoryFree(pSupInfo->colIds);
taosArrayDestroy(pSupInfo->pColAgg);
for(int32_t i = 0; i < blockDataGetNumOfCols(pReader->pResBlock); ++i) {
if (pSupInfo->buildBuf[i] != NULL) {
taosMemoryFreeClear(pSupInfo->buildBuf[i]);
}
}
taosMemoryFree(pSupInfo->buildBuf);
cleanupFilesetIterator(&pReader->status.fileIter);
cleanupDataBlockIterator(&pReader->status.blockIter);
destroyBlockScanInfo(pReader->status.pTableMap);
blockDataDestroy(pReader->pResBlock);
taosArrayDestroy(pReader->suppInfo.pColAgg);
taosMemoryFree(pReader->suppInfo.slotIds);
#if 0 #if 0
// if (pReader->status.pTableScanInfo != NULL) { // if (pReader->status.pTableScanInfo != NULL) {
@ -2954,7 +3003,7 @@ SArray* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
return pReader->pResBlock->pDataBlock; return pReader->pResBlock->pDataBlock;
} }
int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond, int32_t tWinIdx) { int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
if (isEmptyQueryTimeWindow(&pReader->window)) { if (isEmptyQueryTimeWindow(&pReader->window)) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -2964,7 +3013,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond, int32_
pReader->status.loadFromFile = true; pReader->status.loadFromFile = true;
pReader->status.pTableIter = NULL; pReader->status.pTableIter = NULL;
pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows[tWinIdx]); pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows);
// allocate buffer in order to load data blocks from file // allocate buffer in order to load data blocks from file
memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg)); memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg));

View File

@ -450,42 +450,81 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType));
} }
#define USE_TSDB_SNAPSHOT
static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) { static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) {
#ifdef USE_TSDB_SNAPSHOT
SVnode *pVnode = pFsm->data; SVnode *pVnode = pFsm->data;
SSnapshotParam *pSnapshotParam = pParam; SSnapshotParam *pSnapshotParam = pParam;
int32_t code = vnodeSnapReaderOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapReader **)ppReader); int32_t code = vnodeSnapReaderOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapReader **)ppReader);
return code; return code;
#else
*ppReader = taosMemoryMalloc(32);
return 0;
#endif
} }
static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) {
#ifdef USE_TSDB_SNAPSHOT
SVnode *pVnode = pFsm->data; SVnode *pVnode = pFsm->data;
int32_t code = vnodeSnapReaderClose(pReader); int32_t code = vnodeSnapReaderClose(pReader);
return code; return code;
#else
taosMemoryFree(pReader);
return 0;
#endif
} }
static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) { static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) {
#ifdef USE_TSDB_SNAPSHOT
SVnode *pVnode = pFsm->data; SVnode *pVnode = pFsm->data;
int32_t code = vnodeSnapRead(pReader, (uint8_t **)ppBuf, len); int32_t code = vnodeSnapRead(pReader, (uint8_t **)ppBuf, len);
return code; return code;
#else
static int32_t times = 0;
if (times++ < 5) {
*len = 64;
*ppBuf = taosMemoryMalloc(*len);
snprintf(*ppBuf, *len, "snapshot block %d", times);
} else {
*len = 0;
*ppBuf = NULL;
}
return 0;
#endif
} }
static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) { static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) {
#ifdef USE_TSDB_SNAPSHOT
SVnode *pVnode = pFsm->data; SVnode *pVnode = pFsm->data;
SSnapshotParam *pSnapshotParam = pParam; SSnapshotParam *pSnapshotParam = pParam;
int32_t code = vnodeSnapWriterOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapWriter **)ppWriter); int32_t code = vnodeSnapWriterOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapWriter **)ppWriter);
return code; return code;
#else
*ppWriter = taosMemoryMalloc(32);
return 0;
#endif
} }
static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) {
#ifdef USE_TSDB_SNAPSHOT
SVnode *pVnode = pFsm->data; SVnode *pVnode = pFsm->data;
int32_t code = vnodeSnapWriterClose(pWriter, isApply); int32_t code = vnodeSnapWriterClose(pWriter, !isApply);
return code; return code;
#else
taosMemoryFree(pWriter);
return 0;
#endif
} }
static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) {
#ifdef USE_TSDB_SNAPSHOT
SVnode *pVnode = pFsm->data; SVnode *pVnode = pFsm->data;
int32_t code = vnodeSnapWrite(pWriter, pBuf, len); int32_t code = vnodeSnapWrite(pWriter, pBuf, len);
return code; return code;
#else
return 0;
#endif
} }
static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
@ -509,7 +548,8 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
SSyncInfo syncInfo = { SSyncInfo syncInfo = {
.snapshotStrategy = SYNC_STRATEGY_NO_SNAPSHOT, .snapshotStrategy = SYNC_STRATEGY_WAL_FIRST,
//.snapshotStrategy = SYNC_STRATEGY_NO_SNAPSHOT,
.batchSize = 10, .batchSize = 10,
.vgId = pVnode->config.vgId, .vgId = pVnode->config.vgId,
.isStandBy = pVnode->config.standby, .isStandBy = pVnode->config.standby,

View File

@ -166,7 +166,7 @@ typedef struct SCtgDBCache {
int8_t deleted; int8_t deleted;
SCtgVgCache vgCache; SCtgVgCache vgCache;
SHashObj *tbCache; // key:tbname, value:SCtgTbCache SHashObj *tbCache; // key:tbname, value:SCtgTbCache
SHashObj *stbCache; // key:suid, value:STableMeta* SHashObj *stbCache; // key:suid, value:char*
} SCtgDBCache; } SCtgDBCache;
typedef struct SCtgRentSlot { typedef struct SCtgRentSlot {

View File

@ -126,4 +126,6 @@ void cleanupQueryTableDataCond(SQueryTableDataCond* pCond);
int32_t convertFillType(int32_t mode); int32_t convertFillType(int32_t mode);
int32_t resultrowComparAsc(const void* p1, const void* p2);
#endif // TDENGINE_QUERYUTIL_H #endif // TDENGINE_QUERYUTIL_H

View File

@ -144,6 +144,7 @@ typedef struct {
void* metaBlk; // for tmq fetching meta void* metaBlk; // for tmq fetching meta
SSDataBlock* pullOverBlk; // for streaming SSDataBlock* pullOverBlk; // for streaming
SWalFilterCond cond; SWalFilterCond cond;
int64_t lastScanUid;
} SStreamTaskInfo; } SStreamTaskInfo;
typedef struct SExecTaskInfo { typedef struct SExecTaskInfo {
@ -278,9 +279,6 @@ typedef struct STableScanInfo {
SScanInfo scanInfo; SScanInfo scanInfo;
int32_t scanTimes; int32_t scanTimes;
SNode* pFilterNode; // filter info, which is push down by optimizer SNode* pFilterNode; // filter info, which is push down by optimizer
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context,todo: remove this by using SExprSup
int32_t* rowEntryInfoOffset; // todo: remove this by using SExprSup
SExprInfo* pExpr;// todo: remove this by using SExprSup
SSDataBlock* pResBlock; SSDataBlock* pResBlock;
SArray* pColMatchInfo; SArray* pColMatchInfo;
@ -289,19 +287,17 @@ typedef struct STableScanInfo {
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
int32_t dataBlockLoadFlag; int32_t dataBlockLoadFlag;
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
SSampleExecInfo sample; // sample execution info SSampleExecInfo sample; // sample execution info
int32_t curTWinIdx;
int32_t currentGroupId; int32_t currentGroupId;
int32_t currentTable; int32_t currentTable;
uint64_t queryId; // todo remove it
uint64_t taskId; // todo remove it
#if 0
struct { struct {
uint64_t uid; uint64_t uid;
int64_t ts; int64_t ts;
} lastStatus; } lastStatus;
#endif
int8_t scanMode; int8_t scanMode;
int8_t noTable; int8_t noTable;
@ -470,11 +466,22 @@ typedef struct SIntervalAggOperatorInfo {
SNode *pCondition; SNode *pCondition;
} SIntervalAggOperatorInfo; } SIntervalAggOperatorInfo;
typedef struct SMergeAlignedIntervalAggOperatorInfo {
SIntervalAggOperatorInfo *intervalAggOperatorInfo;
bool hasGroupId;
uint64_t groupId;
SSDataBlock* prefetchedBlock;
bool inputBlocksFinished;
SNode* pCondition;
} SMergeAlignedIntervalAggOperatorInfo;
typedef struct SStreamFinalIntervalOperatorInfo { typedef struct SStreamFinalIntervalOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
SOptrBasicInfo binfo; // basic info SOptrBasicInfo binfo; // basic info
SAggSupporter aggSup; // aggregate supporter SAggSupporter aggSup; // aggregate supporter
SExprSupp scalarSupp; // supporter for perform scalar function
SGroupResInfo groupResInfo; // multiple results build supporter SGroupResInfo groupResInfo; // multiple results build supporter
SInterval interval; // interval info SInterval interval; // interval info
int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator.
@ -622,6 +629,7 @@ typedef struct SStateWindowInfo {
typedef struct SStreamSessionAggOperatorInfo { typedef struct SStreamSessionAggOperatorInfo {
SOptrBasicInfo binfo; SOptrBasicInfo binfo;
SStreamAggSupporter streamAggSup; SStreamAggSupporter streamAggSup;
SExprSupp scalarSupp; // supporter for perform scalar function
SGroupResInfo groupResInfo; SGroupResInfo groupResInfo;
int64_t gap; // session window gap int64_t gap; // session window gap
int32_t primaryTsIndex; // primary timestamp slot id int32_t primaryTsIndex; // primary timestamp slot id
@ -672,11 +680,12 @@ typedef struct SStateWindowOperatorInfo {
typedef struct SStreamStateAggOperatorInfo { typedef struct SStreamStateAggOperatorInfo {
SOptrBasicInfo binfo; SOptrBasicInfo binfo;
SStreamAggSupporter streamAggSup; SStreamAggSupporter streamAggSup;
SExprSupp scalarSupp; // supporter for perform scalar function
SGroupResInfo groupResInfo; SGroupResInfo groupResInfo;
int32_t primaryTsIndex; // primary timestamp slot id int32_t primaryTsIndex; // primary timestamp slot id
int32_t order; // current SSDataBlock scan order int32_t order; // current SSDataBlock scan order
STimeWindowAggSupp twAggSup; STimeWindowAggSupp twAggSup;
SColumn stateCol; // start row index SColumn stateCol;
SqlFunctionCtx* pDummyCtx; // for combine SqlFunctionCtx* pDummyCtx; // for combine
SSDataBlock* pDelRes; SSDataBlock* pDelRes;
SHashObj* pSeDeleted; SHashObj* pSeDeleted;
@ -902,7 +911,7 @@ int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result);
int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length); int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length);
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
int32_t precision, int32_t order); int32_t order);
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey, int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order); __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
@ -918,7 +927,6 @@ int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs,
TSKEY* pEndTs, int32_t rows, int32_t start, int64_t gap, SHashObj* pStDeleted); TSKEY* pEndTs, int32_t rows, int32_t start, int64_t gap, SHashObj* pStDeleted);
bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool functionNeedToExecute(SqlFunctionCtx* pCtx);
int32_t compareTimeWindow(const void* p1, const void* p2, const void* param);
int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition,
SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset,
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);

View File

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <common/ttime.h>
#include "function.h" #include "function.h"
#include "functionMgt.h" #include "functionMgt.h"
#include "index.h" #include "index.h"
@ -76,7 +77,7 @@ void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) {
pGroupResInfo->index = 0; pGroupResInfo->index = 0;
} }
static int32_t resultrowComparAsc(const void* p1, const void* p2) { int32_t resultrowComparAsc(const void* p1, const void* p2) {
SResKeyPos* pp1 = *(SResKeyPos**)p1; SResKeyPos* pp1 = *(SResKeyPos**)p1;
SResKeyPos* pp2 = *(SResKeyPos**)p2; SResKeyPos* pp2 = *(SResKeyPos**)p2;
@ -769,11 +770,8 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
// pCond->twindow = pTableScanNode->scanRange; // pCond->twindow = pTableScanNode->scanRange;
// TODO: get it from stable scan node // TODO: get it from stable scan node
pCond->numOfTWindows = 1; pCond->twindows = pTableScanNode->scanRange;
pCond->twindows = taosMemoryCalloc(pCond->numOfTWindows, sizeof(STimeWindow));
pCond->twindows[0] = pTableScanNode->scanRange;
pCond->suid = pTableScanNode->scan.suid; pCond->suid = pTableScanNode->scan.suid;
pCond->type = BLOCK_LOAD_OFFSET_ORDER; pCond->type = BLOCK_LOAD_OFFSET_ORDER;
pCond->startVersion = -1; pCond->startVersion = -1;
pCond->endVersion = -1; pCond->endVersion = -1;
@ -826,3 +824,87 @@ int32_t convertFillType(int32_t mode) {
return type; return type;
} }
static void getInitialStartTimeWindow(SInterval* pInterval, TSKEY ts, STimeWindow* w, bool ascQuery) {
if (ascQuery) {
getAlignQueryTimeWindow(pInterval, pInterval->precision, ts, w);
} else {
// the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
getAlignQueryTimeWindow(pInterval, pInterval->precision, ts, w);
int64_t key = w->skey;
while (key < ts) { // moving towards end
key = taosTimeAdd(key, pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
if (key >= ts) {
break;
}
w->skey = key;
}
}
}
static STimeWindow doCalculateTimeWindow(int64_t ts, SInterval* pInterval) {
STimeWindow w = {0};
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
w.skey = taosTimeTruncate(ts, pInterval, pInterval->precision);
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
} else {
int64_t st = w.skey;
if (st > ts) {
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
int64_t et = st + pInterval->interval - 1;
if (et < ts) {
st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
w.skey = st;
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
}
return w;
}
static STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order) {
int32_t factor = (order == TSDB_ORDER_ASC)? -1:1;
STimeWindow win = *pWindow;
STimeWindow save = win;
while(win.skey <= ts && win.ekey >= ts) {
save = win;
win.skey = taosTimeAdd(win.skey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
win.ekey = taosTimeAdd(win.ekey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
}
return save;
}
// get the correct time window according to the handled timestamp
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
int32_t order) {
STimeWindow w = {0};
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
getInitialStartTimeWindow(pInterval, ts, &w, (order == TSDB_ORDER_ASC));
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
return w;
}
w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win;
// in case of typical time window, we can calculate time window directly.
if (w.skey > ts || w.ekey < ts) {
w = doCalculateTimeWindow(ts, pInterval);
}
if (pInterval->interval != pInterval->sliding) {
// it is an sliding window query, in which sliding value is not equalled to
// interval value, and we need to find the first qualified time window.
w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order);
}
return w;
}

View File

@ -184,7 +184,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
return code; return code;
} }
int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion,
int32_t* tversion) { int32_t* tversion) {
ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL); ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL);
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;

View File

@ -327,17 +327,14 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
ASSERT(found); ASSERT(found);
tsdbSetTableId(pTableScanInfo->dataReader, uid); tsdbSetTableId(pTableScanInfo->dataReader, uid);
int64_t oldSkey = pTableScanInfo->cond.twindows[0].skey; int64_t oldSkey = pTableScanInfo->cond.twindows.skey;
pTableScanInfo->cond.twindows[0].skey = ts + 1; pTableScanInfo->cond.twindows.skey = ts + 1;
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
pTableScanInfo->cond.twindows[0].skey = oldSkey; pTableScanInfo->cond.twindows.skey = oldSkey;
pTableScanInfo->scanTimes = 0; pTableScanInfo->scanTimes = 0;
pTableScanInfo->curTWinIdx = 0;
qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts, qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts,
pTableScanInfo->currentTable, tableSz); pTableScanInfo->currentTable, tableSz);
} else {
// switch to log
} }
} else { } else {
@ -353,6 +350,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) {
return 0; return 0;
} }
#if 0
int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) { int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) {
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
@ -372,3 +370,4 @@ int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts) {
return doGetScanStatus(pTaskInfo->pRoot, uid, ts); return doGetScanStatus(pTaskInfo->pRoot, uid, ts);
} }
#endif

View File

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <executorimpl.h>
#include "filter.h" #include "filter.h"
#include "function.h" #include "function.h"
#include "functionMgt.h" #include "functionMgt.h"
@ -1038,6 +1039,7 @@ static bool overlapWithTimeWindow(STaskAttr* pQueryAttr, SDataBlockInfo* pBlockI
#endif #endif
static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) { static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) {
#if 0
SqlFunctionCtx* pCtx = pTableScanInfo->pCtx; SqlFunctionCtx* pCtx = pTableScanInfo->pCtx;
uint32_t status = BLK_DATA_NOT_LOAD; uint32_t status = BLK_DATA_NOT_LOAD;
@ -1059,6 +1061,8 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
} }
return status; return status;
#endif
return 0;
} }
int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
@ -2844,7 +2848,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
} }
} }
} }
#if 0
int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) { int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) {
uint8_t type = pOperator->operatorType; uint8_t type = pOperator->operatorType;
@ -2887,12 +2891,11 @@ int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) {
ASSERT(found); ASSERT(found);
tsdbSetTableId(pInfo->dataReader, uid); tsdbSetTableId(pInfo->dataReader, uid);
int64_t oldSkey = pInfo->cond.twindows[0].skey; int64_t oldSkey = pInfo->cond.twindows.skey;
pInfo->cond.twindows[0].skey = ts + 1; pInfo->cond.twindows.skey = ts + 1;
tsdbReaderReset(pInfo->dataReader, &pInfo->cond, 0); tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
pInfo->cond.twindows[0].skey = oldSkey; pInfo->cond.twindows.skey = oldSkey;
pInfo->scanTimes = 0; pInfo->scanTimes = 0;
pInfo->curTWinIdx = 0;
qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid, ts, qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid, ts,
pInfo->currentTable, tableSz); pInfo->currentTable, tableSz);
@ -2930,6 +2933,7 @@ int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
#endif
// this is a blocking operator // this is a blocking operator
static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
@ -3341,8 +3345,8 @@ static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo* pInfo, SResult
SExecTaskInfo* pTaskInfo) { SExecTaskInfo* pTaskInfo) {
pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows; pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows;
int64_t ekey = Q_STATUS_EQUAL(pTaskInfo->status, TASK_COMPLETED) ? pInfo->win.ekey int64_t ekey =
: pInfo->existNewGroupBlock->info.window.ekey; Q_STATUS_EQUAL(pTaskInfo->status, TASK_COMPLETED) ? pInfo->win.ekey : pInfo->existNewGroupBlock->info.window.ekey;
taosResetFillInfo(pInfo->pFillInfo, getFillInfoStart(pInfo->pFillInfo)); taosResetFillInfo(pInfo->pFillInfo, getFillInfoStart(pInfo->pFillInfo));
taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey); taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey);
@ -3993,7 +3997,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
int32_t num = 0; int32_t num = 0;
SSDataBlock* pResBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc);
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pTargets, NULL, &num); SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pTargets, NULL, &num);
SInterval* pInterval = &((SIntervalAggOperatorInfo*)downstream->info)->interval; SInterval* pInterval =
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
: &((SIntervalAggOperatorInfo*)downstream->info)->interval;
int32_t type = convertFillType(pPhyFillNode->mode); int32_t type = convertFillType(pPhyFillNode->mode);
SResultInfo* pResultInfo = &pOperator->resultInfo; SResultInfo* pResultInfo = &pOperator->resultInfo;
@ -4050,7 +4057,7 @@ static STsdbReader* doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRea
static SArray* extractColumnInfo(SNodeList* pNodeList); static SArray* extractColumnInfo(SNodeList* pNodeList);
int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) { int32_t extractTableSchemaInfo(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo* pTaskInfo) {
SMetaReader mr = {0}; SMetaReader mr = {0};
metaReaderInit(&mr, pHandle->meta, 0); metaReaderInit(&mr, pHandle->meta, 0);
int32_t code = metaGetTableEntryByUid(&mr, uid); int32_t code = metaGetTableEntryByUid(&mr, uid);
@ -4074,10 +4081,20 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI
} }
metaReaderClear(&mr); metaReaderClear(&mr);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static void cleanupTableSchemaInfo(SExecTaskInfo* pTaskInfo) {
taosMemoryFreeClear(pTaskInfo->schemaVer.dbname);
if (pTaskInfo->schemaVer.sw == NULL) {
return;
}
taosMemoryFree(pTaskInfo->schemaVer.sw->pSchema);
taosMemoryFree(pTaskInfo->schemaVer.sw);
taosMemoryFree(pTaskInfo->schemaVer.tablename);
}
static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) { static int32_t sortTableGroup(STableListInfo* pTableListInfo, int32_t groupNum) {
taosArrayClear(pTableListInfo->pGroupList); taosArrayClear(pTableListInfo->pGroupList);
SArray* sortSupport = taosArrayInit(groupNum, sizeof(uint64_t)); SArray* sortSupport = taosArrayInit(groupNum, sizeof(uint64_t));
@ -4251,7 +4268,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return NULL; return NULL;
} }
code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo);
if (code) { if (code) {
pTaskInfo->code = terrno; pTaskInfo->code = terrno;
return NULL; return NULL;
@ -4269,7 +4286,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
pTaskInfo->code = code; pTaskInfo->code = code;
return NULL; return NULL;
} }
code = extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); code = extractTableSchemaInfo(pHandle, pTableScanNode->scan.uid, pTaskInfo);
if (code) { if (code) {
pTaskInfo->code = terrno; pTaskInfo->code = terrno;
return NULL; return NULL;
@ -4347,9 +4364,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
cond.colList->type = TSDB_DATA_TYPE_TIMESTAMP; cond.colList->type = TSDB_DATA_TYPE_TIMESTAMP;
cond.colList->bytes = sizeof(TSKEY); cond.colList->bytes = sizeof(TSKEY);
cond.numOfTWindows = 1; cond.twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
cond.twindows = taosMemoryCalloc(1, sizeof(STimeWindow));
cond.twindows[0] = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
cond.suid = pBlockNode->suid; cond.suid = pBlockNode->suid;
cond.type = BLOCK_LOAD_OFFSET_ORDER; cond.type = BLOCK_LOAD_OFFSET_ORDER;
} }
@ -4368,7 +4383,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
// return NULL; // return NULL;
// } // }
int32_t code = extractTableSchemaVersion(pHandle, pScanNode->uid, pTaskInfo); int32_t code = extractTableSchemaInfo(pHandle, pScanNode->uid, pTaskInfo);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
pTaskInfo->code = code; pTaskInfo->code = code;
return NULL; return NULL;
@ -4465,7 +4480,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision}; .precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision};
int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
pOptr = createMergeAlignedIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, pPhyNode->pConditions, pTaskInfo); pOptr = createMergeAlignedIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId,
pPhyNode->pConditions, pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL == type) {
SMergeIntervalPhysiNode* pIntervalPhyNode = (SMergeIntervalPhysiNode*)pPhyNode; SMergeIntervalPhysiNode* pIntervalPhyNode = (SMergeIntervalPhysiNode*)pPhyNode;
@ -4504,8 +4520,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
int32_t tsSlotId = ((SColumnNode*)pSessionNode->window.pTspk)->slotId; int32_t tsSlotId = ((SColumnNode*)pSessionNode->window.pTspk)->slotId;
pOptr = pOptr = createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, tsSlotId, &as,
createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, tsSlotId, &as, pPhyNode->pConditions, pTaskInfo); pPhyNode->pConditions, pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION == type) {
pOptr = createStreamSessionAggOperatorInfo(ops[0], pPhyNode, pTaskInfo); pOptr = createStreamSessionAggOperatorInfo(ops[0], pPhyNode, pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION == type) {
@ -4527,7 +4543,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SColumnNode* pColNode = (SColumnNode*)((STargetNode*)pStateNode->pStateKey)->pExpr; SColumnNode* pColNode = (SColumnNode*)((STargetNode*)pStateNode->pStateKey)->pExpr;
SColumn col = extractColumnFromColumnNode(pColNode); SColumn col = extractColumnFromColumnNode(pColNode);
pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, &as, tsSlotId, &col, pPhyNode->pConditions, pTaskInfo); pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, &as, tsSlotId, &col, pPhyNode->pConditions,
pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE == type) {
pOptr = createStreamStateAggOperatorInfo(ops[0], pPhyNode, pTaskInfo); pOptr = createStreamStateAggOperatorInfo(ops[0], pPhyNode, pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN == type) {
@ -4546,18 +4563,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return pOptr; return pOptr;
} }
int32_t compareTimeWindow(const void* p1, const void* p2, const void* param) {
const SQueryTableDataCond* pCond = param;
const STimeWindow* pWin1 = p1;
const STimeWindow* pWin2 = p2;
if (pCond->order == TSDB_ORDER_ASC) {
return pWin1->skey - pWin2->skey;
} else if (pCond->order == TSDB_ORDER_DESC) {
return pWin2->skey - pWin1->skey;
}
return 0;
}
SArray* extractColumnInfo(SNodeList* pNodeList) { SArray* extractColumnInfo(SNodeList* pNodeList) {
size_t numOfCols = LIST_LENGTH(pNodeList); size_t numOfCols = LIST_LENGTH(pNodeList);
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn)); SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
@ -4879,11 +4884,8 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) {
doDestroyTableList(&pTaskInfo->tableqinfoList); doDestroyTableList(&pTaskInfo->tableqinfoList);
destroyOperatorInfo(pTaskInfo->pRoot); destroyOperatorInfo(pTaskInfo->pRoot);
// taosArrayDestroy(pTaskInfo->summary.queryProfEvents); cleanupTableSchemaInfo(pTaskInfo);
// taosHashCleanup(pTaskInfo->summary.operatorProfResults);
taosMemoryFree(pTaskInfo->schemaVer.dbname);
taosMemoryFree(pTaskInfo->schemaVer.tablename);
taosMemoryFreeClear(pTaskInfo->sql); taosMemoryFreeClear(pTaskInfo->sql);
taosMemoryFreeClear(pTaskInfo->id.str); taosMemoryFreeClear(pTaskInfo->id.str);
taosMemoryFreeClear(pTaskInfo); taosMemoryFreeClear(pTaskInfo);

View File

@ -294,15 +294,10 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
// setupQueryRangeForReverseScan(pTableScanInfo); // setupQueryRangeForReverseScan(pTableScanInfo);
pTableScanInfo->cond.order = TSDB_ORDER_DESC; pTableScanInfo->cond.order = TSDB_ORDER_DESC;
for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) { STimeWindow* pTWindow = &pTableScanInfo->cond.twindows;
STimeWindow* pTWindow = &pTableScanInfo->cond.twindows[i];
TSWAP(pTWindow->skey, pTWindow->ekey); TSWAP(pTWindow->skey, pTWindow->ekey);
} }
SQueryTableDataCond* pCond = &pTableScanInfo->cond;
taosqsort(pCond->twindows, pCond->numOfTWindows, sizeof(STimeWindow), pCond, compareTimeWindow);
}
int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr,
SSDataBlock* pBlock, const char* idStr) { SSDataBlock* pBlock, const char* idStr) {
// currently only the tbname pseudo column // currently only the tbname pseudo column
@ -427,8 +422,11 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
pOperator->cost.totalCost = pTableScanInfo->readRecorder.elapsedTime; pOperator->cost.totalCost = pTableScanInfo->readRecorder.elapsedTime;
// todo refactor // todo refactor
pTableScanInfo->lastStatus.uid = pBlock->info.uid; /*pTableScanInfo->lastStatus.uid = pBlock->info.uid;*/
pTableScanInfo->lastStatus.ts = pBlock->info.window.ekey; /*pTableScanInfo->lastStatus.ts = pBlock->info.window.ekey;*/
pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_DATA;
pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.uid;
pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey;
ASSERT(pBlock->info.uid != 0); ASSERT(pBlock->info.uid != 0);
return pBlock; return pBlock;
@ -447,17 +445,11 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
// do the ascending order traverse in the first place. // do the ascending order traverse in the first place.
while (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) { while (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) {
while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
SSDataBlock* p = doTableScanImpl(pOperator); SSDataBlock* p = doTableScanImpl(pOperator);
if (p != NULL) { if (p != NULL) {
ASSERT(p->info.uid != 0); ASSERT(p->info.uid != 0);
return p; return p;
} }
pTableScanInfo->curTWinIdx += 1;
if (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, pTableScanInfo->curTWinIdx);
}
}
pTableScanInfo->scanTimes += 1; pTableScanInfo->scanTimes += 1;
@ -465,41 +457,26 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
pTableScanInfo->scanFlag = REPEAT_SCAN; pTableScanInfo->scanFlag = REPEAT_SCAN;
qDebug("%s start to repeat ascending order scan data blocks due to query func required", GET_TASKID(pTaskInfo)); qDebug("%s start to repeat ascending order scan data blocks due to query func required", GET_TASKID(pTaskInfo));
for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) {
STimeWindow* pWin = &pTableScanInfo->cond.twindows[i];
qDebug("%s qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
}
// do prepare for the next round table scan operation // do prepare for the next round table scan operation
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
pTableScanInfo->curTWinIdx = 0;
} }
} }
int32_t total = pTableScanInfo->scanInfo.numOfAsc + pTableScanInfo->scanInfo.numOfDesc; int32_t total = pTableScanInfo->scanInfo.numOfAsc + pTableScanInfo->scanInfo.numOfDesc;
if (pTableScanInfo->scanTimes < total) { if (pTableScanInfo->scanTimes < total) {
if (pTableScanInfo->cond.order == TSDB_ORDER_ASC) { if (pTableScanInfo->cond.order == TSDB_ORDER_ASC) {
prepareForDescendingScan(pTableScanInfo, pTableScanInfo->pCtx, 0); prepareForDescendingScan(pTableScanInfo, pOperator->exprSupp.pCtx, 0);
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
pTableScanInfo->curTWinIdx = 0;
} }
qDebug("%s start to descending order scan data blocks due to query func required", GET_TASKID(pTaskInfo)); qDebug("%s start to descending order scan data blocks due to query func required", GET_TASKID(pTaskInfo));
for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) {
STimeWindow* pWin = &pTableScanInfo->cond.twindows[i];
qDebug("%s qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
}
while (pTableScanInfo->scanTimes < total) { while (pTableScanInfo->scanTimes < total) {
while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
SSDataBlock* p = doTableScanImpl(pOperator); SSDataBlock* p = doTableScanImpl(pOperator);
if (p != NULL) { if (p != NULL) {
return p; return p;
} }
pTableScanInfo->curTWinIdx += 1;
if (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, pTableScanInfo->curTWinIdx);
}
}
pTableScanInfo->scanTimes += 1; pTableScanInfo->scanTimes += 1;
@ -509,12 +486,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
qDebug("%s start to repeat descending order scan data blocks due to query func required", qDebug("%s start to repeat descending order scan data blocks due to query func required",
GET_TASKID(pTaskInfo)); GET_TASKID(pTaskInfo));
for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) { tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
STimeWindow* pWin = &pTableScanInfo->cond.twindows[i];
qDebug("%s qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
}
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
pTableScanInfo->curTWinIdx = 0;
} }
} }
} }
@ -541,9 +513,8 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
} }
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable); STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable);
tsdbSetTableId(pInfo->dataReader, pTableInfo->uid); tsdbSetTableId(pInfo->dataReader, pTableInfo->uid);
tsdbReaderReset(pInfo->dataReader, &pInfo->cond, 0); tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
pInfo->scanTimes = 0; pInfo->scanTimes = 0;
pInfo->curTWinIdx = 0;
} }
} }
@ -575,8 +546,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId); SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId);
// tsdbSetTableList(pInfo->dataReader, tableList); // tsdbSetTableList(pInfo->dataReader, tableList);
tsdbReaderReset(pInfo->dataReader, &pInfo->cond, 0); tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
pInfo->curTWinIdx = 0;
pInfo->scanTimes = 0; pInfo->scanTimes = 0;
result = doTableScanGroup(pOperator); result = doTableScanGroup(pOperator);
@ -647,7 +617,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions; pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
pInfo->scanFlag = MAIN_SCAN; pInfo->scanFlag = MAIN_SCAN;
pInfo->pColMatchInfo = pColList; pInfo->pColMatchInfo = pColList;
pInfo->curTWinIdx = 0;
pInfo->currentGroupId = -1; pInfo->currentGroupId = -1;
pOperator->name = "TableScanOperator"; // for debug purpose pOperator->name = "TableScanOperator"; // for debug purpose
@ -877,12 +846,7 @@ static void setGroupId(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t grou
} }
void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) { void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) {
pTableScanInfo->cond.twindows[0] = *pWin; pTableScanInfo->cond.twindows = *pWin;
pTableScanInfo->curTWinIdx = 0;
// tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
// if (!pTableScanInfo->dataReader) {
// return false;
// }
pTableScanInfo->scanTimes = 0; pTableScanInfo->scanTimes = 0;
pTableScanInfo->currentGroupId = -1; pTableScanInfo->currentGroupId = -1;
} }
@ -940,8 +904,7 @@ static bool prepareDataScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32_t t
setGroupId(pInfo, pSDB, GROUPID_COLUMN_INDEX, *pRowIndex); setGroupId(pInfo, pSDB, GROUPID_COLUMN_INDEX, *pRowIndex);
(*pRowIndex) += updateSessionWindowInfo(pCurWin, tsCols, NULL, pSDB->info.rows, *pRowIndex, gap, NULL); (*pRowIndex) += updateSessionWindowInfo(pCurWin, tsCols, NULL, pSDB->info.rows, *pRowIndex, gap, NULL);
} else { } else {
win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[*pRowIndex], &pInfo->interval, pInfo->interval.precision, win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[*pRowIndex], &pInfo->interval, TSDB_ORDER_ASC);
TSDB_ORDER_ASC);
setGroupId(pInfo, pSDB, GROUPID_COLUMN_INDEX, *pRowIndex); setGroupId(pInfo, pSDB, GROUPID_COLUMN_INDEX, *pRowIndex);
(*pRowIndex) += (*pRowIndex) +=
getNumOfRowsInTimeWindow(&pSDB->info, tsCols, *pRowIndex, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); getNumOfRowsInTimeWindow(&pSDB->info, tsCols, *pRowIndex, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
@ -1231,9 +1194,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
doFilter(pInfo->pCondition, pInfo->pRes); doFilter(pInfo->pCondition, pInfo->pRes);
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
if (pBlockInfo->rows > 0) {
return 0;
}
return 0; return 0;
} }
@ -1259,7 +1219,9 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
/*pTaskInfo->streamInfo.lastStatus = ret.offset;*/ /*pTaskInfo->streamInfo.lastStatus = ret.offset;*/
if (pInfo->pRes->info.rows > 0) { if (pInfo->pRes->info.rows > 0) {
return pInfo->pRes; return pInfo->pRes;
/*} else {*/ } else {
// data is filtered out, do clean
/*tDeleteSSDataBlock(&ret.data);*/ /*tDeleteSSDataBlock(&ret.data);*/
} }
} else if (ret.fetchType == FETCH_TYPE__META) { } else if (ret.fetchType == FETCH_TYPE__META) {
@ -1268,13 +1230,8 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
pTaskInfo->streamInfo.metaBlk = ret.meta; pTaskInfo->streamInfo.metaBlk = ret.meta;
return NULL; return NULL;
} else if (ret.fetchType == FETCH_TYPE__NONE) { } else if (ret.fetchType == FETCH_TYPE__NONE) {
/*if (ret.offset.version == -1) {*/
/*pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG;*/
/*pTaskInfo->streamInfo.lastStatus.version = pTaskInfo->streamInfo.prepareStatus.version - 1;*/
/*} else {*/
pTaskInfo->streamInfo.lastStatus = ret.offset; pTaskInfo->streamInfo.lastStatus = ret.offset;
ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 >= pTaskInfo->streamInfo.prepareStatus.version); ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 >= pTaskInfo->streamInfo.prepareStatus.version);
/*}*/
return NULL; return NULL;
} else { } else {
ASSERT(0); ASSERT(0);
@ -1394,72 +1351,8 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
return NULL; return NULL;
} }
pInfo->pRes->info.rows = block.info.rows; setBlockIntoRes(pInfo, &block);
pInfo->pRes->info.uid = block.info.uid;
pInfo->pRes->info.type = STREAM_NORMAL;
pInfo->pRes->info.capacity = block.info.rows;
uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &block.info.uid, sizeof(int64_t));
if (groupIdPre) {
pInfo->pRes->info.groupId = *groupIdPre;
} else {
pInfo->pRes->info.groupId = 0;
}
// for generating rollup SMA result, each time is an independent time serie.
// TODO temporarily used, when the statement of "partition by tbname" is ready, remove this
if (pInfo->assignBlockUid) {
pInfo->pRes->info.groupId = block.info.uid;
}
// todo extract method
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) {
SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i);
if (!pColMatchInfo->output) {
continue;
}
bool colExists = false;
for (int32_t j = 0; j < blockDataGetNumOfCols(&block); ++j) {
SColumnInfoData* pResCol = bdGetColumnInfoData(&block, j);
if (pResCol->info.colId == pColMatchInfo->colId) {
taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol);
colExists = true;
break;
}
}
// the required column does not exists in submit block, let's set it to be all null value
if (!colExists) {
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId);
colDataAppendNNULL(pDst, 0, pBlockInfo->rows);
}
}
taosArrayDestroy(block.pDataBlock);
ASSERT(pInfo->pRes->pDataBlock != NULL);
#if 0
if (pInfo->pRes->pDataBlock == NULL) {
// TODO add log
updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo);
pOperator->status = OP_EXEC_DONE;
pTaskInfo->code = terrno;
return NULL;
}
#endif
// currently only the tbname pseudo column
if (pInfo->numOfPseudoExpr > 0) {
code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
GET_TASKID(pTaskInfo));
if (code != TSDB_CODE_SUCCESS) {
longjmp(pTaskInfo->env, code);
}
}
doFilter(pInfo->pCondition, pInfo->pRes);
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
if (pBlockInfo->rows > 0) { if (pBlockInfo->rows > 0) {
break; break;
} }
@ -1489,12 +1382,14 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes; return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
#if 0
} else if (pInfo->blockType == STREAM_INPUT__TABLE_SCAN) { } else if (pInfo->blockType == STREAM_INPUT__TABLE_SCAN) {
/*ASSERT(0);*/ ASSERT(0);
// check reader last status // check reader last status
// if not match, reset status // if not match, reset status
SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp);
return pResult && pResult->info.rows > 0 ? pResult : NULL; return pResult && pResult->info.rows > 0 ? pResult : NULL;
#endif
} else { } else {
ASSERT(0); ASSERT(0);
@ -1558,6 +1453,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
if (pHandle) { if (pHandle) {
SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo);
STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanOp->info; STableScanInfo* pSTInfo = (STableScanInfo*)pTableScanOp->info;
if (pHandle->version > 0) {
pSTInfo->cond.endVersion = pHandle->version;
}
SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, 0); SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, 0);
if (pHandle->initTableReader) { if (pHandle->initTableReader) {

View File

@ -59,136 +59,6 @@ static void doCloseWindow(SResultRowInfo* pResultRowInfo, const SIntervalAggOper
static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols) { return tsCols == NULL ? win->skey : tsCols[0]; } static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols) { return tsCols == NULL ? win->skey : tsCols[0]; }
static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, TSKEY ts, STimeWindow* w,
bool ascQuery) {
if (ascQuery) {
getAlignQueryTimeWindow(pInterval, precision, ts, w);
} else {
// the start position of the first time window in the endpoint that spreads beyond the queried last timestamp
getAlignQueryTimeWindow(pInterval, precision, ts, w);
int64_t key = w->skey;
while (key < ts) { // moving towards end
key = taosTimeAdd(key, pInterval->sliding, pInterval->slidingUnit, precision);
if (key >= ts) {
break;
}
w->skey = key;
}
}
}
static STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order) {
int32_t factor = (order == TSDB_ORDER_ASC)? -1:1;
STimeWindow win = *pWindow;
STimeWindow save = win;
while(win.skey <= ts && win.ekey >= ts) {
save = win;
win.skey = taosTimeAdd(win.skey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
win.ekey = taosTimeAdd(win.ekey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision);
}
return save;
}
// todo do refactor
// get the correct time window according to the handled timestamp
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
int32_t precision, int32_t order) {
STimeWindow w = {0};
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
getInitialStartTimeWindow(pInterval, precision, ts, &w, true);
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
return w;
}
w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win;
if (pInterval->interval == pInterval->sliding) {
if (w.skey > ts || w.ekey < ts) {
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
w.skey = taosTimeTruncate(ts, pInterval, precision);
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
} else {
int64_t st = w.skey;
if (st > ts) {
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
int64_t et = st + pInterval->interval - 1;
if (et < ts) {
st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
w.skey = st;
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
}
}
} else { // it is an sliding window query, in which sliding value is not equalled to
// interval value, and we need to find the first qualified time window for asc/desc traverse respectively.
if (order == TSDB_ORDER_ASC) {
if (w.skey <= ts && w.ekey >= ts) {
// ts is resident in current time window, but we need to find the first
//qualified time window that cover this timestamp
w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order);
} else {
// todo refactor:
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
w.skey = taosTimeTruncate(ts, pInterval, precision);
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
} else {
int64_t st = w.skey;
if (st > ts) {
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
int64_t et = st + pInterval->interval - 1;
if (et < ts) {
st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
w.skey = st;
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order);
}
}
} else {
if (w.skey <= ts && w.ekey >= ts) {
w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order);
} else {
// todo refactor:
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
w.skey = taosTimeTruncate(ts, pInterval, precision);
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
} else {
int64_t st = w.skey;
if (st > ts) {
st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
int64_t et = st + pInterval->interval - 1;
if (et < ts) {
st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding;
}
w.skey = st;
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order);
}
}
}
}
return w;
}
static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindow* win, bool masterscan, static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindow* win, bool masterscan,
SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx,
int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup, int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup,
@ -907,7 +777,6 @@ static void removeDeleteResults(SArray* pUpdated, SArray* pDelWins) {
} }
} }
bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup) { bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup) {
ASSERT(pSup->maxTs == INT64_MIN || pSup->maxTs > 0); ASSERT(pSup->maxTs == INT64_MIN || pSup->maxTs > 0);
return pSup->maxTs != INT64_MIN && ts < pSup->maxTs - pSup->waterMark; return pSup->maxTs != INT64_MIN && ts < pSup->maxTs - pSup->waterMark;
@ -930,8 +799,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols); TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols);
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->order);
pInfo->interval.precision, pInfo->order);
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
if (!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) { if (!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) {
ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx,
@ -1287,11 +1155,13 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
while (1) { while (1) {
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
doFilter(pInfo->pCondition, pBlock); doFilter(pInfo->pCondition, pBlock);
bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo); bool hasRemain = hasDataInGroupInfo(&pInfo->groupResInfo);
if (!hasRemain) { if (!hasRemain) {
doSetOperatorCompleted(pOperator); doSetOperatorCompleted(pOperator);
break; break;
} }
if (pBlock->info.rows > 0) { if (pBlock->info.rows > 0) {
break; break;
} }
@ -1390,7 +1260,7 @@ void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock,
for (int32_t i = 0; i < pBlock->info.rows; i++) { for (int32_t i = 0; i < pBlock->info.rows; i++) {
SResultRowInfo dumyInfo; SResultRowInfo dumyInfo;
dumyInfo.cur.pageId = -1; dumyInfo.cur.pageId = -1;
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, pInterval->precision, TSDB_ORDER_ASC); STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, TSDB_ORDER_ASC);
doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]); doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]);
if (pUpWins) { if (pUpWins) {
SWinRes winRes = {.ts = win.skey, .groupId = groupIds[i]}; SWinRes winRes = {.ts = win.skey, .groupId = groupIds[i]};
@ -1399,8 +1269,8 @@ void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock,
} }
} }
static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* pInterval, static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* pInterval, int32_t numOfOutput,
int32_t numOfOutput, SSDataBlock* pBlock, SArray* pUpWins) { SSDataBlock* pBlock, SArray* pUpWins) {
SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
TSKEY* tsCols = (TSKEY*)pTsCol->pData; TSKEY* tsCols = (TSKEY*)pTsCol->pData;
uint64_t* pGpDatas = NULL; uint64_t* pGpDatas = NULL;
@ -1412,7 +1282,7 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval*
for (int32_t i = 0; i < pBlock->info.rows; i += step) { for (int32_t i = 0; i < pBlock->info.rows; i += step) {
SResultRowInfo dumyInfo; SResultRowInfo dumyInfo;
dumyInfo.cur.pageId = -1; dumyInfo.cur.pageId = -1;
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], pInterval, pInterval->precision, TSDB_ORDER_ASC); STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], pInterval, TSDB_ORDER_ASC);
step = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, i, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); step = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, i, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
uint64_t winGpId = pGpDatas ? pGpDatas[i] : pBlock->info.groupId; uint64_t winGpId = pGpDatas ? pGpDatas[i] : pBlock->info.groupId;
bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TKEY), winGpId, numOfOutput); bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TKEY), winGpId, numOfOutput);
@ -1440,9 +1310,9 @@ static int32_t getAllIntervalWindow(SHashObj* pHashMap, SArray* resWins) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, SInterval* pInterval,
SInterval* pInterval, SHashObj* pPullDataMap, SArray* closeWins, SHashObj* pPullDataMap, SArray* closeWins, SArray* pRecyPages,
SArray* pRecyPages, SDiskbasedBuf* pDiscBuf) { SDiskbasedBuf* pDiscBuf) {
void* pIte = NULL; void* pIte = NULL;
size_t keyLen = 0; size_t keyLen = 0;
while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) {
@ -1452,7 +1322,7 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup,
TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t));
SResultRowInfo dumyInfo; SResultRowInfo dumyInfo;
dumyInfo.cur.pageId = -1; dumyInfo.cur.pageId = -1;
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, pInterval->precision, TSDB_ORDER_ASC); STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, TSDB_ORDER_ASC);
SWinRes winRe = { SWinRes winRe = {
.ts = win.skey, .ts = win.skey,
.groupId = groupId, .groupId = groupId,
@ -1497,8 +1367,8 @@ static void closeChildIntervalWindow(SArray* pChildren, TSKEY maxTs) {
SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info; SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info;
ASSERT(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE); ASSERT(pChInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);
pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs); pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs);
closeIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, closeIntervalWindow(pChInfo->aggSup.pResultRowHashTable, &pChInfo->twAggSup, &pChInfo->interval, NULL, NULL, NULL,
&pChInfo->interval, NULL, NULL, NULL, pChInfo->aggSup.pResultBuf); pChInfo->aggSup.pResultBuf);
} }
} }
@ -1568,11 +1438,12 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
printDataBlock(pBlock, "single interval recv"); printDataBlock(pBlock, "single interval recv");
if (pBlock->info.type == STREAM_CLEAR) { if (pBlock->info.type == STREAM_CLEAR) {
doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock,
pOperator->exprSupp.numOfExprs, pBlock, NULL); NULL);
qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo)); qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
continue; continue;
} if (pBlock->info.type == STREAM_DELETE_DATA) { }
if (pBlock->info.type == STREAM_DELETE_DATA) {
doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval); doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval);
continue; continue;
} else if (pBlock->info.type == STREAM_GET_ALL) { } else if (pBlock->info.type == STREAM_GET_ALL) {
@ -1597,8 +1468,8 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdated); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdated);
} }
pOperator->status = OP_RES_TO_RETURN; pOperator->status = OP_RES_TO_RETURN;
closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdated,
&pInfo->interval, NULL, pUpdated, pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset); finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset);
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
@ -2391,7 +2262,8 @@ void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) {
SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock* pResBlock, int64_t gap, int32_t tsSlotId, SSDataBlock* pResBlock, int64_t gap, int32_t tsSlotId,
STimeWindowAggSupp* pTwAggSupp, SNode* pCondition, SExecTaskInfo* pTaskInfo) { STimeWindowAggSupp* pTwAggSupp, SNode* pCondition,
SExecTaskInfo* pTaskInfo) {
SSessionAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSessionAggOperatorInfo)); SSessionAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSessionAggOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) { if (pInfo == NULL || pOperator == NULL) {
@ -2470,8 +2342,8 @@ bool hasIntervalWindow(SAggSupporter* pSup, TSKEY ts, uint64_t groupId) {
return p1 != NULL; return p1 != NULL;
} }
static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, SArray* pWinArray,
SArray* pWinArray, int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo, SArray* pUpdated) { int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo, SArray* pUpdated) {
int32_t size = taosArrayGetSize(pWinArray); int32_t size = taosArrayGetSize(pWinArray);
if (!pInfo->pChildren) { if (!pInfo->pChildren) {
return; return;
@ -2480,8 +2352,8 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr
SWinRes* pWinRes = taosArrayGet(pWinArray, i); SWinRes* pWinRes = taosArrayGet(pWinArray, i);
SResultRow* pCurResult = NULL; SResultRow* pCurResult = NULL;
STimeWindow ParentWin = {.skey = pWinRes->ts, .ekey = pWinRes->ts + 1}; STimeWindow ParentWin = {.skey = pWinRes->ts, .ekey = pWinRes->ts + 1};
setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &ParentWin, true, &pCurResult, pWinRes->groupId, pSup->pCtx, numOfOutput, setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &ParentWin, true, &pCurResult, pWinRes->groupId, pSup->pCtx,
pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren); int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren);
bool find = true; bool find = true;
for (int32_t j = 0; j < numOfChildren; j++) { for (int32_t j = 0; j < numOfChildren; j++) {
@ -2493,8 +2365,9 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr
} }
find = true; find = true;
SResultRow* pChResult = NULL; SResultRow* pChResult = NULL;
setTimeWindowOutputBuf(&pChInfo->binfo.resultRowInfo, &ParentWin, true, &pChResult, pWinRes->groupId, pChildSup->pCtx, setTimeWindowOutputBuf(&pChInfo->binfo.resultRowInfo, &ParentWin, true, &pChResult, pWinRes->groupId,
pChildSup->numOfExprs, pChildSup->rowEntryInfoOffset, &pChInfo->aggSup, pTaskInfo); pChildSup->pCtx, pChildSup->numOfExprs, pChildSup->rowEntryInfoOffset, &pChInfo->aggSup,
pTaskInfo);
compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo); compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo);
} }
if (find && pUpdated) { if (find && pUpdated) {
@ -2528,6 +2401,12 @@ void addPullWindow(SHashObj* pMap, SWinRes* pWinRes, int32_t size) {
static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; } static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; }
STimeWindow getFinalTimeWindow(int64_t ts, SInterval* pInterval) {
STimeWindow w = {.skey = ts, .ekey = INT64_MAX};
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
return w;
}
static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId, static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId,
SArray* pUpdated) { SArray* pUpdated) {
SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)pOperatorInfo->info; SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)pOperatorInfo->info;
@ -2547,8 +2426,12 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
int32_t startPos = ascScan ? 0 : (pSDataBlock->info.rows - 1); int32_t startPos = ascScan ? 0 : (pSDataBlock->info.rows - 1);
TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols); TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols);
STimeWindow nextWin = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, STimeWindow nextWin = {0};
pInfo->interval.precision, pInfo->order); if (IS_FINAL_OP(pInfo)) {
nextWin = getFinalTimeWindow(ts, &pInfo->interval);
} else {
nextWin = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->order);
}
while (1) { while (1) {
bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup);
if (pInfo->ignoreExpiredData && isClosed) { if (pInfo->ignoreExpiredData && isClosed) {
@ -2605,8 +2488,12 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
if (IS_FINAL_OP(pInfo)) {
forwardRows = 1;
} else {
forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL,
TSDB_ORDER_ASC); TSDB_ORDER_ASC);
}
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdated) { if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdated) {
saveResultRow(pResult, tableGroupId, pUpdated); saveResultRow(pResult, tableGroupId, pUpdated);
} }
@ -2772,7 +2659,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
clearSpecialDataBlock(pInfo->pUpdateRes); clearSpecialDataBlock(pInfo->pUpdateRes);
removeDeleteResults(pUpdated, pInfo->pDelWins); removeDeleteResults(pUpdated, pInfo->pDelWins);
pOperator->status = OP_RES_TO_RETURN; pOperator->status = OP_RES_TO_RETURN;
qInfo("Stream Final Interval return data"); qInfo("%s return data", IS_FINAL_OP(pInfo) ? "interval Final" : "interval Semi");
break; break;
} }
printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval Final recv" : "interval Semi recv"); printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval Final recv" : "interval Semi recv");
@ -2783,18 +2670,16 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
pInfo->binfo.pRes->info.type = pBlock->info.type; pInfo->binfo.pRes->info.type = pBlock->info.type;
} else if (pBlock->info.type == STREAM_CLEAR) { } else if (pBlock->info.type == STREAM_CLEAR) {
SArray* pUpWins = taosArrayInit(8, sizeof(SWinRes)); SArray* pUpWins = taosArrayInit(8, sizeof(SWinRes));
doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pOperator->exprSupp.numOfExprs, doClearWindows(&pInfo->aggSup, pSup, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pUpWins);
pBlock, pUpWins);
if (IS_FINAL_OP(pInfo)) { if (IS_FINAL_OP(pInfo)) {
int32_t childIndex = getChildIndex(pBlock); int32_t childIndex = getChildIndex(pBlock);
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info; SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info;
SExprSupp* pChildSup = &pChildOp->exprSupp; SExprSupp* pChildSup = &pChildOp->exprSupp;
doClearWindows(&pChildInfo->aggSup, pChildSup, &pChildInfo->interval, doClearWindows(&pChildInfo->aggSup, pChildSup, &pChildInfo->interval, pChildSup->numOfExprs, pBlock, NULL);
pChildSup->numOfExprs, pBlock, NULL); rebuildIntervalWindow(pInfo, pSup, pUpWins, pInfo->binfo.pRes->info.groupId, pOperator->exprSupp.numOfExprs,
rebuildIntervalWindow(pInfo, pSup, pUpWins, pInfo->binfo.pRes->info.groupId, pOperator->pTaskInfo, NULL);
pOperator->exprSupp.numOfExprs, pOperator->pTaskInfo, NULL);
taosArrayDestroy(pUpWins); taosArrayDestroy(pUpWins);
continue; continue;
} }
@ -2834,6 +2719,10 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
continue; continue;
} }
if (pInfo->scalarSupp.pExprInfo != NULL) {
SExprSupp* pExprSup = &pInfo->scalarSupp;
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
}
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, MAIN_SCAN, true); setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
doHashInterval(pOperator, pBlock, pBlock->info.groupId, pUpdated); doHashInterval(pOperator, pBlock, pBlock->info.groupId, pUpdated);
if (IS_FINAL_OP(pInfo)) { if (IS_FINAL_OP(pInfo)) {
@ -2862,8 +2751,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
if (IS_FINAL_OP(pInfo)) { if (IS_FINAL_OP(pInfo)) {
closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, pInfo->pPullDataMap,
&pInfo->interval, pInfo->pPullDataMap, pUpdated, pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); pUpdated, pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
closeChildIntervalWindow(pInfo->pChildren, pInfo->twAggSup.maxTs); closeChildIntervalWindow(pInfo->pChildren, pInfo->twAggSup.maxTs);
} }
@ -2951,6 +2840,15 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
initResultSizeInfo(pOperator, 4096); initResultSizeInfo(pOperator, 4096);
if (pIntervalPhyNode->window.pExprs != NULL) {
int32_t numOfScalar = 0;
SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar);
int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
}
int32_t numOfCols = 0; int32_t numOfCols = 0;
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols); SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols);
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
@ -3117,6 +3015,14 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
} }
initResultSizeInfo(pOperator, 4096); initResultSizeInfo(pOperator, 4096);
if (pSessionNode->window.pExprs != NULL) {
int32_t numOfScalar = 0;
SExprInfo* pScalarExprInfo = createExprInfo(pSessionNode->window.pExprs, NULL, &numOfScalar);
int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
}
SExprSupp* pSup = &pOperator->exprSupp; SExprSupp* pSup = &pOperator->exprSupp;
code = initBasicInfoEx(&pInfo->binfo, pSup, pExprInfo, numOfCols, pResBlock); code = initBasicInfoEx(&pInfo->binfo, pSup, pExprInfo, numOfCols, pResBlock);
@ -3206,9 +3112,7 @@ bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap) {
return false; return false;
} }
bool isInWindow(SResultWindowInfo* pWinInfo, TSKEY ts, int64_t gap) { bool isInWindow(SResultWindowInfo* pWinInfo, TSKEY ts, int64_t gap) { return isInTimeWindow(&pWinInfo->win, ts, gap); }
return isInTimeWindow(&pWinInfo->win, ts, gap);
}
static SResultWindowInfo* insertNewSessionWindow(SArray* pWinInfos, TSKEY ts, int32_t index) { static SResultWindowInfo* insertNewSessionWindow(SArray* pWinInfos, TSKEY ts, int32_t index) {
SResultWindowInfo win = {.pos.offset = -1, .pos.pageId = -1, .win.skey = ts, .win.ekey = ts, .isOutput = false}; SResultWindowInfo win = {.pos.offset = -1, .pos.pageId = -1, .win.skey = ts, .win.ekey = ts, .isOutput = false};
@ -3522,8 +3426,7 @@ static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc
for (int32_t i = 0; i < pBlock->info.rows; i++) { for (int32_t i = 0; i < pBlock->info.rows; i++) {
int32_t winIndex = 0; int32_t winIndex = 0;
while (1) { while (1) {
SResultWindowInfo* pCurWin = SResultWindowInfo* pCurWin = getCurSessionWindow(pAggSup, startDatas[i], endDatas[i], gpDatas[i], gap, &winIndex);
getCurSessionWindow(pAggSup, startDatas[i], endDatas[i], gpDatas[i], gap, &winIndex);
if (!pCurWin) { if (!pCurWin) {
break; break;
} }
@ -3573,6 +3476,7 @@ static int32_t copyUpdateResult(SHashObj* pStUpdated, SArray* pUpdated) {
*(int64_t*)pos->key = ((SWinRes*)pData)->ts; *(int64_t*)pos->key = ((SWinRes*)pData)->ts;
taosArrayPush(pUpdated, &pos); taosArrayPush(pUpdated, &pos);
} }
taosArraySort(pUpdated, resultrowComparAsc);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -3755,8 +3659,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
if (pBlock->info.type == STREAM_CLEAR) { if (pBlock->info.type == STREAM_CLEAR) {
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
doClearSessionWindows(&pInfo->streamAggSup, &pOperator->exprSupp, pBlock, 0, pOperator->exprSupp.numOfExprs, doClearSessionWindows(&pInfo->streamAggSup, &pOperator->exprSupp, pBlock, 0, pOperator->exprSupp.numOfExprs, 0,
0, pWins); pWins);
if (IS_FINAL_OP(pInfo)) { if (IS_FINAL_OP(pInfo)) {
int32_t childIndex = getChildIndex(pBlock); int32_t childIndex = getChildIndex(pBlock);
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
@ -3787,6 +3691,10 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
continue; continue;
} }
if (pInfo->scalarSupp.pExprInfo != NULL) {
SExprSupp* pExprSup = &pInfo->scalarSupp;
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
}
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, IS_FINAL_OP(pInfo)); doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, IS_FINAL_OP(pInfo));
@ -3919,6 +3827,10 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
continue; continue;
} }
if (pInfo->scalarSupp.pExprInfo != NULL) {
SExprSupp* pExprSup = &pInfo->scalarSupp;
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
}
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, false); doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, false);
@ -4315,6 +4227,10 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
continue; continue;
} }
if (pInfo->scalarSupp.pExprInfo != NULL) {
SExprSupp* pExprSup = &pInfo->scalarSupp;
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
}
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted); doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted);
@ -4368,6 +4284,15 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
pInfo->stateCol = extractColumnFromColumnNode(pColNode); pInfo->stateCol = extractColumnFromColumnNode(pColNode);
initResultSizeInfo(pOperator, 4096); initResultSizeInfo(pOperator, 4096);
if (pStateNode->window.pExprs != NULL) {
int32_t numOfScalar = 0;
SExprInfo* pScalarExprInfo = createExprInfo(pStateNode->window.pExprs, NULL, &numOfScalar);
int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
}
initResultRowInfo(&pInfo->binfo.resultRowInfo); initResultRowInfo(&pInfo->binfo.resultRowInfo);
pInfo->twAggSup = (STimeWindowAggSupp){ pInfo->twAggSup = (STimeWindowAggSupp){
.waterMark = pStateNode->window.watermark, .waterMark = pStateNode->window.watermark,
@ -4428,17 +4353,6 @@ _error:
return NULL; return NULL;
} }
typedef struct SMergeAlignedIntervalAggOperatorInfo {
SIntervalAggOperatorInfo *intervalAggOperatorInfo;
bool hasGroupId;
uint64_t groupId;
SSDataBlock* prefetchedBlock;
bool inputBlocksFinished;
SNode* pCondition;
} SMergeAlignedIntervalAggOperatorInfo;
void destroyMergeAlignedIntervalOperatorInfo(void* param, int32_t numOfOutput) { void destroyMergeAlignedIntervalOperatorInfo(void* param, int32_t numOfOutput) {
SMergeAlignedIntervalAggOperatorInfo* miaInfo = (SMergeAlignedIntervalAggOperatorInfo*)param; SMergeAlignedIntervalAggOperatorInfo* miaInfo = (SMergeAlignedIntervalAggOperatorInfo*)param;
destroyIntervalOperatorInfo(miaInfo->intervalAggOperatorInfo, numOfOutput); destroyIntervalOperatorInfo(miaInfo->intervalAggOperatorInfo, numOfOutput);
@ -4514,7 +4428,8 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
currTs = tsCols[currPos]; currTs = tsCols[currPos];
currWin.skey = currTs; currWin.skey = currTs;
currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit,
iaInfo->interval.precision) - 1; iaInfo->interval.precision) -
1;
startPos = currPos; startPos = currPos;
ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
@ -4593,7 +4508,8 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo,
int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval,
int32_t primaryTsSlotId, SNode* pCondition, SExecTaskInfo* pTaskInfo) { int32_t primaryTsSlotId, SNode* pCondition,
SExecTaskInfo* pTaskInfo) {
SMergeAlignedIntervalAggOperatorInfo* miaInfo = taosMemoryCalloc(1, sizeof(SMergeAlignedIntervalAggOperatorInfo)); SMergeAlignedIntervalAggOperatorInfo* miaInfo = taosMemoryCalloc(1, sizeof(SMergeAlignedIntervalAggOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (miaInfo == NULL || pOperator == NULL) { if (miaInfo == NULL || pOperator == NULL) {
@ -4725,7 +4641,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t
continue; continue;
} }
STimeWindow* prevWin = &prevGrpWin->window; STimeWindow* prevWin = &prevGrpWin->window;
if ((ascScan && newWin->skey > prevWin->ekey || (!ascScan) && newWin->skey < prevWin->ekey)) { if ((ascScan && newWin->skey > prevWin->ekey) || ((!ascScan) && newWin->skey < prevWin->ekey)) {
finalizeWindowResult(pOperatorInfo, tableGroupId, prevWin, pResultBlock); finalizeWindowResult(pOperatorInfo, tableGroupId, prevWin, pResultBlock);
tdListPopNode(miaInfo->groupIntervals, listNode); tdListPopNode(miaInfo->groupIntervals, listNode);
} }
@ -4750,8 +4666,8 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols); TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols);
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
STimeWindow win = getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, STimeWindow win =
iaInfo->interval.precision, iaInfo->order); getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, iaInfo->order);
int32_t ret = int32_t ret =
setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,

View File

@ -1863,8 +1863,6 @@ static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) {
} }
pOutput->count += pInput->count; pOutput->count += pInput->count;
return;
} }
int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) { int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) {
@ -1874,14 +1872,13 @@ int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) {
SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
int32_t start = pInput->startRowIndex; for(int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
char* data = colDataGetData(pCol, start); char* data = colDataGetData(pCol, i);
SStddevRes* pInputInfo = (SStddevRes*)varDataVal(data); SStddevRes* pInputInfo = (SStddevRes*)varDataVal(data);
stddevTransferInfo(pInputInfo, pInfo); stddevTransferInfo(pInputInfo, pInfo);
}
SET_VAL(GET_RES_INFO(pCtx), 1, 1); SET_VAL(GET_RES_INFO(pCtx), 1, 1);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -139,7 +139,7 @@ bool fmIsAggFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MG
bool fmIsScalarFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SCALAR_FUNC); } bool fmIsScalarFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SCALAR_FUNC); }
bool fmIsVectorFunc(int32_t funcId) { return !fmIsScalarFunc(funcId); } bool fmIsVectorFunc(int32_t funcId) { return !fmIsScalarFunc(funcId) && !fmIsScanPseudoColumnFunc(funcId); }
bool fmIsSelectFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SELECT_FUNC); } bool fmIsSelectFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_SELECT_FUNC); }

View File

@ -4,6 +4,7 @@
#include "tutil.h" #include "tutil.h"
extern const uint8_t COMMON_INPUTS[]; extern const uint8_t COMMON_INPUTS[];
extern const char COMMON_INPUTS_INV[]; extern const char COMMON_INPUTS_INV[];
extern const int32_t COMMON_INPUTS_LEN;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -32,7 +32,7 @@ typedef struct {
SArray *insts; SArray *insts;
uint32_t next[256]; uint32_t next[256];
bool isMatch; bool isMatch;
} State; } DfaState;
/* /*
* dfa builder related func * dfa builder related func
@ -51,7 +51,7 @@ FstDfa *dfaBuilderBuild(FstDfaBuilder *builder);
bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet *next, uint32_t state, uint8_t bytes, bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet *next, uint32_t state, uint8_t bytes,
uint32_t *result); uint32_t *result);
bool dfaBuilderCachedState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *result); bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *result);
/* /*
* dfa related func * dfa related func

View File

@ -65,6 +65,7 @@ typedef struct {
} FstRegex; } FstRegex;
FstRegex *regexCreate(const char *str); FstRegex *regexCreate(const char *str);
void regexDestroy(FstRegex *regex);
uint32_t regexAutomStart(FstRegex *regex); uint32_t regexAutomStart(FstRegex *regex);
bool regexAutomIsMatch(FstRegex *regex, uint32_t state); bool regexAutomIsMatch(FstRegex *regex, uint32_t state);

View File

@ -23,17 +23,18 @@ extern "C" {
#endif #endif
typedef struct FstSparseSet { typedef struct FstSparseSet {
uint32_t *dense; int32_t *dense;
uint32_t *sparse; int32_t *sparse;
int32_t size; int32_t size;
int32_t cap;
} FstSparseSet; } FstSparseSet;
FstSparseSet *sparSetCreate(int32_t sz); FstSparseSet *sparSetCreate(int32_t sz);
void sparSetDestroy(FstSparseSet *s); void sparSetDestroy(FstSparseSet *s);
uint32_t sparSetLen(FstSparseSet *ss); uint32_t sparSetLen(FstSparseSet *ss);
uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip); bool sparSetAdd(FstSparseSet *ss, int32_t ip, int32_t *val);
uint32_t sparSetGet(FstSparseSet *ss, uint32_t i); bool sparSetGet(FstSparseSet *ss, int32_t i, int32_t *val);
bool sparSetContains(FstSparseSet *ss, uint32_t ip); bool sparSetContains(FstSparseSet *ss, int32_t ip);
void sparSetClear(FstSparseSet *ss); void sparSetClear(FstSparseSet *ss);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -22,7 +22,7 @@
#define MAX_INDEX_KEY_LEN 256 // test only, change later #define MAX_INDEX_KEY_LEN 256 // test only, change later
#define MEM_TERM_LIMIT 10 * 10000 #define MEM_TERM_LIMIT 10 * 10000
#define MEM_THRESHOLD 64 * 1024 #define MEM_THRESHOLD 512 * 1024
#define MEM_SIGNAL_QUIT MEM_THRESHOLD * 20 #define MEM_SIGNAL_QUIT MEM_THRESHOLD * 20
#define MEM_ESTIMATE_RADIO 1.5 #define MEM_ESTIMATE_RADIO 1.5
@ -204,7 +204,6 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr
if (0 == strcmp(c->colVal, pCt->colVal)) { if (0 == strcmp(c->colVal, pCt->colVal)) {
if (c->operaType == ADD_VALUE) { if (c->operaType == ADD_VALUE) {
INDEX_MERGE_ADD_DEL(tr->del, tr->add, c->uid) INDEX_MERGE_ADD_DEL(tr->del, tr->add, c->uid)
// taosArrayPush(result, &c->uid);
*s = kTypeValue; *s = kTypeValue;
} else if (c->operaType == DEL_VALUE) { } else if (c->operaType == DEL_VALUE) {
INDEX_MERGE_ADD_DEL(tr->add, tr->del, c->uid) INDEX_MERGE_ADD_DEL(tr->add, tr->del, c->uid)
@ -309,7 +308,6 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
if (cond == MATCH) { if (cond == MATCH) {
if (c->operaType == ADD_VALUE) { if (c->operaType == ADD_VALUE) {
INDEX_MERGE_ADD_DEL(tr->del, tr->add, c->uid) INDEX_MERGE_ADD_DEL(tr->del, tr->add, c->uid)
// taosArrayPush(result, &c->uid);
*s = kTypeValue; *s = kTypeValue;
} else if (c->operaType == DEL_VALUE) { } else if (c->operaType == DEL_VALUE) {
INDEX_MERGE_ADD_DEL(tr->add, tr->del, c->uid) INDEX_MERGE_ADD_DEL(tr->add, tr->del, c->uid)

View File

@ -1307,7 +1307,6 @@ FStmStRslt* stmStNextWith(FStmSt* sws, StreamCallback callback) {
taosArrayPush(sws->inp, &(trn.inp)); taosArrayPush(sws->inp, &(trn.inp));
if (FST_NODE_IS_FINAL(nextNode)) { if (FST_NODE_IS_FINAL(nextNode)) {
// void *eofState = sws->aut->acceptEof(nextState);
void* eofState = automFuncs[aut->type].acceptEof(aut, nextState); void* eofState = automFuncs[aut->type].acceptEof(aut, nextState);
if (eofState != NULL) { if (eofState != NULL) {
isMatch = automFuncs[aut->type].isMatch(aut, eofState); isMatch = automFuncs[aut->type].isMatch(aut, eofState);

View File

@ -294,3 +294,4 @@ const char COMMON_INPUTS_INV[] = {
'\xee', '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7', '\xf8', '\xf9', '\xfa', '\xfb', '\xee', '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7', '\xf8', '\xf9', '\xfa', '\xfb',
'\xfc', '\xfd', '\xfe', '\xff', '\xfc', '\xfd', '\xfe', '\xff',
}; };
const int32_t COMMON_INPUTS_LEN = sizeof(COMMON_INPUTS) / sizeof(COMMON_INPUTS[0]);

View File

@ -41,7 +41,7 @@ FstDfaBuilder *dfaBuilderCreate(SArray *insts) {
return NULL; return NULL;
} }
SArray *states = taosArrayInit(4, sizeof(State)); SArray *states = taosArrayInit(4, sizeof(DfaState));
builder->dfa = dfaCreate(insts, states); builder->dfa = dfaCreate(insts, states);
builder->cache = taosHashInit( builder->cache = taosHashInit(
@ -64,7 +64,7 @@ void dfaBuilderDestroy(FstDfaBuilder *builder) {
taosMemoryFree(builder); taosMemoryFree(builder);
} }
FstDfa *dfaBuilder(FstDfaBuilder *builder) { FstDfa *dfaBuilderBuild(FstDfaBuilder *builder) {
uint32_t sz = taosArrayGetSize(builder->dfa->insts); uint32_t sz = taosArrayGetSize(builder->dfa->insts);
FstSparseSet *cur = sparSetCreate(sz); FstSparseSet *cur = sparSetCreate(sz);
FstSparseSet *nxt = sparSetCreate(sz); FstSparseSet *nxt = sparSetCreate(sz);
@ -73,7 +73,7 @@ FstDfa *dfaBuilder(FstDfaBuilder *builder) {
SArray *states = taosArrayInit(0, sizeof(uint32_t)); SArray *states = taosArrayInit(0, sizeof(uint32_t));
uint32_t result; uint32_t result;
if (dfaBuilderCachedState(builder, cur, &result)) { if (dfaBuilderCacheState(builder, cur, &result)) {
taosArrayPush(states, &result); taosArrayPush(states, &result);
} }
SHashObj *seen = taosHashInit(12, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); SHashObj *seen = taosHashInit(12, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
@ -101,17 +101,18 @@ FstDfa *dfaBuilder(FstDfaBuilder *builder) {
bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet *next, uint32_t state, uint8_t byte, bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet *next, uint32_t state, uint8_t byte,
uint32_t *result) { uint32_t *result) {
sparSetClear(cur); sparSetClear(cur);
State *t = taosArrayGet(builder->dfa->states, state); DfaState *t = taosArrayGet(builder->dfa->states, state);
for (int i = 0; i < taosArrayGetSize(t->insts); i++) { for (int i = 0; i < taosArrayGetSize(t->insts); i++) {
uint32_t ip = *(int32_t *)taosArrayGet(t->insts, i); int32_t ip = *(int32_t *)taosArrayGet(t->insts, i);
sparSetAdd(cur, ip); bool succ = sparSetAdd(cur, ip, NULL);
assert(succ == true);
} }
dfaRun(builder->dfa, cur, next, byte); dfaRun(builder->dfa, cur, next, byte);
t = taosArrayGet(builder->dfa->states, state); t = taosArrayGet(builder->dfa->states, state);
uint32_t nxtState; uint32_t nxtState;
if (dfaBuilderCachedState(builder, next, &nxtState)) { if (dfaBuilderCacheState(builder, next, &nxtState)) {
t->next[byte] = nxtState; t->next[byte] = nxtState;
*result = nxtState; *result = nxtState;
return true; return true;
@ -119,12 +120,13 @@ bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet
return false; return false;
} }
bool dfaBuilderCachedState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *result) { bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *result) {
SArray *tinsts = taosArrayInit(4, sizeof(uint32_t)); SArray *tinsts = taosArrayInit(4, sizeof(uint32_t));
bool isMatch = false; bool isMatch = false;
for (int i = 0; i < sparSetLen(set); i++) { for (int i = 0; i < sparSetLen(set); i++) {
uint32_t ip = sparSetGet(set, i); int32_t ip;
if (false == sparSetGet(set, i, &ip)) continue;
Inst *inst = taosArrayGet(builder->dfa->insts, ip); Inst *inst = taosArrayGet(builder->dfa->insts, ip);
if (inst->ty == JUMP || inst->ty == SPLIT) { if (inst->ty == JUMP || inst->ty == SPLIT) {
@ -144,7 +146,7 @@ bool dfaBuilderCachedState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *
*result = *v; *result = *v;
taosArrayDestroy(tinsts); taosArrayDestroy(tinsts);
} else { } else {
State st; DfaState st;
st.insts = tinsts; st.insts = tinsts;
st.isMatch = isMatch; st.isMatch = isMatch;
taosArrayPush(builder->dfa->states, &st); taosArrayPush(builder->dfa->states, &st);
@ -169,14 +171,14 @@ bool dfaIsMatch(FstDfa *dfa, uint32_t si) {
if (dfa->states == NULL || si < taosArrayGetSize(dfa->states)) { if (dfa->states == NULL || si < taosArrayGetSize(dfa->states)) {
return false; return false;
} }
State *st = taosArrayGet(dfa->states, si); DfaState *st = taosArrayGet(dfa->states, si);
return st != NULL ? st->isMatch : false; return st != NULL ? st->isMatch : false;
} }
bool dfaAccept(FstDfa *dfa, uint32_t si, uint8_t byte, uint32_t *result) { bool dfaAccept(FstDfa *dfa, uint32_t si, uint8_t byte, uint32_t *result) {
if (dfa->states == NULL || si < taosArrayGetSize(dfa->states)) { if (dfa->states == NULL || si < taosArrayGetSize(dfa->states)) {
return false; return false;
} }
State *st = taosArrayGet(dfa->states, si); DfaState *st = taosArrayGet(dfa->states, si);
*result = st->next[byte]; *result = st->next[byte];
return true; return true;
} }
@ -184,7 +186,8 @@ void dfaAdd(FstDfa *dfa, FstSparseSet *set, uint32_t ip) {
if (sparSetContains(set, ip)) { if (sparSetContains(set, ip)) {
return; return;
} }
sparSetAdd(set, ip); bool succ = sparSetAdd(set, ip, NULL);
// assert(succ == true);
Inst *inst = taosArrayGet(dfa->insts, ip); Inst *inst = taosArrayGet(dfa->insts, ip);
if (inst->ty == MATCH || inst->ty == RANGE) { if (inst->ty == MATCH || inst->ty == RANGE) {
// do nothing // do nothing
@ -201,7 +204,8 @@ bool dfaRun(FstDfa *dfa, FstSparseSet *from, FstSparseSet *to, uint8_t byte) {
bool isMatch = false; bool isMatch = false;
sparSetClear(to); sparSetClear(to);
for (int i = 0; i < sparSetLen(from); i++) { for (int i = 0; i < sparSetLen(from); i++) {
uint32_t ip = sparSetGet(from, i); int32_t ip;
if (false == sparSetGet(from, i, &ip)) continue;
Inst *inst = taosArrayGet(dfa->insts, ip); Inst *inst = taosArrayGet(dfa->insts, ip);
if (inst->ty == JUMP || inst->ty == SPLIT) { if (inst->ty == JUMP || inst->ty == SPLIT) {

View File

@ -22,20 +22,26 @@ FstRegex *regexCreate(const char *str) {
if (regex == NULL) { if (regex == NULL) {
return NULL; return NULL;
} }
int32_t sz = (int32_t)strlen(str);
char * orig = taosMemoryCalloc(1, sz);
memcpy(orig, str, sz);
regex->orig = orig; regex->orig = tstrdup(str);
// construct insts based on str // construct insts based on str
SArray *insts = NULL; SArray *insts = taosArrayInit(256, sizeof(uint8_t));
for (int i = 0; i < strlen(str); i++) {
uint8_t v = str[i];
taosArrayPush(insts, &v);
}
FstDfaBuilder *builder = dfaBuilderCreate(insts); FstDfaBuilder *builder = dfaBuilderCreate(insts);
regex->dfa = dfaBuilderBuild(builder); regex->dfa = dfaBuilderBuild(builder);
return regex; return regex;
} }
void regexDestroy(FstRegex *regex) {
if (regex == NULL) return;
taosMemoryFree(regex->orig);
taosMemoryFree(regex);
}
uint32_t regexAutomStart(FstRegex *regex) { uint32_t regexAutomStart(FstRegex *regex) {
///// no nothing ///// no nothing
return 0; return 0;

View File

@ -15,14 +15,24 @@
#include "indexFstSparse.h" #include "indexFstSparse.h"
static void sparSetUtil(int32_t *buf, int32_t cap) {
for (int32_t i = 0; i < cap; i++) {
buf[i] = -1;
}
}
FstSparseSet *sparSetCreate(int32_t sz) { FstSparseSet *sparSetCreate(int32_t sz) {
FstSparseSet *ss = taosMemoryCalloc(1, sizeof(FstSparseSet)); FstSparseSet *ss = taosMemoryCalloc(1, sizeof(FstSparseSet));
if (ss == NULL) { if (ss == NULL) {
return NULL; return NULL;
} }
ss->dense = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t)); ss->dense = (int32_t *)taosMemoryMalloc(sz * sizeof(int32_t));
ss->sparse = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t)); ss->sparse = (int32_t *)taosMemoryMalloc(sz * sizeof(int32_t));
sparSetUtil(ss->dense, sz);
sparSetUtil(ss->sparse, sz);
ss->cap = sz;
ss->size = 0; ss->size = 0;
return ss; return ss;
} }
@ -38,23 +48,39 @@ uint32_t sparSetLen(FstSparseSet *ss) {
// Get occupied size // Get occupied size
return ss == NULL ? 0 : ss->size; return ss == NULL ? 0 : ss->size;
} }
uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip) { bool sparSetAdd(FstSparseSet *ss, int32_t ip, int32_t *idx) {
if (ss == NULL) { if (ss == NULL) {
return 0; return false;
}
if (ip >= ss->cap || ip < 0) {
return false;
} }
uint32_t i = ss->size; uint32_t i = ss->size;
ss->dense[i] = ip; ss->dense[i] = ip;
ss->sparse[ip] = i; ss->sparse[ip] = i;
ss->size += 1; ss->size += 1;
return i;
if (idx != NULL) *idx = i;
return true;
} }
uint32_t sparSetGet(FstSparseSet *ss, uint32_t i) { bool sparSetGet(FstSparseSet *ss, int32_t idx, int32_t *ip) {
// check later if (idx >= ss->cap || idx >= ss->size || idx < 0) {
return ss->dense[i]; return false;
} }
bool sparSetContains(FstSparseSet *ss, uint32_t ip) { int32_t val = ss->dense[idx];
uint32_t i = ss->sparse[ip]; if (ip != NULL) {
if (i < ss->size && ss->dense[i] == ip) { *ip = val;
}
return val == -1 ? false : true;
}
bool sparSetContains(FstSparseSet *ss, int32_t ip) {
if (ip >= ss->cap || ip < 0) {
return false;
}
int32_t i = ss->sparse[ip];
if (i >= 0 && i < ss->cap && i < ss->size && ss->dense[i] == ip) {
return true; return true;
} else { } else {
return false; return false;
@ -64,5 +90,7 @@ void sparSetClear(FstSparseSet *ss) {
if (ss == NULL) { if (ss == NULL) {
return; return;
} }
sparSetUtil(ss->dense, ss->cap);
sparSetUtil(ss->sparse, ss->cap);
ss->size = 0; ss->size = 0;
} }

View File

@ -4,6 +4,7 @@ IF(NOT TD_DARWIN)
add_executable(idxFstUT "") add_executable(idxFstUT "")
add_executable(idxUtilUT "") add_executable(idxUtilUT "")
add_executable(idxJsonUT "") add_executable(idxJsonUT "")
add_executable(idxFstUtilUT "")
target_sources(idxTest target_sources(idxTest
PRIVATE PRIVATE
@ -23,6 +24,25 @@ IF(NOT TD_DARWIN)
"utilUT.cc" "utilUT.cc"
) )
target_sources(idxJsonUT
PRIVATE
"jsonUT.cc"
)
target_sources(idxFstUtilUT
PRIVATE
"fstUtilUT.cc"
)
target_include_directories (idxTest
PUBLIC
"${TD_SOURCE_DIR}/include/libs/index"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
target_include_directories (idxFstTest
PUBLIC
"${TD_SOURCE_DIR}/include/libs/index"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
target_sources(idxJsonUT target_sources(idxJsonUT
PRIVATE PRIVATE
"jsonUT.cc" "jsonUT.cc"
@ -50,6 +70,38 @@ IF(NOT TD_DARWIN)
"${CMAKE_CURRENT_SOURCE_DIR}/../inc" "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
) )
target_include_directories (idxJsonUT
PUBLIC
"${TD_SOURCE_DIR}/include/libs/index"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
target_include_directories (idxFstUtilUT
PUBLIC
"${TD_SOURCE_DIR}/include/libs/index"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
target_link_libraries (idxTest
os
util
common
gtest_main
index
)
target_link_libraries (idxFstTest
os
util
common
gtest_main
index
)
target_link_libraries (idxFstUT
os
util
common
gtest_main
index
)
target_include_directories (idxJsonUT target_include_directories (idxJsonUT
PUBLIC PUBLIC
"${TD_SOURCE_DIR}/include/libs/index" "${TD_SOURCE_DIR}/include/libs/index"
@ -92,15 +144,28 @@ IF(NOT TD_DARWIN)
gtest_main gtest_main
index index
) )
target_link_libraries (idxFstUtilUT
os
util
common
gtest_main
index
)
add_test(
NAME idxJsonUT
COMMAND idxJsonUT
)
add_test(
NAME idxFstUtilUT
COMMAND idxFstUtilUT
)
add_test( add_test(
NAME idxtest NAME idxtest
COMMAND idxTest COMMAND idxTest
) )
add_test(
NAME idxJsonUT
COMMAND idxJsonUT
)
add_test( add_test(
NAME idxUtilUT NAME idxUtilUT
COMMAND idxUtilUT COMMAND idxUtilUT

View File

@ -0,0 +1,112 @@
#include <gtest/gtest.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include "index.h"
#include "indexCache.h"
#include "indexFst.h"
#include "indexFstDfa.h"
#include "indexFstRegex.h"
#include "indexFstSparse.h"
#include "indexFstUtil.h"
#include "indexInt.h"
#include "indexTfile.h"
#include "tglobal.h"
#include "tlog.h"
#include "tskiplist.h"
#include "tutil.h"
class FstUtilEnv : public ::testing::Test {
protected:
virtual void SetUp() {
SArray *inst = taosArrayInit(4, sizeof(char));
builder = dfaBuilderCreate(inst);
}
virtual void TearDown() { dfaBuilderDestroy(builder); }
FstDfaBuilder *builder;
};
class FstRegexEnv : public ::testing::Test {
protected:
virtual void SetUp() { regex = regexCreate("test"); }
virtual void TearDown() { regexDestroy(regex); }
FstRegex *regex;
};
class FstSparseSetEnv : public ::testing::Test {
protected:
virtual void SetUp() { set = sparSetCreate(256); }
virtual void TearDown() {
// tear down
sparSetDestroy(set);
}
void ReBuild(int32_t sz) {
sparSetDestroy(set);
set = sparSetCreate(sz);
}
FstSparseSet *set;
};
// test FstDfaBuilder
TEST_F(FstUtilEnv, test1) {
// test
}
TEST_F(FstUtilEnv, test2) {
// test
}
TEST_F(FstUtilEnv, test3) {
// test
}
TEST_F(FstUtilEnv, test4) {
// test
}
// test FstRegex
TEST_F(FstRegexEnv, test1) {
//
EXPECT_EQ(regex != NULL, true);
}
TEST_F(FstRegexEnv, test2) {}
TEST_F(FstRegexEnv, test3) {}
TEST_F(FstRegexEnv, test4) {}
// test FstSparseSet
TEST_F(FstSparseSetEnv, test1) {
for (int8_t i = 0; i < 20; i++) {
int32_t val = -1;
bool succ = sparSetAdd(set, 'a' + i, &val);
}
EXPECT_EQ(sparSetLen(set), 20);
for (int8_t i = 0; i < 20; i++) {
int val = -1;
bool find = sparSetGet(set, i, &val);
EXPECT_EQ(find, true);
EXPECT_EQ(val, i + 'a');
}
for (int8_t i = 'a'; i < 'a' + 20; i++) {
EXPECT_EQ(sparSetContains(set, i), true);
}
for (int8_t i = 'A'; i < 20; i++) {
EXPECT_EQ(sparSetContains(set, 'A'), false);
}
for (int i = 512; i < 1000; i++) {
EXPECT_EQ(sparSetAdd(set, i, NULL), false);
EXPECT_EQ(sparSetGet(set, i, NULL), false);
EXPECT_EQ(sparSetContains(set, i), false);
}
sparSetClear(set);
for (int i = 'a'; i < 'a' + 20; i++) {
EXPECT_EQ(sparSetGet(set, i, NULL), false);
}
for (int i = 1000; i < 2000; i++) {
EXPECT_EQ(sparSetGet(set, i, NULL), false);
}
}

View File

@ -8,6 +8,7 @@
#include "indexCache.h" #include "indexCache.h"
#include "indexComm.h" #include "indexComm.h"
#include "indexFst.h" #include "indexFst.h"
#include "indexFstCommon.h"
#include "indexFstUtil.h" #include "indexFstUtil.h"
#include "indexInt.h" #include "indexInt.h"
#include "indexTfile.h" #include "indexTfile.h"
@ -356,3 +357,11 @@ TEST_F(UtilEnv, TempResultExcept) {
idxTRsltMergeTo(relt, f); idxTRsltMergeTo(relt, f);
EXPECT_EQ(taosArrayGetSize(f), 1); EXPECT_EQ(taosArrayGetSize(f), 1);
} }
TEST_F(UtilEnv, testDictComm) {
int32_t count = COMMON_INPUTS_LEN;
for (int i = 0; i < 256; i++) {
uint8_t v = COMMON_INPUTS_INV[i];
EXPECT_EQ(COMMON_INPUTS[v], i);
}
}

View File

@ -543,11 +543,40 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
static const char* jkScanLogicPlanScanCols = "ScanCols"; static const char* jkScanLogicPlanScanCols = "ScanCols";
static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols"; static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
static const char* jkScanLogicPlanTableId = "TableId";
static const char* jkScanLogicPlanTableType = "TableType"; static const char* jkScanLogicPlanTableType = "TableType";
static const char* jkScanLogicPlanTableId = "TableId";
static const char* jkScanLogicPlanStableId = "StableId";
static const char* jkScanLogicPlanScanCount = "ScanCount";
static const char* jkScanLogicPlanReverseScanCount = "ReverseScanCount";
static const char* jkScanLogicPlanTagCond = "TagCond"; static const char* jkScanLogicPlanTagCond = "TagCond";
static const char* jkScanLogicPlanGroupTags = "GroupTags"; static const char* jkScanLogicPlanGroupTags = "GroupTags";
// typedef struct SScanLogicNode {
// uint64_t stableId;
// SVgroupsInfo* pVgroupList;
// EScanType scanType;
// uint8_t scanSeq[2]; // first is scan count, and second is reverse scan count
// STimeWindow scanRange;
// SName tableName;
// bool showRewrite;
// double ratio;
// SNodeList* pDynamicScanFuncs;
// int32_t dataRequired;
// int64_t interval;
// int64_t offset;
// int64_t sliding;
// int8_t intervalUnit;
// int8_t slidingUnit;
// SNode* pTagCond;
// SNode* pTagIndexCond;
// int8_t triggerType;
// int64_t watermark;
// int8_t igExpired;
// SArray* pSmaIndexes;
// SNodeList* pGroupTags;
// bool groupSort;
// } SScanLogicNode;
static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) { static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
const SScanLogicNode* pNode = (const SScanLogicNode*)pObj; const SScanLogicNode* pNode = (const SScanLogicNode*)pObj;
@ -558,11 +587,20 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = nodeListToJson(pJson, jkScanLogicPlanScanPseudoCols, pNode->pScanPseudoCols); code = nodeListToJson(pJson, jkScanLogicPlanScanPseudoCols, pNode->pScanPseudoCols);
} }
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableType, pNode->tableType);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableId, pNode->tableId); code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableId, pNode->tableId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableType, pNode->tableType); code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanStableId, pNode->stableId);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanScanCount, pNode->scanSeq[0]);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanReverseScanCount, pNode->scanSeq[1]);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond); code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond);
@ -585,11 +623,20 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeList(pJson, jkScanLogicPlanScanPseudoCols, &pNode->pScanPseudoCols); code = jsonToNodeList(pJson, jkScanLogicPlanScanPseudoCols, &pNode->pScanPseudoCols);
} }
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetTinyIntValue(pJson, jkScanLogicPlanTableType, &pNode->tableType);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetUBigIntValue(pJson, jkScanLogicPlanTableId, &pNode->tableId); code = tjsonGetUBigIntValue(pJson, jkScanLogicPlanTableId, &pNode->tableId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetTinyIntValue(pJson, jkScanLogicPlanTableType, &pNode->tableType); code = tjsonGetUBigIntValue(pJson, jkScanLogicPlanStableId, &pNode->stableId);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetUTinyIntValue(pJson, jkScanLogicPlanScanCount, &pNode->scanSeq[0]);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetUTinyIntValue(pJson, jkScanLogicPlanReverseScanCount, &pNode->scanSeq[1]);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond); code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond);

View File

@ -769,7 +769,7 @@ compare_op(A) ::= CONTAINS.
in_op(A) ::= IN. { A = OP_TYPE_IN; } in_op(A) ::= IN. { A = OP_TYPE_IN; }
in_op(A) ::= NOT IN. { A = OP_TYPE_NOT_IN; } in_op(A) ::= NOT IN. { A = OP_TYPE_NOT_IN; }
in_predicate_value(A) ::= NK_LP(C) expression_list(B) NK_RP(D). { A = createRawExprNodeExt(pCxt, &C, &D, createNodeListNode(pCxt, B)); } in_predicate_value(A) ::= NK_LP(C) literal_list(B) NK_RP(D). { A = createRawExprNodeExt(pCxt, &C, &D, createNodeListNode(pCxt, B)); }
/************************************************ boolean_value_expression ********************************************/ /************************************************ boolean_value_expression ********************************************/
boolean_value_expression(A) ::= boolean_primary(B). { A = B; } boolean_value_expression(A) ::= boolean_primary(B). { A = B; }

View File

@ -270,6 +270,9 @@ static int32_t collectMetaKeyFromCreateIndex(SCollectMetaKeyCxt* pCxt, SCreateIn
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pCxt->pMetaCache); code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pCxt->pMetaCache);
} }
if (TSDB_CODE_SUCCESS == code) {
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pCxt->pMetaCache);
}
} }
return code; return code;
} }

View File

@ -195,8 +195,8 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
return code; return code;
} }
static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) { static bool isUselessCol(SExprNode* pProj) {
if (hasSelectValFunc && QUERY_NODE_FUNCTION == nodeType(pProj) && fmIsSelectFunc(((SFunctionNode*)pProj)->funcId)) { if (QUERY_NODE_FUNCTION == nodeType(pProj) && !fmIsScalarFunc(((SFunctionNode*)pProj)->funcId)) {
return false; return false;
} }
return NULL == ((SExprNode*)pProj)->pAssociation; return NULL == ((SExprNode*)pProj)->pAssociation;
@ -218,7 +218,7 @@ static SNode* createConstantValue() {
static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
SNode* pProj = NULL; SNode* pProj = NULL;
WHERE_EACH(pProj, pSelect->pProjectionList) { WHERE_EACH(pProj, pSelect->pProjectionList) {
if (subquery && isUselessCol(pSelect->hasSelectValFunc, (SExprNode*)pProj)) { if (subquery && isUselessCol((SExprNode*)pProj)) {
ERASE_NODE(pSelect->pProjectionList); ERASE_NODE(pSelect->pProjectionList);
continue; continue;
} }

View File

@ -120,86 +120,6 @@ static int32_t skipInsertInto(char** pSql, SMsgBuf* pMsg) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t parserValidateIdToken(SToken* pToken) {
if (pToken == NULL || pToken->z == NULL || pToken->type != TK_NK_ID) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
// it is a token quoted with escape char '`'
if (pToken->z[0] == TS_ESCAPE_CHAR && pToken->z[pToken->n - 1] == TS_ESCAPE_CHAR) {
return TSDB_CODE_SUCCESS;
}
char* sep = strnchr(pToken->z, TS_PATH_DELIMITER[0], pToken->n, true);
if (sep == NULL) { // It is a single part token, not a complex type
if (isNumber(pToken)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
strntolower(pToken->z, pToken->z, pToken->n);
} else { // two part
int32_t oldLen = pToken->n;
char* pStr = pToken->z;
if (pToken->type == TK_NK_SPACE) {
pToken->n = (uint32_t)strtrim(pToken->z);
}
pToken->n = tGetToken(pToken->z, &pToken->type);
if (pToken->z[pToken->n] != TS_PATH_DELIMITER[0]) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if (pToken->type != TK_NK_ID) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
int32_t firstPartLen = pToken->n;
pToken->z = sep + 1;
pToken->n = (uint32_t)(oldLen - (sep - pStr) - 1);
int32_t len = tGetToken(pToken->z, &pToken->type);
if (len != pToken->n || pToken->type != TK_NK_ID) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
// re-build the whole name string
if (pStr[firstPartLen] == TS_PATH_DELIMITER[0]) {
// first part do not have quote do nothing
} else {
pStr[firstPartLen] = TS_PATH_DELIMITER[0];
memmove(&pStr[firstPartLen + 1], pToken->z, pToken->n);
uint32_t offset = (uint32_t)(pToken->z - (pStr + firstPartLen + 1));
memset(pToken->z + pToken->n - offset, ' ', offset);
}
pToken->n += (firstPartLen + sizeof(TS_PATH_DELIMITER[0]));
pToken->z = pStr;
strntolower(pToken->z, pToken->z, pToken->n);
}
return TSDB_CODE_SUCCESS;
}
static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullDbName, char* tableName) {
if (parserValidateIdToken(pStname) != TSDB_CODE_SUCCESS) {
return buildSyntaxErrMsg(&pCxt->msg, "invalid table name", pStname->z);
}
char* p = strnchr(pStname->z, TS_PATH_DELIMITER[0], pStname->n, false);
if (NULL != p) { // db.table
int32_t n = sprintf(fullDbName, "%d.", pCxt->pComCxt->acctId);
strncpy(fullDbName + n, pStname->z, p - pStname->z);
strncpy(tableName, p + 1, pStname->n - (p - pStname->z) - 1);
} else {
snprintf(fullDbName, TSDB_DB_FNAME_LEN, "%d.%s", pCxt->pComCxt->acctId, pCxt->pComCxt->db);
strncpy(tableName, pStname->z, pStname->n);
}
return TSDB_CODE_SUCCESS;
}
static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, const char* dbName, SMsgBuf* pMsgBuf) { static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, const char* dbName, SMsgBuf* pMsgBuf) {
const char* msg1 = "name too long"; const char* msg1 = "name too long";
const char* msg2 = "invalid database name"; const char* msg2 = "invalid database name";
@ -978,11 +898,11 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
int32_t output = 0; int32_t output = 0;
void* p = taosMemoryCalloc(1, pToken->n * TSDB_NCHAR_SIZE); void* p = taosMemoryCalloc(1, pSchema->bytes - VARSTR_HEADER_SIZE);
if (p == NULL) { if (p == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)(p), pToken->n * TSDB_NCHAR_SIZE, &output)) { if (!taosMbsToUcs4(pToken->z, pToken->n, (TdUcs4*)(p), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) {
if (errno == E2BIG) { if (errno == E2BIG) {
taosMemoryFree(p); taosMemoryFree(p);
return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name); return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);

View File

@ -954,6 +954,10 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
return translateValueImpl(pCxt, pVal, dt, false); return translateValueImpl(pCxt, pVal, dt, false);
} }
static int32_t doTranslateValue(STranslateContext* pCxt, SValueNode* pVal) {
return DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS;
}
static bool isMultiResFunc(SNode* pNode) { static bool isMultiResFunc(SNode* pNode) {
if (NULL == pNode) { if (NULL == pNode) {
return false; return false;
@ -969,131 +973,11 @@ static bool isMultiResFunc(SNode* pNode) {
return (QUERY_NODE_COLUMN == nodeType(pParam) ? 0 == strcmp(((SColumnNode*)pParam)->colName, "*") : false); return (QUERY_NODE_COLUMN == nodeType(pParam) ? 0 == strcmp(((SColumnNode*)pParam)->colName, "*") : false);
} }
static int32_t rewriteNegativeOperator(SNode** pOp) {
SNode* pRes = NULL;
int32_t code = scalarCalculateConstants(*pOp, &pRes);
if (TSDB_CODE_SUCCESS == code) {
*pOp = pRes;
}
return code;
}
static EDealRes translateUnaryOperator(STranslateContext* pCxt, SOperatorNode** pOpRef) {
SOperatorNode* pOp = *pOpRef;
if (OP_TYPE_MINUS == pOp->opType) {
if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
}
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
pCxt->errCode = rewriteNegativeOperator((SNode**)pOpRef);
} else {
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
}
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
}
static EDealRes translateArithmeticOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_BLOB == rdt.type) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
}
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) ||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) ||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
}
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) ||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) ||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) ||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) {
pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
} else {
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
}
return DEAL_RES_CONTINUE;
}
static bool dataTypeEqual(const SDataType* l, const SDataType* r) { static bool dataTypeEqual(const SDataType* l, const SDataType* r) {
return (l->type == r->type && l->bytes == r->bytes && l->precision == r->precision && l->scale == r->scale); return (l->type == r->type && l->bytes == r->bytes && l->precision == r->precision && l->scale == r->scale);
} }
static EDealRes translateComparisonOperator(STranslateContext* pCxt, SOperatorNode* pOp) { static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_BLOB == rdt.type) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
}
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
SNodeListNode* pRight = (SNodeListNode*)pOp->pRight;
bool first = true;
SDataType targetDt = {0};
SNode* pNode = NULL;
FOREACH(pNode, pRight->pNodeList) {
SDataType dt = ((SExprNode*)pNode)->resType;
if (first) {
targetDt = dt;
if (targetDt.type != TSDB_DATA_TYPE_NULL) {
first = false;
}
} else if (dt.type != targetDt.type && dt.type != TSDB_DATA_TYPE_NULL) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pNode)->aliasName);
} else if (dt.bytes > targetDt.bytes) {
targetDt.bytes = dt.bytes;
}
}
pRight->dataType = targetDt;
}
if (nodesIsRegularOp(pOp)) {
if (!IS_VAR_DATA_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
}
if (QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
((!IS_STR_DATA_TYPE(((SExprNode*)(pOp->pRight))->resType.type)) &&
(((SExprNode*)(pOp->pRight))->resType.type != TSDB_DATA_TYPE_NULL))) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
}
}
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
return DEAL_RES_CONTINUE;
}
static EDealRes translateJsonOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (TSDB_DATA_TYPE_JSON != ldt.type || TSDB_DATA_TYPE_BINARY != rdt.type) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
}
if (pOp->opType == OP_TYPE_JSON_GET_VALUE) {
pOp->node.resType.type = TSDB_DATA_TYPE_JSON;
} else if (pOp->opType == OP_TYPE_JSON_CONTAINS) {
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
}
pOp->node.resType.bytes = tDataTypes[pOp->node.resType.type].bytes;
return DEAL_RES_CONTINUE;
}
static EDealRes translateBitwiseOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_BLOB == rdt.type) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
}
pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
return DEAL_RES_CONTINUE;
}
static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode** pOpRef) {
SOperatorNode* pOp = *pOpRef;
if (isMultiResFunc(pOp->pLeft)) { if (isMultiResFunc(pOp->pLeft)) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName); return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pLeft))->aliasName);
} }
@ -1101,17 +985,10 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode** pOpRe
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
} }
if (nodesIsUnaryOp(pOp)) { if (TSDB_CODE_SUCCESS != scalarGetOperatorResultType(pOp)) {
return translateUnaryOperator(pCxt, pOpRef); return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pOp->node.aliasName);
} else if (nodesIsArithmeticOp(pOp)) {
return translateArithmeticOperator(pCxt, pOp);
} else if (nodesIsComparisonOp(pOp)) {
return translateComparisonOperator(pCxt, pOp);
} else if (nodesIsJsonOp(pOp)) {
return translateJsonOperator(pCxt, pOp);
} else if (nodesIsBitwiseOp(pOp)) {
return translateBitwiseOperator(pCxt, pOp);
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
@ -1309,6 +1186,12 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) {
pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId); pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId);
pSelect->hasRepeatScanFuncs = pSelect->hasRepeatScanFuncs ? true : fmIsRepeatScanFunc(pFunc->funcId); pSelect->hasRepeatScanFuncs = pSelect->hasRepeatScanFuncs ? true : fmIsRepeatScanFunc(pFunc->funcId);
pSelect->hasIndefiniteRowsFunc = pSelect->hasIndefiniteRowsFunc ? true : fmIsIndefiniteRowsFunc(pFunc->funcId); pSelect->hasIndefiniteRowsFunc = pSelect->hasIndefiniteRowsFunc ? true : fmIsIndefiniteRowsFunc(pFunc->funcId);
if (fmIsSelectFunc(pFunc->funcId)) {
pSelect->hasSelectFunc = true;
++(pSelect->selectFuncNum);
} else if (fmIsAggFunc(pFunc->funcId) || fmIsIndefiniteRowsFunc(pFunc->funcId)) {
pSelect->hasOtherVectorFunc = true;
}
pSelect->hasUniqueFunc = pSelect->hasUniqueFunc ? true : (FUNCTION_TYPE_UNIQUE == pFunc->funcType); pSelect->hasUniqueFunc = pSelect->hasUniqueFunc ? true : (FUNCTION_TYPE_UNIQUE == pFunc->funcType);
pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType); pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType);
pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType); pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType);
@ -1477,7 +1360,7 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) {
case QUERY_NODE_VALUE: case QUERY_NODE_VALUE:
return translateValue(pCxt, (SValueNode*)*pNode); return translateValue(pCxt, (SValueNode*)*pNode);
case QUERY_NODE_OPERATOR: case QUERY_NODE_OPERATOR:
return translateOperator(pCxt, (SOperatorNode**)pNode); return translateOperator(pCxt, (SOperatorNode*)*pNode);
case QUERY_NODE_FUNCTION: case QUERY_NODE_FUNCTION:
return translateFunction(pCxt, (SFunctionNode**)pNode); return translateFunction(pCxt, (SFunctionNode**)pNode);
case QUERY_NODE_LOGIC_CONDITION: case QUERY_NODE_LOGIC_CONDITION:
@ -1518,15 +1401,11 @@ static int32_t getGroupByErrorCode(STranslateContext* pCxt) {
if (isDistinctOrderBy(pCxt)) { if (isDistinctOrderBy(pCxt)) {
return TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION; return TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION;
} }
if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pGroupByList) {
return TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION; return TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION;
} }
return TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN;
typedef struct SCheckExprForGroupByCxt { }
STranslateContext* pTranslateCxt;
int32_t selectFuncNum;
bool hasSelectValFunc;
bool hasOtherAggFunc;
} SCheckExprForGroupByCxt;
static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) { static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
@ -1549,68 +1428,68 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR;
} }
static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) {
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR;
}
strcpy(pFunc->functionName, "_group_key");
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
*pNode = (SNode*)pFunc;
pCxt->errCode = fmGetFuncInfo(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len);
}
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
}
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
SCheckExprForGroupByCxt* pCxt = (SCheckExprForGroupByCxt*)pContext; STranslateContext* pCxt = (STranslateContext*)pContext;
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) { if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) {
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
if (isSelectFunc(*pNode)) { if (isVectorFunc(*pNode) && !isDistinctOrderBy(pCxt)) {
++(pCxt->selectFuncNum);
} else if (isAggFunc(*pNode)) {
pCxt->hasOtherAggFunc = true;
}
if ((pCxt->selectFuncNum > 1 && pCxt->hasSelectValFunc) || (pCxt->hasOtherAggFunc && pCxt->hasSelectValFunc)) {
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
}
if (isAggFunc(*pNode) && !isDistinctOrderBy(pCxt->pTranslateCxt)) {
return DEAL_RES_IGNORE_CHILD; return DEAL_RES_IGNORE_CHILD;
} }
SNode* pGroupNode = NULL; SNode* pGroupNode = NULL;
FOREACH(pGroupNode, getGroupByList(pCxt->pTranslateCxt)) { FOREACH(pGroupNode, getGroupByList(pCxt)) {
if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) { if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) {
return DEAL_RES_IGNORE_CHILD; return DEAL_RES_IGNORE_CHILD;
} }
} }
SNode* pPartKey = NULL; SNode* pPartKey = NULL;
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) { FOREACH(pPartKey, pSelect->pPartitionByList) {
if (nodesEqualNode(pPartKey, *pNode)) { if (nodesEqualNode(pPartKey, *pNode)) {
return DEAL_RES_IGNORE_CHILD; return rewriteExprToGroupKeyFunc(pCxt, pNode);
} }
} }
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
if (pCxt->selectFuncNum > 1 || pCxt->hasOtherAggFunc) { if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) {
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt)); return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt));
} else { } else {
pCxt->hasSelectValFunc = true; return rewriteColToSelectValFunc(pCxt, pNode);
return rewriteColToSelectValFunc(pCxt->pTranslateCxt, pNode);
} }
} }
if (isAggFunc(*pNode) && isDistinctOrderBy(pCxt->pTranslateCxt)) { if (isVectorFunc(*pNode) && isDistinctOrderBy(pCxt)) {
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt)); return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt));
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
static int32_t checkExprForGroupBy(STranslateContext* pCxt, SNode** pNode) { static int32_t checkExprForGroupBy(STranslateContext* pCxt, SNode** pNode) {
SCheckExprForGroupByCxt cxt = { nodesRewriteExpr(pNode, doCheckExprForGroupBy, pCxt);
.pTranslateCxt = pCxt, .selectFuncNum = 0, .hasSelectValFunc = false, .hasOtherAggFunc = false};
nodesRewriteExpr(pNode, doCheckExprForGroupBy, &cxt);
if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) {
return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt));
}
return pCxt->errCode; return pCxt->errCode;
} }
static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList) { static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect, SNodeList* pList) {
if (NULL == getGroupByList(pCxt)) { if (NULL == getGroupByList(pCxt) && NULL == pSelect->pWindow) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SCheckExprForGroupByCxt cxt = { nodesRewriteExprs(pList, doCheckExprForGroupBy, pCxt);
.pTranslateCxt = pCxt, .selectFuncNum = 0, .hasSelectValFunc = false, .hasOtherAggFunc = false};
nodesRewriteExprs(pList, doCheckExprForGroupBy, &cxt);
if (cxt.selectFuncNum != 1 && cxt.hasSelectValFunc) {
return generateSyntaxErrMsg(&pCxt->msgBuf, getGroupByErrorCode(pCxt));
}
return pCxt->errCode; return pCxt->errCode;
} }
@ -1634,63 +1513,50 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt*
typedef struct CheckAggColCoexistCxt { typedef struct CheckAggColCoexistCxt {
STranslateContext* pTranslateCxt; STranslateContext* pTranslateCxt;
bool existAggFunc;
bool existCol; bool existCol;
bool existIndefiniteRowsFunc;
int32_t selectFuncNum; int32_t selectFuncNum;
bool existOtherAggFunc; bool existOtherVectorFunc;
} CheckAggColCoexistCxt; } CheckAggColCoexistCxt;
static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) { static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) {
CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext; CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext;
if (isSelectFunc(pNode)) { if (isVectorFunc(*pNode)) {
if (isSelectFunc(*pNode)) {
++(pCxt->selectFuncNum); ++(pCxt->selectFuncNum);
} else if (isAggFunc(pNode)) { } else {
pCxt->existOtherAggFunc = true; pCxt->existOtherVectorFunc = true;
} }
if (isAggFunc(pNode)) {
pCxt->existAggFunc = true;
return DEAL_RES_IGNORE_CHILD;
}
if (isIndefiniteRowsFunc(pNode)) {
pCxt->existIndefiniteRowsFunc = true;
return DEAL_RES_IGNORE_CHILD; return DEAL_RES_IGNORE_CHILD;
} }
SNode* pPartKey = NULL; SNode* pPartKey = NULL;
FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) { FOREACH(pPartKey, ((SSelectStmt*)pCxt->pTranslateCxt->pCurrStmt)->pPartitionByList) {
if (nodesEqualNode(pPartKey, pNode)) { if (nodesEqualNode(pPartKey, *pNode)) {
return DEAL_RES_IGNORE_CHILD; return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode);
} }
} }
if (isScanPseudoColumnFunc(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)) { if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
pCxt->existCol = true; pCxt->existCol = true;
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) { static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
if (NULL != pSelect->pGroupByList) { if (NULL != pSelect->pGroupByList || NULL != pSelect->pWindow ||
(!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc)) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt, CheckAggColCoexistCxt cxt = {
.existAggFunc = false, .pTranslateCxt = pCxt, .existCol = false, .selectFuncNum = 0, .existOtherVectorFunc = false};
.existCol = false, nodesRewriteExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt);
.existIndefiniteRowsFunc = false,
.selectFuncNum = 0,
.existOtherAggFunc = false};
nodesWalkExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt);
if (!pSelect->isDistinct) { if (!pSelect->isDistinct) {
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt); nodesRewriteExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
} }
if (1 == cxt.selectFuncNum && !cxt.existOtherAggFunc) { if (1 == cxt.selectFuncNum && !cxt.existOtherVectorFunc) {
return rewriteColsToSelectValFunc(pCxt, pSelect); return rewriteColsToSelectValFunc(pCxt, pSelect);
} }
if ((cxt.selectFuncNum > 1 || cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) { if (cxt.existCol) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP);
} }
if (cxt.existIndefiniteRowsFunc && cxt.existCol) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -2170,7 +2036,7 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
pCxt->currClause = SQL_CLAUSE_ORDER_BY; pCxt->currClause = SQL_CLAUSE_ORDER_BY;
code = translateExprList(pCxt, pSelect->pOrderByList); code = translateExprList(pCxt, pSelect->pOrderByList);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkExprListForGroupBy(pCxt, pSelect->pOrderByList); code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
} }
} }
return code; return code;
@ -2183,7 +2049,7 @@ static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect
code = translateStar(pCxt, pSelect); code = translateStar(pCxt, pSelect);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkExprListForGroupBy(pCxt, pSelect->pProjectionList); code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
} }
return code; return code;
} }
@ -3344,7 +3210,7 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
if (NULL == pFuncs) { if (NULL == pFuncs) {
if (NULL != pDbCfg->pRetensions) { if (NULL != pDbCfg->pRetensions) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION,
"To create a super table in a database with the retensions parameter configured, " "To create a super table in databases configured with the 'RETENTIONS' option, "
"the 'ROLLUP' option must be present"); "the 'ROLLUP' option must be present");
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -3555,10 +3421,12 @@ static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions*
} }
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, bool createStable) { static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt, bool createStable) {
int32_t code = TSDB_CODE_SUCCESS;
SDbCfgInfo dbCfg = {0}; SDbCfgInfo dbCfg = {0};
if (createStable) { int32_t code = getDBCfg(pCxt, pStmt->dbName, &dbCfg);
code = getDBCfg(pCxt, pStmt->dbName, &dbCfg); if (TSDB_CODE_SUCCESS == code && !createStable && NULL != dbCfg.pRetensions) {
code = generateSyntaxErrMsgExt(
&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION,
"Only super table creation is supported in databases configured with the 'RETENTIONS' option");
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkTableMaxDelayOption(pCxt, pStmt->pOptions, createStable, &dbCfg); code = checkTableMaxDelayOption(pCxt, pStmt->pOptions, createStable, &dbCfg);
@ -4164,29 +4032,42 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
return code; return code;
} }
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || SDbCfgInfo dbCfg = {0};
(NULL != pStmt->pOptions->pOffset && int32_t code = getDBCfg(pCxt, pCxt->pParseCxt->db, &dbCfg);
DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || if (TSDB_CODE_SUCCESS == code && NULL != dbCfg.pRetensions) {
(NULL != pStmt->pOptions->pSliding && code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_SMA_INDEX,
DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { "Tables configured with the 'ROLLUP' option do not support creating sma index");
return pCxt->errCode; }
if (TSDB_CODE_SUCCESS == code) {
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval);
}
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pOffset) {
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset);
}
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pSliding) {
code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding);
} }
if (NULL != pStmt->pOptions->pStreamOptions) { if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pStreamOptions) {
SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions; SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions;
if (NULL != pStreamOpt->pWatermark && if (NULL != pStreamOpt->pWatermark) {
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark))) { code = doTranslateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark);
return pCxt->errCode;
} }
if (TSDB_CODE_SUCCESS == code && NULL != pStreamOpt->pDelay) {
if (NULL != pStreamOpt->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pDelay))) { code = doTranslateValue(pCxt, (SValueNode*)pStreamOpt->pDelay);
return pCxt->errCode;
} }
} }
return code;
}
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
SMCreateSmaReq createSmaReq = {0}; SMCreateSmaReq createSmaReq = {0};
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); int32_t code = checkCreateSmaIndex(pCxt, pStmt);
if (TSDB_CODE_SUCCESS == code) {
code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq); code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq);
} }

View File

@ -38,6 +38,8 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
t = tStrGetToken((char*)pStr, &index, false); t = tStrGetToken((char*)pStr, &index, false);
if (TK_USING == t.type || TK_VALUES == t.type) { if (TK_USING == t.type || TK_VALUES == t.type) {
return true; return true;
} else if (TK_SELECT == t.type) {
return false;
} }
if (0 == t.type) { if (0 == t.type) {
break; break;

View File

@ -216,244 +216,252 @@ typedef union {
** yy_default[] Default action for each state. ** yy_default[] Default action for each state.
** **
*********** Begin parsing tables **********************************************/ *********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (2360) #define YY_ACTTAB_COUNT (2436)
static const YYACTIONTYPE yy_action[] = { static const YYACTIONTYPE yy_action[] = {
/* 0 */ 430, 1920, 431, 1491, 438, 71, 431, 1491, 514, 62, /* 0 */ 430, 1920, 431, 1491, 438, 71, 431, 1491, 514, 62,
/* 10 */ 1645, 1693, 40, 38, 1919, 550, 323, 325, 1917, 1690, /* 10 */ 1645, 1693, 39, 37, 1919, 549, 323, 325, 1917, 1690,
/* 20 */ 337, 86, 1254, 1457, 34, 33, 1643, 1589, 41, 39, /* 20 */ 337, 86, 1254, 1457, 33, 32, 1643, 1589, 40, 38,
/* 30 */ 37, 36, 35, 1329, 119, 1252, 1777, 41, 39, 37, /* 30 */ 36, 35, 34, 1329, 119, 1252, 1777, 40, 38, 36,
/* 40 */ 36, 35, 1585, 122, 103, 1734, 550, 102, 101, 100, /* 40 */ 35, 34, 1585, 122, 103, 1734, 549, 102, 101, 100,
/* 50 */ 99, 98, 97, 96, 95, 94, 1324, 526, 550, 23, /* 50 */ 99, 98, 97, 96, 95, 94, 1324, 526, 549, 22,
/* 60 */ 14, 1016, 342, 1015, 1795, 1638, 1640, 1260, 113, 142, /* 60 */ 14, 1016, 342, 1015, 1795, 1638, 1640, 1260, 113, 142,
/* 70 */ 1795, 1468, 578, 79, 122, 468, 466, 1747, 543, 577, /* 70 */ 1795, 1468, 578, 79, 122, 468, 466, 1747, 542, 577,
/* 80 */ 40, 38, 1392, 120, 1, 1593, 122, 61, 337, 61, /* 80 */ 39, 37, 1392, 120, 1, 1593, 122, 61, 337, 61,
/* 90 */ 1254, 1017, 358, 555, 1586, 555, 379, 552, 155, 1862, /* 90 */ 1254, 1017, 358, 554, 1586, 554, 379, 551, 155, 1862,
/* 100 */ 1863, 1329, 1867, 1252, 1808, 1479, 659, 1521, 89, 1778, /* 100 */ 1863, 1329, 1867, 1252, 1808, 1479, 659, 1521, 89, 1778,
/* 110 */ 580, 1780, 1781, 576, 120, 571, 542, 553, 1854, 553, /* 110 */ 580, 1780, 1781, 576, 120, 571, 541, 552, 1854, 552,
/* 120 */ 1331, 1332, 304, 1850, 1324, 1478, 120, 526, 14, 249, /* 120 */ 1331, 1332, 304, 1850, 1324, 1478, 120, 526, 14, 249,
/* 130 */ 1862, 549, 1456, 548, 1920, 1260, 1920, 1920, 164, 31, /* 130 */ 1862, 548, 1456, 547, 1920, 1260, 1920, 1920, 164, 30,
/* 140 */ 259, 156, 1862, 1863, 1777, 1867, 1747, 161, 447, 161, /* 140 */ 259, 156, 1862, 1863, 1777, 1867, 1747, 161, 447, 161,
/* 150 */ 159, 1917, 2, 1917, 1917, 1593, 112, 111, 110, 109, /* 150 */ 159, 1917, 2, 1917, 1917, 1593, 112, 111, 110, 109,
/* 160 */ 108, 107, 106, 105, 104, 1255, 1747, 1253, 1279, 483, /* 160 */ 108, 107, 106, 105, 104, 1255, 1747, 1253, 1279, 483,
/* 170 */ 482, 481, 1795, 1920, 659, 480, 220, 221, 118, 477, /* 170 */ 482, 481, 1795, 1920, 659, 480, 220, 221, 118, 477,
/* 180 */ 578, 44, 476, 475, 474, 1747, 160, 577, 1331, 1332, /* 180 */ 578, 43, 476, 475, 474, 1747, 160, 577, 1331, 1332,
/* 190 */ 1917, 429, 1258, 1259, 433, 1307, 1308, 1310, 1311, 1312, /* 190 */ 1917, 429, 1258, 1259, 433, 1307, 1308, 1310, 1311, 1312,
/* 200 */ 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, /* 200 */ 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, 1327, 1328,
/* 210 */ 1330, 1333, 1808, 1413, 1278, 539, 90, 1778, 580, 1780, /* 210 */ 1330, 1333, 1808, 1413, 1278, 538, 90, 1778, 580, 1780,
/* 220 */ 1781, 576, 1279, 571, 162, 1454, 1854, 162, 553, 162, /* 220 */ 1781, 576, 1279, 571, 162, 1454, 1854, 162, 552, 162,
/* 230 */ 330, 1850, 1933, 1255, 314, 1253, 61, 303, 140, 143, /* 230 */ 328, 1850, 1933, 1255, 314, 1253, 61, 303, 140, 143,
/* 240 */ 516, 1888, 999, 1549, 34, 33, 1645, 1596, 41, 39, /* 240 */ 516, 1888, 999, 1549, 33, 32, 1645, 1596, 40, 38,
/* 250 */ 37, 36, 35, 341, 536, 1411, 1412, 1414, 1415, 1477, /* 250 */ 36, 35, 34, 341, 535, 1411, 1412, 1414, 1415, 1477,
/* 260 */ 1258, 1259, 1643, 1307, 1308, 1310, 1311, 1312, 1313, 1314, /* 260 */ 1258, 1259, 1643, 1307, 1308, 1310, 1311, 1312, 1313, 1314,
/* 270 */ 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, 1330, 1333, /* 270 */ 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, 1330, 1333,
/* 280 */ 40, 38, 1003, 1004, 315, 349, 313, 312, 337, 470, /* 280 */ 39, 37, 1003, 1004, 315, 349, 313, 312, 337, 470,
/* 290 */ 1254, 1777, 43, 472, 545, 540, 305, 1353, 11, 10, /* 290 */ 1254, 1777, 42, 472, 544, 539, 305, 1353, 11, 10,
/* 300 */ 1747, 1329, 103, 1252, 153, 102, 101, 100, 99, 98, /* 300 */ 1747, 1329, 103, 1252, 153, 102, 101, 100, 99, 98,
/* 310 */ 97, 96, 95, 94, 385, 471, 378, 1632, 377, 1795, /* 310 */ 97, 96, 95, 94, 385, 471, 378, 1632, 377, 1795,
/* 320 */ 1358, 1292, 1151, 1152, 1324, 1278, 1920, 554, 14, 1351, /* 320 */ 1358, 1292, 1151, 1152, 1324, 1278, 1920, 553, 14, 1351,
/* 330 */ 1639, 1640, 1747, 437, 577, 1260, 433, 40, 38, 159, /* 330 */ 1639, 1640, 1747, 437, 577, 1260, 433, 39, 37, 159,
/* 340 */ 483, 482, 481, 1917, 1920, 337, 480, 1254, 1518, 118, /* 340 */ 483, 482, 481, 1917, 1920, 337, 480, 1254, 1518, 118,
/* 350 */ 477, 301, 2, 476, 475, 474, 605, 1918, 1329, 1808, /* 350 */ 477, 301, 2, 476, 475, 474, 605, 1918, 1329, 1808,
/* 360 */ 1252, 1917, 28, 90, 1778, 580, 1780, 1781, 576, 435, /* 360 */ 1252, 1917, 27, 90, 1778, 580, 1780, 1781, 576, 435,
/* 370 */ 571, 71, 370, 1854, 659, 1276, 162, 330, 1850, 154, /* 370 */ 571, 71, 370, 1854, 659, 1276, 162, 328, 1850, 154,
/* 380 */ 1396, 1324, 1365, 1352, 117, 1016, 1278, 1015, 1331, 1332, /* 380 */ 1396, 1324, 1365, 1352, 117, 1016, 1278, 1015, 1331, 1332,
/* 390 */ 1309, 158, 1260, 1588, 372, 368, 544, 34, 33, 1880, /* 390 */ 1309, 158, 1260, 1588, 372, 368, 543, 33, 32, 1880,
/* 400 */ 1571, 41, 39, 37, 36, 35, 1357, 479, 478, 8, /* 400 */ 1571, 40, 38, 36, 35, 34, 1357, 479, 478, 8,
/* 410 */ 636, 635, 634, 633, 345, 1017, 632, 631, 630, 123, /* 410 */ 636, 635, 634, 633, 345, 1017, 632, 631, 630, 123,
/* 420 */ 625, 624, 623, 622, 621, 620, 619, 618, 133, 614, /* 420 */ 625, 624, 623, 622, 621, 620, 619, 618, 133, 614,
/* 430 */ 324, 659, 162, 1255, 562, 1253, 34, 33, 140, 613, /* 430 */ 324, 659, 162, 1255, 561, 1253, 33, 32, 140, 613,
/* 440 */ 41, 39, 37, 36, 35, 1331, 1332, 1595, 30, 335, /* 440 */ 40, 38, 36, 35, 34, 1331, 1332, 1595, 29, 335,
/* 450 */ 1346, 1347, 1348, 1349, 1350, 1354, 1355, 1356, 1280, 447, /* 450 */ 1346, 1347, 1348, 1349, 1350, 1354, 1355, 1356, 1280, 447,
/* 460 */ 1258, 1259, 1476, 1307, 1308, 1310, 1311, 1312, 1313, 1314, /* 460 */ 1258, 1259, 1476, 1307, 1308, 1310, 1311, 1312, 1313, 1314,
/* 470 */ 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, 1330, 1333, /* 470 */ 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, 1330, 1333,
/* 480 */ 34, 33, 214, 526, 41, 39, 37, 36, 35, 170, /* 480 */ 33, 32, 214, 526, 40, 38, 36, 35, 34, 170,
/* 490 */ 1255, 207, 1253, 219, 165, 1281, 340, 37, 36, 35, /* 490 */ 1255, 207, 1253, 219, 165, 1281, 340, 36, 35, 34,
/* 500 */ 59, 34, 33, 1747, 140, 41, 39, 37, 36, 35, /* 500 */ 59, 33, 32, 1747, 140, 40, 38, 36, 35, 34,
/* 510 */ 61, 1593, 75, 1595, 629, 627, 69, 1258, 1259, 68, /* 510 */ 61, 1593, 75, 1595, 629, 627, 69, 1258, 1259, 68,
/* 520 */ 1307, 1308, 1310, 1311, 1312, 1313, 1314, 573, 569, 1322, /* 520 */ 1307, 1308, 1310, 1311, 1312, 1313, 1314, 573, 569, 1322,
/* 530 */ 1323, 1325, 1326, 1327, 1328, 1330, 1333, 40, 38, 1334, /* 530 */ 1323, 1325, 1326, 1327, 1328, 1330, 1333, 39, 37, 1334,
/* 540 */ 1689, 139, 298, 1475, 343, 337, 1777, 1254, 1277, 162, /* 540 */ 1689, 139, 298, 1475, 343, 337, 1777, 1254, 1277, 162,
/* 550 */ 73, 303, 140, 305, 516, 1234, 1235, 1423, 1329, 418, /* 550 */ 73, 303, 140, 305, 516, 1234, 1235, 1423, 1329, 418,
/* 560 */ 1252, 1595, 1309, 1109, 602, 601, 600, 1113, 599, 1115, /* 560 */ 1252, 1595, 1309, 1109, 602, 601, 600, 1113, 599, 1115,
/* 570 */ 1116, 598, 1118, 595, 1795, 1124, 592, 1126, 1127, 589, /* 570 */ 1116, 598, 1118, 595, 1795, 1124, 592, 1126, 1127, 589,
/* 580 */ 586, 1324, 578, 488, 1747, 1449, 1351, 1747, 526, 577, /* 580 */ 586, 1324, 578, 488, 1747, 1449, 1351, 1747, 526, 577,
/* 590 */ 251, 472, 1260, 1474, 40, 38, 1683, 1254, 498, 383, /* 590 */ 251, 472, 1260, 1474, 39, 37, 1683, 1254, 498, 383,
/* 600 */ 45, 4, 337, 555, 1254, 174, 173, 172, 1260, 9, /* 600 */ 44, 4, 337, 554, 1254, 174, 173, 172, 1260, 9,
/* 610 */ 1252, 1071, 206, 471, 1808, 1329, 1593, 1252, 89, 1778, /* 610 */ 1252, 1071, 206, 471, 1808, 1329, 1593, 1252, 89, 1778,
/* 620 */ 580, 1780, 1781, 576, 497, 571, 491, 231, 1854, 1473, /* 620 */ 580, 1780, 1781, 576, 497, 571, 491, 231, 1854, 1473,
/* 630 */ 485, 659, 304, 1850, 1747, 205, 563, 495, 1324, 493, /* 630 */ 485, 659, 304, 1850, 1747, 205, 562, 495, 1324, 493,
/* 640 */ 1352, 27, 1260, 1073, 1920, 1331, 1332, 34, 33, 1260, /* 640 */ 1352, 26, 1260, 1073, 1920, 1331, 1332, 33, 32, 1260,
/* 650 */ 162, 41, 39, 37, 36, 35, 1569, 159, 1869, 1472, /* 650 */ 162, 40, 38, 36, 35, 34, 1569, 159, 1869, 1472,
/* 660 */ 1471, 1917, 56, 1357, 611, 55, 9, 1869, 559, 526, /* 660 */ 1471, 1917, 56, 1357, 611, 55, 9, 1869, 558, 526,
/* 670 */ 1747, 34, 33, 1645, 1448, 41, 39, 37, 36, 35, /* 670 */ 1747, 33, 32, 1645, 1448, 40, 38, 36, 35, 34,
/* 680 */ 384, 659, 1866, 131, 130, 608, 607, 606, 659, 1644, /* 680 */ 384, 659, 1866, 131, 130, 608, 607, 606, 659, 1644,
/* 690 */ 1255, 1865, 1253, 1003, 1004, 1869, 513, 1593, 1470, 7, /* 690 */ 1255, 1865, 1253, 1003, 1004, 1869, 513, 1593, 1470, 7,
/* 700 */ 1747, 1747, 1331, 1332, 1570, 30, 335, 1346, 1347, 1348, /* 700 */ 1747, 1747, 1331, 1332, 1570, 29, 335, 1346, 1347, 1348,
/* 710 */ 1349, 1350, 1354, 1355, 1356, 613, 1582, 1258, 1259, 1864, /* 710 */ 1349, 1350, 1354, 1355, 1356, 613, 1582, 1258, 1259, 1864,
/* 720 */ 1307, 1308, 1310, 1311, 1312, 1313, 1314, 573, 569, 1322, /* 720 */ 1307, 1308, 1310, 1311, 1312, 1313, 1314, 573, 569, 1322,
/* 730 */ 1323, 1325, 1326, 1327, 1328, 1330, 1333, 1920, 557, 1747, /* 730 */ 1323, 1325, 1326, 1327, 1328, 1330, 1333, 1920, 556, 1747,
/* 740 */ 1255, 1688, 1253, 298, 617, 29, 1565, 1255, 1403, 1253, /* 740 */ 1255, 1688, 1253, 298, 617, 28, 1565, 1255, 1403, 1253,
/* 750 */ 159, 34, 33, 514, 1917, 41, 39, 37, 36, 35, /* 750 */ 159, 33, 32, 514, 1917, 40, 38, 36, 35, 34,
/* 760 */ 347, 1874, 1385, 1263, 1691, 34, 33, 1258, 1259, 41, /* 760 */ 347, 1874, 1385, 616, 1691, 33, 32, 1258, 1259, 40,
/* 770 */ 39, 37, 36, 35, 1258, 1259, 213, 1307, 1308, 1310, /* 770 */ 38, 36, 35, 34, 1258, 1259, 213, 1307, 1308, 1310,
/* 780 */ 1311, 1312, 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, /* 780 */ 1311, 1312, 1313, 1314, 573, 569, 1322, 1323, 1325, 1326,
/* 790 */ 1327, 1328, 1330, 1333, 40, 38, 300, 1578, 1276, 1467, /* 790 */ 1327, 1328, 1330, 1333, 39, 37, 300, 1578, 1276, 1467,
/* 800 */ 611, 1920, 337, 1777, 1254, 411, 74, 609, 423, 1466, /* 800 */ 611, 1920, 337, 1777, 1254, 411, 74, 609, 423, 1466,
/* 810 */ 1636, 1508, 1389, 526, 159, 1329, 499, 1252, 1917, 131, /* 810 */ 1636, 1508, 1389, 526, 159, 1329, 499, 1252, 1917, 131,
/* 820 */ 130, 608, 607, 606, 388, 396, 1465, 424, 1464, 398, /* 820 */ 130, 608, 607, 606, 388, 396, 1465, 424, 1464, 398,
/* 830 */ 1339, 1795, 610, 484, 271, 1636, 1278, 1623, 1324, 578, /* 830 */ 1339, 1795, 610, 484, 271, 1636, 1278, 1623, 1324, 578,
/* 840 */ 1747, 1593, 1292, 1568, 1747, 526, 577, 34, 33, 1260, /* 840 */ 1747, 1593, 1292, 1568, 1747, 526, 577, 33, 32, 1260,
/* 850 */ 1747, 41, 39, 37, 36, 35, 113, 1920, 550, 52, /* 850 */ 1747, 40, 38, 36, 35, 34, 113, 1920, 549, 52,
/* 860 */ 510, 389, 198, 473, 1262, 196, 2, 1747, 560, 1747, /* 860 */ 510, 389, 198, 473, 1263, 196, 2, 1747, 559, 1747,
/* 870 */ 159, 1808, 616, 1593, 1917, 90, 1778, 580, 1780, 1781, /* 870 */ 159, 1808, 1580, 1593, 1917, 90, 1778, 580, 1780, 1781,
/* 880 */ 576, 1463, 571, 1385, 1462, 1854, 122, 1461, 659, 330, /* 880 */ 576, 1463, 571, 1385, 1462, 1854, 122, 1461, 659, 328,
/* 890 */ 1850, 1933, 1460, 1459, 200, 1266, 1497, 199, 567, 1580, /* 890 */ 1850, 1933, 1460, 1459, 200, 11, 10, 199, 1262, 1576,
/* 900 */ 1911, 422, 1331, 1332, 417, 416, 415, 414, 413, 410, /* 900 */ 1911, 422, 1331, 1332, 417, 416, 415, 414, 413, 410,
/* 910 */ 409, 408, 407, 406, 402, 401, 400, 399, 393, 392, /* 910 */ 409, 408, 407, 406, 402, 401, 400, 399, 393, 392,
/* 920 */ 391, 390, 1747, 387, 386, 1747, 120, 526, 1747, 526, /* 920 */ 391, 390, 1747, 387, 386, 1747, 120, 526, 1747, 526,
/* 930 */ 628, 141, 1576, 1747, 1747, 526, 277, 526, 403, 611, /* 930 */ 628, 141, 1042, 1747, 1747, 526, 277, 526, 403, 611,
/* 940 */ 404, 157, 1862, 1863, 654, 1867, 446, 1255, 1590, 1253, /* 940 */ 404, 157, 1862, 1863, 567, 1867, 446, 1255, 1590, 1253,
/* 950 */ 275, 58, 11, 10, 57, 1593, 506, 1593, 131, 130, /* 950 */ 275, 58, 1451, 1452, 57, 1593, 506, 1593, 131, 130,
/* 960 */ 608, 607, 606, 1593, 210, 1593, 1777, 1451, 1452, 572, /* 960 */ 608, 607, 606, 1593, 1043, 1593, 1777, 210, 572, 604,
/* 970 */ 176, 426, 373, 42, 1258, 1259, 550, 1307, 1308, 1310, /* 970 */ 176, 426, 373, 41, 1258, 1259, 549, 1307, 1308, 1310,
/* 980 */ 1311, 1312, 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, /* 980 */ 1311, 1312, 1313, 1314, 573, 569, 1322, 1323, 1325, 1326,
/* 990 */ 1327, 1328, 1330, 1333, 1795, 526, 1265, 61, 202, 526, /* 990 */ 1327, 1328, 1330, 1333, 1795, 526, 1266, 61, 202, 526,
/* 1000 */ 526, 201, 554, 526, 122, 204, 1722, 1747, 203, 577, /* 1000 */ 526, 201, 553, 526, 122, 204, 1722, 1747, 203, 577,
/* 1010 */ 507, 511, 1309, 1584, 524, 1202, 218, 1469, 1764, 604, /* 1010 */ 507, 511, 1309, 1584, 524, 1202, 218, 1469, 1764, 1550,
/* 1020 */ 1550, 526, 254, 1593, 1761, 555, 465, 1593, 1593, 1761, /* 1020 */ 254, 526, 500, 1593, 1761, 554, 465, 1593, 1593, 1761,
/* 1030 */ 1343, 1593, 525, 1388, 1808, 88, 526, 1777, 90, 1778, /* 1030 */ 1265, 1593, 525, 1388, 1808, 88, 526, 1777, 90, 1778,
/* 1040 */ 580, 1780, 1781, 576, 120, 571, 1503, 260, 1854, 1593, /* 1040 */ 580, 1780, 1781, 576, 120, 571, 1503, 260, 1854, 1593,
/* 1050 */ 1757, 1763, 330, 1850, 154, 1757, 1763, 326, 222, 249, /* 1050 */ 1757, 1763, 328, 1850, 154, 1757, 1763, 326, 222, 249,
/* 1060 */ 1862, 549, 571, 548, 1593, 1795, 1920, 571, 486, 1501, /* 1060 */ 1862, 548, 571, 547, 1593, 1795, 1920, 571, 486, 1501,
/* 1070 */ 66, 65, 382, 578, 1881, 169, 537, 243, 1747, 159, /* 1070 */ 66, 65, 382, 578, 1881, 169, 1343, 85, 1747, 159,
/* 1080 */ 577, 376, 1767, 1917, 125, 328, 327, 526, 128, 1042, /* 1080 */ 577, 376, 536, 1917, 1767, 334, 333, 82, 125, 243,
/* 1090 */ 129, 489, 1796, 50, 299, 1268, 235, 366, 344, 364, /* 1090 */ 128, 489, 1796, 129, 299, 1268, 50, 366, 1492, 364,
/* 1100 */ 360, 356, 166, 351, 348, 1808, 1329, 1765, 1261, 90, /* 1100 */ 360, 356, 166, 351, 348, 1808, 1329, 1764, 1261, 90,
/* 1110 */ 1778, 580, 1780, 1781, 576, 1593, 571, 42, 1761, 1854, /* 1110 */ 1778, 580, 1780, 1781, 576, 1765, 571, 235, 1761, 1854,
/* 1120 */ 1769, 1043, 42, 330, 1850, 1933, 519, 346, 42, 1324, /* 1120 */ 526, 1633, 1769, 328, 1850, 1933, 1761, 1497, 41, 1324,
/* 1130 */ 228, 584, 1102, 1777, 1873, 1410, 85, 162, 238, 128, /* 1130 */ 519, 344, 228, 1777, 1873, 1102, 346, 162, 1410, 50,
/* 1140 */ 1260, 129, 114, 128, 1757, 1763, 82, 500, 1492, 1633, /* 1140 */ 1260, 41, 1884, 584, 1757, 1763, 332, 128, 1593, 129,
/* 1150 */ 551, 1884, 253, 256, 258, 248, 571, 3, 53, 1359, /* 1150 */ 114, 128, 1757, 1763, 550, 248, 571, 253, 256, 238,
/* 1160 */ 80, 1795, 5, 350, 1315, 1276, 353, 357, 310, 578, /* 1160 */ 258, 1795, 80, 53, 571, 5, 3, 350, 1276, 578,
/* 1170 */ 270, 1071, 1218, 1130, 1747, 311, 577, 405, 267, 535, /* 1170 */ 270, 353, 357, 310, 1747, 654, 577, 1071, 311, 566,
/* 1180 */ 1685, 1134, 171, 1141, 1139, 132, 412, 420, 419, 421, /* 1180 */ 1218, 1359, 267, 1315, 405, 1130, 1685, 171, 412, 1134,
/* 1190 */ 555, 425, 427, 1282, 1777, 1285, 1284, 428, 436, 439, /* 1190 */ 554, 1141, 1139, 132, 1777, 420, 419, 425, 421, 427,
/* 1200 */ 179, 1808, 440, 181, 441, 284, 1778, 580, 1780, 1781, /* 1200 */ 428, 1808, 1282, 436, 1285, 284, 1778, 580, 1780, 1781,
/* 1210 */ 576, 1286, 571, 442, 184, 186, 444, 1283, 188, 70, /* 1210 */ 576, 439, 571, 1284, 179, 440, 181, 441, 1286, 184,
/* 1220 */ 445, 448, 1795, 191, 467, 469, 1583, 195, 1579, 197, /* 1220 */ 442, 444, 1795, 186, 1283, 188, 445, 70, 448, 191,
/* 1230 */ 578, 1920, 134, 135, 93, 1747, 302, 577, 1269, 268, /* 1230 */ 578, 1920, 268, 467, 469, 1747, 1583, 577, 1269, 302,
/* 1240 */ 1264, 208, 1581, 1577, 161, 136, 137, 1777, 1917, 211, /* 1240 */ 1264, 93, 195, 501, 161, 208, 1579, 1777, 1917, 197,
/* 1250 */ 1727, 555, 502, 501, 508, 505, 512, 534, 1281, 215, /* 1250 */ 134, 554, 135, 1581, 1577, 136, 137, 1727, 211, 502,
/* 1260 */ 515, 1726, 1808, 520, 1695, 1272, 284, 1778, 580, 1780, /* 1260 */ 508, 512, 1808, 534, 215, 1272, 284, 1778, 580, 1780,
/* 1270 */ 1781, 576, 320, 571, 517, 1795, 569, 1322, 1323, 1325, /* 1270 */ 1781, 576, 505, 571, 226, 1795, 569, 1322, 1323, 1325,
/* 1280 */ 1326, 1327, 1328, 578, 126, 322, 521, 127, 1747, 224, /* 1280 */ 1326, 1327, 1328, 578, 126, 515, 1726, 1695, 1747, 520,
/* 1290 */ 577, 522, 1920, 269, 226, 78, 1594, 530, 1885, 1777, /* 1290 */ 577, 127, 1920, 521, 320, 224, 517, 322, 522, 1777,
/* 1300 */ 538, 6, 233, 532, 533, 159, 237, 547, 329, 1917, /* 1300 */ 269, 78, 1594, 1281, 530, 159, 532, 1885, 537, 1917,
/* 1310 */ 531, 541, 1385, 528, 1895, 1808, 529, 247, 121, 91, /* 1310 */ 233, 533, 237, 1895, 1894, 1808, 327, 6, 540, 91,
/* 1320 */ 1778, 580, 1780, 1781, 576, 1894, 571, 1795, 244, 1854, /* 1320 */ 1778, 580, 1780, 1781, 576, 546, 571, 1795, 531, 1854,
/* 1330 */ 246, 1876, 148, 1853, 1850, 578, 1280, 564, 1870, 561, /* 1330 */ 1876, 529, 528, 1853, 1850, 578, 1385, 247, 148, 1280,
/* 1340 */ 1747, 331, 577, 242, 19, 245, 1835, 582, 272, 1637, /* 1340 */ 1747, 563, 577, 246, 244, 121, 242, 48, 1870, 329,
/* 1350 */ 1566, 252, 1777, 655, 1916, 51, 147, 263, 1741, 558, /* 1350 */ 582, 272, 1777, 245, 560, 1637, 1566, 263, 655, 656,
/* 1360 */ 1936, 656, 658, 285, 63, 255, 1777, 1808, 276, 565, /* 1360 */ 658, 51, 285, 147, 1741, 1835, 1777, 1808, 295, 276,
/* 1370 */ 257, 91, 1778, 580, 1780, 1781, 576, 1740, 571, 274, /* 1370 */ 252, 91, 1778, 580, 1780, 1781, 576, 63, 571, 274,
/* 1380 */ 1795, 1854, 1739, 295, 294, 566, 1850, 64, 575, 1738, /* 1380 */ 1795, 1854, 1916, 557, 1740, 565, 1850, 564, 575, 294,
/* 1390 */ 352, 1735, 354, 1747, 1795, 577, 355, 1246, 1247, 167, /* 1390 */ 1739, 1936, 255, 1747, 1795, 577, 257, 64, 1738, 352,
/* 1400 */ 359, 1733, 578, 361, 362, 363, 1732, 1747, 365, 577, /* 1400 */ 1735, 354, 578, 355, 1246, 1247, 167, 1747, 359, 577,
/* 1410 */ 1731, 1730, 369, 367, 1729, 371, 1712, 168, 374, 1777, /* 1410 */ 1733, 361, 362, 363, 1732, 365, 1731, 367, 1730, 1777,
/* 1420 */ 1808, 375, 1221, 1220, 292, 1778, 580, 1780, 1781, 576, /* 1420 */ 1808, 369, 1729, 371, 292, 1778, 580, 1780, 1781, 576,
/* 1430 */ 574, 571, 568, 1826, 1808, 1706, 1705, 1777, 144, 1778, /* 1430 */ 574, 571, 568, 1826, 1808, 1712, 168, 1777, 144, 1778,
/* 1440 */ 580, 1780, 1781, 576, 380, 571, 381, 1795, 1704, 1703, /* 1440 */ 580, 1780, 1781, 576, 375, 571, 374, 1795, 1221, 1706,
/* 1450 */ 1190, 1678, 1677, 1676, 67, 578, 1675, 1674, 1673, 1672, /* 1450 */ 1220, 1705, 380, 381, 1704, 578, 1703, 1190, 1678, 1677,
/* 1460 */ 1747, 1671, 577, 394, 395, 1795, 1670, 397, 1669, 1668, /* 1460 */ 1747, 1676, 577, 1675, 67, 1795, 1674, 1673, 1672, 1671,
/* 1470 */ 321, 1667, 1666, 578, 1665, 1664, 1663, 1662, 1747, 1661, /* 1470 */ 321, 394, 395, 578, 1670, 397, 1669, 1668, 1747, 1667,
/* 1480 */ 577, 1660, 556, 1934, 1659, 1658, 1657, 1808, 1656, 1777, /* 1480 */ 577, 1666, 555, 1934, 1665, 1664, 1663, 1808, 1662, 1777,
/* 1490 */ 1655, 91, 1778, 580, 1780, 1781, 576, 124, 571, 1654, /* 1490 */ 1661, 91, 1778, 580, 1780, 1781, 576, 1660, 571, 1659,
/* 1500 */ 1653, 1854, 1652, 1651, 1650, 1808, 1851, 1649, 1648, 293, /* 1500 */ 1658, 1854, 1657, 1656, 124, 1808, 1851, 1655, 1654, 293,
/* 1510 */ 1778, 580, 1780, 1781, 576, 1192, 571, 1795, 1647, 1646, /* 1510 */ 1778, 580, 1780, 1781, 576, 1653, 571, 1795, 1192, 1649,
/* 1520 */ 1522, 175, 527, 1520, 1488, 578, 152, 1006, 115, 177, /* 1520 */ 1648, 1647, 527, 1652, 1651, 578, 1650, 1646, 1522, 175,
/* 1530 */ 1747, 1777, 577, 1487, 178, 1005, 116, 432, 434, 1720, /* 1530 */ 1747, 1777, 577, 1520, 1488, 177, 1006, 115, 152, 1005,
/* 1540 */ 1714, 1777, 1702, 185, 183, 1701, 1687, 1572, 1519, 1517, /* 1540 */ 1487, 1777, 1720, 1714, 1702, 178, 1701, 432, 116, 183,
/* 1550 */ 449, 451, 1515, 455, 1513, 459, 1035, 1808, 450, 1795, /* 1550 */ 434, 185, 1687, 1572, 1519, 1517, 451, 1808, 450, 1795,
/* 1560 */ 453, 293, 1778, 580, 1780, 1781, 576, 578, 571, 1795, /* 1560 */ 1515, 293, 1778, 580, 1780, 1781, 576, 578, 571, 1795,
/* 1570 */ 457, 1511, 1747, 454, 577, 458, 461, 578, 462, 1500, /* 1570 */ 449, 453, 1747, 1035, 577, 1513, 454, 578, 455, 458,
/* 1580 */ 1499, 1484, 1747, 463, 577, 1574, 1145, 1144, 1573, 194, /* 1580 */ 457, 1511, 1747, 461, 577, 462, 459, 1500, 463, 1499,
/* 1590 */ 1070, 1777, 1069, 1068, 49, 1067, 626, 1509, 1064, 1808, /* 1590 */ 1484, 1777, 1574, 1145, 1144, 1573, 1070, 1069, 1068, 1808,
/* 1600 */ 316, 1063, 628, 288, 1778, 580, 1780, 1781, 576, 1808, /* 1600 */ 1067, 1064, 626, 288, 1778, 580, 1780, 1781, 576, 1808,
/* 1610 */ 571, 662, 1062, 144, 1778, 580, 1780, 1781, 576, 1795, /* 1610 */ 571, 628, 1063, 144, 1778, 580, 1780, 1781, 576, 1795,
/* 1620 */ 571, 1061, 1504, 317, 334, 266, 490, 578, 1502, 318, /* 1620 */ 571, 1062, 194, 49, 1509, 316, 1061, 575, 1504, 317,
/* 1630 */ 1483, 487, 1747, 1777, 577, 492, 1482, 494, 1481, 151, /* 1630 */ 1502, 487, 1747, 318, 577, 1483, 490, 492, 1482, 494,
/* 1640 */ 496, 546, 1719, 92, 652, 648, 644, 640, 264, 1713, /* 1640 */ 1481, 545, 496, 1777, 1719, 92, 1713, 1228, 503, 138,
/* 1650 */ 1228, 1777, 1700, 138, 503, 1698, 1699, 1697, 1935, 1808, /* 1650 */ 1700, 1698, 1699, 1697, 1696, 15, 1694, 223, 1935, 1808,
/* 1660 */ 1696, 1795, 54, 293, 1778, 580, 1780, 1781, 576, 575, /* 1660 */ 1777, 217, 212, 292, 1778, 580, 1780, 1781, 576, 1238,
/* 1670 */ 571, 212, 217, 15, 1747, 87, 577, 1694, 229, 1795, /* 1670 */ 571, 1795, 1827, 1686, 82, 225, 336, 76, 77, 578,
/* 1680 */ 223, 504, 319, 76, 336, 225, 509, 578, 518, 1238, /* 1680 */ 230, 16, 41, 23, 1747, 47, 577, 241, 1795, 54,
/* 1690 */ 1686, 227, 1747, 77, 577, 16, 230, 82, 1425, 1437, /* 1690 */ 1425, 234, 232, 338, 1407, 509, 578, 236, 240, 227,
/* 1700 */ 24, 1808, 42, 1777, 232, 292, 1778, 580, 1780, 1781, /* 1700 */ 1409, 1747, 504, 577, 1402, 145, 239, 518, 319, 1767,
/* 1710 */ 576, 523, 571, 236, 1827, 1270, 234, 48, 1407, 1808, /* 1710 */ 25, 1808, 1382, 662, 1381, 293, 1778, 580, 1780, 1781,
/* 1720 */ 1409, 145, 240, 293, 1778, 580, 1780, 1781, 576, 239, /* 1720 */ 576, 24, 571, 250, 46, 1766, 18, 266, 1808, 81,
/* 1730 */ 571, 1795, 25, 241, 1767, 193, 338, 26, 1402, 578, /* 1730 */ 149, 1437, 293, 1778, 580, 1780, 1781, 576, 45, 571,
/* 1740 */ 47, 250, 81, 216, 1747, 17, 577, 1382, 1381, 146, /* 1740 */ 1436, 151, 17, 1442, 1431, 193, 652, 648, 644, 640,
/* 1750 */ 1766, 149, 1442, 1777, 464, 460, 456, 452, 192, 46, /* 1750 */ 264, 1777, 330, 1441, 1440, 331, 10, 1270, 19, 146,
/* 1760 */ 18, 1431, 13, 1777, 1226, 1436, 209, 332, 1441, 1440, /* 1760 */ 1811, 1300, 1344, 1777, 464, 460, 456, 452, 192, 150,
/* 1770 */ 333, 1808, 10, 1811, 20, 293, 1778, 580, 1780, 1781, /* 1770 */ 1319, 570, 163, 1317, 31, 1777, 1316, 87, 579, 1795,
/* 1780 */ 576, 1795, 571, 1319, 570, 72, 1344, 32, 190, 578, /* 1780 */ 229, 12, 20, 21, 581, 1131, 583, 578, 339, 1128,
/* 1790 */ 150, 1795, 1317, 1316, 1747, 12, 577, 21, 163, 578, /* 1790 */ 585, 1795, 1747, 587, 577, 72, 1125, 13, 190, 578,
/* 1800 */ 1300, 581, 579, 22, 1747, 1131, 577, 583, 339, 585, /* 1800 */ 588, 590, 593, 1795, 1747, 591, 577, 1119, 594, 596,
/* 1810 */ 587, 1128, 588, 1108, 1125, 590, 593, 596, 1123, 1777, /* 1810 */ 1117, 578, 597, 523, 1108, 1123, 1747, 1122, 577, 1808,
/* 1820 */ 591, 1808, 1122, 1119, 594, 278, 1778, 580, 1780, 1781, /* 1820 */ 1140, 1121, 1120, 278, 1778, 580, 1780, 1781, 576, 83,
/* 1830 */ 576, 1808, 571, 1117, 597, 279, 1778, 580, 1780, 1781, /* 1830 */ 571, 1808, 603, 84, 60, 279, 1778, 580, 1780, 1781,
/* 1840 */ 576, 603, 571, 83, 84, 1140, 60, 1795, 261, 1121, /* 1840 */ 576, 261, 571, 1808, 1136, 216, 612, 280, 1778, 580,
/* 1850 */ 189, 182, 1136, 187, 1120, 578, 1033, 443, 612, 1058, /* 1850 */ 1780, 1781, 576, 1058, 571, 1033, 1077, 1777, 615, 262,
/* 1860 */ 1747, 1777, 577, 1077, 262, 615, 1051, 1056, 1055, 1054, /* 1860 */ 189, 182, 1056, 187, 1055, 1054, 1226, 443, 209, 1053,
/* 1870 */ 1053, 1777, 1052, 1050, 1049, 1074, 180, 1072, 1046, 1516, /* 1870 */ 1052, 1777, 1051, 1050, 1049, 1074, 1516, 1072, 1046, 1045,
/* 1880 */ 1045, 1044, 1041, 1777, 1040, 1039, 1038, 1808, 637, 1795, /* 1880 */ 1044, 1041, 1040, 1039, 1038, 1795, 180, 637, 1514, 1512,
/* 1890 */ 1514, 280, 1778, 580, 1780, 1781, 576, 578, 571, 1795, /* 1890 */ 639, 641, 643, 578, 645, 1510, 649, 647, 1747, 1795,
/* 1900 */ 639, 638, 1747, 641, 577, 642, 643, 578, 1512, 645, /* 1900 */ 577, 638, 642, 651, 646, 1498, 653, 578, 996, 650,
/* 1910 */ 646, 1795, 1747, 1510, 577, 647, 649, 650, 1498, 578, /* 1910 */ 1480, 657, 1747, 265, 577, 1256, 273, 660, 661, 1455,
/* 1920 */ 653, 651, 996, 1480, 1747, 1777, 577, 265, 657, 1808, /* 1920 */ 1455, 1777, 1455, 1455, 1455, 1808, 1455, 1455, 1455, 287,
/* 1930 */ 1455, 1256, 273, 287, 1778, 580, 1780, 1781, 576, 1808, /* 1930 */ 1778, 580, 1780, 1781, 576, 1455, 571, 1777, 1455, 1808,
/* 1940 */ 571, 660, 1777, 289, 1778, 580, 1780, 1781, 576, 661, /* 1940 */ 1455, 1455, 1455, 289, 1778, 580, 1780, 1781, 576, 1795,
/* 1950 */ 571, 1808, 1455, 1795, 1455, 281, 1778, 580, 1780, 1781, /* 1950 */ 571, 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455,
/* 1960 */ 576, 578, 571, 1455, 1455, 1455, 1747, 1455, 577, 1455, /* 1960 */ 1455, 1455, 1747, 1455, 577, 1795, 1455, 1455, 1455, 1455,
/* 1970 */ 1795, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, /* 1970 */ 1455, 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, 1455,
/* 1980 */ 1455, 1455, 1455, 1747, 1777, 577, 1455, 1455, 1455, 1455, /* 1980 */ 577, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1808,
/* 1990 */ 1455, 1455, 1455, 1808, 1777, 1455, 1455, 290, 1778, 580, /* 1990 */ 1777, 1455, 1455, 281, 1778, 580, 1780, 1781, 576, 1455,
/* 2000 */ 1780, 1781, 576, 1455, 571, 1455, 1455, 1455, 1455, 1455, /* 2000 */ 571, 1455, 1455, 1455, 1777, 1808, 1455, 1455, 1455, 290,
/* 2010 */ 1808, 1455, 1795, 1455, 282, 1778, 580, 1780, 1781, 576, /* 2010 */ 1778, 580, 1780, 1781, 576, 1455, 571, 1455, 1795, 1455,
/* 2020 */ 578, 571, 1795, 1455, 1455, 1747, 1455, 577, 1455, 1455, /* 2020 */ 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455,
/* 2030 */ 578, 1455, 1455, 1455, 1455, 1747, 1777, 577, 1455, 1455, /* 2030 */ 1455, 1747, 1795, 577, 1455, 1455, 1455, 1455, 1455, 1455,
/* 2040 */ 1455, 1455, 1455, 1455, 1455, 1455, 1777, 1455, 1455, 1455, /* 2040 */ 578, 1455, 1455, 1455, 1455, 1747, 1455, 577, 1455, 1455,
/* 2050 */ 1455, 1455, 1808, 1455, 1455, 1455, 291, 1778, 580, 1780, /* 2050 */ 1455, 1455, 1455, 1455, 1455, 1455, 1777, 1455, 1808, 1455,
/* 2060 */ 1781, 576, 1808, 571, 1795, 1455, 283, 1778, 580, 1780, /* 2060 */ 1455, 1455, 282, 1778, 580, 1780, 1781, 576, 1455, 571,
/* 2070 */ 1781, 576, 578, 571, 1795, 1455, 1455, 1747, 1455, 577, /* 2070 */ 1455, 1455, 1808, 1455, 1777, 1455, 291, 1778, 580, 1780,
/* 2080 */ 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, 1777, 577, /* 2080 */ 1781, 576, 1455, 571, 1795, 1455, 1455, 1455, 1455, 1455,
/* 2090 */ 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1777, 1455, /* 2090 */ 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, 1777, 577,
/* 2100 */ 1455, 1455, 1455, 1455, 1808, 1455, 1455, 1455, 296, 1778, /* 2100 */ 1455, 1455, 1795, 1455, 1455, 1455, 1455, 1455, 1455, 1455,
/* 2110 */ 580, 1780, 1781, 576, 1808, 571, 1795, 1455, 297, 1778, /* 2110 */ 578, 1455, 1455, 1455, 1455, 1747, 1455, 577, 1455, 1455,
/* 2120 */ 580, 1780, 1781, 576, 578, 571, 1795, 1455, 1455, 1747, /* 2120 */ 1455, 1455, 1455, 1455, 1808, 1455, 1795, 1455, 283, 1778,
/* 2130 */ 1455, 577, 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, /* 2130 */ 580, 1780, 1781, 576, 578, 571, 1455, 1455, 1455, 1747,
/* 2140 */ 1455, 577, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, /* 2140 */ 1455, 577, 1808, 1455, 1455, 1455, 296, 1778, 580, 1780,
/* 2150 */ 1777, 1455, 1455, 1455, 1455, 1455, 1808, 1455, 1455, 1455, /* 2150 */ 1781, 576, 1455, 571, 1455, 1455, 1777, 1455, 1455, 1455,
/* 2160 */ 1789, 1778, 580, 1780, 1781, 576, 1808, 571, 1455, 1777, /* 2160 */ 1455, 1455, 1455, 1455, 1455, 1455, 1808, 1455, 1455, 1455,
/* 2170 */ 1788, 1778, 580, 1780, 1781, 576, 1455, 571, 1795, 1455, /* 2170 */ 297, 1778, 580, 1780, 1781, 576, 1455, 571, 1455, 1777,
/* 2180 */ 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455, /* 2180 */ 1455, 1455, 1455, 1455, 1795, 1455, 1455, 1455, 1455, 1455,
/* 2190 */ 1455, 1747, 1777, 577, 1455, 1455, 1455, 1795, 1455, 1455, /* 2190 */ 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, 1455, 577,
/* 2200 */ 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455, 1455, /* 2200 */ 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1795, 1455, 1455,
/* 2210 */ 1747, 1777, 577, 1455, 1455, 1455, 1455, 1455, 1808, 1455, /* 2210 */ 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455, 1455,
/* 2220 */ 1795, 1455, 1787, 1778, 580, 1780, 1781, 576, 578, 571, /* 2220 */ 1747, 1455, 577, 1455, 1808, 1455, 1455, 1455, 1789, 1778,
/* 2230 */ 1455, 1455, 1455, 1747, 1455, 577, 1455, 1808, 1455, 1795, /* 2230 */ 580, 1780, 1781, 576, 1455, 571, 1777, 1455, 1455, 1455,
/* 2240 */ 1455, 308, 1778, 580, 1780, 1781, 576, 578, 571, 1455, /* 2240 */ 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1808, 1777, 1455,
/* 2250 */ 1455, 1455, 1747, 1455, 577, 1455, 1455, 1455, 1455, 1455, /* 2250 */ 1455, 1788, 1778, 580, 1780, 1781, 576, 1455, 571, 1455,
/* 2260 */ 1808, 1455, 1455, 1455, 307, 1778, 580, 1780, 1781, 576, /* 2260 */ 1455, 1455, 1777, 1455, 1795, 1455, 1455, 1455, 1455, 1455,
/* 2270 */ 1777, 571, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1808, /* 2270 */ 1455, 1455, 578, 1455, 1455, 1455, 1795, 1747, 1455, 577,
/* 2280 */ 1777, 1455, 1455, 309, 1778, 580, 1780, 1781, 576, 1455, /* 2280 */ 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747,
/* 2290 */ 571, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1795, 1455, /* 2290 */ 1795, 577, 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455,
/* 2300 */ 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, 1795, 1455, /* 2300 */ 1455, 1455, 1455, 1747, 1808, 577, 1455, 1455, 1787, 1778,
/* 2310 */ 1455, 1747, 1455, 577, 1455, 1455, 578, 1455, 1455, 1455, /* 2310 */ 580, 1780, 1781, 576, 1777, 571, 1808, 1455, 1455, 1455,
/* 2320 */ 1455, 1747, 1455, 577, 1455, 1455, 1455, 1455, 1455, 1455, /* 2320 */ 308, 1778, 580, 1780, 1781, 576, 1455, 571, 1455, 1455,
/* 2330 */ 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1808, 1455, /* 2330 */ 1808, 1455, 1777, 1455, 307, 1778, 580, 1780, 1781, 576,
/* 2340 */ 1455, 1455, 306, 1778, 580, 1780, 1781, 576, 1808, 571, /* 2340 */ 1455, 571, 1795, 1455, 1455, 1455, 1455, 1455, 1455, 1455,
/* 2350 */ 1455, 1455, 286, 1778, 580, 1780, 1781, 576, 1455, 571, /* 2350 */ 578, 1455, 1455, 1455, 1455, 1747, 1777, 577, 1455, 1455,
/* 2360 */ 1795, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455,
/* 2370 */ 1455, 1455, 1455, 1747, 1455, 577, 1455, 1455, 1455, 1455,
/* 2380 */ 1455, 1455, 1808, 1455, 1795, 1455, 309, 1778, 580, 1780,
/* 2390 */ 1781, 576, 578, 571, 1455, 1455, 1455, 1747, 1455, 577,
/* 2400 */ 1808, 1455, 1455, 1455, 306, 1778, 580, 1780, 1781, 576,
/* 2410 */ 1455, 571, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455,
/* 2420 */ 1455, 1455, 1455, 1455, 1808, 1455, 1455, 1455, 286, 1778,
/* 2430 */ 580, 1780, 1781, 576, 1455, 571,
}; };
static const YYCODETYPE yy_lookahead[] = { static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 261, 355, 263, 264, 261, 269, 263, 264, 300, 4, /* 0 */ 261, 355, 263, 264, 261, 269, 263, 264, 300, 4,
@ -532,7 +540,7 @@ static const YYCODETYPE yy_lookahead[] = {
/* 730 */ 205, 206, 207, 208, 209, 210, 211, 355, 241, 298, /* 730 */ 205, 206, 207, 208, 209, 210, 211, 355, 241, 298,
/* 740 */ 165, 310, 167, 312, 273, 2, 275, 165, 85, 167, /* 740 */ 165, 310, 167, 312, 273, 2, 275, 165, 85, 167,
/* 750 */ 368, 8, 9, 300, 372, 12, 13, 14, 15, 16, /* 750 */ 368, 8, 9, 300, 372, 12, 13, 14, 15, 16,
/* 760 */ 314, 222, 223, 35, 311, 8, 9, 192, 193, 12, /* 760 */ 314, 222, 223, 67, 311, 8, 9, 192, 193, 12,
/* 770 */ 13, 14, 15, 16, 192, 193, 56, 195, 196, 197, /* 770 */ 13, 14, 15, 16, 192, 193, 56, 195, 196, 197,
/* 780 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, /* 780 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
/* 790 */ 208, 209, 210, 211, 12, 13, 18, 286, 20, 257, /* 790 */ 208, 209, 210, 211, 12, 13, 18, 286, 20, 257,
@ -543,165 +551,173 @@ static const YYCODETYPE yy_lookahead[] = {
/* 840 */ 298, 293, 85, 0, 298, 265, 300, 8, 9, 67, /* 840 */ 298, 293, 85, 0, 298, 265, 300, 8, 9, 67,
/* 850 */ 298, 12, 13, 14, 15, 16, 276, 355, 265, 152, /* 850 */ 298, 12, 13, 14, 15, 16, 276, 355, 265, 152,
/* 860 */ 153, 83, 88, 283, 35, 91, 84, 298, 243, 298, /* 860 */ 153, 83, 88, 283, 35, 91, 84, 298, 243, 298,
/* 870 */ 368, 325, 67, 293, 372, 329, 330, 331, 332, 333, /* 870 */ 368, 325, 286, 293, 372, 329, 330, 331, 332, 333,
/* 880 */ 334, 257, 336, 223, 257, 339, 293, 257, 106, 343, /* 880 */ 334, 257, 336, 223, 257, 339, 293, 257, 106, 343,
/* 890 */ 344, 345, 257, 257, 88, 167, 0, 91, 60, 286, /* 890 */ 344, 345, 257, 257, 88, 1, 2, 91, 35, 286,
/* 900 */ 354, 123, 120, 121, 126, 127, 128, 129, 130, 131, /* 900 */ 354, 123, 120, 121, 126, 127, 128, 129, 130, 131,
/* 910 */ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, /* 910 */ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
/* 920 */ 142, 143, 298, 145, 146, 298, 333, 265, 298, 265, /* 920 */ 142, 143, 298, 145, 146, 298, 333, 265, 298, 265,
/* 930 */ 43, 18, 286, 298, 298, 265, 23, 265, 276, 96, /* 930 */ 43, 18, 35, 298, 298, 265, 23, 265, 276, 96,
/* 940 */ 276, 348, 349, 350, 48, 352, 276, 165, 276, 167, /* 940 */ 276, 348, 349, 350, 60, 352, 276, 165, 276, 167,
/* 950 */ 37, 38, 1, 2, 41, 293, 318, 293, 115, 116, /* 950 */ 37, 38, 120, 121, 41, 293, 318, 293, 115, 116,
/* 960 */ 117, 118, 119, 293, 286, 293, 257, 120, 121, 286, /* 960 */ 117, 118, 119, 293, 67, 293, 257, 286, 286, 286,
/* 970 */ 57, 58, 85, 43, 192, 193, 265, 195, 196, 197, /* 970 */ 57, 58, 85, 43, 192, 193, 265, 195, 196, 197,
/* 980 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, /* 980 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
/* 990 */ 208, 209, 210, 211, 285, 265, 167, 84, 88, 265, /* 990 */ 208, 209, 210, 211, 285, 265, 167, 84, 88, 265,
/* 1000 */ 265, 91, 293, 265, 293, 88, 276, 298, 91, 300, /* 1000 */ 265, 91, 293, 265, 293, 88, 276, 298, 91, 300,
/* 1010 */ 276, 276, 196, 287, 276, 85, 43, 258, 287, 286, /* 1010 */ 276, 276, 196, 287, 276, 85, 43, 258, 287, 274,
/* 1020 */ 274, 265, 375, 293, 298, 314, 266, 293, 293, 298, /* 1020 */ 375, 265, 321, 293, 298, 314, 266, 293, 293, 298,
/* 1030 */ 192, 293, 276, 225, 325, 122, 265, 257, 329, 330, /* 1030 */ 167, 293, 276, 225, 325, 122, 265, 257, 329, 330,
/* 1040 */ 331, 332, 333, 334, 333, 336, 0, 276, 339, 293, /* 1040 */ 331, 332, 333, 334, 333, 336, 0, 276, 339, 293,
/* 1050 */ 324, 325, 343, 344, 345, 324, 325, 326, 85, 348, /* 1050 */ 324, 325, 343, 344, 345, 324, 325, 326, 85, 348,
/* 1060 */ 349, 350, 336, 352, 293, 285, 355, 336, 22, 0, /* 1060 */ 349, 350, 336, 352, 293, 285, 355, 336, 22, 0,
/* 1070 */ 157, 158, 159, 293, 365, 162, 366, 362, 298, 368, /* 1070 */ 157, 158, 159, 293, 365, 162, 192, 84, 298, 368,
/* 1080 */ 300, 168, 46, 372, 43, 12, 13, 265, 43, 35, /* 1080 */ 300, 168, 366, 372, 46, 12, 13, 94, 43, 362,
/* 1090 */ 43, 22, 285, 43, 181, 22, 43, 184, 276, 186, /* 1090 */ 43, 22, 285, 43, 181, 22, 43, 184, 264, 186,
/* 1100 */ 187, 188, 189, 190, 191, 325, 33, 287, 35, 329, /* 1100 */ 187, 188, 189, 190, 191, 325, 33, 287, 35, 329,
/* 1110 */ 330, 331, 332, 333, 334, 293, 336, 43, 298, 339, /* 1110 */ 330, 331, 332, 333, 334, 287, 336, 43, 298, 339,
/* 1120 */ 84, 67, 43, 343, 344, 345, 85, 266, 43, 56, /* 1120 */ 265, 297, 84, 343, 344, 345, 298, 0, 43, 56,
/* 1130 */ 85, 43, 85, 257, 354, 85, 84, 224, 85, 43, /* 1130 */ 85, 276, 85, 257, 354, 85, 266, 224, 85, 43,
/* 1140 */ 67, 43, 43, 43, 324, 325, 94, 321, 264, 297, /* 1140 */ 67, 43, 328, 43, 324, 325, 326, 43, 293, 43,
/* 1150 */ 353, 328, 369, 369, 369, 346, 336, 356, 289, 85, /* 1150 */ 43, 43, 324, 325, 353, 346, 336, 369, 369, 85,
/* 1160 */ 84, 285, 226, 323, 85, 20, 265, 47, 322, 293, /* 1160 */ 369, 285, 84, 289, 336, 226, 356, 323, 20, 293,
/* 1170 */ 85, 35, 163, 85, 298, 271, 300, 265, 316, 106, /* 1170 */ 85, 265, 47, 322, 298, 48, 300, 35, 271, 106,
/* 1180 */ 265, 85, 42, 85, 85, 85, 305, 147, 303, 303, /* 1180 */ 163, 85, 316, 85, 265, 85, 265, 42, 305, 85,
/* 1190 */ 314, 265, 265, 20, 257, 20, 20, 259, 259, 320, /* 1190 */ 314, 85, 85, 85, 257, 147, 303, 265, 303, 265,
/* 1200 */ 269, 325, 300, 269, 313, 329, 330, 331, 332, 333, /* 1200 */ 259, 325, 20, 259, 20, 329, 330, 331, 332, 333,
/* 1210 */ 334, 20, 336, 315, 269, 269, 313, 20, 269, 269, /* 1210 */ 334, 320, 336, 20, 269, 300, 269, 313, 20, 269,
/* 1220 */ 306, 265, 285, 269, 259, 285, 285, 285, 285, 285, /* 1220 */ 315, 313, 285, 269, 20, 269, 306, 269, 265, 269,
/* 1230 */ 293, 355, 285, 285, 265, 298, 259, 300, 165, 320, /* 1230 */ 293, 355, 320, 259, 285, 298, 285, 300, 165, 259,
/* 1240 */ 167, 267, 285, 285, 368, 285, 285, 257, 372, 267, /* 1240 */ 167, 265, 285, 173, 368, 267, 285, 257, 372, 285,
/* 1250 */ 298, 314, 319, 173, 265, 300, 265, 231, 20, 267, /* 1250 */ 285, 314, 285, 285, 285, 285, 285, 298, 267, 319,
/* 1260 */ 298, 298, 325, 149, 298, 192, 329, 330, 331, 332, /* 1260 */ 265, 265, 325, 231, 267, 192, 329, 330, 331, 332,
/* 1270 */ 333, 334, 313, 336, 298, 285, 203, 204, 205, 206, /* 1270 */ 333, 334, 300, 336, 267, 285, 203, 204, 205, 206,
/* 1280 */ 207, 208, 209, 293, 309, 298, 307, 309, 298, 293, /* 1280 */ 207, 208, 209, 293, 309, 298, 298, 298, 298, 149,
/* 1290 */ 300, 306, 355, 281, 267, 267, 293, 298, 328, 257, /* 1290 */ 300, 309, 355, 307, 313, 293, 298, 298, 306, 257,
/* 1300 */ 232, 238, 309, 298, 298, 368, 309, 156, 298, 372, /* 1300 */ 281, 267, 293, 20, 298, 368, 298, 328, 232, 372,
/* 1310 */ 240, 298, 223, 227, 361, 325, 239, 323, 293, 329, /* 1310 */ 309, 298, 309, 361, 361, 325, 298, 238, 298, 329,
/* 1320 */ 330, 331, 332, 333, 334, 361, 336, 285, 360, 339, /* 1320 */ 330, 331, 332, 333, 334, 156, 336, 285, 240, 339,
/* 1330 */ 358, 364, 361, 343, 344, 293, 20, 244, 327, 242, /* 1330 */ 364, 239, 227, 343, 344, 293, 223, 323, 361, 20,
/* 1340 */ 298, 247, 300, 363, 84, 359, 342, 289, 265, 298, /* 1340 */ 298, 244, 300, 358, 360, 293, 363, 84, 327, 247,
/* 1350 */ 275, 370, 257, 36, 371, 317, 312, 267, 0, 371, /* 1350 */ 289, 265, 257, 359, 242, 298, 275, 267, 36, 260,
/* 1360 */ 376, 260, 259, 279, 175, 370, 257, 325, 255, 371, /* 1360 */ 259, 317, 279, 312, 0, 342, 257, 325, 279, 255,
/* 1370 */ 370, 329, 330, 331, 332, 333, 334, 0, 336, 268, /* 1370 */ 370, 329, 330, 331, 332, 333, 334, 175, 336, 268,
/* 1380 */ 285, 339, 0, 279, 279, 343, 344, 42, 293, 0, /* 1380 */ 285, 339, 371, 371, 0, 343, 344, 371, 293, 279,
/* 1390 */ 75, 0, 35, 298, 285, 300, 185, 35, 35, 35, /* 1390 */ 0, 376, 370, 298, 285, 300, 370, 42, 0, 75,
/* 1400 */ 185, 0, 293, 35, 35, 185, 0, 298, 185, 300, /* 1400 */ 0, 35, 293, 185, 35, 35, 35, 298, 185, 300,
/* 1410 */ 0, 0, 22, 35, 0, 35, 0, 84, 170, 257, /* 1410 */ 0, 35, 35, 185, 0, 185, 0, 35, 0, 257,
/* 1420 */ 325, 169, 167, 165, 329, 330, 331, 332, 333, 334, /* 1420 */ 325, 22, 0, 35, 329, 330, 331, 332, 333, 334,
/* 1430 */ 335, 336, 337, 338, 325, 0, 0, 257, 329, 330, /* 1430 */ 335, 336, 337, 338, 325, 0, 84, 257, 329, 330,
/* 1440 */ 331, 332, 333, 334, 161, 336, 160, 285, 0, 0, /* 1440 */ 331, 332, 333, 334, 169, 336, 170, 285, 167, 0,
/* 1450 */ 46, 0, 0, 0, 144, 293, 0, 0, 0, 0, /* 1450 */ 165, 0, 161, 160, 0, 293, 0, 46, 0, 0,
/* 1460 */ 298, 0, 300, 139, 35, 285, 0, 139, 0, 0, /* 1460 */ 298, 0, 300, 0, 144, 285, 0, 0, 0, 0,
/* 1470 */ 290, 0, 0, 293, 0, 0, 0, 0, 298, 0, /* 1470 */ 290, 139, 35, 293, 0, 139, 0, 0, 298, 0,
/* 1480 */ 300, 0, 373, 374, 0, 0, 0, 325, 0, 257, /* 1480 */ 300, 0, 373, 374, 0, 0, 0, 325, 0, 257,
/* 1490 */ 0, 329, 330, 331, 332, 333, 334, 42, 336, 0, /* 1490 */ 0, 329, 330, 331, 332, 333, 334, 0, 336, 0,
/* 1500 */ 0, 339, 0, 0, 0, 325, 344, 0, 0, 329, /* 1500 */ 0, 339, 0, 0, 42, 325, 344, 0, 0, 329,
/* 1510 */ 330, 331, 332, 333, 334, 22, 336, 285, 0, 0, /* 1510 */ 330, 331, 332, 333, 334, 0, 336, 285, 22, 0,
/* 1520 */ 0, 56, 290, 0, 0, 293, 43, 14, 39, 42, /* 1520 */ 0, 0, 290, 0, 0, 293, 0, 0, 0, 56,
/* 1530 */ 298, 257, 300, 0, 40, 14, 39, 46, 46, 0, /* 1530 */ 298, 257, 300, 0, 0, 42, 14, 39, 43, 14,
/* 1540 */ 0, 257, 0, 156, 39, 0, 0, 0, 0, 0, /* 1540 */ 0, 257, 0, 0, 0, 40, 0, 46, 39, 39,
/* 1550 */ 35, 39, 0, 39, 0, 39, 61, 325, 47, 285, /* 1550 */ 46, 156, 0, 0, 0, 0, 39, 325, 47, 285,
/* 1560 */ 35, 329, 330, 331, 332, 333, 334, 293, 336, 285, /* 1560 */ 0, 329, 330, 331, 332, 333, 334, 293, 336, 285,
/* 1570 */ 35, 0, 298, 47, 300, 47, 35, 293, 47, 0, /* 1570 */ 35, 35, 298, 61, 300, 0, 47, 293, 39, 47,
/* 1580 */ 0, 0, 298, 39, 300, 0, 35, 22, 0, 91, /* 1580 */ 35, 0, 298, 35, 300, 47, 39, 0, 39, 0,
/* 1590 */ 35, 257, 35, 35, 93, 35, 43, 0, 35, 325, /* 1590 */ 0, 257, 0, 35, 22, 0, 35, 35, 35, 325,
/* 1600 */ 22, 35, 43, 329, 330, 331, 332, 333, 334, 325, /* 1600 */ 35, 35, 43, 329, 330, 331, 332, 333, 334, 325,
/* 1610 */ 336, 19, 35, 329, 330, 331, 332, 333, 334, 285, /* 1610 */ 336, 43, 35, 329, 330, 331, 332, 333, 334, 285,
/* 1620 */ 336, 35, 0, 22, 290, 33, 35, 293, 0, 22, /* 1620 */ 336, 35, 91, 93, 0, 22, 35, 293, 0, 22,
/* 1630 */ 0, 49, 298, 257, 300, 35, 0, 35, 0, 47, /* 1630 */ 0, 49, 298, 22, 300, 0, 35, 35, 0, 35,
/* 1640 */ 22, 367, 0, 20, 52, 53, 54, 55, 56, 0, /* 1640 */ 0, 367, 22, 257, 0, 20, 0, 35, 22, 171,
/* 1650 */ 35, 257, 0, 171, 22, 0, 0, 0, 374, 325, /* 1650 */ 0, 0, 0, 0, 0, 84, 0, 84, 374, 325,
/* 1660 */ 0, 285, 152, 329, 330, 331, 332, 333, 334, 293, /* 1660 */ 257, 85, 149, 329, 330, 331, 332, 333, 334, 180,
/* 1670 */ 336, 149, 85, 84, 298, 83, 300, 0, 86, 285, /* 1670 */ 336, 285, 338, 0, 94, 39, 290, 84, 84, 293,
/* 1680 */ 84, 152, 152, 84, 290, 39, 154, 293, 150, 180, /* 1680 */ 46, 228, 43, 84, 298, 43, 300, 46, 285, 152,
/* 1690 */ 0, 148, 298, 84, 300, 228, 46, 94, 85, 35, /* 1690 */ 85, 85, 84, 290, 85, 154, 293, 84, 43, 148,
/* 1700 */ 84, 325, 43, 257, 84, 329, 330, 331, 332, 333, /* 1700 */ 85, 298, 152, 300, 85, 84, 84, 150, 152, 46,
/* 1710 */ 334, 119, 336, 84, 338, 22, 85, 43, 85, 325, /* 1710 */ 43, 325, 85, 19, 85, 329, 330, 331, 332, 333,
/* 1720 */ 85, 84, 43, 329, 330, 331, 332, 333, 334, 84, /* 1720 */ 334, 84, 336, 46, 43, 46, 43, 33, 325, 84,
/* 1730 */ 336, 285, 84, 46, 46, 33, 290, 43, 85, 293, /* 1730 */ 46, 35, 329, 330, 331, 332, 333, 334, 222, 336,
/* 1740 */ 43, 46, 84, 151, 298, 228, 300, 85, 85, 47, /* 1740 */ 35, 47, 228, 85, 85, 33, 52, 53, 54, 55,
/* 1750 */ 46, 46, 85, 257, 52, 53, 54, 55, 56, 222, /* 1750 */ 56, 257, 35, 35, 35, 35, 2, 22, 43, 47,
/* 1760 */ 43, 85, 228, 257, 172, 35, 174, 35, 35, 35, /* 1760 */ 84, 22, 192, 257, 52, 53, 54, 55, 56, 46,
/* 1770 */ 35, 325, 2, 84, 43, 329, 330, 331, 332, 333, /* 1770 */ 85, 84, 46, 85, 84, 257, 85, 83, 194, 285,
/* 1780 */ 334, 285, 336, 85, 84, 83, 192, 84, 86, 293, /* 1780 */ 86, 84, 84, 84, 95, 85, 35, 293, 35, 85,
/* 1790 */ 46, 285, 85, 85, 298, 84, 300, 84, 46, 293, /* 1790 */ 84, 285, 298, 35, 300, 83, 85, 228, 86, 293,
/* 1800 */ 22, 95, 194, 84, 298, 85, 300, 35, 35, 84, /* 1800 */ 84, 35, 35, 285, 298, 84, 300, 85, 84, 35,
/* 1810 */ 35, 85, 84, 22, 85, 35, 35, 35, 108, 257, /* 1810 */ 85, 293, 84, 119, 22, 108, 298, 108, 300, 325,
/* 1820 */ 84, 325, 108, 85, 84, 329, 330, 331, 332, 333, /* 1820 */ 35, 108, 108, 329, 330, 331, 332, 333, 334, 84,
/* 1830 */ 334, 325, 336, 85, 84, 329, 330, 331, 332, 333, /* 1830 */ 336, 325, 96, 84, 84, 329, 330, 331, 332, 333,
/* 1840 */ 334, 96, 336, 84, 84, 35, 84, 285, 43, 108, /* 1840 */ 334, 43, 336, 325, 22, 151, 60, 329, 330, 331,
/* 1850 */ 148, 149, 22, 151, 108, 293, 61, 155, 60, 35, /* 1850 */ 332, 333, 334, 35, 336, 61, 67, 257, 82, 43,
/* 1860 */ 298, 257, 300, 67, 43, 82, 22, 35, 35, 35, /* 1860 */ 148, 149, 35, 151, 35, 35, 172, 155, 174, 35,
/* 1870 */ 35, 257, 35, 35, 35, 67, 174, 35, 35, 0, /* 1870 */ 35, 257, 22, 35, 35, 67, 0, 35, 35, 35,
/* 1880 */ 35, 35, 35, 257, 35, 35, 35, 325, 35, 285, /* 1880 */ 35, 35, 35, 35, 35, 285, 174, 35, 0, 0,
/* 1890 */ 0, 329, 330, 331, 332, 333, 334, 293, 336, 285, /* 1890 */ 39, 35, 39, 293, 35, 0, 35, 39, 298, 285,
/* 1900 */ 39, 47, 298, 35, 300, 47, 39, 293, 0, 35, /* 1900 */ 300, 47, 47, 39, 47, 0, 35, 293, 35, 47,
/* 1910 */ 47, 285, 298, 0, 300, 39, 35, 47, 0, 293, /* 1910 */ 0, 21, 298, 22, 300, 22, 22, 21, 20, 377,
/* 1920 */ 35, 39, 35, 0, 298, 257, 300, 22, 21, 325, /* 1920 */ 377, 257, 377, 377, 377, 325, 377, 377, 377, 329,
/* 1930 */ 377, 22, 22, 329, 330, 331, 332, 333, 334, 325, /* 1930 */ 330, 331, 332, 333, 334, 377, 336, 257, 377, 325,
/* 1940 */ 336, 21, 257, 329, 330, 331, 332, 333, 334, 20, /* 1940 */ 377, 377, 377, 329, 330, 331, 332, 333, 334, 285,
/* 1950 */ 336, 325, 377, 285, 377, 329, 330, 331, 332, 333, /* 1950 */ 336, 377, 377, 377, 377, 377, 377, 293, 377, 377,
/* 1960 */ 334, 293, 336, 377, 377, 377, 298, 377, 300, 377, /* 1960 */ 377, 377, 298, 377, 300, 285, 377, 377, 377, 377,
/* 1970 */ 285, 377, 377, 377, 377, 377, 377, 377, 293, 377, /* 1970 */ 377, 377, 377, 293, 377, 377, 377, 377, 298, 377,
/* 1980 */ 377, 377, 377, 298, 257, 300, 377, 377, 377, 377, /* 1980 */ 300, 377, 377, 377, 377, 377, 377, 377, 377, 325,
/* 1990 */ 377, 377, 377, 325, 257, 377, 377, 329, 330, 331, /* 1990 */ 257, 377, 377, 329, 330, 331, 332, 333, 334, 377,
/* 2000 */ 332, 333, 334, 377, 336, 377, 377, 377, 377, 377, /* 2000 */ 336, 377, 377, 377, 257, 325, 377, 377, 377, 329,
/* 2010 */ 325, 377, 285, 377, 329, 330, 331, 332, 333, 334, /* 2010 */ 330, 331, 332, 333, 334, 377, 336, 377, 285, 377,
/* 2020 */ 293, 336, 285, 377, 377, 298, 377, 300, 377, 377, /* 2020 */ 377, 377, 377, 377, 377, 377, 293, 377, 377, 377,
/* 2030 */ 293, 377, 377, 377, 377, 298, 257, 300, 377, 377, /* 2030 */ 377, 298, 285, 300, 377, 377, 377, 377, 377, 377,
/* 2040 */ 377, 377, 377, 377, 377, 377, 257, 377, 377, 377, /* 2040 */ 293, 377, 377, 377, 377, 298, 377, 300, 377, 377,
/* 2050 */ 377, 377, 325, 377, 377, 377, 329, 330, 331, 332, /* 2050 */ 377, 377, 377, 377, 377, 377, 257, 377, 325, 377,
/* 2060 */ 333, 334, 325, 336, 285, 377, 329, 330, 331, 332, /* 2060 */ 377, 377, 329, 330, 331, 332, 333, 334, 377, 336,
/* 2070 */ 333, 334, 293, 336, 285, 377, 377, 298, 377, 300, /* 2070 */ 377, 377, 325, 377, 257, 377, 329, 330, 331, 332,
/* 2080 */ 377, 377, 293, 377, 377, 377, 377, 298, 257, 300, /* 2080 */ 333, 334, 377, 336, 285, 377, 377, 377, 377, 377,
/* 2090 */ 377, 377, 377, 377, 377, 377, 377, 377, 257, 377, /* 2090 */ 377, 377, 293, 377, 377, 377, 377, 298, 257, 300,
/* 2100 */ 377, 377, 377, 377, 325, 377, 377, 377, 329, 330, /* 2100 */ 377, 377, 285, 377, 377, 377, 377, 377, 377, 377,
/* 2110 */ 331, 332, 333, 334, 325, 336, 285, 377, 329, 330, /* 2110 */ 293, 377, 377, 377, 377, 298, 377, 300, 377, 377,
/* 2120 */ 331, 332, 333, 334, 293, 336, 285, 377, 377, 298, /* 2120 */ 377, 377, 377, 377, 325, 377, 285, 377, 329, 330,
/* 2130 */ 377, 300, 377, 377, 293, 377, 377, 377, 377, 298, /* 2130 */ 331, 332, 333, 334, 293, 336, 377, 377, 377, 298,
/* 2140 */ 377, 300, 377, 377, 377, 377, 377, 377, 377, 377, /* 2140 */ 377, 300, 325, 377, 377, 377, 329, 330, 331, 332,
/* 2150 */ 257, 377, 377, 377, 377, 377, 325, 377, 377, 377, /* 2150 */ 333, 334, 377, 336, 377, 377, 257, 377, 377, 377,
/* 2160 */ 329, 330, 331, 332, 333, 334, 325, 336, 377, 257, /* 2160 */ 377, 377, 377, 377, 377, 377, 325, 377, 377, 377,
/* 2170 */ 329, 330, 331, 332, 333, 334, 377, 336, 285, 377, /* 2170 */ 329, 330, 331, 332, 333, 334, 377, 336, 377, 257,
/* 2180 */ 377, 377, 377, 377, 377, 377, 293, 377, 377, 377, /* 2180 */ 377, 377, 377, 377, 285, 377, 377, 377, 377, 377,
/* 2190 */ 377, 298, 257, 300, 377, 377, 377, 285, 377, 377, /* 2190 */ 377, 377, 293, 377, 377, 377, 377, 298, 377, 300,
/* 2200 */ 377, 377, 377, 377, 377, 293, 377, 377, 377, 377, /* 2200 */ 377, 377, 377, 377, 377, 377, 377, 285, 377, 377,
/* 2210 */ 298, 257, 300, 377, 377, 377, 377, 377, 325, 377, /* 2210 */ 377, 377, 377, 377, 377, 293, 377, 377, 377, 377,
/* 2220 */ 285, 377, 329, 330, 331, 332, 333, 334, 293, 336, /* 2220 */ 298, 377, 300, 377, 325, 377, 377, 377, 329, 330,
/* 2230 */ 377, 377, 377, 298, 377, 300, 377, 325, 377, 285, /* 2230 */ 331, 332, 333, 334, 377, 336, 257, 377, 377, 377,
/* 2240 */ 377, 329, 330, 331, 332, 333, 334, 293, 336, 377, /* 2240 */ 377, 377, 377, 377, 377, 377, 377, 325, 257, 377,
/* 2250 */ 377, 377, 298, 377, 300, 377, 377, 377, 377, 377, /* 2250 */ 377, 329, 330, 331, 332, 333, 334, 377, 336, 377,
/* 2260 */ 325, 377, 377, 377, 329, 330, 331, 332, 333, 334, /* 2260 */ 377, 377, 257, 377, 285, 377, 377, 377, 377, 377,
/* 2270 */ 257, 336, 377, 377, 377, 377, 377, 377, 377, 325, /* 2270 */ 377, 377, 293, 377, 377, 377, 285, 298, 377, 300,
/* 2280 */ 257, 377, 377, 329, 330, 331, 332, 333, 334, 377, /* 2280 */ 377, 377, 377, 377, 293, 377, 377, 377, 377, 298,
/* 2290 */ 336, 377, 377, 377, 377, 377, 377, 377, 285, 377, /* 2290 */ 285, 300, 377, 377, 377, 377, 377, 377, 293, 377,
/* 2300 */ 377, 377, 377, 377, 377, 377, 293, 377, 285, 377, /* 2300 */ 377, 377, 377, 298, 325, 300, 377, 377, 329, 330,
/* 2310 */ 377, 298, 377, 300, 377, 377, 293, 377, 377, 377, /* 2310 */ 331, 332, 333, 334, 257, 336, 325, 377, 377, 377,
/* 2320 */ 377, 298, 377, 300, 377, 377, 377, 377, 377, 377, /* 2320 */ 329, 330, 331, 332, 333, 334, 377, 336, 377, 377,
/* 2330 */ 377, 377, 377, 377, 377, 377, 377, 377, 325, 377, /* 2330 */ 325, 377, 257, 377, 329, 330, 331, 332, 333, 334,
/* 2340 */ 377, 377, 329, 330, 331, 332, 333, 334, 325, 336, /* 2340 */ 377, 336, 285, 377, 377, 377, 377, 377, 377, 377,
/* 2350 */ 377, 377, 329, 330, 331, 332, 333, 334, 377, 336, /* 2350 */ 293, 377, 377, 377, 377, 298, 257, 300, 377, 377,
/* 2360 */ 285, 377, 377, 377, 377, 377, 377, 377, 293, 377,
/* 2370 */ 377, 377, 377, 298, 377, 300, 377, 377, 377, 377,
/* 2380 */ 377, 377, 325, 377, 285, 377, 329, 330, 331, 332,
/* 2390 */ 333, 334, 293, 336, 377, 377, 377, 298, 377, 300,
/* 2400 */ 325, 377, 377, 377, 329, 330, 331, 332, 333, 334,
/* 2410 */ 377, 336, 377, 377, 377, 377, 377, 377, 377, 377,
/* 2420 */ 377, 377, 377, 377, 325, 377, 377, 377, 329, 330,
/* 2430 */ 331, 332, 333, 334, 377, 336,
}; };
#define YY_SHIFT_COUNT (662) #define YY_SHIFT_COUNT (662)
#define YY_SHIFT_MIN (0) #define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (1929) #define YY_SHIFT_MAX (1910)
static const unsigned short int yy_shift_ofst[] = { static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 913, 0, 0, 68, 68, 268, 268, 268, 325, 325, /* 0 */ 913, 0, 0, 68, 68, 268, 268, 268, 325, 325,
/* 10 */ 268, 268, 525, 582, 782, 582, 582, 582, 582, 582, /* 10 */ 268, 268, 525, 582, 782, 582, 582, 582, 582, 582,
/* 20 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, /* 20 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582,
/* 30 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, /* 30 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582,
/* 40 */ 582, 582, 582, 208, 208, 97, 97, 97, 1073, 1073, /* 40 */ 582, 582, 208, 208, 97, 97, 97, 1073, 1073, 1073,
/* 50 */ 1073, 152, 426, 3, 3, 99, 99, 238, 238, 5, /* 50 */ 1073, 152, 426, 3, 3, 99, 99, 238, 238, 5,
/* 60 */ 202, 3, 3, 99, 99, 99, 99, 99, 99, 99, /* 60 */ 202, 3, 3, 99, 99, 99, 99, 99, 99, 99,
/* 70 */ 99, 99, 89, 99, 99, 99, 148, 305, 99, 99, /* 70 */ 99, 99, 89, 99, 99, 99, 148, 305, 99, 99,
@ -710,93 +726,93 @@ static const unsigned short int yy_shift_ofst[] = {
/* 100 */ 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, /* 100 */ 575, 575, 575, 575, 575, 575, 575, 575, 575, 575,
/* 110 */ 575, 575, 575, 197, 202, 355, 355, 400, 576, 656, /* 110 */ 575, 575, 575, 197, 202, 355, 355, 400, 576, 656,
/* 120 */ 438, 438, 438, 576, 528, 148, 11, 11, 305, 305, /* 120 */ 438, 438, 438, 576, 528, 148, 11, 11, 305, 305,
/* 130 */ 541, 541, 261, 805, 466, 466, 466, 466, 466, 466, /* 130 */ 541, 541, 261, 696, 466, 466, 466, 466, 466, 466,
/* 140 */ 466, 1592, 23, 107, 428, 21, 41, 375, 65, 366, /* 140 */ 466, 1694, 23, 107, 428, 21, 41, 375, 65, 366,
/* 150 */ 816, 365, 649, 495, 475, 539, 660, 539, 558, 497, /* 150 */ 816, 365, 649, 495, 475, 539, 660, 539, 558, 497,
/* 160 */ 497, 497, 808, 194, 1076, 936, 1145, 1120, 1136, 1009, /* 160 */ 497, 497, 808, 194, 1078, 939, 1148, 1125, 1142, 1017,
/* 170 */ 1145, 1145, 1140, 1040, 1040, 1145, 1145, 1173, 1173, 1175, /* 170 */ 1148, 1148, 1145, 1048, 1048, 1148, 1148, 1182, 1182, 1184,
/* 180 */ 89, 148, 89, 1176, 1191, 89, 1176, 89, 1197, 89, /* 180 */ 89, 148, 89, 1193, 1198, 89, 1193, 89, 1204, 89,
/* 190 */ 89, 1145, 89, 1173, 305, 305, 305, 305, 305, 305, /* 190 */ 89, 1148, 89, 1182, 305, 305, 305, 305, 305, 305,
/* 200 */ 305, 305, 305, 305, 305, 1145, 1173, 541, 1175, 380, /* 200 */ 305, 305, 305, 305, 305, 1148, 1182, 541, 1184, 380,
/* 210 */ 1080, 148, 380, 1145, 1145, 1176, 380, 1026, 541, 541, /* 210 */ 1070, 148, 380, 1148, 1148, 1193, 380, 1032, 541, 541,
/* 220 */ 541, 541, 1026, 541, 1114, 528, 1197, 380, 261, 380, /* 220 */ 541, 541, 1032, 541, 1140, 528, 1204, 380, 261, 380,
/* 230 */ 528, 1238, 541, 1068, 1026, 541, 541, 1068, 1026, 541, /* 230 */ 528, 1283, 541, 1076, 1032, 541, 541, 1076, 1032, 541,
/* 240 */ 541, 305, 1063, 1151, 1068, 1070, 1077, 1086, 936, 1089, /* 240 */ 541, 305, 1079, 1169, 1076, 1088, 1092, 1105, 939, 1113,
/* 250 */ 528, 1316, 1093, 1097, 1094, 1093, 1097, 1093, 1097, 1260, /* 250 */ 528, 1319, 1097, 1112, 1102, 1097, 1112, 1097, 1112, 1263,
/* 260 */ 1076, 541, 805, 1145, 380, 1317, 1173, 2360, 2360, 2360, /* 260 */ 1078, 541, 696, 1148, 380, 1322, 1182, 2436, 2436, 2436,
/* 270 */ 2360, 2360, 2360, 2360, 348, 1702, 132, 579, 472, 16, /* 270 */ 2436, 2436, 2436, 2436, 348, 1712, 132, 579, 472, 16,
/* 280 */ 663, 639, 743, 389, 757, 704, 839, 839, 839, 839, /* 280 */ 663, 639, 743, 389, 757, 704, 839, 839, 839, 839,
/* 290 */ 839, 839, 839, 839, 843, 568, 25, 25, 61, 212, /* 290 */ 839, 839, 839, 839, 843, 568, 25, 25, 61, 212,
/* 300 */ 433, 481, 603, 378, 297, 150, 483, 483, 483, 483, /* 300 */ 433, 481, 603, 378, 297, 150, 483, 483, 483, 483,
/* 310 */ 45, 887, 774, 806, 910, 917, 811, 1046, 1069, 720, /* 310 */ 45, 887, 774, 806, 910, 917, 811, 1046, 1069, 720,
/* 320 */ 707, 930, 973, 1041, 1045, 1047, 1050, 728, 829, 1053, /* 320 */ 707, 930, 973, 1045, 1047, 1050, 1053, 1074, 894, 832,
/* 330 */ 951, 847, 625, 391, 1074, 838, 1079, 1036, 1085, 1088, /* 330 */ 625, 391, 1096, 829, 863, 884, 1098, 1038, 1085, 1100,
/* 340 */ 1096, 1098, 1099, 1100, 1052, 1054, 896, 1358, 1189, 1377, /* 340 */ 1104, 1106, 1107, 1108, 993, 897, 1127, 1364, 1202, 1384,
/* 350 */ 1382, 1345, 1389, 1315, 1391, 1357, 1211, 1362, 1363, 1364, /* 350 */ 1390, 1355, 1398, 1324, 1400, 1366, 1218, 1369, 1370, 1371,
/* 360 */ 1215, 1401, 1368, 1369, 1220, 1406, 1223, 1410, 1378, 1411, /* 360 */ 1223, 1410, 1376, 1377, 1228, 1414, 1230, 1416, 1382, 1418,
/* 370 */ 1390, 1414, 1380, 1416, 1333, 1248, 1252, 1255, 1258, 1435, /* 370 */ 1399, 1422, 1388, 1435, 1352, 1276, 1275, 1281, 1285, 1449,
/* 380 */ 1436, 1283, 1286, 1448, 1449, 1404, 1451, 1452, 1453, 1310, /* 380 */ 1451, 1291, 1293, 1454, 1456, 1411, 1458, 1459, 1461, 1320,
/* 390 */ 1456, 1457, 1458, 1459, 1461, 1324, 1429, 1466, 1328, 1468, /* 390 */ 1463, 1466, 1467, 1468, 1469, 1332, 1437, 1474, 1336, 1476,
/* 400 */ 1469, 1471, 1472, 1474, 1475, 1476, 1477, 1479, 1481, 1484, /* 400 */ 1477, 1479, 1481, 1484, 1485, 1486, 1488, 1490, 1497, 1499,
/* 410 */ 1485, 1486, 1488, 1455, 1490, 1499, 1500, 1502, 1503, 1504, /* 410 */ 1500, 1502, 1503, 1462, 1507, 1508, 1515, 1523, 1524, 1526,
/* 420 */ 1493, 1507, 1508, 1518, 1519, 1520, 1465, 1523, 1524, 1487, /* 420 */ 1496, 1519, 1520, 1521, 1527, 1528, 1473, 1533, 1534, 1493,
/* 430 */ 1489, 1483, 1513, 1491, 1521, 1492, 1533, 1494, 1497, 1539, /* 430 */ 1498, 1495, 1522, 1501, 1525, 1504, 1540, 1505, 1509, 1542,
/* 440 */ 1540, 1542, 1505, 1387, 1545, 1546, 1547, 1495, 1548, 1549, /* 440 */ 1543, 1544, 1510, 1395, 1546, 1552, 1553, 1512, 1554, 1555,
/* 450 */ 1515, 1511, 1512, 1552, 1525, 1526, 1514, 1554, 1535, 1528, /* 450 */ 1535, 1511, 1517, 1560, 1536, 1529, 1539, 1575, 1545, 1532,
/* 460 */ 1516, 1571, 1541, 1531, 1544, 1579, 1580, 1581, 1585, 1501, /* 460 */ 1547, 1581, 1548, 1538, 1549, 1587, 1589, 1590, 1592, 1530,
/* 470 */ 1498, 1551, 1565, 1588, 1555, 1557, 1558, 1560, 1553, 1559, /* 470 */ 1531, 1558, 1572, 1595, 1561, 1562, 1563, 1565, 1559, 1568,
/* 480 */ 1563, 1566, 1577, 1586, 1597, 1578, 1622, 1601, 1582, 1628, /* 480 */ 1566, 1577, 1586, 1591, 1624, 1603, 1628, 1607, 1582, 1630,
/* 490 */ 1607, 1591, 1630, 1600, 1636, 1602, 1638, 1618, 1623, 1642, /* 490 */ 1611, 1601, 1635, 1602, 1638, 1604, 1640, 1620, 1625, 1644,
/* 500 */ 1510, 1615, 1649, 1482, 1632, 1529, 1522, 1652, 1655, 1530, /* 500 */ 1537, 1612, 1646, 1478, 1626, 1550, 1513, 1650, 1651, 1556,
/* 510 */ 1532, 1656, 1657, 1660, 1589, 1587, 1509, 1677, 1596, 1538, /* 510 */ 1541, 1652, 1653, 1654, 1571, 1576, 1489, 1656, 1573, 1557,
/* 520 */ 1599, 1690, 1646, 1543, 1609, 1603, 1650, 1659, 1467, 1616, /* 520 */ 1593, 1673, 1636, 1551, 1594, 1580, 1634, 1639, 1453, 1599,
/* 530 */ 1613, 1620, 1631, 1633, 1629, 1693, 1674, 1635, 1637, 1645, /* 530 */ 1605, 1608, 1606, 1609, 1613, 1642, 1615, 1621, 1622, 1637,
/* 540 */ 1648, 1653, 1679, 1687, 1688, 1658, 1694, 1517, 1662, 1663, /* 540 */ 1619, 1655, 1641, 1663, 1645, 1667, 1514, 1627, 1629, 1677,
/* 550 */ 1695, 1537, 1697, 1704, 1705, 1667, 1717, 1534, 1676, 1664, /* 550 */ 1516, 1681, 1679, 1684, 1658, 1683, 1569, 1659, 1696, 1705,
/* 560 */ 1730, 1732, 1733, 1734, 1735, 1676, 1770, 1594, 1731, 1689, /* 560 */ 1717, 1718, 1719, 1720, 1659, 1754, 1735, 1570, 1715, 1676,
/* 570 */ 1698, 1700, 1707, 1703, 1708, 1744, 1711, 1713, 1752, 1778, /* 570 */ 1685, 1687, 1688, 1690, 1691, 1723, 1697, 1698, 1726, 1739,
/* 580 */ 1608, 1719, 1706, 1720, 1772, 1773, 1725, 1726, 1775, 1728, /* 580 */ 1584, 1699, 1689, 1700, 1751, 1753, 1706, 1704, 1758, 1716,
/* 590 */ 1729, 1780, 1736, 1738, 1781, 1740, 1748, 1782, 1750, 1710, /* 590 */ 1711, 1766, 1721, 1722, 1767, 1724, 1725, 1774, 1728, 1707,
/* 600 */ 1714, 1741, 1746, 1791, 1745, 1759, 1760, 1810, 1762, 1805, /* 600 */ 1709, 1713, 1714, 1792, 1736, 1745, 1749, 1785, 1750, 1798,
/* 610 */ 1805, 1830, 1795, 1798, 1824, 1796, 1783, 1821, 1832, 1833, /* 610 */ 1798, 1822, 1794, 1786, 1818, 1789, 1776, 1816, 1827, 1829,
/* 620 */ 1834, 1835, 1837, 1844, 1838, 1839, 1808, 1553, 1842, 1559, /* 620 */ 1830, 1834, 1835, 1850, 1838, 1839, 1808, 1559, 1842, 1568,
/* 630 */ 1843, 1845, 1846, 1847, 1849, 1850, 1851, 1879, 1853, 1854, /* 630 */ 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1876, 1852, 1854,
/* 640 */ 1861, 1890, 1868, 1858, 1867, 1908, 1874, 1863, 1876, 1913, /* 640 */ 1851, 1888, 1856, 1855, 1853, 1889, 1859, 1857, 1858, 1895,
/* 650 */ 1881, 1870, 1882, 1918, 1885, 1887, 1923, 1905, 1907, 1909, /* 650 */ 1861, 1862, 1864, 1905, 1871, 1873, 1910, 1891, 1890, 1893,
/* 660 */ 1910, 1920, 1929, /* 660 */ 1894, 1896, 1898,
}; };
#define YY_REDUCE_COUNT (273) #define YY_REDUCE_COUNT (273)
#define YY_REDUCE_MIN (-354) #define YY_REDUCE_MIN (-354)
#define YY_REDUCE_MAX (2023) #define YY_REDUCE_MAX (2099)
static const short yy_reduce_ofst[] = { static const short yy_reduce_ofst[] = {
/* 0 */ -29, -221, 289, 34, 709, -113, 546, 780, 876, 937, /* 0 */ -29, -221, 289, 34, 709, -113, 546, 780, 876, 937,
/* 10 */ 990, 1042, 1095, 1109, 1162, 1180, 1232, 1274, 1284, 1334, /* 10 */ 990, 1042, 1095, 1109, 1162, 1180, 1232, 1274, 1284, 1334,
/* 20 */ 1376, 1394, 1446, 1496, 1506, 1562, 1604, 1614, 1626, 1668, /* 20 */ 1386, 1403, 1494, 1506, 1518, 1600, 1614, 1664, 1680, 1733,
/* 30 */ 1685, 1727, 1737, 1779, 1789, 1831, 1841, 1893, 1912, 1935, /* 30 */ 1747, 1799, 1817, 1841, 1899, 1922, 1979, 1991, 2005, 2057,
/* 40 */ 1954, 2013, 2023, -219, 711, -250, -207, 593, 731, 726, /* 40 */ 2075, 2099, -219, 711, -250, -207, 593, 731, 820, 726,
/* 50 */ 820, -218, 382, 446, 502, -208, 580, -261, -257, -354, /* 50 */ 828, -218, 382, 446, 502, -208, 580, -261, -257, -354,
/* 60 */ -234, -182, -11, -138, 218, 323, 404, 548, 662, 664, /* 60 */ -234, -182, -11, -138, 218, 323, 404, 548, 662, 664,
/* 70 */ 670, 672, 102, 730, 734, 735, -292, 153, 738, 756, /* 70 */ 670, 672, 102, 730, 734, 735, -292, 153, 738, 756,
/* 80 */ -275, -215, 771, 219, -39, 267, 822, -246, 49, -201, /* 80 */ -275, -215, 771, 219, -39, 267, 855, -246, 49, -201,
/* 90 */ -201, -201, -187, -31, -152, -132, 2, 205, 286, 336, /* 90 */ -201, -201, -187, -31, -152, -132, 2, 205, 286, 336,
/* 100 */ 372, 402, 403, 441, 542, 552, 569, 571, 624, 627, /* 100 */ 372, 402, 403, 441, 542, 552, 569, 571, 624, 627,
/* 110 */ 630, 635, 636, 20, 31, -71, 71, -264, 136, -194, /* 110 */ 630, 635, 636, 20, 31, -71, 71, -264, 136, -194,
/* 120 */ 331, 340, 368, 243, 303, 453, 230, 431, -47, 388, /* 120 */ 331, 340, 368, 243, 303, 453, 230, 431, -47, 388,
/* 130 */ 512, 537, 556, 471, 430, 511, 613, 646, 678, 683, /* 130 */ 512, 537, 556, 471, 430, 511, 586, 613, 681, 682,
/* 140 */ 733, 638, 759, 746, 647, 710, 760, 826, 715, 807, /* 140 */ 683, 638, 759, 745, 645, 716, 760, 701, 727, 807,
/* 150 */ 807, 861, 884, 852, 823, 797, 797, 797, 809, 783, /* 150 */ 807, 870, 834, 824, 814, 801, 801, 801, 809, 788,
/* 160 */ 784, 785, 801, 807, 869, 840, 901, 846, 904, 862, /* 160 */ 789, 791, 810, 807, 874, 844, 906, 851, 907, 866,
/* 170 */ 912, 915, 881, 885, 886, 926, 927, 938, 939, 879, /* 170 */ 919, 921, 883, 893, 895, 932, 934, 941, 944, 891,
/* 180 */ 931, 902, 934, 891, 898, 945, 903, 946, 914, 949, /* 180 */ 945, 915, 947, 904, 905, 950, 908, 954, 920, 956,
/* 190 */ 950, 956, 954, 965, 940, 941, 942, 943, 944, 947, /* 190 */ 958, 963, 960, 974, 949, 951, 957, 961, 964, 965,
/* 200 */ 948, 957, 958, 960, 961, 969, 977, 952, 919, 974, /* 200 */ 967, 968, 969, 970, 971, 976, 980, 959, 912, 978,
/* 210 */ 933, 955, 982, 989, 991, 959, 992, 975, 962, 963, /* 210 */ 940, 972, 991, 995, 996, 981, 997, 975, 987, 988,
/* 220 */ 966, 976, 978, 987, 979, 996, 985, 1027, 1012, 1028, /* 220 */ 989, 998, 982, 999, 986, 1002, 992, 1007, 1019, 1034,
/* 230 */ 1003, 970, 999, 953, 993, 1005, 1006, 964, 997, 1010, /* 230 */ 1009, 979, 1006, 952, 1001, 1008, 1013, 953, 1003, 1018,
/* 240 */ 1013, 807, 967, 980, 971, 968, 986, 972, 994, 797, /* 240 */ 1020, 807, 966, 983, 977, 984, 994, 985, 1014, 801,
/* 250 */ 1025, 1011, 983, 981, 984, 988, 995, 998, 1000, 1004, /* 250 */ 1052, 1021, 1011, 1000, 1015, 1012, 1022, 1016, 1026, 1023,
/* 260 */ 1058, 1051, 1075, 1083, 1090, 1101, 1103, 1038, 1044, 1084, /* 260 */ 1061, 1057, 1081, 1086, 1090, 1099, 1101, 1044, 1051, 1083,
/* 270 */ 1104, 1105, 1111, 1113, /* 270 */ 1089, 1110, 1111, 1114,
}; };
static const YYACTIONTYPE yy_default[] = { static const YYACTIONTYPE yy_default[] = {
/* 0 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 0 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
@ -831,8 +847,8 @@ static const YYACTIONTYPE yy_default[] = {
/* 290 */ 1831, 1830, 1828, 1793, 1453, 1587, 1792, 1791, 1453, 1453, /* 290 */ 1831, 1830, 1828, 1793, 1453, 1587, 1792, 1791, 1453, 1453,
/* 300 */ 1453, 1453, 1453, 1453, 1453, 1453, 1785, 1786, 1784, 1783, /* 300 */ 1453, 1453, 1453, 1453, 1453, 1453, 1785, 1786, 1784, 1783,
/* 310 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 310 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
/* 320 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 320 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1857, 1453,
/* 330 */ 1857, 1453, 1925, 1929, 1453, 1453, 1453, 1768, 1453, 1453, /* 330 */ 1925, 1929, 1453, 1453, 1453, 1453, 1453, 1768, 1453, 1453,
/* 340 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 340 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
/* 350 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 350 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
/* 360 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 360 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
@ -853,9 +869,9 @@ static const YYACTIONTYPE yy_default[] = {
/* 510 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1727, 1453, 1453, /* 510 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1727, 1453, 1453,
/* 520 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1890, 1453, 1453, /* 520 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1890, 1453, 1453,
/* 530 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 530 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
/* 540 */ 1453, 1453, 1453, 1453, 1768, 1453, 1907, 1453, 1867, 1863, /* 540 */ 1453, 1453, 1453, 1768, 1453, 1907, 1453, 1867, 1863, 1453,
/* 550 */ 1453, 1453, 1859, 1767, 1453, 1453, 1923, 1453, 1453, 1453, /* 550 */ 1453, 1859, 1767, 1453, 1453, 1923, 1453, 1453, 1453, 1453,
/* 560 */ 1453, 1453, 1453, 1453, 1453, 1453, 1852, 1453, 1825, 1810, /* 560 */ 1453, 1453, 1453, 1453, 1453, 1852, 1453, 1453, 1825, 1810,
/* 570 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, /* 570 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453,
/* 580 */ 1779, 1453, 1453, 1453, 1453, 1453, 1619, 1453, 1453, 1453, /* 580 */ 1779, 1453, 1453, 1453, 1453, 1453, 1619, 1453, 1453, 1453,
/* 590 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1604, /* 590 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1604,
@ -2003,7 +2019,7 @@ static const char *const yyRuleName[] = {
/* 390 */ "compare_op ::= CONTAINS", /* 390 */ "compare_op ::= CONTAINS",
/* 391 */ "in_op ::= IN", /* 391 */ "in_op ::= IN",
/* 392 */ "in_op ::= NOT IN", /* 392 */ "in_op ::= NOT IN",
/* 393 */ "in_predicate_value ::= NK_LP expression_list NK_RP", /* 393 */ "in_predicate_value ::= NK_LP literal_list NK_RP",
/* 394 */ "boolean_value_expression ::= boolean_primary", /* 394 */ "boolean_value_expression ::= boolean_primary",
/* 395 */ "boolean_value_expression ::= NOT boolean_primary", /* 395 */ "boolean_value_expression ::= NOT boolean_primary",
/* 396 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", /* 396 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
@ -3089,7 +3105,7 @@ static const struct {
{ 340, -1 }, /* (390) compare_op ::= CONTAINS */ { 340, -1 }, /* (390) compare_op ::= CONTAINS */
{ 341, -1 }, /* (391) in_op ::= IN */ { 341, -1 }, /* (391) in_op ::= IN */
{ 341, -2 }, /* (392) in_op ::= NOT IN */ { 341, -2 }, /* (392) in_op ::= NOT IN */
{ 342, -3 }, /* (393) in_predicate_value ::= NK_LP expression_list NK_RP */ { 342, -3 }, /* (393) in_predicate_value ::= NK_LP literal_list NK_RP */
{ 343, -1 }, /* (394) boolean_value_expression ::= boolean_primary */ { 343, -1 }, /* (394) boolean_value_expression ::= boolean_primary */
{ 343, -2 }, /* (395) boolean_value_expression ::= NOT boolean_primary */ { 343, -2 }, /* (395) boolean_value_expression ::= NOT boolean_primary */
{ 343, -3 }, /* (396) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { 343, -3 }, /* (396) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
@ -4477,7 +4493,7 @@ static YYACTIONTYPE yy_reduce(
case 392: /* in_op ::= NOT IN */ case 392: /* in_op ::= NOT IN */
{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_IN; } { yymsp[-1].minor.yy428 = OP_TYPE_NOT_IN; }
break; break;
case 393: /* in_predicate_value ::= NK_LP expression_list NK_RP */ case 393: /* in_predicate_value ::= NK_LP literal_list NK_RP */
{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy210)); } { yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy210)); }
yymsp[-2].minor.yy652 = yylhsminor.yy652; yymsp[-2].minor.yy652 = yylhsminor.yy652;
break; break;

View File

@ -144,9 +144,9 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) {
TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) { TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) {
useDb("root", "test"); useDb("root", "test");
run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_SINGLE_GROUP);
run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_SINGLE_GROUP);
run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
@ -273,7 +273,7 @@ TEST_F(ParserSelectTest, interval) {
TEST_F(ParserSelectTest, intervalSemanticCheck) { TEST_F(ParserSelectTest, intervalSemanticCheck) {
useDb("root", "test"); useDb("root", "test");
run("SELECT c1 FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_NOT_SINGLE_GROUP); run("SELECT c1 FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN);
run("SELECT DISTINCT c1, c2 FROM t1 WHERE c1 > 3 INTERVAL(1d) FILL(NEXT)", TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE); run("SELECT DISTINCT c1, c2 FROM t1 WHERE c1 > 3 INTERVAL(1d) FILL(NEXT)", TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE);
run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 " run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 "
"WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)", "WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)",

View File

@ -485,10 +485,6 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY);
} }
if (NULL != pSelect->pPartitionByList) {
code = createGroupKeysFromPartKeys(pSelect->pPartitionByList, &pAgg->pGroupKeys);
}
if (NULL != pSelect->pGroupByList) { if (NULL != pSelect->pGroupByList) {
if (NULL != pAgg->pGroupKeys) { if (NULL != pAgg->pGroupKeys) {
code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList)); code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList));
@ -845,8 +841,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
} }
static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
if (NULL == pSelect->pPartitionByList || (pSelect->hasAggFuncs && NULL == pSelect->pWindow) || if (NULL == pSelect->pPartitionByList) {
NULL != pSelect->pGroupByList) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -1010,8 +1010,13 @@ static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicS
SNodeList* pScanNodes) { SNodeList* pScanNodes) {
EOrder order = sortPriKeyOptGetPriKeyOrder(pSort); EOrder order = sortPriKeyOptGetPriKeyOrder(pSort);
if (ORDER_DESC == order) { if (ORDER_DESC == order) {
SNode* pScan = NULL; SNode* pScanNode = NULL;
FOREACH(pScan, pScanNodes) { TSWAP(((SScanLogicNode*)pScan)->scanSeq[0], ((SScanLogicNode*)pScan)->scanSeq[1]); } FOREACH(pScanNode, pScanNodes) {
SScanLogicNode* pScan = (SScanLogicNode*)pScanNode;
if (pScan->scanSeq[0] > 0) {
TSWAP(pScan->scanSeq[0], pScan->scanSeq[1]);
}
}
} }
int32_t code = int32_t code =
@ -1020,6 +1025,7 @@ static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicS
NODES_CLEAR_LIST(pSort->node.pChildren); NODES_CLEAR_LIST(pSort->node.pChildren);
nodesDestroyNode((SNode*)pSort); nodesDestroyNode((SNode*)pSort);
} }
pCxt->optimized = true;
return code; return code;
} }
@ -1183,7 +1189,7 @@ static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNo
if (smaFuncIndex < 0) { if (smaFuncIndex < 0) {
break; break;
} else { } else {
code = nodesListMakeStrictAppend(&pCols, smaIndexOptCreateSmaCol(pFunc, tableId, smaFuncIndex + 2)); code = nodesListMakeStrictAppend(&pCols, smaIndexOptCreateSmaCol(pFunc, tableId, smaFuncIndex + 1));
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
break; break;
} }

View File

@ -1317,10 +1317,7 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
pFill->pWStartTs = nodesCloneNode(pFillNode->pWStartTs); code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->pWStartTs, &pFill->pWStartTs);
if (NULL == pFill->pWStartTs) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
} }
if (TSDB_CODE_SUCCESS == code && NULL != pFillNode->pValues) { if (TSDB_CODE_SUCCESS == code && NULL != pFillNode->pValues) {

View File

@ -945,6 +945,7 @@ static int32_t stbSplSplitPartitionNode(SSplitContext* pCxt, SStableSplitInfo* p
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
(SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT));
} }
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
++(pCxt->groupId); ++(pCxt->groupId);
return code; return code;
} }

View File

@ -62,4 +62,6 @@ TEST_F(PlanIntervalTest, stable) {
run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)");
run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
run("SELECT TBNAME, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
} }

View File

@ -53,6 +53,12 @@ TEST_F(PlanOrderByTest, withGroupBy) {
run("SELECT SUM(c1) AS a FROM t1 GROUP BY c2 ORDER BY a"); run("SELECT SUM(c1) AS a FROM t1 GROUP BY c2 ORDER BY a");
} }
TEST_F(PlanOrderByTest, withSubquery) {
useDb("root", "test");
run("SELECT ts FROM (SELECT * FROM t1 ORDER BY ts DESC) ORDER BY ts DESC");
}
TEST_F(PlanOrderByTest, stable) { TEST_F(PlanOrderByTest, stable) {
useDb("root", "test"); useDb("root", "test");

View File

@ -35,6 +35,10 @@ TEST_F(PlanPartitionByTest, withAggFunc) {
run("select count(*) from t1 partition by c1"); run("select count(*) from t1 partition by c1");
run("select count(*) from st1 partition by c1");
run("select sample(c1, 2) from st1 partition by c1");
run("select count(*), c1 from t1 partition by c1"); run("select count(*), c1 from t1 partition by c1");
} }

View File

@ -436,7 +436,7 @@ void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
char dbFName[TSDB_DB_FNAME_LEN] = {0}; char dbFName[TSDB_DB_FNAME_LEN] = {0};
char tbName[TSDB_TABLE_NAME_LEN] = {0}; char tbName[TSDB_TABLE_NAME_LEN] = {0};
qGetQueriedTableSchemaVersion(pTaskInfo, dbFName, tbName, &ctx->tbInfo.sversion, &ctx->tbInfo.tversion); qGetQueryTableSchemaVersion(pTaskInfo, dbFName, tbName, &ctx->tbInfo.sversion, &ctx->tbInfo.tversion);
if (dbFName[0] && tbName[0]) { if (dbFName[0] && tbName[0]) {
sprintf(ctx->tbInfo.tbFName, "%s.%s", dbFName, tbName); sprintf(ctx->tbInfo.tbFName, "%s.%s", dbFName, tbName);

View File

@ -517,7 +517,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) {
ctx->needFetch = qwMsg->msgInfo.needFetch; ctx->needFetch = qwMsg->msgInfo.needFetch;
ctx->queryType = qwMsg->msgType; ctx->queryType = qwMsg->msgType;
QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg); //QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
code = qStringToSubplan(qwMsg->msg, &plan); code = qStringToSubplan(qwMsg->msg, &plan);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
@ -1041,7 +1041,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, SQWorkerCfg *cfg, void **qW
*qWorkerMgmt = mgmt; *qWorkerMgmt = mgmt;
qDebug("qworker initialized for node, type:%d, id:%d, handle:%p", mgmt->nodeType, mgmt->nodeId, mgmt); qDebug("qworker initialized, type:%d, id:%d, handle:%p", mgmt->nodeType, mgmt->nodeId, mgmt);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;

View File

@ -56,7 +56,7 @@ typedef struct SScalarCtx {
#define SCL_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) #define SCL_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out); int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow);
int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam); int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam);
int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode); int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode);

View File

@ -94,7 +94,7 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType)
return p; return p;
} }
typedef void (*_bufConverteFunc)(char *buf, SScalarParam* pOut, int32_t outType); typedef void (*_bufConverteFunc)(char *buf, SScalarParam* pOut, int32_t outType, int32_t* overflow);
typedef void (*_bin_scalar_fn_t)(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *output, int32_t order); typedef void (*_bin_scalar_fn_t)(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *output, int32_t order);
_bin_scalar_fn_t getBinScalarOperatorFn(int32_t binOperator); _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binOperator);

View File

@ -1043,12 +1043,18 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
for (int32_t i = 0; i < listNode->pNodeList->length; ++i) { for (int32_t i = 0; i < listNode->pNodeList->length; ++i) {
SValueNode *valueNode = (SValueNode *)cell->pNode; SValueNode *valueNode = (SValueNode *)cell->pNode;
if (valueNode->node.resType.type != type) { if (valueNode->node.resType.type != type) {
code = doConvertDataType(valueNode, &out); int32_t overflow = 0;
code = doConvertDataType(valueNode, &out, &overflow);
if (code) { if (code) {
// fltError("convert from %d to %d failed", in.type, out.type); // fltError("convert from %d to %d failed", in.type, out.type);
FLT_ERR_RET(code); FLT_ERR_RET(code);
} }
if (overflow) {
cell = cell->pNext;
continue;
}
len = tDataTypes[type].bytes; len = tDataTypes[type].bytes;
filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true); filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true);
@ -1835,7 +1841,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
} }
// todo refactor the convert // todo refactor the convert
int32_t code = doConvertDataType(var, &out); int32_t code = doConvertDataType(var, &out, NULL);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("convert value to type[%d] failed", type); qError("convert value to type[%d] failed", type);
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;

View File

@ -59,7 +59,7 @@ int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarPara
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) { int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow) {
SScalarParam in = {.numOfRows = 1}; SScalarParam in = {.numOfRows = 1};
int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in); int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
@ -69,7 +69,7 @@ int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) {
colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false); colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false);
colInfoDataEnsureCapacity(out->columnData, 1); colInfoDataEnsureCapacity(out->columnData, 1);
code = vectorConvertImpl(&in, out); code = vectorConvertImpl(&in, out, overflow);
sclFreeParam(&in); sclFreeParam(&in);
return code; return code;
@ -107,15 +107,21 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
out.columnData->info.bytes = tDataTypes[type].bytes; out.columnData->info.bytes = tDataTypes[type].bytes;
} }
code = doConvertDataType(valueNode, &out); int32_t overflow = 0;
code = doConvertDataType(valueNode, &out, &overflow);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
// sclError("convert data from %d to %d failed", in.type, out.type); // sclError("convert data from %d to %d failed", in.type, out.type);
SCL_ERR_JRET(code); SCL_ERR_JRET(code);
} }
if (overflow) {
cell = cell->pNext;
continue;
}
if (IS_VAR_DATA_TYPE(type)) { if (IS_VAR_DATA_TYPE(type)) {
buf = colDataGetVarData(out.columnData, 0); buf = colDataGetVarData(out.columnData, 0);
len = varDataTLen(data); len = varDataTLen(buf);
} else { } else {
len = tDataTypes[type].bytes; len = tDataTypes[type].bytes;
buf = out.columnData->pData; buf = out.columnData->pData;
@ -578,7 +584,7 @@ _return:
SCL_RET(code); SCL_RET(code);
} }
EDealRes sclRewriteBasedOnOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opType) { EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opType) {
if (opType <= OP_TYPE_CALC_MAX) { if (opType <= OP_TYPE_CALC_MAX) {
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
if (NULL == res) { if (NULL == res) {
@ -610,6 +616,24 @@ EDealRes sclRewriteBasedOnOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opT
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
EDealRes sclAggFuncWalker(SNode* pNode, void* pContext) {
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
SFunctionNode* pFunc = (SFunctionNode*)pNode;
*(bool*)pContext = fmIsAggFunc(pFunc->funcId);
if (*(bool*)pContext) {
return DEAL_RES_END;
}
}
return DEAL_RES_CONTINUE;
}
bool sclContainsAggFuncNode(SNode* pNode) {
bool aggFunc = false;
nodesWalkExpr(pNode, sclAggFuncWalker, (void *)&aggFunc);
return aggFunc;
}
EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) { EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
SOperatorNode *node = (SOperatorNode *)*pNode; SOperatorNode *node = (SOperatorNode *)*pNode;
@ -617,8 +641,9 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
if (node->pLeft && (QUERY_NODE_VALUE == nodeType(node->pLeft))) { if (node->pLeft && (QUERY_NODE_VALUE == nodeType(node->pLeft))) {
SValueNode *valueNode = (SValueNode *)node->pLeft; SValueNode *valueNode = (SValueNode *)node->pLeft;
if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) { if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)
return sclRewriteBasedOnOptr(pNode, ctx, node->opType); && (!sclContainsAggFuncNode(node->pRight))) {
return sclRewriteNullInOptr(pNode, ctx, node->opType);
} }
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight) if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight)
@ -633,8 +658,9 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
if (node->pRight && (QUERY_NODE_VALUE == nodeType(node->pRight))) { if (node->pRight && (QUERY_NODE_VALUE == nodeType(node->pRight))) {
SValueNode *valueNode = (SValueNode *)node->pRight; SValueNode *valueNode = (SValueNode *)node->pRight;
if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) { if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)
return sclRewriteBasedOnOptr(pNode, ctx, node->opType); && (!sclContainsAggFuncNode(node->pLeft))) {
return sclRewriteNullInOptr(pNode, ctx, node->opType);
} }
if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft) if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft)
@ -656,7 +682,7 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
ERASE_NODE(listNode->pNodeList); ERASE_NODE(listNode->pNodeList);
continue; continue;
} else { //OP_TYPE_NOT_IN } else { //OP_TYPE_NOT_IN
return sclRewriteBasedOnOptr(pNode, ctx, node->opType); return sclRewriteNullInOptr(pNode, ctx, node->opType);
} }
} }
@ -664,7 +690,7 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) {
} }
if (listNode->pNodeList->length <= 0) { if (listNode->pNodeList->length <= 0) {
return sclRewriteBasedOnOptr(pNode, ctx, node->opType); return sclRewriteNullInOptr(pNode, ctx, node->opType);
} }
} }
@ -1047,71 +1073,122 @@ _return:
return code; return code;
} }
int32_t scalarGetOperatorResultType(SDataType left, SDataType right, EOperatorType op, SDataType* pRes) { static int32_t getMinusOperatorResultType(SOperatorNode* pOp) {
switch (op) { if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
return TSDB_CODE_SUCCESS;
}
static int32_t getArithmeticOperatorResultType(SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) ||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) ||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && IS_INTEGER_TYPE(rdt.type)) ||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && IS_INTEGER_TYPE(ldt.type)) ||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BOOL == rdt.type) ||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BOOL == ldt.type)) {
pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
} else {
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
}
return TSDB_CODE_SUCCESS;
}
static int32_t getComparisonOperatorResultType(SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) {
((SExprNode*)(pOp->pRight))->resType = ldt;
} else if (nodesIsRegularOp(pOp)) {
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
(!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
}
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
return TSDB_CODE_SUCCESS;
}
static int32_t getJsonOperatorResultType(SOperatorNode* pOp) {
SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode*)(pOp->pRight))->resType;
if (TSDB_DATA_TYPE_JSON != ldt.type || !IS_STR_DATA_TYPE(rdt.type)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if (pOp->opType == OP_TYPE_JSON_GET_VALUE) {
pOp->node.resType.type = TSDB_DATA_TYPE_JSON;
} else if (pOp->opType == OP_TYPE_JSON_CONTAINS) {
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
}
pOp->node.resType.bytes = tDataTypes[pOp->node.resType.type].bytes;
return TSDB_CODE_SUCCESS;
}
static int32_t getBitwiseOperatorResultType(SOperatorNode* pOp) {
pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT;
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
return TSDB_CODE_SUCCESS;
}
int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
if (TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pLeft))->resType.type ||
(NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pRight))->resType.type)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
switch (pOp->opType) {
case OP_TYPE_ADD: case OP_TYPE_ADD:
if (left.type == TSDB_DATA_TYPE_TIMESTAMP && right.type == TSDB_DATA_TYPE_TIMESTAMP) {
qError("invalid op %d, left type:%d, right type:%d", op, left.type, right.type);
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if ((left.type == TSDB_DATA_TYPE_TIMESTAMP && (IS_INTEGER_TYPE(right.type) || right.type == TSDB_DATA_TYPE_BOOL)) ||
(right.type == TSDB_DATA_TYPE_TIMESTAMP && (IS_INTEGER_TYPE(left.type) || left.type == TSDB_DATA_TYPE_BOOL))) {
pRes->type = TSDB_DATA_TYPE_TIMESTAMP;
return TSDB_CODE_SUCCESS;
}
pRes->type = TSDB_DATA_TYPE_DOUBLE;
return TSDB_CODE_SUCCESS;
case OP_TYPE_SUB: case OP_TYPE_SUB:
if ((left.type == TSDB_DATA_TYPE_TIMESTAMP && right.type == TSDB_DATA_TYPE_BIGINT) ||
(right.type == TSDB_DATA_TYPE_TIMESTAMP && left.type == TSDB_DATA_TYPE_BIGINT)) {
pRes->type = TSDB_DATA_TYPE_TIMESTAMP;
return TSDB_CODE_SUCCESS;
}
pRes->type = TSDB_DATA_TYPE_DOUBLE;
return TSDB_CODE_SUCCESS;
case OP_TYPE_MULTI: case OP_TYPE_MULTI:
if (left.type == TSDB_DATA_TYPE_TIMESTAMP && right.type == TSDB_DATA_TYPE_TIMESTAMP) {
qError("invalid op %d, left type:%d, right type:%d", op, left.type, right.type);
return TSDB_CODE_TSC_INVALID_OPERATION;
}
case OP_TYPE_DIV: case OP_TYPE_DIV:
if (left.type == TSDB_DATA_TYPE_TIMESTAMP && right.type == TSDB_DATA_TYPE_TIMESTAMP) {
qError("invalid op %d, left type:%d, right type:%d", op, left.type, right.type);
return TSDB_CODE_TSC_INVALID_OPERATION;
}
case OP_TYPE_REM: case OP_TYPE_REM:
return getArithmeticOperatorResultType(pOp);
case OP_TYPE_MINUS: case OP_TYPE_MINUS:
pRes->type = TSDB_DATA_TYPE_DOUBLE; return getMinusOperatorResultType(pOp);
return TSDB_CODE_SUCCESS; case OP_TYPE_ASSIGN:
pOp->node.resType = ((SExprNode*)(pOp->pLeft))->resType;
break;
case OP_TYPE_BIT_AND:
case OP_TYPE_BIT_OR:
return getBitwiseOperatorResultType(pOp);
case OP_TYPE_GREATER_THAN: case OP_TYPE_GREATER_THAN:
case OP_TYPE_GREATER_EQUAL: case OP_TYPE_GREATER_EQUAL:
case OP_TYPE_LOWER_THAN: case OP_TYPE_LOWER_THAN:
case OP_TYPE_LOWER_EQUAL: case OP_TYPE_LOWER_EQUAL:
case OP_TYPE_EQUAL: case OP_TYPE_EQUAL:
case OP_TYPE_NOT_EQUAL: case OP_TYPE_NOT_EQUAL:
case OP_TYPE_IN: case OP_TYPE_IS_NULL:
case OP_TYPE_NOT_IN: case OP_TYPE_IS_NOT_NULL:
case OP_TYPE_IS_TRUE:
case OP_TYPE_IS_FALSE:
case OP_TYPE_IS_UNKNOWN:
case OP_TYPE_IS_NOT_TRUE:
case OP_TYPE_IS_NOT_FALSE:
case OP_TYPE_IS_NOT_UNKNOWN:
case OP_TYPE_LIKE: case OP_TYPE_LIKE:
case OP_TYPE_NOT_LIKE: case OP_TYPE_NOT_LIKE:
case OP_TYPE_MATCH: case OP_TYPE_MATCH:
case OP_TYPE_NMATCH: case OP_TYPE_NMATCH:
case OP_TYPE_IS_NULL: case OP_TYPE_IN:
case OP_TYPE_IS_NOT_NULL: case OP_TYPE_NOT_IN:
case OP_TYPE_IS_TRUE: return getComparisonOperatorResultType(pOp);
case OP_TYPE_JSON_CONTAINS:
pRes->type = TSDB_DATA_TYPE_BOOL;
return TSDB_CODE_SUCCESS;
case OP_TYPE_BIT_AND:
case OP_TYPE_BIT_OR:
pRes->type = TSDB_DATA_TYPE_BIGINT;
return TSDB_CODE_SUCCESS;
case OP_TYPE_JSON_GET_VALUE: case OP_TYPE_JSON_GET_VALUE:
pRes->type = TSDB_DATA_TYPE_JSON; case OP_TYPE_JSON_CONTAINS:
return TSDB_CODE_SUCCESS; return getJsonOperatorResultType(pOp);
default: default:
ASSERT(0); break;
return TSDB_CODE_APP_ERROR;
}
} }
return TSDB_CODE_SUCCESS;
}

View File

@ -276,7 +276,7 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
return p; return p;
} }
static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
int64_t value = 0; int64_t value = 0;
if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) { if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) {
value = 0; value = 0;
@ -285,10 +285,26 @@ static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t r
colDataAppendInt64(pOut->columnData, rowIndex, &value); colDataAppendInt64(pOut->columnData, rowIndex, &value);
} }
static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
if (overflow) {
int64_t minValue = tDataTypes[pOut->columnData->info.type].minValue;
int64_t maxValue = tDataTypes[pOut->columnData->info.type].maxValue;
int64_t value = (int64_t)taosStr2Int64(buf, NULL, 10);
if (value > maxValue) {
*overflow = 1;
return;
} else if (value < minValue) {
*overflow = -1;
return;
} else {
*overflow = 0;
}
}
switch (pOut->columnData->info.type) { switch (pOut->columnData->info.type) {
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
int8_t value = (int8_t)taosStr2Int8(buf, NULL, 10); int8_t value = (int8_t)taosStr2Int8(buf, NULL, 10);
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value); colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value);
break; break;
} }
@ -310,7 +326,22 @@ static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowI
} }
} }
static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
if (overflow) {
uint64_t minValue = (uint64_t)tDataTypes[pOut->columnData->info.type].minValue;
uint64_t maxValue = (uint64_t)tDataTypes[pOut->columnData->info.type].maxValue;
uint64_t value = (uint64_t)taosStr2UInt64(buf, NULL, 10);
if (value > maxValue) {
*overflow = 1;
return;
} else if (value < minValue) {
*overflow = -1;
return;
} else {
*overflow = 0;
}
}
switch (pOut->columnData->info.type) { switch (pOut->columnData->info.type) {
case TSDB_DATA_TYPE_UTINYINT: { case TSDB_DATA_TYPE_UTINYINT: {
uint8_t value = (uint8_t)taosStr2UInt8(buf, NULL, 10); uint8_t value = (uint8_t)taosStr2UInt8(buf, NULL, 10);
@ -335,18 +366,24 @@ static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t ro
} }
} }
static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
if (TSDB_DATA_TYPE_FLOAT == pOut->columnData->info.type) {
float value = taosStr2Float(buf, NULL);
colDataAppendFloat(pOut->columnData, rowIndex, &value);
return;
}
double value = taosStr2Double(buf, NULL); double value = taosStr2Double(buf, NULL);
colDataAppendDouble(pOut->columnData, rowIndex, &value); colDataAppendDouble(pOut->columnData, rowIndex, &value);
} }
static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
int64_t value = taosStr2Int64(buf, NULL, 10); int64_t value = taosStr2Int64(buf, NULL, 10);
bool v = (value != 0)? true:false; bool v = (value != 0)? true:false;
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v); colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v);
} }
static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
int32_t len = 0; int32_t len = 0;
int32_t inputLen = varDataLen(buf); int32_t inputLen = varDataLen(buf);
int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
@ -359,7 +396,7 @@ static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIn
taosMemoryFree(t); taosMemoryFree(t);
} }
static FORCE_INLINE void ncharToVar(char* buf, SScalarParam* pOut, int32_t rowIndex) { static FORCE_INLINE void ncharToVar(char* buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) {
int32_t inputLen = varDataLen(buf); int32_t inputLen = varDataLen(buf);
char* t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE); char* t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE);
@ -376,7 +413,7 @@ static FORCE_INLINE void ncharToVar(char* buf, SScalarParam* pOut, int32_t rowIn
//TODO opt performance, tmp is not needed. //TODO opt performance, tmp is not needed.
int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) { int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType, int32_t* overflow) {
bool vton = false; bool vton = false;
_bufConverteFunc func = NULL; _bufConverteFunc func = NULL;
@ -415,8 +452,7 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
if(inType == TSDB_DATA_TYPE_JSON){ if(inType == TSDB_DATA_TYPE_JSON){
if(*data == TSDB_DATA_TYPE_NULL) { if(*data == TSDB_DATA_TYPE_NULL) {
ASSERT(0); ASSERT(0);
} } else if(*data == TSDB_DATA_TYPE_NCHAR) {
else if(*data == TSDB_DATA_TYPE_NCHAR) {
data += CHAR_BYTES; data += CHAR_BYTES;
convertType = TSDB_DATA_TYPE_NCHAR; convertType = TSDB_DATA_TYPE_NCHAR;
} else if(tTagIsJson(data)){ } else if(tTagIsJson(data)){
@ -453,7 +489,7 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
} }
} }
(*func)(tmp, pOut, i); (*func)(tmp, pOut, i, overflow);
taosMemoryFreeClear(tmp); taosMemoryFreeClear(tmp);
} }
@ -606,7 +642,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value); int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value);
varDataLen(tmp) = len; varDataLen(tmp) = len;
if (outType == TSDB_DATA_TYPE_NCHAR) { if (outType == TSDB_DATA_TYPE_NCHAR) {
varToNchar(tmp, pOut, i); varToNchar(tmp, pOut, i, NULL);
} else { } else {
colDataAppend(pOutputCol, i, (char *)tmp, false); colDataAppend(pOutputCol, i, (char *)tmp, false);
} }
@ -623,7 +659,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value); int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value);
varDataLen(tmp) = len; varDataLen(tmp) = len;
if (outType == TSDB_DATA_TYPE_NCHAR) { if (outType == TSDB_DATA_TYPE_NCHAR) {
varToNchar(tmp, pOut, i); varToNchar(tmp, pOut, i, NULL);
} else { } else {
colDataAppend(pOutputCol, i, (char *)tmp, false); colDataAppend(pOutputCol, i, (char *)tmp, false);
} }
@ -640,7 +676,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
int32_t len = sprintf(varDataVal(tmp), "%lf", value); int32_t len = sprintf(varDataVal(tmp), "%lf", value);
varDataLen(tmp) = len; varDataLen(tmp) = len;
if (outType == TSDB_DATA_TYPE_NCHAR) { if (outType == TSDB_DATA_TYPE_NCHAR) {
varToNchar(tmp, pOut, i); varToNchar(tmp, pOut, i, NULL);
} else { } else {
colDataAppend(pOutputCol, i, (char *)tmp, false); colDataAppend(pOutputCol, i, (char *)tmp, false);
} }
@ -653,9 +689,8 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
// TODO opt performance // TODO opt performance
int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) { int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* overflow) {
SColumnInfoData* pInputCol = pIn->columnData; SColumnInfoData* pInputCol = pIn->columnData;
SColumnInfoData* pOutputCol = pOut->columnData; SColumnInfoData* pOutputCol = pOut->columnData;
@ -668,7 +703,47 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) {
int16_t outType = pOutputCol->info.type; int16_t outType = pOutputCol->info.type;
if (IS_VAR_DATA_TYPE(inType)) { if (IS_VAR_DATA_TYPE(inType)) {
return vectorConvertFromVarData(pIn, pOut, inType, outType); return vectorConvertFromVarData(pIn, pOut, inType, outType, overflow);
}
if (overflow) {
ASSERT(1 == pIn->numOfRows);
pOut->numOfRows = 0;
if (IS_SIGNED_NUMERIC_TYPE(outType)) {
int64_t minValue = tDataTypes[outType].minValue;
int64_t maxValue = tDataTypes[outType].maxValue;
double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
if (value > maxValue) {
*overflow = 1;
return TSDB_CODE_SUCCESS;
} else if (value < minValue) {
*overflow = -1;
return TSDB_CODE_SUCCESS;
} else {
*overflow = 0;
}
} else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) {
uint64_t minValue = (uint64_t)tDataTypes[outType].minValue;
uint64_t maxValue = (uint64_t)tDataTypes[outType].maxValue;
double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
if (value > maxValue) {
*overflow = 1;
return TSDB_CODE_SUCCESS;
} else if (value < minValue) {
*overflow = -1;
return TSDB_CODE_SUCCESS;
} else {
*overflow = 0;
}
}
} }
pOut->numOfRows = pIn->numOfRows; pOut->numOfRows = pIn->numOfRows;
@ -829,6 +904,8 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = { int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = {
/* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB */ /* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB */
/*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -873,7 +950,7 @@ int32_t vectorConvertScalarParam(SScalarParam *input, SScalarParam *output, int3
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
code = vectorConvertImpl(input, output); code = vectorConvertImpl(input, output, NULL);
if (code) { if (code) {
// taosMemoryFreeClear(paramOut1->data); // taosMemoryFreeClear(paramOut1->data);
return code; return code;
@ -944,7 +1021,7 @@ static int32_t doConvertHelper(SScalarParam* pDest, int32_t* convert, const SSca
return code; return code;
} }
code = vectorConvertImpl(pParam, pDest); code = vectorConvertImpl(pParam, pDest, NULL);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return code; return code;
} }
@ -1714,7 +1791,7 @@ void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
} }
void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
vectorConvertImpl(pLeft, pOut); vectorConvertImpl(pLeft, pOut, NULL);
for(int32_t i = 0; i < pOut->numOfRows; ++i) { for(int32_t i = 0; i < pOut->numOfRows; ++i) {
if(colDataIsNull_s(pOut->columnData, i)) { if(colDataIsNull_s(pOut->columnData, i)) {
int8_t v = 0; int8_t v = 0;

View File

@ -235,10 +235,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie
// do nothing // do nothing
} else { } else {
SSyncRaftEntry* pEntry; SSnapshot oldSnapshot;
int32_t code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, nextIndex, &pEntry); ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &oldSnapshot);
ASSERT(code == 0); SyncTerm newSnapshotTerm = oldSnapshot.lastApplyTerm;
syncNodeStartSnapshotOnce(ths, SYNC_INDEX_BEGIN, nextIndex, pEntry->term, pMsg); syncNodeStartSnapshotOnce(ths, SYNC_INDEX_BEGIN, nextIndex, newSnapshotTerm, pMsg);
// get sender // get sender
SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId)); SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId));

View File

@ -745,14 +745,14 @@ cmp_end:
void taosSetAllDebugFlag(int32_t flag) { void taosSetAllDebugFlag(int32_t flag) {
if (flag <= 0) return; if (flag <= 0) return;
uDebugFlag = flag;
rpcDebugFlag = flag;
jniDebugFlag = flag;
qDebugFlag = flag;
cDebugFlag = flag;
dDebugFlag = flag; dDebugFlag = flag;
vDebugFlag = flag; vDebugFlag = flag;
mDebugFlag = flag; mDebugFlag = flag;
cDebugFlag = flag;
jniDebugFlag = flag;
uDebugFlag = flag;
rpcDebugFlag = flag;
qDebugFlag = flag;
wDebugFlag = flag; wDebugFlag = flag;
sDebugFlag = flag; sDebugFlag = flag;
tsdbDebugFlag = flag; tsdbDebugFlag = flag;
@ -761,6 +761,5 @@ void taosSetAllDebugFlag(int32_t flag) {
udfDebugFlag = flag; udfDebugFlag = flag;
smaDebugFlag = flag; smaDebugFlag = flag;
idxDebugFlag = flag; idxDebugFlag = flag;
uInfo("all debug flag are set to %d", flag); uInfo("all debug flag are set to %d", flag);
} }

View File

@ -39,7 +39,7 @@ int32_t tQWorkerInit(SQWorkerPool *pool) {
worker->pool = pool; worker->pool = pool;
} }
uDebug("worker:%s is initialized, min:%d max:%d", pool->name, pool->min, pool->max); uInfo("worker:%s is initialized, min:%d max:%d", pool->name, pool->min, pool->max);
return 0; return 0;
} }

View File

@ -58,9 +58,10 @@ class ConfigureyCluster:
self.dnodes.append(dnode) self.dnodes.append(dnode)
return self.dnodes return self.dnodes
def create_dnode(self,conn): def create_dnode(self,conn,dnodeNum):
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
for dnode in self.dnodes[1:]: dnodeNum=int(dnodeNum)
for dnode in self.dnodes[1:dnodeNum]:
# print(dnode.cfgDict) # print(dnode.cfgDict)
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
tdSql.execute(" create dnode '%s';"%dnode_id) tdSql.execute(" create dnode '%s';"%dnode_id)

View File

@ -52,6 +52,7 @@
./test.sh -f tsim/insert/null.sim ./test.sh -f tsim/insert/null.sim
./test.sh -f tsim/insert/update0.sim ./test.sh -f tsim/insert/update0.sim
./test.sh -f tsim/insert/commit-merge0.sim ./test.sh -f tsim/insert/commit-merge0.sim
./test.sh -f tsim/insert/insert_select.sim
# ---- parser # ---- parser
./test.sh -f tsim/parser/groupby-basic.sim ./test.sh -f tsim/parser/groupby-basic.sim
@ -97,7 +98,7 @@
./test.sh -f tsim/stream/distributeInterval0.sim ./test.sh -f tsim/stream/distributeInterval0.sim
# ./test.sh -f tsim/stream/distributeIntervalRetrive0.sim # ./test.sh -f tsim/stream/distributeIntervalRetrive0.sim
# ./test.sh -f tsim/stream/distributesession0.sim # ./test.sh -f tsim/stream/distributesession0.sim
# ./test.sh -f tsim/stream/session0.sim ./test.sh -f tsim/stream/session0.sim
./test.sh -f tsim/stream/session1.sim ./test.sh -f tsim/stream/session1.sim
# ./test.sh -f tsim/stream/state0.sim # ./test.sh -f tsim/stream/state0.sim
./test.sh -f tsim/stream/triggerInterval0.sim ./test.sh -f tsim/stream/triggerInterval0.sim
@ -193,4 +194,7 @@
# --- catalog # --- catalog
./test.sh -f tsim/catalog/alterInCurrent.sim ./test.sh -f tsim/catalog/alterInCurrent.sim
# --- scalar
./test.sh -f tsim/scalar/in.sim
#======================b1-end=============== #======================b1-end===============

View File

@ -122,28 +122,29 @@ echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG
echo "fqdn ${HOSTNAME}" >> $TAOS_CFG echo "fqdn ${HOSTNAME}" >> $TAOS_CFG
echo "serverPort ${NODE}" >> $TAOS_CFG echo "serverPort ${NODE}" >> $TAOS_CFG
echo "supportVnodes 1024" >> $TAOS_CFG echo "supportVnodes 1024" >> $TAOS_CFG
echo "statusInterval 1" >> $TAOS_CFG
echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG
echo "logDir $LOG_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG
echo "debugFlag 0" >> $TAOS_CFG echo "debugFlag 0" >> $TAOS_CFG
echo "mDebugFlag 143" >> $TAOS_CFG
echo "dDebugFlag 143" >> $TAOS_CFG
echo "vDebugFlag 143" >> $TAOS_CFG
echo "tqDebugFlag 143" >> $TAOS_CFG
echo "tsdbDebugFlag 143" >> $TAOS_CFG
echo "cDebugFlag 143" >> $TAOS_CFG
echo "jniDebugFlag 143" >> $TAOS_CFG
echo "qDebugFlag 143" >> $TAOS_CFG
echo "rpcDebugFlag 143" >> $TAOS_CFG
echo "sDebugFlag 143" >> $TAOS_CFG
echo "wDebugFlag 143" >> $TAOS_CFG
echo "idxDebugFlag 143" >> $TAOS_CFG
echo "fsDebugFlag 143" >> $TAOS_CFG
echo "udfDebugFlag 143" >> $TAOS_CFG
echo "smaDebugFlag 143" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "uDebugFlag 131" >> $TAOS_CFG echo "uDebugFlag 131" >> $TAOS_CFG
echo "rpcDebugFlag 131" >> $TAOS_CFG
echo "jniDebugFlag 143" >> $TAOS_CFG
echo "qDebugFlag 143" >> $TAOS_CFG
echo "cDebugFlag 143" >> $TAOS_CFG
echo "dDebugFlag 143" >> $TAOS_CFG
echo "vDebugFlag 143" >> $TAOS_CFG
echo "mDebugFlag 143" >> $TAOS_CFG
echo "wDebugFlag 143" >> $TAOS_CFG
echo "sDebugFlag 143" >> $TAOS_CFG
echo "tsdbDebugFlag 143" >> $TAOS_CFG
echo "tqDebugFlag 143" >> $TAOS_CFG
echo "fsDebugFlag 143" >> $TAOS_CFG
echo "idxDebugFlag 143" >> $TAOS_CFG
echo "udfDebugFlag 143" >> $TAOS_CFG
echo "smaDebugFlag 143" >> $TAOS_CFG
echo "idxDebugFlag 143" >> $TAOS_CFG
echo "numOfLogLines 20000000" >> $TAOS_CFG echo "numOfLogLines 20000000" >> $TAOS_CFG
echo "statusInterval 1" >> $TAOS_CFG
echo "asyncLog 0" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG
echo "locale en_US.UTF-8" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG
echo "telemetryReporting 0" >> $TAOS_CFG echo "telemetryReporting 0" >> $TAOS_CFG

View File

@ -0,0 +1,83 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ======== step1
sql drop database if exists db1;
sql create database db1 vgroups 3;
sql use db1;
sql create stable st1 (fts timestamp, fbool bool, ftiny tinyint, fsmall smallint, fint int, fbig bigint, futiny tinyint unsigned, fusmall smallint unsigned, fuint int unsigned, fubig bigint unsigned, ffloat float, fdouble double, fbin binary(10), fnchar nchar(10)) tags(tts timestamp, tbool bool, ttiny tinyint, tsmall smallint, tint int, tbig bigint, tutiny tinyint unsigned, tusmall smallint unsigned, tuint int unsigned, tubig bigint unsigned, tfloat float, tdouble double, tbin binary(10), tnchar nchar(10));
sql create table tb1 using st1 tags('2022-07-10 16:31:00', true, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql create table tb2 using st1 tags('2022-07-10 16:32:00', false, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql create table tb3 using st1 tags('2022-07-10 16:33:00', true, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb1 values ('2022-07-10 16:31:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql insert into tb1 values ('2022-07-10 16:31:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql insert into tb1 values ('2022-07-10 16:31:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb1 values ('2022-07-10 16:31:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd');
sql insert into tb1 values ('2022-07-10 16:31:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e');
sql insert into tb2 values ('2022-07-10 16:32:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql insert into tb2 values ('2022-07-10 16:32:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql insert into tb2 values ('2022-07-10 16:32:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb2 values ('2022-07-10 16:32:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd');
sql insert into tb2 values ('2022-07-10 16:32:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e');
sql insert into tb3 values ('2022-07-10 16:33:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql insert into tb3 values ('2022-07-10 16:33:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql insert into tb3 values ('2022-07-10 16:33:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb3 values ('2022-07-10 16:33:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd');
sql insert into tb3 values ('2022-07-10 16:33:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e');
sql select * from tb1 where fts in ('2022-07-10 16:31:01', '2022-07-10 16:31:03', 1657441865000);
if $rows != 3 then
return -1
endi
sql select * from tb1 where fbool in (0, 3);
if $rows != 5 then
return -1
endi
sql select * from tb1 where ftiny in (257);
if $rows != 0 then
return -1
endi
sql select * from tb1 where ftiny in (2, 257);
if $rows != 1 then
return -1
endi
sql select * from tb1 where futiny in (0, 257);
if $rows != 0 then
return -1
endi
sql select * from st1 where tts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441865000);
if $rows != 10 then
return -1
endi
sql select * from st1 where tbool in (0, 3);
if $rows != 15 then
return -1
endi
sql select * from st1 where ttiny in (257);
if $rows != 0 then
return -1
endi
sql select * from st1 where ttiny in (2, 257);
if $rows != 5 then
return -1
endi
sql select * from st1 where tutiny in (0, 257);
if $rows != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -99,7 +99,7 @@ if $rows != 1 then
endi endi
#sql select * from information_schema.`streams` #sql select * from information_schema.`streams`
sql select * from information_schema.user_tables sql select * from information_schema.user_tables
if $rows != 31 then if $rows != 30 then
return -1 return -1
endi endi
#sql select * from information_schema.user_table_distributed #sql select * from information_schema.user_table_distributed
@ -197,7 +197,7 @@ if $rows != 1 then
endi endi
#sql select * from performance_schema.`streams` #sql select * from performance_schema.`streams`
sql select * from information_schema.user_tables sql select * from information_schema.user_tables
if $rows != 31 then if $rows != 30 then
return -1 return -1
endi endi
#sql select * from information_schema.user_table_distributed #sql select * from information_schema.user_table_distributed

View File

@ -1,6 +1,6 @@
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 #system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start

View File

@ -48,7 +48,7 @@ sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s
print =============== step6: select data print =============== step6: select data
sql select * from ct1 sql select * from ct1
#sql select * from stb sql select * from stb
_OVER: _OVER:
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -47,7 +47,7 @@ sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3)
print =============== step6: select data print =============== step6: select data
#sql select * from ct1 sql select * from ct1
#sql select * from stb #sql select * from stb
_OVER: _OVER:
@ -58,7 +58,7 @@ print ----> start to check if there are ERRORS in vagrind log file for each dnod
system_content sh/checkValgrind.sh -n dnode1 system_content sh/checkValgrind.sh -n dnode1
print cmd return result ----> [ $system_content ] print cmd return result ----> [ $system_content ]
if $system_content <= 0 then if $system_content <= 2 then
return 0 return 0
endi endi

View File

@ -1,262 +0,0 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import os
import threading as thd
import multiprocessing as mp
from numpy.lib.function_base import insert
import taos
from taos import *
from util.log import *
from util.cases import *
from util.sql import *
import numpy as np
import datetime as dt
from datetime import datetime
from ctypes import *
import time
# constant define
WAITS = 5 # wait seconds
class TDTestCase:
#
# --------------- main frame -------------------
def caseDescription(self):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: offset return valid
'''
return
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files or "taosd.exe" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
break
return buildPath
# init
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
# tdSql.prepare()
# self.create_tables();
self.ts = 1500000000000
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
# --------------- case -------------------
def newcon(self,host,cfg):
user = "root"
password = "taosdata"
port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
print(con)
return con
def test_stmt_set_tbname_tag(self,conn):
dbname = "stmt_tag"
try:
conn.execute("drop database if exists %s" % dbname)
conn.execute("create database if not exists %s PRECISION 'us' " % dbname)
conn.select_db(dbname)
conn.execute("create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\
bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \
ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,\
t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned, \
t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)")
stmt = conn.statement("insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
tags = new_bind_params(16)
tags[0].timestamp(1626861392589123, PrecisionEnum.Microseconds)
tags[1].bool(True)
tags[2].bool(False)
tags[3].tinyint(2)
tags[4].smallint(3)
tags[5].int(4)
tags[6].bigint(5)
tags[7].tinyint_unsigned(6)
tags[8].smallint_unsigned(7)
tags[9].int_unsigned(8)
tags[10].bigint_unsigned(9)
tags[11].float(10.1)
tags[12].double(10.11)
tags[13].binary("hello")
tags[14].nchar("stmt")
tags[15].timestamp(1626861392589, PrecisionEnum.Milliseconds)
stmt.set_tbname_tags("tb1", tags)
params = new_multi_binds(17)
params[0].timestamp((1626861392589111, 1626861392590111, 1626861392591111))
params[1].bool((True, None, False))
params[2].tinyint([-128, -128, None]) # -128 is tinyint null
params[3].tinyint([0, 127, None])
params[4].smallint([3, None, 2])
params[5].int([3, 4, None])
params[6].bigint([3, 4, None])
params[7].tinyint_unsigned([3, 4, None])
params[8].smallint_unsigned([3, 4, None])
params[9].int_unsigned([3, 4, None])
params[10].bigint_unsigned([3, 4, 5])
params[11].float([3, None, 1])
params[12].double([3, None, 1.2])
params[13].binary(["abc", "dddafadfadfadfadfa", None])
params[14].nchar(["涛思数据", None, "a long string with 中文字符"])
params[15].timestamp([None, None, 1626861392591])
params[16].binary(["涛思数据16", None, "a long string with 中文-字符"])
stmt.bind_param_batch(params)
stmt.execute()
assert stmt.affected_rows == 3
#query all
querystmt1=conn.statement("select * from log where bu < ?")
queryparam1=new_bind_params(1)
print(type(queryparam1))
queryparam1[0].int(10)
querystmt1.bind_param(queryparam1)
querystmt1.execute()
result1=querystmt1.use_result()
rows1=result1.fetch_all()
print(rows1[0])
print(rows1[1])
print(rows1[2])
assert str(rows1[0][0]) == "2021-07-21 17:56:32.589111"
assert rows1[0][10] == 3
assert rows1[1][10] == 4
#query: Numeric Functions
querystmt2=conn.statement("select abs(?) from log where bu < ?")
queryparam2=new_bind_params(2)
print(type(queryparam2))
queryparam2[0].int(5)
queryparam2[1].int(5)
querystmt2.bind_param(queryparam2)
querystmt2.execute()
result2=querystmt2.use_result()
rows2=result2.fetch_all()
print("2",rows2)
assert rows2[0][0] == 5
assert rows2[1][0] == 5
#query: Numeric Functions and escapes
querystmt3=conn.statement("select abs(?) from log where nn= 'a? long string with 中文字符' ")
queryparam3=new_bind_params(1)
print(type(queryparam3))
queryparam3[0].int(5)
querystmt3.bind_param(queryparam3)
querystmt3.execute()
result3=querystmt3.use_result()
rows3=result3.fetch_all()
print("3",rows3)
assert rows3 == []
#query: string Functions
querystmt9=conn.statement("select CHAR_LENGTH(?) from log ")
queryparam9=new_bind_params(1)
print(type(queryparam9))
queryparam9[0].binary('中文字符')
querystmt9.bind_param(queryparam9)
querystmt9.execute()
result9=querystmt9.use_result()
rows9=result9.fetch_all()
print("9",rows9)
assert rows9[0][0] == 12, 'fourth case is failed'
assert rows9[1][0] == 12, 'fourth case is failed'
#query: conversion Functions
querystmt4=conn.statement("select cast( ? as bigint) from log ")
queryparam4=new_bind_params(1)
print(type(queryparam4))
queryparam4[0].binary('1232a')
querystmt4.bind_param(queryparam4)
querystmt4.execute()
result4=querystmt4.use_result()
rows4=result4.fetch_all()
print("5",rows4)
assert rows4[0][0] == 1232
assert rows4[1][0] == 1232
querystmt4=conn.statement("select cast( ? as binary(10)) from log ")
queryparam4=new_bind_params(1)
print(type(queryparam4))
queryparam4[0].int(123)
querystmt4.bind_param(queryparam4)
querystmt4.execute()
result4=querystmt4.use_result()
rows4=result4.fetch_all()
print("6",rows4)
assert rows4[0][0] == '123'
assert rows4[1][0] == '123'
# #query: datatime Functions
# querystmt4=conn.statement(" select timediff('2021-07-21 17:56:32.590111',?,1s) from log ")
# queryparam4=new_bind_params(1)
# print(type(queryparam4))
# queryparam4[0].timestamp(1626861392591111)
# querystmt4.bind_param(queryparam4)
# querystmt4.execute()
# result4=querystmt4.use_result()
# rows4=result4.fetch_all()
# print("7",rows4)
# assert rows4[0][0] == 1, 'seventh case is failed'
# assert rows4[1][0] == 1, 'seventh case is failed'
# conn.execute("drop database if exists %s" % dbname)
conn.close()
except Exception as err:
# conn.execute("drop database if exists %s" % dbname)
conn.close()
raise err
def run(self):
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
host="localhost"
connectstmt=self.newcon(host,config)
self.test_stmt_set_tbname_tag(connectstmt)
return
# add case with filename
#
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -614,12 +614,12 @@ class TDTestCase:
self.__insert_data() self.__insert_data()
self.all_test() self.all_test()
tdLog.printNoPrefix("==========step2:create table in rollup database") #tdLog.printNoPrefix("==========step2:create table in rollup database")
tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") #tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m")
tdSql.execute("use db3") #tdSql.execute("use db3")
# self.__create_tb() # self.__create_tb()
tdSql.execute(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL}) ") #tdSql.execute(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL}) ")
self.all_test() #self.all_test()
# self.__insert_data() # self.__insert_data()

View File

@ -278,22 +278,7 @@ class TDTestCase:
tdSql.checkData(0,0,rowsPerSTable) tdSql.checkData(0,0,rowsPerSTable)
return return
# test case1 base # test case : Switch back and forth among the three queryPolicy1\2\3
def test_case1(self):
#stableCount=threadNumbersCtb
parameterDict = {'vgroups': 1, \
'threadNumbersCtb': 5, \
'threadNumbersIda': 5, \
'stableCount': 5, \
'tablesPerStb': 50, \
'rowsPerTable': 10, \
'dbname': 'db', \
'stbname': 'stb', \
'host': 'localhost', \
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
tdLog.debug("-----create database and muti-thread create tables test------- ")
def test_case1(self): def test_case1(self):
self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10) self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 1, 2, 1*10)
tdSql.execute("use db1;") tdSql.execute("use db1;")
@ -407,6 +392,7 @@ class TDTestCase:
tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;") tdSql.query("select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;")
assert unionallQnode==tdSql.queryResult assert unionallQnode==tdSql.queryResult
# test case : queryPolicy = 2
def test_case2(self): def test_case2(self):
self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 10, 2, 1*10) self.taosBenchCreate("127.0.0.1","no","db1", "stb1", 10, 2, 1*10)
tdSql.query("show qnodes") tdSql.query("show qnodes")
@ -438,8 +424,9 @@ class TDTestCase:
tdSql.query("select max(c1) from stb10_0;") tdSql.query("select max(c1) from stb10_0;")
tdSql.query("select min(c1) from stb11_0;") tdSql.query("select min(c1) from stb11_0;")
def test_case3(self): # test case : queryPolicy = 3
def test_case3(self):
tdSql.execute('alter local "queryPolicy" "3"') tdSql.execute('alter local "queryPolicy" "3"')
tdLog.debug("create qnode on dnode 1") tdLog.debug("create qnode on dnode 1")
tdSql.execute("create qnode on dnode 1") tdSql.execute("create qnode on dnode 1")
@ -472,10 +459,16 @@ class TDTestCase:
# run case # run case
def run(self): def run(self):
# test qnode # test qnode
tdLog.debug(" test_case1 ............ [start]")
self.test_case1() self.test_case1()
tdLog.debug(" test_case1 ............ [OK]")
tdLog.debug(" test_case2 ............ [start]")
self.test_case2() self.test_case2()
tdLog.debug(" test_case2 ............ [OK]")
tdLog.debug(" test_case3 ............ [start]")
self.test_case3() self.test_case3()
tdLog.debug(" test_case3 ............ [OK]")
# tdLog.debug(" LIMIT test_case3 ............ [OK]") # tdLog.debug(" LIMIT test_case3 ............ [OK]")
def stop(self): def stop(self):

View File

@ -1066,7 +1066,7 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# in # in
query_sql = f'select {select_elm} from {tb_name} where c5 in (1, 6.6)' query_sql = f'select {select_elm} from {tb_name} where c5 in (1, 6.6)'
tdSql.error(query_sql) tdSql.query(query_sql)
# not in # not in
query_sql = f'select {select_elm} from {tb_name} where c5 not in (2, 3)' query_sql = f'select {select_elm} from {tb_name} where c5 not in (2, 3)'
tdSql.query(query_sql) tdSql.query(query_sql)
@ -1074,10 +1074,10 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# and # and
query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 and c5 < 7 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 6.6 and c5 is not null and c5 between 2 and 6.6 and c5 not between 1 and 2 and c5 in (2,6.6) and c5 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 and c5 < 7 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 6.6 and c5 is not null and c5 between 2 and 6.6 and c5 not between 1 and 2 and c5 in (2,6.6) and c5 not in (1,2)'
tdSql.error(query_sql) tdSql.query(query_sql)
# or # or
query_sql = f'select {select_elm} from {tb_name} where c5 > 6 or c5 >= 6.6 or c5 < 1 or c5 <= 0 or c5 != 1.1 or c5 <> 1.1 or c5 = 5 or c5 is null or c5 between 4 and 5 or c5 not between 1 and 3 or c5 in (4,5) or c5 not in (1.1,3)' query_sql = f'select {select_elm} from {tb_name} where c5 > 6 or c5 >= 6.6 or c5 < 1 or c5 <= 0 or c5 != 1.1 or c5 <> 1.1 or c5 = 5 or c5 is null or c5 between 4 and 5 or c5 not between 1 and 3 or c5 in (4,5) or c5 not in (1.1,3)'
tdSql.error(query_sql) tdSql.query(query_sql)
# and or # and or
query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)'
tdSql.query(query_sql) tdSql.query(query_sql)
@ -1145,7 +1145,7 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# in # in
query_sql = f'select {select_elm} from {tb_name} where c6 in (1, 7.7)' query_sql = f'select {select_elm} from {tb_name} where c6 in (1, 7.7)'
tdSql.error(query_sql) tdSql.query(query_sql)
# not in # not in
query_sql = f'select {select_elm} from {tb_name} where c6 not in (2, 3)' query_sql = f'select {select_elm} from {tb_name} where c6 not in (2, 3)'
tdSql.query(query_sql) tdSql.query(query_sql)
@ -1153,10 +1153,10 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# and # and
query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 and c6 < 8 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 7.7 and c6 is not null and c6 between 2 and 7.7 and c6 not between 1 and 2 and c6 in (2,7.7) and c6 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 and c6 < 8 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 7.7 and c6 is not null and c6 between 2 and 7.7 and c6 not between 1 and 2 and c6 in (2,7.7) and c6 not in (1,2)'
tdSql.error(query_sql) tdSql.query(query_sql)
# or # or
query_sql = f'select {select_elm} from {tb_name} where c6 > 7 or c6 >= 7.7 or c6 < 1 or c6 <= 0 or c6 != 1.1 or c6 <> 1.1 or c6 = 5 or c6 is null or c6 between 4 and 5 or c6 not between 1 and 3 or c6 in (4,5) or c6 not in (1.1,3)' query_sql = f'select {select_elm} from {tb_name} where c6 > 7 or c6 >= 7.7 or c6 < 1 or c6 <= 0 or c6 != 1.1 or c6 <> 1.1 or c6 = 5 or c6 is null or c6 between 4 and 5 or c6 not between 1 and 3 or c6 in (4,5) or c6 not in (1.1,3)'
tdSql.error(query_sql) tdSql.query(query_sql)
# and or # and or
query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)' query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)'
tdSql.query(query_sql) tdSql.query(query_sql)
@ -1398,7 +1398,7 @@ class TDTestCase:
tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False
# in # in
query_sql = f'select {select_elm} from {tb_name} where c9 in ("binar", false)' query_sql = f'select {select_elm} from {tb_name} where c9 in ("binar", false)'
tdSql.error(query_sql) tdSql.query(query_sql)
# # not in # # not in
query_sql = f'select {select_elm} from {tb_name} where c9 not in (true)' query_sql = f'select {select_elm} from {tb_name} where c9 not in (true)'
tdSql.query(query_sql) tdSql.query(query_sql)
@ -1407,13 +1407,13 @@ class TDTestCase:
# # and # # and
query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" and c9 <> "binary" and c9 is not null and c9 in ("binary", true) and c9 not in ("binary")' query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" and c9 <> "binary" and c9 is not null and c9 in ("binary", true) and c9 not in ("binary")'
tdSql.error(query_sql) tdSql.query(query_sql)
# # or # # or
query_sql = f'select {select_elm} from {tb_name} where c9 = true or c9 != "false" or c9 <> "binary" or c9 = "true" or c9 is not null or c9 in ("binary", true) or c9 not in ("binary")' query_sql = f'select {select_elm} from {tb_name} where c9 = true or c9 != "false" or c9 <> "binary" or c9 = "true" or c9 is not null or c9 in ("binary", true) or c9 not in ("binary")'
tdSql.error(query_sql) tdSql.query(query_sql)
# # and or # # and or
query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" or c9 <> "binary" or c9 = "true" and c9 is not null or c9 in ("binary", true) or c9 not in ("binary")' query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" or c9 <> "binary" or c9 = "true" and c9 is not null or c9 in ("binary", true) or c9 not in ("binary")'
tdSql.error(query_sql) tdSql.query(query_sql)
query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2)' query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2)'
tdSql.query(query_sql) tdSql.query(query_sql)
tdSql.checkRows(9) tdSql.checkRows(9)

View File

@ -0,0 +1,74 @@
import taos
import sys
import datetime
import inspect
from util.log import *
from util.sql import *
from util.cases import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor(), True)
def prepareData(self):
database="db_tsbs"
ts=1451606400000
tdSql.execute(f"create database {database};")
tdSql.execute(f"use {database} ")
tdSql.execute('''
create table readings (ts timestamp,latitude double,longitude double,elevation double,velocity double,heading double,grade double,fuel_consumption double,load_capacity double,fuel_capacity double,nominal_fuel_consumption double) tags (name binary(30),fleet binary(30),driver binary(30),model binary(30),device_version binary(30));
''')
tdSql.execute('''
create table diagnostics (ts timestamp,fuel_state double,current_load double,status bigint,load_capacity double,fuel_capacity double,nominal_fuel_consumption double) tags (name binary(30),fleet binary(30),driver binary(30),model binary(30),device_version binary(30)) ;
''')
for i in range(10):
tdSql.execute(f"create table rct{i} using readings (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}','H-{i}','v2.3')")
tdSql.execute(f"create table dct{i} using diagnostics (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}','H-{i}','v2.3')")
for j in range(10):
for i in range(10):
tdSql.execute(
f"insert into rct{j} values ( {ts+i*10000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )"
)
tdSql.execute(
f"insert into dct{j} values ( {ts+i*10000}, {1+i*0.1},{1400+i*15}, {1+i},{1500+i*20}, {150+i*2},{5+i} )"
)
# def check_avg(self ,origin_query , check_query):
# avg_result = tdSql.getResult(origin_query)
# origin_result = tdSql.getResult(check_query)
# check_status = True
# for row_index , row in enumerate(avg_result):
# for col_index , elem in enumerate(row):
# if avg_result[row_index][col_index] != origin_result[row_index][col_index]:
# check_status = False
# if not check_status:
# tdLog.notice("avg function value has not as expected , sql is \"%s\" "%origin_query )
# sys.exit(1)
# else:
# tdLog.info("avg value check pass , it work as expected ,sql is \"%s\" "%check_query )
def tsbsIotQuery(self):
tdSql.execute("use db_tsbs")
tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ")
tdSql.checkRows(1)
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
self.tsbsIotQuery()
self.tsbsIotQuery()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -124,9 +124,9 @@ class TDTestCase:
tdSql.query('show databases;') tdSql.query('show databases;')
tdSql.checkData(2,5,'no_strict') tdSql.checkData(2,5,'no_strict')
tdSql.error('alter database db strict 0') tdSql.error('alter database db strict 0')
tdSql.execute('alter database db strict 1') # tdSql.execute('alter database db strict 1')
tdSql.query('show databases;') # tdSql.query('show databases;')
tdSql.checkData(2,5,'strict') # tdSql.checkData(2,5,'strict')
def getConnection(self, dnode): def getConnection(self, dnode):
host = dnode.cfgDict["fqdn"] host = dnode.cfgDict["fqdn"]

View File

@ -0,0 +1,229 @@
from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
from numpy import row_stack
import taos
import sys
import time
import os
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import TDDnodes
from util.dnodes import TDDnode
from util.cluster import *
sys.path.append("./6-cluster")
from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck
import time
import socket
import subprocess
from multiprocessing import Process
import threading
import time
import inspect
import ctypes
class TDTestCase:
def init(self,conn ,logSql):
tdLog.debug(f"start to excute {__file__}")
self.TDDnodes = None
tdSql.init(conn.cursor())
self.host = socket.gethostname()
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def _async_raise(self, tid, exctype):
"""raises the exception, performs cleanup if needed"""
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stopThread(self,thread):
self._async_raise(thread.ident, SystemExit)
def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti)
print("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("use db%d" %couti)
tdSql.execute(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db0_0',
'dropFlag': 1,
'event': '',
'vgroups': 4,
'replica': 1,
'stbName': 'stb',
'stbNumbers': 2,
'colPrefix': 'c',
'tagPrefix': 't',
'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
'ctbPrefix': 'ctb',
'ctbNum': 200,
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
"rowsPerTbl": 1000,
"batchNum": 5000
}
hostname = socket.gethostname()
dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums)
allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"])
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1
tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(4,1,'%s:6430'%self.host)
clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkMnodeStatus(1)
# fisr add three mnodes;
tdLog.info("fisr add three mnodes and check mnode status")
tdSql.execute("create mnode on dnode 2")
clusterComCheck.checkMnodeStatus(2)
tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3)
# add some error operations and
tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;")
print(tdSql.queryResult)
clusterComCheck.checkDnodes(dnodeNumbers)
# create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes
# dnode6=cluster.addDnode(6)
# tdDnodes.append(dnode6)
# tdDnodes = ClusterDnodes(tdDnodes)
stopcount =0
threads=[]
# create stable:stb_0
stableName= paraDict['stbName']
newTdSql=tdCom.newTdSql()
clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers'])
#create child table:ctb_0
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql()
clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum'])
#insert date
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
for tr in threads:
tr.start()
dnode6Port=int(6030+5*100)
tdSql.execute("create dnode '%s:%d'"%(hostname,dnode6Port))
clusterComCheck.checkDnodes(dnodeNumbers)
while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode":
for i in range(mnodeNums):
tdDnodes[i].stoptaosd()
# sleep(10)
tdDnodes[i].starttaosd()
# sleep(10)
elif stopRole == "vnode":
for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd()
# sleep(10)
tdDnodes[i+mnodeNums].starttaosd()
# sleep(10)
elif stopRole == "dnode":
for i in range(dnodeNumbers):
tdDnodes[i].stoptaosd()
# sleep(10)
tdDnodes[i].starttaosd()
# sleep(10)
# dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123")
else:
print("456")
self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode()
stopcount+=1
for tr in threads:
tr.join()
clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkDbRows(dbNumbers)
# clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"])
tdSql.execute("use %s" %(paraDict["dbName"]))
tdSql.query("show stables")
tdSql.checkRows(paraDict["stbNumbers"])
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
tdSql.query("select * from %s"%stableName)
tdSql.checkRows(rowsPerStb)
def run(self):
# print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -0,0 +1,223 @@
from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
from numpy import row_stack
import taos
import sys
import time
import os
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import TDDnodes
from util.dnodes import TDDnode
from util.cluster import *
sys.path.append("./6-cluster")
from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck
import time
import socket
import subprocess
from multiprocessing import Process
import threading
import time
import inspect
import ctypes
class TDTestCase:
def init(self,conn ,logSql):
tdLog.debug(f"start to excute {__file__}")
self.TDDnodes = None
tdSql.init(conn.cursor())
self.host = socket.gethostname()
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def _async_raise(self, tid, exctype):
"""raises the exception, performs cleanup if needed"""
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stopThread(self,thread):
self._async_raise(thread.ident, SystemExit)
def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti)
print("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("use db%d" %couti)
tdSql.execute(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db0_0',
'dropFlag': 1,
'event': '',
'vgroups': 4,
'replica': 1,
'stbName': 'stb',
'stbNumbers': 2,
'colPrefix': 'c',
'tagPrefix': 't',
'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
'ctbPrefix': 'ctb',
'ctbNum': 200,
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
"rowsPerTbl": 1000,
"batchNum": 5000
}
dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums)
allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"])
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1
tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(4,1,'%s:6430'%self.host)
clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkMnodeStatus(1)
# fisr add three mnodes;
tdLog.info("fisr add three mnodes and check mnode status")
tdSql.execute("create mnode on dnode 2")
clusterComCheck.checkMnodeStatus(2)
tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3)
# add some error operations and
tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;")
print(tdSql.queryResult)
clusterComCheck.checkDnodes(dnodeNumbers)
# create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes
stopcount =0
threads=[]
# create stable:stb_0
stableName= paraDict['stbName']
newTdSql=tdCom.newTdSql()
clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers'])
#create child table:ctb_0
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql()
clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum'])
#insert date
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
for tr in threads:
tr.start()
for tr in threads:
tr.join()
while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode":
for i in range(mnodeNums):
tdDnodes[i].stoptaosd()
# sleep(10)
tdDnodes[i].starttaosd()
# sleep(10)
elif stopRole == "vnode":
for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd()
# sleep(10)
tdDnodes[i+mnodeNums].starttaosd()
# sleep(10)
elif stopRole == "dnode":
for i in range(dnodeNumbers):
tdDnodes[i].stoptaosd()
# sleep(10)
tdDnodes[i].starttaosd()
# sleep(10)
# dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123")
else:
print("456")
self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode()
stopcount+=1
clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkDbRows(dbNumbers)
# clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"])
tdSql.execute("use %s" %(paraDict["dbName"]))
tdSql.query("show stables")
tdSql.checkRows(paraDict["stbNumbers"])
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
tdSql.query("select * from %s"%stableName)
tdSql.checkRows(rowsPerStb)
def run(self):
# print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -143,42 +143,43 @@ class TDTestCase:
threads=[] threads=[]
for i in range(restartNumbers): for i in range(restartNumbers):
dbNameIndex = '%s%d'%(paraDict["dbName"],i) dbNameIndex = '%s%d'%(paraDict["dbName"],i)
threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(tdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']))) newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(newTdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])))
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
# while stopcount < restartNumbers: while stopcount < restartNumbers:
# tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
# if stopRole == "mnode": if stopRole == "mnode":
# for i in range(mnodeNums): for i in range(mnodeNums):
# tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# # sleep(10) # sleep(10)
# tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# # sleep(10) # sleep(10)
# elif stopRole == "vnode": elif stopRole == "vnode":
# for i in range(vnodeNumbers): for i in range(vnodeNumbers):
# tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
# # sleep(10) # sleep(10)
# tdDnodes[i+mnodeNums].starttaosd() tdDnodes[i+mnodeNums].starttaosd()
# # sleep(10) # sleep(10)
# elif stopRole == "dnode": elif stopRole == "dnode":
# for i in range(dnodeNumbers): for i in range(dnodeNumbers):
# tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# # sleep(10) # sleep(10)
# tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# # sleep(10) # sleep(10)
# # dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
# if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
# tdLog.info("check dnodes status is ready") tdLog.info("check dnodes status is ready")
# else: else:
# tdLog.info("check dnodes status is not ready") tdLog.info("check dnodes status is not ready")
# self.stopThread(threads) self.stopThread(threads)
# tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# # self.check3mnode() # self.check3mnode()
# stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()

View File

@ -92,7 +92,7 @@ class TDTestCase:
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
tdLog.printNoPrefix("======== test case 1: ") tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db0_0', paraDict = {'dbName': 'db',
'dropFlag': 1, 'dropFlag': 1,
'event': '', 'event': '',
'vgroups': 4, 'vgroups': 4,
@ -143,7 +143,8 @@ class TDTestCase:
threads=[] threads=[]
for i in range(restartNumbers): for i in range(restartNumbers):
stableName= '%s%d'%(paraDict['stbName'],i) stableName= '%s%d'%(paraDict['stbName'],i)
threads.append(threading.Thread(target=clusterComCreate.create_stables, args=(tdSql, paraDict["dbName"],stableName,paraDict['stbNumbers']))) newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.create_stables, args=(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers'])))
for tr in threads: for tr in threads:
tr.start() tr.start()

View File

@ -0,0 +1,221 @@
from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
from numpy import row_stack
import taos
import sys
import time
import os
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import TDDnodes
from util.dnodes import TDDnode
from util.cluster import *
sys.path.append("./6-cluster")
from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck
import time
import socket
import subprocess
from multiprocessing import Process
import threading
import time
import inspect
import ctypes
class TDTestCase:
def init(self,conn ,logSql):
tdLog.debug(f"start to excute {__file__}")
self.TDDnodes = None
tdSql.init(conn.cursor())
self.host = socket.gethostname()
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def _async_raise(self, tid, exctype):
"""raises the exception, performs cleanup if needed"""
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stopThread(self,thread):
self._async_raise(thread.ident, SystemExit)
def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti)
print("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("use db%d" %couti)
tdSql.execute(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
tdLog.printNoPrefix("======== test case 1: ")
paraDict = {'dbName': 'db0_0',
'dropFlag': 1,
'event': '',
'vgroups': 4,
'replica': 1,
'stbName': 'stb',
'stbNumbers': 2,
'colPrefix': 'c',
'tagPrefix': 't',
'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}],
'ctbPrefix': 'ctb',
'ctbNum': 200,
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
"rowsPerTbl": 10000,
"batchNum": 5000
}
dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums)
allctbNumbers=(paraDict['stbNumbers']*paraDict["ctbNum"])
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1
tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(4,1,'%s:6430'%self.host)
clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkMnodeStatus(1)
# fisr add three mnodes;
tdLog.info("fisr add three mnodes and check mnode status")
tdSql.execute("create mnode on dnode 2")
clusterComCheck.checkMnodeStatus(2)
tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3)
# add some error operations and
tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;")
print(tdSql.queryResult)
clusterComCheck.checkDnodes(dnodeNumbers)
# create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes
stopcount =0
threads=[]
# create stable:stb_0
stableName= paraDict['stbName']
newTdSql=tdCom.newTdSql()
clusterComCreate.create_stables(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers'])
#create child table:ctb_0
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql()
clusterComCreate.create_ctable(newTdSql, paraDict["dbName"],stableName,stableName, paraDict['ctbNum'])
#insert date
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
for tr in threads:
tr.start()
while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode":
for i in range(mnodeNums):
tdDnodes[i].stoptaosd()
# sleep(10)
tdDnodes[i].starttaosd()
# sleep(10)
elif stopRole == "vnode":
for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd()
# sleep(10)
tdDnodes[i+mnodeNums].starttaosd()
# sleep(10)
elif stopRole == "dnode":
for i in range(dnodeNumbers):
tdDnodes[i].stoptaosd()
# sleep(10)
tdDnodes[i].starttaosd()
# sleep(10)
# dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123")
else:
print("456")
self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode()
stopcount+=1
for tr in threads:
tr.join()
clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkDbRows(dbNumbers)
# clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"])
tdSql.execute("use %s" %(paraDict["dbName"]))
tdSql.query("show stables")
tdSql.checkRows(paraDict["stbNumbers"])
for i in range(paraDict['stbNumbers']):
stableName= '%s_%d'%(paraDict['stbName'],i)
tdSql.query("select * from %s"%stableName)
tdSql.checkRows(rowsPerStb)
def run(self):
# print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -116,7 +116,8 @@ class TDTestCase:
threads=[] threads=[]
for i in range(restartNumbers): for i in range(restartNumbers):
dbNameIndex = '%s%d'%(paraDict["dbName"],i) dbNameIndex = '%s%d'%(paraDict["dbName"],i)
threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(tdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']))) newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.create_databases, args=(newTdSql, dbNameIndex,paraDict["dbNumbers"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])))
for tr in threads: for tr in threads:
tr.start() tr.start()

View File

@ -30,7 +30,7 @@ class TDTestCase:
self.TDDnodes = None self.TDDnodes = None
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
self.host = socket.gethostname() self.host = socket.gethostname()
print(tdSql)
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
@ -113,6 +113,7 @@ class TDTestCase:
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
dbNumbers = 1 dbNumbers = 1
print(tdSql)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
@ -141,9 +142,11 @@ class TDTestCase:
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
threads=[] threads=[]
for i in range(restartNumbers): for i in range(restartNumbers):
stableName= '%s%d'%(paraDict['stbName'],i) stableName= '%s%d'%(paraDict['stbName'],i)
threads.append(threading.Thread(target=clusterComCreate.create_stables, args=(tdSql, paraDict["dbName"],stableName,paraDict['stbNumbers']))) newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.create_stables, args=(newTdSql, paraDict["dbName"],stableName,paraDict['stbNumbers'])))
for tr in threads: for tr in threads:
tr.start() tr.start()

View File

@ -152,7 +152,7 @@ class ClusterComCreate:
if (i % 2 == 0): if (i % 2 == 0):
tagValue = 'shanghai' tagValue = 'shanghai'
sql += " %s%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue) sql += " %s_%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue)
if (i > 0) and (i%100 == 0): if (i > 0) and (i%100 == 0):
tsql.execute(sql) tsql.execute(sql)
sql = pre_create sql = pre_create
@ -173,13 +173,13 @@ class ClusterComCreate:
startTs = int(round(t * 1000)) startTs = int(round(t * 1000))
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
for i in range(ctbNum): for i in range(ctbNum):
sql += " %s%d values "%(stbName,i) sql += " %s_%d values "%(stbName,i)
for j in range(rowsPerTbl): for j in range(rowsPerTbl):
sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j) sql += "(%d, %d, %d, 'mnode_%d') "%(startTs + j, j, j,j)
if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
tsql.execute(sql) tsql.execute(sql)
if j < rowsPerTbl - 1: if j < rowsPerTbl - 1:
sql = "insert into %s%d values " %(stbName,i) sql = "insert into %s_%d values " %(stbName,i)
else: else:
sql = "insert into " sql = "insert into "
#end sql #end sql

View File

@ -120,12 +120,12 @@ python3 ./test.py -f 2-query/irate.py
python3 ./test.py -f 2-query/and_or_for_byte.py python3 ./test.py -f 2-query/and_or_for_byte.py
python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/function_null.py
python3 ./test.py -f 2-query/queryQnode.py #python3 ./test.py -f 2-query/queryQnode.py
#python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode1mnode.py
#python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 #BUG python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3
#python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 #python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3
#python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3 python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3
@ -135,7 +135,8 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
# python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 # python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5
# python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 # python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3
# BUG Redict python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3
python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/basic5.py
python3 ./test.py -f 7-tmq/subscribeDb.py python3 ./test.py -f 7-tmq/subscribeDb.py

View File

@ -64,8 +64,9 @@ if __name__ == "__main__":
updateCfgDict = {} updateCfgDict = {}
execCmd = "" execCmd = ""
queryPolicy = 1 queryPolicy = 1
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:', [ createDnodeNums = 1
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy']) opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:', [
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums'])
for key, value in opts: for key, value in opts:
if key in ['-h', '--help']: if key in ['-h', '--help']:
tdLog.printNoPrefix( tdLog.printNoPrefix(
@ -81,9 +82,11 @@ if __name__ == "__main__":
tdLog.printNoPrefix('-d update cfg dict, base64 json str') tdLog.printNoPrefix('-d update cfg dict, base64 json str')
tdLog.printNoPrefix('-k not kill valgrind processer') tdLog.printNoPrefix('-k not kill valgrind processer')
tdLog.printNoPrefix('-e eval str to run') tdLog.printNoPrefix('-e eval str to run')
tdLog.printNoPrefix('-N create dnodes numbers in clusters') tdLog.printNoPrefix('-N start dnodes numbers in clusters')
tdLog.printNoPrefix('-M create mnode numbers in clusters') tdLog.printNoPrefix('-M create mnode numbers in clusters')
tdLog.printNoPrefix('-Q set queryPolicy in one dnode') tdLog.printNoPrefix('-Q set queryPolicy in one dnode')
tdLog.printNoPrefix('-C create Dnode Numbers in one cluster')
sys.exit(0) sys.exit(0)
@ -143,6 +146,9 @@ if __name__ == "__main__":
if key in ['-Q', '--queryPolicy']: if key in ['-Q', '--queryPolicy']:
queryPolicy = value queryPolicy = value
if key in ['-C', '--createDnodeNums']:
createDnodeNums = value
if not execCmd == "": if not execCmd == "":
tdDnodes.init(deployPath) tdDnodes.init(deployPath)
print(execCmd) print(execCmd)
@ -239,7 +245,11 @@ if __name__ == "__main__":
host, host,
config=tdDnodes.getSimCfgPath()) config=tdDnodes.getSimCfgPath())
print(tdDnodes.getSimCfgPath(),host) print(tdDnodes.getSimCfgPath(),host)
cluster.create_dnode(conn) if createDnodeNums == 1:
createDnodeNums=dnodeNums
else:
createDnodeNums=createDnodeNums
cluster.create_dnode(conn,createDnodeNums)
try: try:
if cluster.check_dnode(conn) : if cluster.check_dnode(conn) :
print("check dnode ready") print("check dnode ready")
@ -314,7 +324,11 @@ if __name__ == "__main__":
host, host,
config=tdDnodes.getSimCfgPath()) config=tdDnodes.getSimCfgPath())
print(tdDnodes.getSimCfgPath(),host) print(tdDnodes.getSimCfgPath(),host)
cluster.create_dnode(conn) if createDnodeNums == 1:
createDnodeNums=dnodeNums
else:
createDnodeNums=createDnodeNums
cluster.create_dnode(conn,createDnodeNums)
try: try:
if cluster.check_dnode(conn) : if cluster.check_dnode(conn) :
print("check dnode ready") print("check dnode ready")