Merge remote-tracking branch 'origin/3.0' into feature/shm
This commit is contained in:
commit
d90ebef80b
|
@ -133,7 +133,8 @@ static FORCE_INLINE int32_t colDataAppendInt32(SColumnInfoData* pColumnInfoData,
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t colDataAppendInt64(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int64_t* v) {
|
||||
ASSERT(pColumnInfoData->info.type == TSDB_DATA_TYPE_BIGINT || pColumnInfoData->info.type == TSDB_DATA_TYPE_UBIGINT);
|
||||
int32_t type = pColumnInfoData->info.type;
|
||||
ASSERT(type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_UBIGINT || type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
char* p = pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow;
|
||||
*(int64_t*)p = *(int64_t*)v;
|
||||
}
|
||||
|
@ -175,17 +176,16 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock);
|
|||
double blockDataGetSerialRowSize(const SSDataBlock* pBlock);
|
||||
size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock);
|
||||
|
||||
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols);
|
||||
|
||||
int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo);
|
||||
int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst);
|
||||
|
||||
int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
|
||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||
|
||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock);
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
|
||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||
|
||||
void blockDebugShowData(const SArray* dataBlocks);
|
||||
|
||||
|
|
|
@ -469,8 +469,7 @@ typedef struct {
|
|||
int32_t tz; // query client timezone
|
||||
char intervalUnit;
|
||||
char slidingUnit;
|
||||
char
|
||||
offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
|
||||
char offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
|
||||
int8_t precision;
|
||||
int64_t interval;
|
||||
int64_t sliding;
|
||||
|
@ -2017,7 +2016,6 @@ typedef struct {
|
|||
int8_t slidingUnit; // MACRO: TIME_UNIT_XXX
|
||||
int8_t timezoneInt; // sma data expired if timezone changes.
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char timezone[TD_TIMEZONE_LEN];
|
||||
int32_t exprLen;
|
||||
int32_t tagsFilterLen;
|
||||
int64_t indexUid;
|
||||
|
@ -2055,32 +2053,6 @@ void* tDeserializeSVCreateTSmaReq(void* buf, SVCreateTSmaReq* pReq);
|
|||
int32_t tSerializeSVDropTSmaReq(void** buf, SVDropTSmaReq* pReq);
|
||||
void* tDeserializeSVDropTSmaReq(void* buf, SVDropTSmaReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
col_id_t colId;
|
||||
uint16_t blockSize; // sma data block size
|
||||
char data[];
|
||||
} STSmaColData;
|
||||
|
||||
typedef struct {
|
||||
tb_uid_t tableUid; // super/child/normal table uid
|
||||
int32_t dataLen; // not including head
|
||||
char data[];
|
||||
} STSmaTbData;
|
||||
|
||||
typedef struct {
|
||||
int64_t indexUid;
|
||||
TSKEY skey; // startKey of one interval/sliding window
|
||||
int64_t interval;
|
||||
int32_t dataLen; // not including head
|
||||
int8_t intervalUnit;
|
||||
char data[];
|
||||
} STSmaDataWrapper; // sma data for a interval/sliding window
|
||||
|
||||
// interval/sliding => window
|
||||
|
||||
// => window->table->colId
|
||||
// => 当一个window下所有的表均计算完成时,流计算告知tsdb清除window的过期标记
|
||||
|
||||
// RSma: Rollup SMA
|
||||
typedef struct {
|
||||
int64_t interval;
|
||||
|
|
|
@ -937,9 +937,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
|
|||
STColumn *pCol = NULL;
|
||||
STSchema *pSchema = pIter->pSchema;
|
||||
while (pIter->colIdx <= pSchema->numOfCols) {
|
||||
pCol = &pSchema->columns[pIter->colIdx];
|
||||
pCol = &pSchema->columns[pIter->colIdx]; // 1st column of schema is primary TS key
|
||||
if (colId == pCol->colId) {
|
||||
++pIter->colIdx;
|
||||
break;
|
||||
} else if (colId < pCol->colId) {
|
||||
++pIter->colIdx;
|
||||
|
@ -948,7 +947,8 @@ static FORCE_INLINE bool tdSTSRowIterNext(STSRowIter *pIter, col_id_t colId, col
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return tdGetTpRowDataOfCol(pIter, pCol->type, pCol->offset - sizeof(TSKEY), pVal);
|
||||
tdGetTpRowDataOfCol(pIter, pCol->type, pCol->offset - sizeof(TSKEY), pVal);
|
||||
++pIter->colIdx;
|
||||
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
||||
return tdGetKvRowValOfColEx(pIter, colId, colType, &pIter->kvIdx, pVal);
|
||||
} else {
|
||||
|
|
|
@ -138,55 +138,59 @@
|
|||
#define TK_INTERVAL 120
|
||||
#define TK_TOPIC 121
|
||||
#define TK_AS 122
|
||||
#define TK_NK_BOOL 123
|
||||
#define TK_NULL 124
|
||||
#define TK_NK_VARIABLE 125
|
||||
#define TK_NK_UNDERLINE 126
|
||||
#define TK_ROWTS 127
|
||||
#define TK_TBNAME 128
|
||||
#define TK_QSTARTTS 129
|
||||
#define TK_QENDTS 130
|
||||
#define TK_WSTARTTS 131
|
||||
#define TK_WENDTS 132
|
||||
#define TK_WDURATION 133
|
||||
#define TK_BETWEEN 134
|
||||
#define TK_IS 135
|
||||
#define TK_NK_LT 136
|
||||
#define TK_NK_GT 137
|
||||
#define TK_NK_LE 138
|
||||
#define TK_NK_GE 139
|
||||
#define TK_NK_NE 140
|
||||
#define TK_MATCH 141
|
||||
#define TK_NMATCH 142
|
||||
#define TK_IN 143
|
||||
#define TK_JOIN 144
|
||||
#define TK_INNER 145
|
||||
#define TK_SELECT 146
|
||||
#define TK_DISTINCT 147
|
||||
#define TK_WHERE 148
|
||||
#define TK_PARTITION 149
|
||||
#define TK_BY 150
|
||||
#define TK_SESSION 151
|
||||
#define TK_STATE_WINDOW 152
|
||||
#define TK_SLIDING 153
|
||||
#define TK_FILL 154
|
||||
#define TK_VALUE 155
|
||||
#define TK_NONE 156
|
||||
#define TK_PREV 157
|
||||
#define TK_LINEAR 158
|
||||
#define TK_NEXT 159
|
||||
#define TK_GROUP 160
|
||||
#define TK_HAVING 161
|
||||
#define TK_ORDER 162
|
||||
#define TK_SLIMIT 163
|
||||
#define TK_SOFFSET 164
|
||||
#define TK_LIMIT 165
|
||||
#define TK_OFFSET 166
|
||||
#define TK_ASC 167
|
||||
#define TK_DESC 168
|
||||
#define TK_NULLS 169
|
||||
#define TK_FIRST 170
|
||||
#define TK_LAST 171
|
||||
#define TK_EXPLAIN 123
|
||||
#define TK_ANALYZE 124
|
||||
#define TK_VERBOSE 125
|
||||
#define TK_NK_BOOL 126
|
||||
#define TK_RATIO 127
|
||||
#define TK_NULL 128
|
||||
#define TK_NK_VARIABLE 129
|
||||
#define TK_NK_UNDERLINE 130
|
||||
#define TK_ROWTS 131
|
||||
#define TK_TBNAME 132
|
||||
#define TK_QSTARTTS 133
|
||||
#define TK_QENDTS 134
|
||||
#define TK_WSTARTTS 135
|
||||
#define TK_WENDTS 136
|
||||
#define TK_WDURATION 137
|
||||
#define TK_BETWEEN 138
|
||||
#define TK_IS 139
|
||||
#define TK_NK_LT 140
|
||||
#define TK_NK_GT 141
|
||||
#define TK_NK_LE 142
|
||||
#define TK_NK_GE 143
|
||||
#define TK_NK_NE 144
|
||||
#define TK_MATCH 145
|
||||
#define TK_NMATCH 146
|
||||
#define TK_IN 147
|
||||
#define TK_JOIN 148
|
||||
#define TK_INNER 149
|
||||
#define TK_SELECT 150
|
||||
#define TK_DISTINCT 151
|
||||
#define TK_WHERE 152
|
||||
#define TK_PARTITION 153
|
||||
#define TK_BY 154
|
||||
#define TK_SESSION 155
|
||||
#define TK_STATE_WINDOW 156
|
||||
#define TK_SLIDING 157
|
||||
#define TK_FILL 158
|
||||
#define TK_VALUE 159
|
||||
#define TK_NONE 160
|
||||
#define TK_PREV 161
|
||||
#define TK_LINEAR 162
|
||||
#define TK_NEXT 163
|
||||
#define TK_GROUP 164
|
||||
#define TK_HAVING 165
|
||||
#define TK_ORDER 166
|
||||
#define TK_SLIMIT 167
|
||||
#define TK_SOFFSET 168
|
||||
#define TK_LIMIT 169
|
||||
#define TK_OFFSET 170
|
||||
#define TK_ASC 171
|
||||
#define TK_DESC 172
|
||||
#define TK_NULLS 173
|
||||
#define TK_FIRST 174
|
||||
#define TK_LAST 175
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -37,6 +37,11 @@ typedef struct SReadHandle {
|
|||
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
||||
#define STREAM_DATA_TYPE_SSDATA_BLOCK 0x2
|
||||
|
||||
typedef enum {
|
||||
OPTR_EXEC_MODEL_BATCH = 0x1,
|
||||
OPTR_EXEC_MODEL_STREAM = 0x2,
|
||||
} EOPTR_EXEC_MODEL;
|
||||
|
||||
/**
|
||||
* Create the exec task for streaming mode
|
||||
* @param pMsg
|
||||
|
@ -84,7 +89,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, SArray* tableIdList, bool isA
|
|||
* @return
|
||||
*/
|
||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan,
|
||||
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle);
|
||||
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model);
|
||||
|
||||
/**
|
||||
* The main task execution function, including query on both table and multiple tables,
|
||||
|
|
|
@ -41,6 +41,7 @@ typedef void (*FExecFinalize)(struct SqlFunctionCtx *pCtx);
|
|||
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
typedef struct SScalarFuncExecFuncs {
|
||||
FExecGetEnv getEnv;
|
||||
FScalarExecProcess process;
|
||||
} SScalarFuncExecFuncs;
|
||||
|
||||
|
@ -241,7 +242,6 @@ typedef struct tExprNode {
|
|||
};
|
||||
} tExprNode;
|
||||
|
||||
void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree);
|
||||
void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *));
|
||||
|
||||
typedef struct SAggFunctionInfo {
|
||||
|
@ -267,28 +267,6 @@ struct SScalarParam {
|
|||
int32_t numOfRows;
|
||||
};
|
||||
|
||||
typedef struct SMultiFunctionsDesc {
|
||||
bool stableQuery;
|
||||
bool groupbyColumn;
|
||||
bool agg;
|
||||
bool arithmeticOnAgg;
|
||||
bool projectionQuery;
|
||||
bool hasFilter;
|
||||
bool onlyTagQuery;
|
||||
bool orderProjectQuery;
|
||||
bool globalMerge;
|
||||
bool multigroupResult;
|
||||
bool blockDistribution;
|
||||
bool stateWindow;
|
||||
bool timewindow;
|
||||
bool sessionWindow;
|
||||
bool topbotQuery;
|
||||
bool interpQuery;
|
||||
bool distinct;
|
||||
bool join;
|
||||
bool continueQuery;
|
||||
} SMultiFunctionsDesc;
|
||||
|
||||
int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, SResultDataInfo* pInfo, int16_t extLength,
|
||||
bool isSuperTable);
|
||||
|
||||
|
@ -296,8 +274,6 @@ bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* funct
|
|||
|
||||
tExprNode* exprTreeFromBinary(const void* data, size_t size);
|
||||
|
||||
void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc);
|
||||
|
||||
tExprNode* exprdup(tExprNode* pTree);
|
||||
|
||||
void resetResultRowEntryResult(SqlFunctionCtx* pCtx, int32_t num);
|
||||
|
|
|
@ -70,6 +70,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_DATABASE_OPTIONS,
|
||||
QUERY_NODE_TABLE_OPTIONS,
|
||||
QUERY_NODE_INDEX_OPTIONS,
|
||||
QUERY_NODE_EXPLAIN_OPTIONS,
|
||||
|
||||
// Statement nodes are used in parser and planner module.
|
||||
QUERY_NODE_SET_OPERATOR,
|
||||
|
@ -99,6 +100,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_CREATE_TOPIC_STMT,
|
||||
QUERY_NODE_DROP_TOPIC_STMT,
|
||||
QUERY_NODE_ALTER_LOCAL_STMT,
|
||||
QUERY_NODE_EXPLAIN_STMT,
|
||||
QUERY_NODE_SHOW_DATABASES_STMT,
|
||||
QUERY_NODE_SHOW_TABLES_STMT,
|
||||
QUERY_NODE_SHOW_STABLES_STMT,
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct SScanLogicNode {
|
|||
STimeWindow scanRange;
|
||||
SName tableName;
|
||||
bool showRewrite;
|
||||
double ratio;
|
||||
} SScanLogicNode;
|
||||
|
||||
typedef struct SJoinLogicNode {
|
||||
|
@ -197,6 +198,7 @@ typedef struct STableScanPhysiNode {
|
|||
SScanPhysiNode scan;
|
||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||
STimeWindow scanRange;
|
||||
double ratio;
|
||||
} STableScanPhysiNode;
|
||||
|
||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||
|
@ -297,18 +299,23 @@ typedef struct SSubplan {
|
|||
SDataSinkNode* pDataSink; // data of the subplan flow into the datasink
|
||||
} SSubplan;
|
||||
|
||||
typedef enum EQueryMode {
|
||||
QUERY_MODE_NORMAL = 1,
|
||||
QUERY_MODE_EXPLAIN,
|
||||
QUERY_MODE_EXPLAIN_AN
|
||||
} EQueryMode;
|
||||
typedef enum EExplainMode {
|
||||
EXPLAIN_MODE_DISABLE = 1,
|
||||
EXPLAIN_MODE_STATIC,
|
||||
EXPLAIN_MODE_ANALYZE
|
||||
} EExplainMode;
|
||||
|
||||
typedef struct SExplainInfo {
|
||||
EExplainMode mode;
|
||||
bool verbose;
|
||||
} SExplainInfo;
|
||||
|
||||
typedef struct SQueryPlan {
|
||||
ENodeType type;
|
||||
uint64_t queryId;
|
||||
int32_t numOfSubplans;
|
||||
|
||||
SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0.
|
||||
SExplainInfo explainInfo;
|
||||
} SQueryPlan;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -131,6 +131,7 @@ typedef struct SRealTableNode {
|
|||
struct STableMeta* pMeta;
|
||||
SVgroupsInfo* pVgroupList;
|
||||
char useDbName[TSDB_DB_NAME_LEN];
|
||||
double ratio;
|
||||
} SRealTableNode;
|
||||
|
||||
typedef struct STempTableNode {
|
||||
|
@ -282,6 +283,19 @@ typedef struct SVnodeModifOpStmt {
|
|||
const char* sql; // current sql statement position
|
||||
} SVnodeModifOpStmt;
|
||||
|
||||
typedef struct SExplainOptions {
|
||||
ENodeType type;
|
||||
bool verbose;
|
||||
double ratio;
|
||||
} SExplainOptions;
|
||||
|
||||
typedef struct SExplainStmt {
|
||||
ENodeType type;
|
||||
bool analyze;
|
||||
SExplainOptions* pOptions;
|
||||
SNode* pQuery;
|
||||
} SExplainStmt;
|
||||
|
||||
void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker walker, void* pContext);
|
||||
void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewriter rewriter, void* pContext);
|
||||
|
||||
|
|
|
@ -58,6 +58,14 @@ int32_t ceilFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
int32_t floorFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t roundFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
|
||||
int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t qStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t qEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,9 @@ typedef pthread_once_t TdThreadOnce;
|
|||
typedef pthread_rwlockattr_t TdThreadRwlockAttr;
|
||||
typedef pthread_cond_t TdThreadCond;
|
||||
typedef pthread_condattr_t TdThreadCondAttr;
|
||||
typedef pthread_key_t TdThreadKey;
|
||||
typedef pthread_barrier_t TdThreadBarrier;
|
||||
typedef pthread_barrierattr_t TdThreadBarrierAttr;
|
||||
|
||||
#define taosThreadCleanupPush pthread_cleanup_push
|
||||
#define taosThreadCleanupPop pthread_cleanup_pop
|
||||
|
@ -39,78 +42,190 @@ typedef pthread_condattr_t TdThreadCondAttr;
|
|||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
#define pthread_t PTHREAD_T_TYPE_TAOS_FORBID
|
||||
#define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID
|
||||
#define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID
|
||||
#define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID
|
||||
#define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID
|
||||
#define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID
|
||||
#define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID
|
||||
#define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID
|
||||
#define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID
|
||||
#define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID
|
||||
#define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID
|
||||
#define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID
|
||||
#define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID
|
||||
#define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID
|
||||
#define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID
|
||||
#define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID
|
||||
#define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID
|
||||
#define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID
|
||||
#define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID
|
||||
#define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID
|
||||
#define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID
|
||||
#define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID
|
||||
#define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID
|
||||
#define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID
|
||||
#define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID
|
||||
#define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID
|
||||
#define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID
|
||||
#define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID
|
||||
#define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID
|
||||
#define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID
|
||||
#define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID
|
||||
#define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID
|
||||
#define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID
|
||||
#define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID
|
||||
// #define pthread_t PTHREAD_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID
|
||||
// #define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID
|
||||
// #define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID
|
||||
// #define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID
|
||||
// #define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID
|
||||
// #define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID
|
||||
// #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID
|
||||
// #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID
|
||||
// #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID
|
||||
// #define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID
|
||||
// #define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID
|
||||
// #define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID
|
||||
// #define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID
|
||||
// #define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID
|
||||
// #define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID
|
||||
// #define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID
|
||||
// #define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID
|
||||
// #define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID
|
||||
// #define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID
|
||||
// #define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID
|
||||
// #define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID
|
||||
// #define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID
|
||||
// #define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID
|
||||
// #define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID
|
||||
// #define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID
|
||||
// #define sigwait SIGWAIT_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int pshared);
|
||||
int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr);
|
||||
int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock);
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex);
|
||||
int32_t taosThreadSpinLock(TdThreadSpinlock *lock);
|
||||
int32_t taosThreadMutexLock(TdThreadMutex *mutex);
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock);
|
||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock);
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex *mutex);
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock);
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock);
|
||||
void taosThreadTestCancel(void);
|
||||
int32_t taosThreadAttrInit(TdThreadAttr *attr);
|
||||
int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void*(*start)(void*), void *arg);
|
||||
int32_t taosThreadOnce(TdThreadOnce *onceControl, void(*initRoutine)(void));
|
||||
int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachState);
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr *attr);
|
||||
int32_t taosThreadJoin(TdThread thread, void **pValue);
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr);
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock);
|
||||
int32_t taosThreadCondSignal(TdThreadCond *cond);
|
||||
int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr);
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond *cond);
|
||||
int32_t taosThreadCondDestroy(TdThreadCond *cond);
|
||||
int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex);
|
||||
TdThread taosThreadSelf(void);
|
||||
int32_t taosThreadEqual(TdThread t1, TdThread t2);
|
||||
int32_t taosThreadSigmask(int how, sigset_t const *set, sigset_t *oset);
|
||||
int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg);
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr * attr);
|
||||
int32_t taosThreadAttrGetDetachState(const TdThreadAttr * attr, int32_t *detachstate);
|
||||
int32_t taosThreadAttrGetInheritSched(const TdThreadAttr * attr, int32_t *inheritsched);
|
||||
int32_t taosThreadAttrGetSchedParam(const TdThreadAttr * attr, struct sched_param *param);
|
||||
int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr * attr, int32_t *policy);
|
||||
int32_t taosThreadAttrGetScope(const TdThreadAttr * attr, int32_t *contentionscope);
|
||||
int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize);
|
||||
int32_t taosThreadAttrInit(TdThreadAttr * attr);
|
||||
int32_t taosThreadAttrSetDetachState(TdThreadAttr * attr, int32_t detachstate);
|
||||
int32_t taosThreadAttrSetInheritSched(TdThreadAttr * attr, int32_t inheritsched);
|
||||
int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_param *param);
|
||||
int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy);
|
||||
int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope);
|
||||
int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize);
|
||||
int32_t taosThreadBarrierDestroy(TdThreadBarrier * barrier);
|
||||
int32_t taosThreadBarrierInit(TdThreadBarrier * barrier, const TdThreadBarrierAttr * attr, uint32_t count);
|
||||
int32_t taosThreadBarrierWait(TdThreadBarrier * barrier);
|
||||
int32_t taosThreadBarrierAttrDestroy(TdThreadBarrierAttr * attr);
|
||||
int32_t taosThreadBarrierAttrGetPshared(const TdThreadBarrierAttr * attr, int32_t *pshared);
|
||||
int32_t taosThreadBarrierAttrInit(TdThreadBarrierAttr * attr);
|
||||
int32_t taosThreadBarrierAttrSetPshared(TdThreadBarrierAttr * attr, int32_t pshared);
|
||||
int32_t taosThreadCancel(TdThread thread);
|
||||
int32_t taosThreadKill(TdThread thread, int sig);
|
||||
int32_t taosThreadCondDestroy(TdThreadCond * cond);
|
||||
int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr);
|
||||
int32_t taosThreadCondSignal(TdThreadCond * cond);
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond * cond);
|
||||
int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex);
|
||||
int32_t taosThreadCondTimedWait(TdThreadCond * cond, TdThreadMutex * mutex, const struct timespec *abstime);
|
||||
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr);
|
||||
int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr * attr, int32_t *pshared);
|
||||
int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr);
|
||||
int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr * attr, int32_t pshared);
|
||||
int32_t taosThreadDetach(TdThread thread);
|
||||
int32_t taosThreadEqual(TdThread t1, TdThread t2);
|
||||
void taosThreadExit(void *valuePtr);
|
||||
int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param);
|
||||
void *taosThreadGetSpecific(TdThreadKey key);
|
||||
int32_t taosThreadJoin(TdThread thread, void **valuePtr);
|
||||
int32_t taosThreadKeyCreate(TdThreadKey * key, void(*destructor)(void *));
|
||||
int32_t taosThreadKeyDelete(TdThreadKey key);
|
||||
int32_t taosThreadKill(TdThread thread, int32_t sig);
|
||||
int32_t taosThreadMutexConsistent(TdThreadMutex* mutex);
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex);
|
||||
int32_t taosThreadMutexInit(TdThreadMutex * mutex, const TdThreadMutexAttr * attr);
|
||||
int32_t taosThreadMutexLock(TdThreadMutex * mutex);
|
||||
int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime);
|
||||
int32_t taosThreadMutexTryLock(TdThreadMutex * mutex);
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex * mutex);
|
||||
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr);
|
||||
int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *pshared);
|
||||
int32_t taosThreadMutexAttrGetRobust(const TdThreadMutexAttr * attr, int32_t * robust);
|
||||
int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind);
|
||||
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr);
|
||||
int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared);
|
||||
int32_t taosThreadMutexAttrSetRobust(TdThreadMutexAttr * attr, int32_t robust);
|
||||
int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr * attr, int32_t kind);
|
||||
int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void));
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock);
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock * rwlock, const TdThreadRwlockAttr * attr);
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock);
|
||||
int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime);
|
||||
int32_t taosThreadRwlockTimedWrlock(TdThreadRwlock * rwlock, const struct timespec *abstime);
|
||||
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock);
|
||||
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock);
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock);
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock);
|
||||
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr);
|
||||
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr * attr, int32_t *pshared);
|
||||
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr);
|
||||
int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr * attr, int32_t pshared);
|
||||
TdThread taosThreadSelf(void);
|
||||
int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate);
|
||||
int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype);
|
||||
int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param);
|
||||
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value);
|
||||
int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock);
|
||||
int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared);
|
||||
int32_t taosThreadSpinLock(TdThreadSpinlock * lock);
|
||||
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock);
|
||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock);
|
||||
void taosThreadTestCancel(void);
|
||||
int32_t taosThreadSigMask(int32_t how, sigset_t const *set, sigset_t * oset);
|
||||
int32_t taosThreadSigWait(const sigset_t * set, int32_t *sig);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
// If the error is in a third-party library, place this header file under the third-party library header file.
|
||||
// When you want to use this feature, you should find or add the same function in the following section.
|
||||
#ifndef ALLOW_FORBID_FUNC
|
||||
|
|
|
@ -381,6 +381,14 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MAX_DB_DELAY 10
|
||||
#define TSDB_DEFAULT_DB_DELAY 2
|
||||
|
||||
#define TSDB_DEFAULT_EXPLAIN_VERBOSE false
|
||||
|
||||
#define TSDB_MIN_EXPLAIN_RATIO 0
|
||||
#define TSDB_MAX_EXPLAIN_RATIO 1
|
||||
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
|
||||
|
||||
#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024
|
||||
|
||||
#define TSDB_MAX_JOIN_TABLE_NUM 10
|
||||
#define TSDB_MAX_UNION_CLAUSE 5
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "consumer.h"
|
|
@ -241,6 +241,10 @@ void tmq_list_destroy(tmq_list_t* list) {
|
|||
taosArrayDestroyEx(container, (void (*)(void*))taosMemoryFree);
|
||||
}
|
||||
|
||||
static int32_t tmqMakeTopicVgKey(char* dst, const char* topicName, int32_t vg) {
|
||||
return sprintf(dst, "%s:%d", topicName, vg);
|
||||
}
|
||||
|
||||
void tmqClearUnhandleMsg(tmq_t* tmq) {
|
||||
tmq_message_t* msg = NULL;
|
||||
while (1) {
|
||||
|
@ -827,7 +831,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
SMqClientVg* pVg = pParam->pVg;
|
||||
tmq_t* tmq = pParam->tmq;
|
||||
if (code != 0) {
|
||||
printf("msg discard, code:%x\n", code);
|
||||
tscWarn("msg discard, code:%x", code);
|
||||
goto WRITE_QUEUE_FAIL;
|
||||
}
|
||||
|
||||
|
@ -835,12 +839,12 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
int32_t tmqEpoch = atomic_load_32(&tmq->epoch);
|
||||
if (msgEpoch < tmqEpoch) {
|
||||
tsem_post(&tmq->rspSem);
|
||||
printf("discard rsp epoch %d, current epoch %d\n", msgEpoch, tmqEpoch);
|
||||
tscWarn("discard rsp epoch %d, current epoch %d", msgEpoch, tmqEpoch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msgEpoch != tmqEpoch) {
|
||||
printf("mismatch rsp epoch %d, current epoch %d\n", msgEpoch, tmqEpoch);
|
||||
tscWarn("mismatch rsp epoch %d, current epoch %d", msgEpoch, tmqEpoch);
|
||||
} else {
|
||||
atomic_sub_fetch_32(&tmq->waitingRequest, 1);
|
||||
}
|
||||
|
@ -899,19 +903,54 @@ WRITE_QUEUE_FAIL:
|
|||
bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) {
|
||||
/*printf("call update ep %d\n", epoch);*/
|
||||
bool set = false;
|
||||
int32_t sz = taosArrayGetSize(pRsp->topics);
|
||||
SArray* newTopics = taosArrayInit(sz, sizeof(SMqClientTopic));
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
int32_t topicNumGet = taosArrayGetSize(pRsp->topics);
|
||||
char vgKey[TSDB_TOPIC_FNAME_LEN + 22];
|
||||
SArray* newTopics = taosArrayInit(topicNumGet, sizeof(SMqClientTopic));
|
||||
if (newTopics == NULL) {
|
||||
return false;
|
||||
}
|
||||
SHashObj* pHash = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK);
|
||||
if (pHash == NULL) {
|
||||
taosArrayDestroy(newTopics);
|
||||
return false;
|
||||
}
|
||||
|
||||
// find topic, build hash
|
||||
for (int32_t i = 0; i < topicNumGet; i++) {
|
||||
SMqClientTopic topic = {0};
|
||||
SMqSubTopicEp* pTopicEp = taosArrayGet(pRsp->topics, i);
|
||||
taosHashClear(pHash);
|
||||
topic.topicName = strdup(pTopicEp->topic);
|
||||
int32_t vgSz = taosArrayGetSize(pTopicEp->vgs);
|
||||
topic.vgs = taosArrayInit(vgSz, sizeof(SMqClientVg));
|
||||
for (int32_t j = 0; j < vgSz; j++) {
|
||||
|
||||
int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics);
|
||||
for (int32_t j = 0; j < topicNumCur; j++) {
|
||||
// find old topic
|
||||
SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, j);
|
||||
if (pTopicCur->vgs && strcmp(pTopicCur->topicName, pTopicEp->topic) == 0) {
|
||||
int32_t vgNumCur = taosArrayGetSize(pTopicCur->vgs);
|
||||
if (vgNumCur == 0) break;
|
||||
for (int32_t k = 0; k < vgNumCur; k++) {
|
||||
SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, k);
|
||||
sprintf(vgKey, "%s:%d", topic.topicName, pVgCur->vgId);
|
||||
taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffset, sizeof(int64_t));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t vgNumGet = taosArrayGetSize(pTopicEp->vgs);
|
||||
topic.vgs = taosArrayInit(vgNumGet, sizeof(SMqClientVg));
|
||||
for (int32_t j = 0; j < vgNumGet; j++) {
|
||||
SMqSubVgEp* pVgEp = taosArrayGet(pTopicEp->vgs, j);
|
||||
sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId);
|
||||
int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey));
|
||||
int64_t offset = pVgEp->offset;
|
||||
if (pOffset != NULL) {
|
||||
offset = *pOffset;
|
||||
}
|
||||
SMqClientVg clientVg = {
|
||||
.pollCnt = 0,
|
||||
.currentOffset = pVgEp->offset,
|
||||
.currentOffset = offset,
|
||||
.vgId = pVgEp->vgId,
|
||||
.epSet = pVgEp->epSet,
|
||||
.vgStatus = TMQ_VG_STATUS__IDLE,
|
||||
|
@ -922,6 +961,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) {
|
|||
taosArrayPush(newTopics, &topic);
|
||||
}
|
||||
if (tmq->clientTopics) taosArrayDestroy(tmq->clientTopics);
|
||||
taosHashCleanup(pHash);
|
||||
tmq->clientTopics = newTopics;
|
||||
atomic_store_32(&tmq->epoch, epoch);
|
||||
return set;
|
||||
|
@ -931,7 +971,7 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param;
|
||||
tmq_t* tmq = pParam->tmq;
|
||||
if (code != 0) {
|
||||
printf("get topic endpoint error, not ready, wait:%d\n", pParam->sync);
|
||||
tscError("get topic endpoint error, not ready, wait:%d\n", pParam->sync);
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
@ -1302,6 +1342,7 @@ tmq_message_t* tmq_consumer_poll(tmq_t* tmq, int64_t blocking_time) {
|
|||
|
||||
while (1) {
|
||||
/*printf("cycle\n");*/
|
||||
tmqAskEp(tmq, false);
|
||||
tmqPollImpl(tmq, blocking_time);
|
||||
|
||||
tsem_wait(&tmq->rspSem);
|
||||
|
|
|
@ -331,7 +331,6 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ASSERT(pColInfoData->nullbitmap == NULL);
|
||||
pDataBlock->info.window.skey = *(TSKEY*)colDataGetData(pColInfoData, 0);
|
||||
pDataBlock->info.window.ekey = *(TSKEY*)colDataGetData(pColInfoData, (pDataBlock->info.rows - 1));
|
||||
return 0;
|
||||
|
@ -609,22 +608,6 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) {
|
|||
return sizeof(int32_t) + pBlock->info.numOfCols * sizeof(int32_t);
|
||||
}
|
||||
|
||||
SSchema* blockDataExtractSchema(const SSDataBlock* pBlock, int32_t* numOfCols) {
|
||||
SSchema* pSchema = taosMemoryCalloc(pBlock->info.numOfCols, sizeof(SSchema));
|
||||
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
pSchema[i].bytes = pColInfoData->info.bytes;
|
||||
pSchema[i].type = pColInfoData->info.type;
|
||||
pSchema[i].colId = pColInfoData->info.colId;
|
||||
}
|
||||
|
||||
if (numOfCols != NULL) {
|
||||
*numOfCols = pBlock->info.numOfCols;
|
||||
}
|
||||
|
||||
return pSchema;
|
||||
}
|
||||
|
||||
double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
|
||||
ASSERT(pBlock != NULL);
|
||||
double rowSize = 0;
|
||||
|
|
|
@ -76,7 +76,7 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
|||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
|
||||
dTrace("msg:%p, will be processed in vnode-fetch queue", pMsg);
|
||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, &pMsg->rpcMsg);
|
||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, &pMsg->rpcMsg, pInfo);
|
||||
if (code != 0) {
|
||||
vmSendRsp(pVnode->pWrapper, pMsg, code);
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
|
@ -168,7 +168,7 @@ static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
taosGetQitem(qall, (void **)&pMsg);
|
||||
|
||||
dTrace("msg:%p, will be processed in vnode-merge queue", pMsg);
|
||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, &pMsg->rpcMsg);
|
||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, &pMsg->rpcMsg, pInfo);
|
||||
if (code != 0) {
|
||||
vmSendRsp(pVnode->pWrapper, pMsg, code);
|
||||
dTrace("msg:%p, is freed, result:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code));
|
||||
|
@ -414,8 +414,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
|
|||
pWPool->max = maxMergeThreads;
|
||||
if (tWWorkerInit(pWPool) != 0) return -1;
|
||||
|
||||
SSingleWorkerCfg cfg = {
|
||||
.min = 1, .max = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt};
|
||||
SSingleWorkerCfg cfg = {.min = 1, .max = 1, .name = "vnode-mgmt", .fp = (FItem)vmProcessMgmtQueue, .param = pMgmt};
|
||||
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) {
|
||||
dError("failed to start vnode-mgmt worker since %s", terrstr());
|
||||
return -1;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "parser.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define MND_TOPIC_VER_NUMBER 1
|
||||
#define MND_TOPIC_VER_NUMBER 1
|
||||
#define MND_TOPIC_RESERVE_SIZE 64
|
||||
|
||||
static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic);
|
||||
|
|
|
@ -100,10 +100,11 @@ int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, const char *msg);
|
|||
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param indexUid
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg);
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, int64_t indexUid, const char *msg);
|
||||
|
||||
/**
|
||||
* @brief Drop tSma data and local cache.
|
||||
|
@ -130,16 +131,11 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg);
|
|||
* @param pTsdb
|
||||
* @param pData
|
||||
* @param indexUid
|
||||
* @param interval
|
||||
* @param intervalUnit
|
||||
* @param tableUid
|
||||
* @param colId
|
||||
* @param querySKey
|
||||
* @param nMaxResult
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit,
|
||||
tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult);
|
||||
int32_t tsdbGetTSmaData(STsdb *pTsdb, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult);
|
||||
|
||||
// STsdbCfg
|
||||
int tsdbOptionsInit(STsdbCfg *);
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
#define _TD_VNODE_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "trpc.h"
|
||||
#include "tmsgcb.h"
|
||||
#include "tqueue.h"
|
||||
#include "trpc.h"
|
||||
|
||||
#include "meta.h"
|
||||
#include "tarray.h"
|
||||
|
@ -166,7 +167,7 @@ int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|||
* @param pMsg The request message
|
||||
* @return int 0 for success, -1 for failure
|
||||
*/
|
||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||
|
||||
/* ------------------------ SVnodeCfg ------------------------ */
|
||||
/**
|
||||
|
@ -185,7 +186,6 @@ void vnodeOptionsClear(SVnodeCfg *pOptions);
|
|||
|
||||
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName);
|
||||
|
||||
|
||||
/* ------------------------ FOR COMPILE ------------------------ */
|
||||
|
||||
int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg);
|
||||
|
|
|
@ -44,15 +44,14 @@ int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
|
|||
#endif
|
||||
|
||||
// internal func
|
||||
static FORCE_INLINE int32_t tsdbEncodeTSmaKey(tb_uid_t tableUid, col_id_t colId, TSKEY tsKey, void **pData) {
|
||||
static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void **pData) {
|
||||
int32_t len = 0;
|
||||
len += taosEncodeFixedI64(pData, tableUid);
|
||||
len += taosEncodeFixedU16(pData, colId);
|
||||
len += taosEncodeFixedI64(pData, tsKey);
|
||||
len += taosEncodeFixedI64(pData, groupId);
|
||||
return len;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) {
|
||||
static FORCE_INLINE int32_t tsdbRLockSma(SSmaEnv *pEnv) {
|
||||
int code = taosThreadRwlockRdlock(&(pEnv->lock));
|
||||
if (code != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(code);
|
||||
|
@ -61,7 +60,7 @@ static FORCE_INLINE int tsdbRLockSma(SSmaEnv *pEnv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) {
|
||||
static FORCE_INLINE int32_t tsdbWLockSma(SSmaEnv *pEnv) {
|
||||
int code = taosThreadRwlockWrlock(&(pEnv->lock));
|
||||
if (code != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(code);
|
||||
|
@ -70,7 +69,7 @@ static FORCE_INLINE int tsdbWLockSma(SSmaEnv *pEnv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int tsdbUnLockSma(SSmaEnv *pEnv) {
|
||||
static FORCE_INLINE int32_t tsdbUnLockSma(SSmaEnv *pEnv) {
|
||||
int code = taosThreadRwlockUnlock(&(pEnv->lock));
|
||||
if (code != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(code);
|
||||
|
|
|
@ -197,9 +197,9 @@ int tqCommit(STQ*);
|
|||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg);
|
||||
int32_t tqProcessSetConnReq(STQ* pTq, char* msg);
|
||||
int32_t tqProcessRebReq(STQ* pTq, char* msg);
|
||||
int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen, int32_t workerId);
|
||||
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen);
|
||||
int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen);
|
||||
int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen, int32_t workerId);
|
||||
|
||||
// sma
|
||||
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||
|
|
|
@ -356,7 +356,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
void* buf = rpcMallocCont(tlen);
|
||||
if (buf == NULL) {
|
||||
pMsg->code = -1;
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__POLL_RSP;
|
||||
|
@ -490,7 +489,7 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
|
||||
int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen, int32_t workerId) {
|
||||
void* pIter = NULL;
|
||||
|
||||
while (1) {
|
||||
|
@ -498,14 +497,14 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
|
|||
if (pIter == NULL) break;
|
||||
SStreamTask* pTask = (SStreamTask*)pIter;
|
||||
|
||||
if (streamExecTask(pTask, &pTq->pVnode->msgCb, data, STREAM_DATA_TYPE_SUBMIT_BLOCK, 0) < 0) {
|
||||
if (streamExecTask(pTask, &pTq->pVnode->msgCb, data, STREAM_DATA_TYPE_SUBMIT_BLOCK, workerId) < 0) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen, int32_t workerId) {
|
||||
SStreamTaskExecReq req;
|
||||
tDecodeSStreamTaskExecReq(msg, &req);
|
||||
|
||||
|
@ -515,7 +514,7 @@ int32_t tqProcessTaskExec(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
SStreamTask* pTask = taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t));
|
||||
ASSERT(pTask);
|
||||
|
||||
if (streamExecTask(pTask, &pTq->pVnode->msgCb, req.data, STREAM_DATA_TYPE_SSDATA_BLOCK, 0) < 0) {
|
||||
if (streamExecTask(pTask, &pTq->pVnode->msgCb, req.data, STREAM_DATA_TYPE_SSDATA_BLOCK, workerId) < 0) {
|
||||
// TODO
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -167,8 +167,10 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
|
|||
if (!tdSTSRowIterNext(&iter, pColData->info.colId, pColData->info.type, &sVal)) {
|
||||
break;
|
||||
}
|
||||
// TODO handle null
|
||||
colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL);
|
||||
if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) {
|
||||
taosArrayDestroyEx(pArray, (void (*)(void*))tDeleteSSDataBlock);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
curRow++;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ static const char *TSDB_SMA_DNAME[] = {
|
|||
#define SMA_STORAGE_TSDB_DAYS 30
|
||||
#define SMA_STORAGE_TSDB_TIMES 10
|
||||
#define SMA_STORAGE_SPLIT_HOURS 24
|
||||
#define SMA_KEY_LEN 18 // tableUid_colId_TSKEY 8+2+8
|
||||
#define SMA_KEY_LEN 16 // TSKEY+groupId 8+8
|
||||
#define SMA_DROP_EXPIRED_TIME 10 // default is 10 seconds
|
||||
|
||||
#define SMA_STATE_HASH_SLOT 4
|
||||
|
@ -38,10 +38,10 @@ typedef enum {
|
|||
} ESmaStorageLevel;
|
||||
|
||||
typedef struct {
|
||||
STsdb *pTsdb;
|
||||
SDBFile dFile;
|
||||
SSDataBlock *pData; // sma data
|
||||
int32_t interval; // interval with the precision of DB
|
||||
STsdb *pTsdb;
|
||||
SDBFile dFile;
|
||||
const SArray *pDataBlocks; // sma data
|
||||
int32_t interval; // interval with the precision of DB
|
||||
} STSmaWriteH;
|
||||
|
||||
typedef struct {
|
||||
|
@ -94,26 +94,24 @@ static int32_t tsdbUnRefSmaStat(STsdb *pTsdb, SSmaStat *pStat);
|
|||
|
||||
// read data
|
||||
// TODO: This is the basic params, and should wrap the params to a queryHandle.
|
||||
static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval,
|
||||
int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey,
|
||||
int32_t nMaxResult);
|
||||
static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult);
|
||||
|
||||
// insert data
|
||||
static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, SSDataBlock *pData, int64_t interval,
|
||||
static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, const SArray *pDataBlocks, int64_t interval,
|
||||
int8_t intervalUnit);
|
||||
static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH);
|
||||
static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interval, int8_t intervalUnit);
|
||||
static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit);
|
||||
static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *pData);
|
||||
static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, int32_t fid);
|
||||
static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen);
|
||||
static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision);
|
||||
static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision, bool adjusted);
|
||||
static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel);
|
||||
static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int64_t indexUid, int32_t fid);
|
||||
static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t fid);
|
||||
static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey);
|
||||
static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey);
|
||||
static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]);
|
||||
static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg);
|
||||
static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg);
|
||||
static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char *msg);
|
||||
static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, const char *msg);
|
||||
|
||||
// mgmt interface
|
||||
static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid);
|
||||
|
@ -387,7 +385,6 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
};
|
||||
|
||||
|
||||
static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey) {
|
||||
SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid));
|
||||
if (pItem == NULL) {
|
||||
|
@ -480,18 +477,15 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, const char *msg) {
|
|||
TSKEY expiredWindows[SMA_TEST_EXPIRED_WINDOW_SIZE];
|
||||
#endif
|
||||
|
||||
|
||||
// Firstly, assume that tSma can only be created on super table/normal table.
|
||||
// getActiveTimeWindow
|
||||
|
||||
|
||||
SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, TSDB_SMA_TYPE_TIME_RANGE);
|
||||
SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, TSDB_SMA_TYPE_TIME_RANGE);
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||
SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv);
|
||||
|
||||
TASSERT(pEnv != NULL && pStat != NULL && pItemsHash != NULL);
|
||||
|
||||
|
||||
// basic procedure
|
||||
// TODO: optimization
|
||||
tsdbRefSmaStat(pTsdb, pStat);
|
||||
|
@ -523,11 +517,11 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, const char *msg) {
|
|||
tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
if(pSW == NULL) {
|
||||
if((pSW =metaGetSmaInfoByTable(REPO_META(pTsdb), pBlock->suid)) == NULL) {
|
||||
if (pSW == NULL) {
|
||||
if ((pSW = metaGetSmaInfoByTable(REPO_META(pTsdb), pBlock->suid)) == NULL) {
|
||||
break;
|
||||
}
|
||||
if((pSW->number) <= 0 || (pSW->tSma == NULL)) {
|
||||
if ((pSW->number) <= 0 || (pSW->tSma == NULL)) {
|
||||
tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
|
@ -657,9 +651,8 @@ static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) {
|
|||
*/
|
||||
static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen) {
|
||||
SDBFile *pDBFile = &pSmaH->dFile;
|
||||
tsdbDebug("vgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", dataLen %d",
|
||||
REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8),
|
||||
*(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen);
|
||||
printf("\nvgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIx64 ", dataLen %" PRIu32 "\n",
|
||||
REPO_ID(pSmaH->pTsdb), pDBFile->path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), dataLen);
|
||||
|
||||
// TODO: insert sma data blocks into B+Tree(TDB)
|
||||
if (tsdbSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen) != 0) {
|
||||
|
@ -683,9 +676,15 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k
|
|||
* @param interval
|
||||
* @param intervalUnit
|
||||
* @param precision
|
||||
* @param adjusted Interval already adjusted according to DB precision
|
||||
* @return int64_t
|
||||
*/
|
||||
static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision) {
|
||||
static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision, bool adjusted) {
|
||||
|
||||
if (adjusted) {
|
||||
return interval;
|
||||
}
|
||||
|
||||
switch (intervalUnit) {
|
||||
case TIME_UNIT_YEAR: // approximate value
|
||||
interval *= 365 * 86400 * 1e3;
|
||||
|
@ -753,59 +752,12 @@ static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit
|
|||
return interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Split the TSma data blocks into expected size and insert into B+Tree.
|
||||
*
|
||||
* @param pSmaH
|
||||
* @param pData
|
||||
* @param nOffset The nOffset of blocks since fid changes.
|
||||
* @param nBlocks The nBlocks with the same fid since nOffset.
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *pData) {
|
||||
STsdb *pTsdb = pSmaH->pTsdb;
|
||||
|
||||
tsdbDebug("tsdbInsertTSmaDataSection: index %" PRIi64 ", skey %" PRIi64, pData->indexUid, pData->skey);
|
||||
|
||||
// TODO: check the data integrity
|
||||
|
||||
int32_t len = 0;
|
||||
while (true) {
|
||||
if (len >= pData->dataLen) {
|
||||
break;
|
||||
}
|
||||
assert(pData->dataLen > 0);
|
||||
STSmaTbData *pTbData = (STSmaTbData *)POINTER_SHIFT(pData->data, len);
|
||||
|
||||
int32_t tbLen = 0;
|
||||
while (true) {
|
||||
if (tbLen >= pTbData->dataLen) {
|
||||
break;
|
||||
}
|
||||
assert(pTbData->dataLen > 0);
|
||||
STSmaColData *pColData = (STSmaColData *)POINTER_SHIFT(pTbData->data, tbLen);
|
||||
char smaKey[SMA_KEY_LEN] = {0};
|
||||
void *pSmaKey = &smaKey;
|
||||
#if 0
|
||||
printf("tsdbInsertTSmaDataSection: index %" PRIi64 ", skey %" PRIi64 " table[%" PRIi64 "]col[%" PRIu16 "]\n",
|
||||
pData->indexUid, pData->skey, pTbData->tableUid, pColData->colId);
|
||||
#endif
|
||||
tsdbEncodeTSmaKey(pTbData->tableUid, pColData->colId, pData->skey, (void **)&pSmaKey);
|
||||
if (tsdbInsertTSmaBlocks(pSmaH, smaKey, SMA_KEY_LEN, pColData->data, pColData->blockSize) < 0) {
|
||||
tsdbWarn("vgId:%d insert tSma blocks failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
tbLen += (sizeof(STSmaColData) + pColData->blockSize);
|
||||
}
|
||||
len += (sizeof(STSmaTbData) + pTbData->dataLen);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, SSDataBlock *pData, int64_t interval, int8_t intervalUnit) {
|
||||
static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, const SArray *pDataBlocks, int64_t interval,
|
||||
int8_t intervalUnit) {
|
||||
pSmaH->pTsdb = pTsdb;
|
||||
pSmaH->interval = tsdbGetIntervalByPrecision(interval, intervalUnit, REPO_CFG(pTsdb)->precision);
|
||||
pSmaH->pData = pData;
|
||||
pSmaH->interval = tsdbGetIntervalByPrecision(interval, intervalUnit, REPO_CFG(pTsdb)->precision, true);
|
||||
pSmaH->pDataBlocks = pDataBlocks;
|
||||
pSmaH->dFile.fid = TSDB_IVLD_FID;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -815,7 +767,7 @@ static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int64_t indexUid, int32_t fid) {
|
||||
static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t fid) {
|
||||
STsdb *pTsdb = pSmaH->pTsdb;
|
||||
ASSERT(pSmaH->dFile.path == NULL && pSmaH->dFile.pDB == NULL);
|
||||
|
||||
|
@ -859,11 +811,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe
|
|||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
SSDataBlock *pData = (SSDataBlock *)msg;
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv);
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, int64_t indexUid, const char *msg) {
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
const SArray *pDataBlocks = (const SArray *)msg;
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv);
|
||||
|
||||
if (pEnv == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
|
@ -871,15 +822,15 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
return terrno;
|
||||
}
|
||||
|
||||
if (pData == NULL) {
|
||||
if (pDataBlocks == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
tsdbWarn("vgId:%d insert tSma data failed since pData is NULL", REPO_ID(pTsdb));
|
||||
tsdbWarn("vgId:%d insert tSma data failed since pDataBlocks is NULL", REPO_ID(pTsdb));
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pData->pDataBlock) <= 0) {
|
||||
if (taosArrayGetSize(pDataBlocks) <= 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tsdbWarn("vgId:%d insert tSma data failed since pDataBlock is empty", REPO_ID(pTsdb));
|
||||
tsdbWarn("vgId:%d insert tSma data failed since pDataBlocks is empty", REPO_ID(pTsdb));
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -899,10 +850,9 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
}
|
||||
|
||||
STSma *pSma = pItem->pSma;
|
||||
|
||||
STSmaWriteH tSmaH = {0};
|
||||
|
||||
if (tsdbInitTSmaWriteH(&tSmaH, pTsdb, pData, pSma->interval, pSma->intervalUnit) != 0) {
|
||||
if (tsdbInitTSmaWriteH(&tSmaH, pTsdb, pDataBlocks, pSma->interval, pSma->intervalUnit) != 0) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -921,33 +871,134 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
int32_t storageLevel = tsdbGetSmaStorageLevel(pSma->interval, pSma->intervalUnit);
|
||||
int32_t daysPerFile = tsdbGetTSmaDays(pTsdb, tSmaH.interval, storageLevel);
|
||||
|
||||
// key: skey + groupId
|
||||
char smaKey[SMA_KEY_LEN] = {0};
|
||||
char dataBuf[512] = {0};
|
||||
void *pDataBuf = &dataBuf;
|
||||
int32_t sz = taosArrayGetSize(pDataBlocks);
|
||||
for (int32_t i = 0; i < sz; ++i) {
|
||||
SSDataBlock *pDataBlock = *(SSDataBlock **)taosArrayGet(pDataBlocks, i);
|
||||
int32_t colNum = pDataBlock->info.numOfCols;
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
int32_t rowSize = pDataBlock->info.rowSize;
|
||||
int64_t groupId = pDataBlock->info.groupId;
|
||||
for (int32_t j = 0; j < rows; ++j) {
|
||||
printf("|");
|
||||
TSKEY skey = TSKEY_INITIAL_VAL; // the start key of TS window by interval
|
||||
void *pSmaKey = &smaKey;
|
||||
int32_t tlen = 0;
|
||||
for (int32_t k = 0; k < colNum; ++k) {
|
||||
SColumnInfoData *pColInfoData = *(SColumnInfoData **)taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
void *var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
skey = *(TSKEY *)var;
|
||||
printf("==> skey = %" PRIi64 " groupId = %" PRId64 "|", skey, groupId);
|
||||
tsdbEncodeTSmaKey(groupId, skey, &pSmaKey);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
printf(" %15d |", *(uint8_t *)var);
|
||||
tlen += taosEncodeFixedU8(&pDataBuf, *(uint8_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
printf(" %15d |", *(int8_t *)var);
|
||||
tlen += taosEncodeFixedI8(&pDataBuf, *(int8_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
printf(" %15d |", *(int16_t *)var);
|
||||
tlen += taosEncodeFixedI16(&pDataBuf, *(int16_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
printf(" %15d |", *(uint16_t *)var);
|
||||
tlen += taosEncodeFixedU16(&pDataBuf, *(uint16_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
printf(" %15d |", *(int32_t *)var);
|
||||
tlen += taosEncodeFixedI32(&pDataBuf, *(int32_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
printf(" %15u |", *(uint32_t *)var);
|
||||
tlen += taosEncodeFixedU32(&pDataBuf, *(uint32_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
printf(" %15ld |", *(int64_t *)var);
|
||||
tlen += taosEncodeFixedI64(&pDataBuf, *(int64_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
printf(" %15lu |", *(uint64_t *)var);
|
||||
tlen += taosEncodeFixedU64(&pDataBuf, *(uint64_t *)var);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
char tmpChar[100] = {0};
|
||||
strncpy(tmpChar, varDataVal(var), varDataLen(var));
|
||||
printf(" %s |", tmpChar);
|
||||
tlen += taosEncodeBinary(&pDataBuf, varDataVal(var), varDataLen(var));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
||||
char tmpChar[100] = {0};
|
||||
strncpy(tmpChar, varDataVal(var), varDataLen(var));
|
||||
printf(" %s |", tmpChar);
|
||||
tlen += taosEncodeBinary(&pDataBuf, varDataVal(var), varDataLen(var));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
// TODO: add binary/varbinary
|
||||
TASSERT(0);
|
||||
default:
|
||||
printf("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type);
|
||||
TASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((tlen > 0) && (skey != TSKEY_INITIAL_VAL)) {
|
||||
int32_t fid = (int32_t)(TSDB_KEY_FID(skey, daysPerFile, pCfg->precision));
|
||||
|
||||
#if 0
|
||||
int32_t fid = (int32_t)(TSDB_KEY_FID(pData->skey, daysPerFile, pCfg->precision));
|
||||
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index
|
||||
// file
|
||||
// - Set and open the DFile or the B+Tree file
|
||||
// TODO: tsdbStartTSmaCommit();
|
||||
if (fid != tSmaH.dFile.fid) {
|
||||
if (tSmaH.dFile.fid != TSDB_IVLD_FID) {
|
||||
tsdbCloseDBF(&tSmaH.dFile);
|
||||
}
|
||||
tsdbSetTSmaDataFile(&tSmaH, indexUid, fid);
|
||||
if (tsdbOpenDBF(pTsdb->pTSmaEnv->dbEnv, &tSmaH.dFile) != 0) {
|
||||
tsdbWarn("vgId:%d open DB file %s failed since %s", REPO_ID(pTsdb),
|
||||
tSmaH.dFile.path ? tSmaH.dFile.path : "path is NULL", tstrerror(terrno));
|
||||
tsdbDestroyTSmaWriteH(&tSmaH);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file
|
||||
// - Set and open the DFile or the B+Tree file
|
||||
// TODO: tsdbStartTSmaCommit();
|
||||
tsdbSetTSmaDataFile(&tSmaH, pData, indexUid, fid);
|
||||
if (tsdbOpenDBF(pTsdb->pTSmaEnv->dbEnv, &tSmaH.dFile) != 0) {
|
||||
tsdbWarn("vgId:%d open DB file %s failed since %s", REPO_ID(pTsdb),
|
||||
tSmaH.dFile.path ? tSmaH.dFile.path : "path is NULL", tstrerror(terrno));
|
||||
tsdbDestroyTSmaWriteH(&tSmaH);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
if (tsdbInsertTSmaBlocks(&tSmaH, &smaKey, SMA_KEY_LEN, pDataBuf, tlen) != 0) {
|
||||
tsdbWarn("vgId:%d insert tSma data blocks failed for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64
|
||||
" since %s",
|
||||
REPO_ID(pTsdb), indexUid, skey, groupId, tstrerror(terrno));
|
||||
tsdbDestroyTSmaWriteH(&tSmaH);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
} else {
|
||||
tsdbWarn("vgId:%d insert tSma data blocks success for index %" PRIi64 ", skey %" PRIi64 ", groupId %" PRIi64,
|
||||
REPO_ID(pTsdb), indexUid, skey, groupId);
|
||||
}
|
||||
// TODO:tsdbEndTSmaCommit();
|
||||
|
||||
// Step 3: reset the SSmaStat
|
||||
tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), indexUid, skey);
|
||||
} else {
|
||||
tsdbWarn("vgId:%d invalid data skey:%" PRIi64 ", tlen %" PRIi32 " during insert tSma data for %" PRIi64,
|
||||
REPO_ID(pTsdb), skey, tlen, indexUid);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (tsdbInsertTSmaDataSection(&tSmaH, pData) != 0) {
|
||||
tsdbWarn("vgId:%d insert tSma data section failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
tsdbDestroyTSmaWriteH(&tSmaH);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
// TODO:tsdbEndTSmaCommit();
|
||||
|
||||
// Step 3: reset the SSmaStat
|
||||
tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey);
|
||||
#endif
|
||||
tsdbDestroyTSmaWriteH(&tSmaH);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1002,7 +1053,7 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
|
|||
// TODO:
|
||||
}
|
||||
|
||||
static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t fid) {
|
||||
static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, int32_t fid) {
|
||||
STsdb *pTsdb = pSmaH->pTsdb;
|
||||
|
||||
char tSmaFile[TSDB_FILENAME_LEN] = {0};
|
||||
|
@ -1012,11 +1063,11 @@ static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
SSDataBlock *pData = (SSDataBlock *)msg;
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pRSmaEnv);
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, const char *msg) {
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
const SArray *pDataBlocks = (const SArray *)msg;
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pRSmaEnv);
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
|
||||
if (pEnv == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
|
@ -1030,15 +1081,15 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
return terrno;
|
||||
}
|
||||
|
||||
if (pData == NULL) {
|
||||
if (pDataBlocks == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
tsdbWarn("vgId:%d insert rSma data failed since pData is NULL", REPO_ID(pTsdb));
|
||||
tsdbWarn("vgId:%d insert rSma data failed since pDataBlocks is NULL", REPO_ID(pTsdb));
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pData->pDataBlock) <= 0) {
|
||||
if (taosArrayGetSize(pDataBlocks) <= 0) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
tsdbWarn("vgId:%d insert rSma data failed since pDataBlock is empty", REPO_ID(pTsdb));
|
||||
tsdbWarn("vgId:%d insert rSma data failed since pDataBlocks is empty", REPO_ID(pTsdb));
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -1061,12 +1112,12 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
|
||||
STSmaWriteH tSmaH = {0};
|
||||
|
||||
if (tsdbInitTSmaWriteH(&tSmaH, pTsdb, pData, pSma->interval, pSma->intervalUnit) != 0) {
|
||||
if (tsdbInitTSmaWriteH(&tSmaH, pTsdb, pDataBlocks, pSma->interval, pSma->intervalUnit) != 0) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
char rPath[TSDB_FILENAME_LEN] = {0};
|
||||
char aPath[TSDB_FILENAME_LEN] = {0};
|
||||
char rPath[TSDB_FILENAME_LEN] = {0};
|
||||
char aPath[TSDB_FILENAME_LEN] = {0};
|
||||
snprintf(rPath, TSDB_FILENAME_LEN, "%s%s%" PRIi64, SMA_ENV_PATH(pEnv), TD_DIRSEP, indexUid);
|
||||
tfsAbsoluteName(REPO_TFS(pTsdb), SMA_ENV_DID(pEnv), rPath, aPath);
|
||||
if (!taosCheckExistFile(aPath)) {
|
||||
|
@ -1078,7 +1129,7 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
// Step 1: Judge the storage level and days
|
||||
int32_t storageLevel = tsdbGetSmaStorageLevel(pSma->interval, pSma->intervalUnit);
|
||||
int32_t daysPerFile = tsdbGetTSmaDays(pTsdb, tSmaH.interval, storageLevel);
|
||||
#if 0
|
||||
#if 0
|
||||
int32_t fid = (int32_t)(TSDB_KEY_FID(pData->skey, daysPerFile, pCfg->precision));
|
||||
|
||||
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file
|
||||
|
@ -1119,7 +1170,7 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
*/
|
||||
static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interval, int8_t intervalUnit) {
|
||||
pSmaH->pTsdb = pTsdb;
|
||||
pSmaH->interval = tsdbGetIntervalByPrecision(interval, intervalUnit, REPO_CFG(pTsdb)->precision);
|
||||
pSmaH->interval = tsdbGetIntervalByPrecision(interval, intervalUnit, REPO_CFG(pTsdb)->precision, true);
|
||||
pSmaH->storageLevel = tsdbGetSmaStorageLevel(interval, intervalUnit);
|
||||
pSmaH->days = tsdbGetTSmaDays(pTsdb, pSmaH->interval, pSmaH->storageLevel);
|
||||
}
|
||||
|
@ -1185,17 +1236,11 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) {
|
|||
* @param pTsdb Return the data between queryWin and fill the pData.
|
||||
* @param pData
|
||||
* @param indexUid
|
||||
* @param interval
|
||||
* @param intervalUnit
|
||||
* @param tableUid
|
||||
* @param colId
|
||||
* @param pQuerySKey
|
||||
* @param nMaxResult The query invoker should control the nMaxResult need to return to avoid OOM.
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval,
|
||||
int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey,
|
||||
int32_t nMaxResult) {
|
||||
static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) {
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv);
|
||||
|
||||
if (!pEnv) {
|
||||
|
@ -1243,35 +1288,38 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
|
|||
tsdbDebug("vgId:%d skey %" PRIi64 " of window not in expired window for index %" PRIi64, REPO_ID(pTsdb), querySKey,
|
||||
indexUid);
|
||||
}
|
||||
tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv));
|
||||
|
||||
STSma *pTSma = pItem->pSma;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
STSmaReadH tReadH = {0};
|
||||
tsdbInitTSmaReadH(&tReadH, pTsdb, interval, intervalUnit);
|
||||
tsdbInitTSmaReadH(&tReadH, pTsdb, pTSma->interval, pTSma->intervalUnit);
|
||||
tsdbCloseDBF(&tReadH.dFile);
|
||||
|
||||
tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv));
|
||||
|
||||
tsdbInitTSmaFile(&tReadH, indexUid, querySKey);
|
||||
if (tsdbOpenDBF(SMA_ENV_ENV(pTsdb->pTSmaEnv), &tReadH.dFile) != 0) {
|
||||
tsdbWarn("vgId:%d open DBF %s failed since %s", REPO_ID(pTsdb), tReadH.dFile.path, tstrerror(terrno));
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
char smaKey[SMA_KEY_LEN] = {0};
|
||||
void *pSmaKey = &smaKey;
|
||||
tsdbEncodeTSmaKey(tableUid, colId, querySKey, (void **)&pSmaKey);
|
||||
char smaKey[SMA_KEY_LEN] = {0};
|
||||
void *pSmaKey = &smaKey;
|
||||
int64_t queryGroupId = 1;
|
||||
tsdbEncodeTSmaKey(queryGroupId, querySKey, (void **)&pSmaKey);
|
||||
|
||||
tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb),
|
||||
tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8),
|
||||
*(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN);
|
||||
tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb),
|
||||
tReadH.dFile.path, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), SMA_KEY_LEN);
|
||||
|
||||
void *result = NULL;
|
||||
uint32_t valueSize = 0;
|
||||
if ((result = tsdbGetSmaDataByKey(&tReadH.dFile, smaKey, SMA_KEY_LEN, &valueSize)) == NULL) {
|
||||
tsdbWarn("vgId:%d get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64
|
||||
" since %s",
|
||||
REPO_ID(pTsdb), indexUid, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8),
|
||||
*(int64_t *)POINTER_SHIFT(smaKey, 10), tstrerror(terrno));
|
||||
tsdbWarn("vgId:%d get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIx64 " since %s",
|
||||
REPO_ID(pTsdb), indexUid, *(int64_t *)smaKey, *(int64_t *)POINTER_SHIFT(smaKey, 8), tstrerror(terrno));
|
||||
tsdbCloseDBF(&tReadH.dFile);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -1347,11 +1395,10 @@ int32_t tsdbRemoveTSmaData(STsdb *pTsdb, void *smaIndex, STimeWindow *pWin) {
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
// TODO: Who is responsible for resource allocate and release?
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, int64_t indexUid, const char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbInsertTSmaDataImpl(pTsdb, msg)) < 0) {
|
||||
if ((code = tsdbInsertTSmaDataImpl(pTsdb, indexUid, msg)) < 0) {
|
||||
tsdbWarn("vgId:%d insert tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
return code;
|
||||
|
@ -1373,18 +1420,14 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit,
|
||||
tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) {
|
||||
int32_t tsdbGetTSmaData(STsdb *pTsdb, char*pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbGetTSmaDataImpl(pTsdb, pData, indexUid, interval, intervalUnit, tableUid, colId, querySKey,
|
||||
nMaxResult)) < 0) {
|
||||
if ((code = tsdbGetTSmaDataImpl(pTsdb, pData, indexUid, querySKey, nMaxResult)) < 0) {
|
||||
tsdbWarn("vgId:%d get tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbDropTSmaDataImpl(pTsdb, indexUid)) < 0) {
|
||||
|
|
|
@ -41,7 +41,7 @@ int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||
vTrace("message in fetch queue is processing");
|
||||
char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||
|
@ -69,9 +69,9 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||
case TDMT_VND_TASK_PIPE_EXEC:
|
||||
case TDMT_VND_TASK_MERGE_EXEC:
|
||||
return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen);
|
||||
return tqProcessTaskExec(pVnode->pTq, msgstr, msgLen, pInfo->workerId);
|
||||
case TDMT_VND_STREAM_TRIGGER:
|
||||
return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen);
|
||||
return tqProcessStreamTrigger(pVnode->pTq, pMsg->pCont, pMsg->contLen, pInfo->workerId);
|
||||
case TDMT_VND_QUERY_HEARTBEAT:
|
||||
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg);
|
||||
default:
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
||||
// TODO
|
||||
|
||||
blockDebugShowData(data);
|
||||
tsdbInsertTSmaData(((SVnode *)pVnode)->pTsdb, smaId, (const char *)data);
|
||||
}
|
||||
|
||||
void vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
|
||||
|
@ -184,8 +186,8 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
}
|
||||
} break;
|
||||
case TDMT_VND_TASK_WRITE_EXEC: {
|
||||
if (tqProcessTaskExec(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||
if (tqProcessTaskExec(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), pMsg->contLen - sizeof(SMsgHead),
|
||||
0) < 0) {
|
||||
}
|
||||
} break;
|
||||
case TDMT_VND_CREATE_SMA: { // timeRangeSMA
|
||||
|
@ -194,14 +196,15 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
SSmaCfg vCreateSmaReq = {0};
|
||||
if (tDeserializeSVCreateTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateSmaReq) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
vWarn("vgId%d: TDMT_VND_CREATE_SMA received but deserialize failed since %s", pVnode->config.vgId, terrstr(terrno));
|
||||
vWarn("vgId%d: TDMT_VND_CREATE_SMA received but deserialize failed since %s", pVnode->config.vgId,
|
||||
terrstr(terrno));
|
||||
return -1;
|
||||
}
|
||||
vWarn("vgId%d: TDMT_VND_CREATE_SMA received for %s:%" PRIi64, pVnode->config.vgId, vCreateSmaReq.tSma.indexName,
|
||||
vCreateSmaReq.tSma.indexUid);
|
||||
|
||||
// record current timezone of server side
|
||||
tstrncpy(vCreateSmaReq.tSma.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
|
||||
vCreateSmaReq.tSma.timezoneInt = tsTimezone;
|
||||
|
||||
if (metaCreateTSma(pVnode->pMeta, &vCreateSmaReq) < 0) {
|
||||
// TODO: handle error
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
#include <tsdbDef.h>
|
||||
|
||||
#include <taoserror.h>
|
||||
#include <tglobal.h>
|
||||
#include <iostream>
|
||||
|
@ -58,20 +59,21 @@ TEST(testCase, unionEncodeDecodeTest) {
|
|||
|
||||
void *buf = taosMemoryMalloc(1024);
|
||||
void *pBuf = buf;
|
||||
void *qBuf = buf;
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedU8(&buf, sut.info);
|
||||
tlen += taosEncodeFixedI16(&buf, sut.nBSmaCols);
|
||||
tlen += taosEncodeFixedU8(&pBuf, sut.info);
|
||||
tlen += taosEncodeFixedI16(&pBuf, sut.nBSmaCols);
|
||||
for (col_id_t i = 0; i < sut.nBSmaCols; ++i) {
|
||||
tlen += taosEncodeFixedI16(&buf, sut.pBSmaCols[i]);
|
||||
tlen += taosEncodeFixedI16(&pBuf, sut.pBSmaCols[i]);
|
||||
}
|
||||
|
||||
SUnionTest dut = {0};
|
||||
pBuf = taosDecodeFixedU8(pBuf, &dut.info);
|
||||
pBuf = taosDecodeFixedI16(pBuf, &dut.nBSmaCols);
|
||||
qBuf = taosDecodeFixedU8(qBuf, &dut.info);
|
||||
qBuf = taosDecodeFixedI16(qBuf, &dut.nBSmaCols);
|
||||
if (dut.nBSmaCols > 0) {
|
||||
dut.pBSmaCols = (col_id_t *)taosMemoryMalloc(dut.nBSmaCols * sizeof(col_id_t));
|
||||
for (col_id_t i = 0; i < dut.nBSmaCols; ++i) {
|
||||
pBuf = taosDecodeFixedI16(pBuf, dut.pBSmaCols + i);
|
||||
qBuf = taosDecodeFixedI16(qBuf, dut.pBSmaCols + i);
|
||||
}
|
||||
} else {
|
||||
dut.pBSmaCols = NULL;
|
||||
|
@ -80,13 +82,17 @@ TEST(testCase, unionEncodeDecodeTest) {
|
|||
printf("sut.rollup=%" PRIu8 ", type=%" PRIu8 ", info=%" PRIu8 "\n", sut.rollup, sut.type, sut.info);
|
||||
printf("dut.rollup=%" PRIu8 ", type=%" PRIu8 ", info=%" PRIu8 "\n", dut.rollup, dut.type, dut.info);
|
||||
|
||||
ASSERT_EQ(sut.rollup, dut.rollup);
|
||||
ASSERT_EQ(sut.type, dut.type);
|
||||
ASSERT_EQ(sut.nBSmaCols, dut.nBSmaCols);
|
||||
EXPECT_EQ(sut.rollup, dut.rollup);
|
||||
EXPECT_EQ(sut.type, dut.type);
|
||||
EXPECT_EQ(sut.nBSmaCols, dut.nBSmaCols);
|
||||
for (col_id_t i = 0; i < sut.nBSmaCols; ++i) {
|
||||
ASSERT_EQ(*(col_id_t *)(sut.pBSmaCols + i), sut.pBSmaCols[i]);
|
||||
ASSERT_EQ(*(col_id_t *)(sut.pBSmaCols + i), dut.pBSmaCols[i]);
|
||||
EXPECT_EQ(*(col_id_t *)(sut.pBSmaCols + i), sut.pBSmaCols[i]);
|
||||
EXPECT_EQ(*(col_id_t *)(sut.pBSmaCols + i), dut.pBSmaCols[i]);
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(buf);
|
||||
taosMemoryFreeClear(dut.pBSmaCols);
|
||||
taosMemoryFreeClear(sut.pBSmaCols);
|
||||
}
|
||||
#if 1
|
||||
TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
||||
|
@ -106,37 +112,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
|||
uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper);
|
||||
|
||||
void *buf = taosMemoryCalloc(1, bufLen);
|
||||
ASSERT_NE(buf, nullptr);
|
||||
EXPECT_NE(buf, nullptr);
|
||||
|
||||
STSmaWrapper *pSW = (STSmaWrapper *)buf;
|
||||
uint32_t len = tEncodeTSmaWrapper(&buf, &tSmaWrapper);
|
||||
|
||||
ASSERT_EQ(len, bufLen);
|
||||
EXPECT_EQ(len, bufLen);
|
||||
|
||||
// decode
|
||||
STSmaWrapper dstTSmaWrapper = {0};
|
||||
void *result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper);
|
||||
ASSERT_NE(result, nullptr);
|
||||
EXPECT_NE(result, nullptr);
|
||||
|
||||
ASSERT_EQ(tSmaWrapper.number, dstTSmaWrapper.number);
|
||||
EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number);
|
||||
|
||||
for (int i = 0; i < tSmaWrapper.number; ++i) {
|
||||
STSma *pSma = tSmaWrapper.tSma + i;
|
||||
STSma *qSma = dstTSmaWrapper.tSma + i;
|
||||
|
||||
ASSERT_EQ(pSma->version, qSma->version);
|
||||
ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit);
|
||||
ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit);
|
||||
ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName);
|
||||
ASSERT_EQ(pSma->timezoneInt, qSma->timezoneInt);
|
||||
ASSERT_EQ(pSma->indexUid, qSma->indexUid);
|
||||
ASSERT_EQ(pSma->tableUid, qSma->tableUid);
|
||||
ASSERT_EQ(pSma->interval, qSma->interval);
|
||||
ASSERT_EQ(pSma->sliding, qSma->sliding);
|
||||
ASSERT_EQ(pSma->exprLen, qSma->exprLen);
|
||||
ASSERT_STRCASEEQ(pSma->expr, qSma->expr);
|
||||
ASSERT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen);
|
||||
ASSERT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter);
|
||||
EXPECT_EQ(pSma->version, qSma->version);
|
||||
EXPECT_EQ(pSma->intervalUnit, qSma->intervalUnit);
|
||||
EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit);
|
||||
EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName);
|
||||
EXPECT_EQ(pSma->timezoneInt, qSma->timezoneInt);
|
||||
EXPECT_EQ(pSma->indexUid, qSma->indexUid);
|
||||
EXPECT_EQ(pSma->tableUid, qSma->tableUid);
|
||||
EXPECT_EQ(pSma->interval, qSma->interval);
|
||||
EXPECT_EQ(pSma->sliding, qSma->sliding);
|
||||
EXPECT_EQ(pSma->exprLen, qSma->exprLen);
|
||||
EXPECT_STRCASEEQ(pSma->expr, qSma->expr);
|
||||
EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen);
|
||||
EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter);
|
||||
}
|
||||
|
||||
// resource release
|
||||
|
@ -172,12 +178,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
|
||||
tSma.exprLen = strlen(expr);
|
||||
tSma.expr = (char *)taosMemoryCalloc(1, tSma.exprLen + 1);
|
||||
ASSERT_NE(tSma.expr, nullptr);
|
||||
EXPECT_NE(tSma.expr, nullptr);
|
||||
tstrncpy(tSma.expr, expr, tSma.exprLen + 1);
|
||||
|
||||
tSma.tagsFilterLen = strlen(tagsFilter);
|
||||
tSma.tagsFilter = (char *)taosMemoryCalloc(tSma.tagsFilterLen + 1, 1);
|
||||
ASSERT_NE(tSma.tagsFilter, nullptr);
|
||||
EXPECT_NE(tSma.tagsFilter, nullptr);
|
||||
tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);
|
||||
|
||||
SMeta *pMeta = NULL;
|
||||
|
@ -189,7 +195,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
|
||||
assert(pMeta != NULL);
|
||||
// save index 1
|
||||
ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||
EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||
|
||||
pSmaCfg->indexUid = indexUid2;
|
||||
tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN);
|
||||
|
@ -200,7 +206,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
pSmaCfg->sliding = 5;
|
||||
|
||||
// save index 2
|
||||
ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||
EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||
|
||||
// get value by indexName
|
||||
STSma *qSmaCfg = NULL;
|
||||
|
@ -210,8 +216,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
printf("timezone1 = %" PRIi8 "\n", qSmaCfg->timezoneInt);
|
||||
printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
|
||||
printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
||||
ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1);
|
||||
ASSERT_EQ(qSmaCfg->tableUid, tSma.tableUid);
|
||||
EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1);
|
||||
EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid);
|
||||
tdDestroyTSma(qSmaCfg);
|
||||
taosMemoryFreeClear(qSmaCfg);
|
||||
|
||||
|
@ -221,8 +227,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
printf("timezone2 = %" PRIi8 "\n", qSmaCfg->timezoneInt);
|
||||
printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
|
||||
printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
||||
ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2);
|
||||
ASSERT_EQ(qSmaCfg->interval, tSma.interval);
|
||||
EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2);
|
||||
EXPECT_EQ(qSmaCfg->interval, tSma.interval);
|
||||
tdDestroyTSma(qSmaCfg);
|
||||
taosMemoryFreeClear(qSmaCfg);
|
||||
|
||||
|
@ -238,25 +244,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
printf("indexName = %s\n", indexName);
|
||||
++indexCnt;
|
||||
}
|
||||
ASSERT_EQ(indexCnt, nCntTSma);
|
||||
EXPECT_EQ(indexCnt, nCntTSma);
|
||||
metaCloseSmaCurosr(pSmaCur);
|
||||
|
||||
// get wrapper by table uid
|
||||
STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid);
|
||||
assert(pSW != NULL);
|
||||
ASSERT_EQ(pSW->number, nCntTSma);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1);
|
||||
ASSERT_EQ(pSW->tSma->timezoneInt, timezone);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->expr, expr);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter);
|
||||
ASSERT_EQ(pSW->tSma->indexUid, indexUid1);
|
||||
ASSERT_EQ(pSW->tSma->tableUid, tbUid);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2);
|
||||
ASSERT_EQ((pSW->tSma + 1)->timezoneInt, timezone);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter);
|
||||
ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2);
|
||||
ASSERT_EQ((pSW->tSma + 1)->tableUid, tbUid);
|
||||
EXPECT_EQ(pSW->number, nCntTSma);
|
||||
EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1);
|
||||
EXPECT_EQ(pSW->tSma->timezoneInt, timezone);
|
||||
EXPECT_STRCASEEQ(pSW->tSma->expr, expr);
|
||||
EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter);
|
||||
EXPECT_EQ(pSW->tSma->indexUid, indexUid1);
|
||||
EXPECT_EQ(pSW->tSma->tableUid, tbUid);
|
||||
EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2);
|
||||
EXPECT_EQ((pSW->tSma + 1)->timezoneInt, timezone);
|
||||
EXPECT_STRCASEEQ((pSW->tSma + 1)->expr, expr);
|
||||
EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter);
|
||||
EXPECT_EQ((pSW->tSma + 1)->indexUid, indexUid2);
|
||||
EXPECT_EQ((pSW->tSma + 1)->tableUid, tbUid);
|
||||
|
||||
tdDestroyTSmaWrapper(pSW);
|
||||
taosMemoryFreeClear(pSW);
|
||||
|
@ -268,7 +274,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
printf("metaGetSmaTbUids: uid[%" PRIu32 "] = %" PRIi64 "\n", i, *(tb_uid_t *)taosArrayGet(pUids, i));
|
||||
// printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i));
|
||||
}
|
||||
ASSERT_EQ(taosArrayGetSize(pUids), 1);
|
||||
EXPECT_EQ(taosArrayGetSize(pUids), 1);
|
||||
taosArrayDestroy(pUids);
|
||||
|
||||
// resource release
|
||||
|
@ -280,7 +286,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
TEST(testCase, tSma_Data_Insert_Query_Test) {
|
||||
// step 1: prepare meta
|
||||
const char *smaIndexName1 = "sma_index_test_1";
|
||||
|
@ -299,9 +305,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
// encode
|
||||
STSma tSma = {0};
|
||||
tSma.version = 0;
|
||||
tSma.intervalUnit = TIME_UNIT_DAY;
|
||||
tSma.intervalUnit = TIME_UNIT_MINUTE;
|
||||
tSma.interval = 1;
|
||||
tSma.slidingUnit = TIME_UNIT_HOUR;
|
||||
tSma.slidingUnit = TIME_UNIT_MINUTE;
|
||||
tSma.sliding = 1; // sliding = interval when it's convert window
|
||||
tSma.indexUid = indexUid1;
|
||||
tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
|
||||
|
@ -310,12 +316,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
|
||||
tSma.exprLen = strlen(expr);
|
||||
tSma.expr = (char *)taosMemoryCalloc(1, tSma.exprLen + 1);
|
||||
ASSERT_NE(tSma.expr, nullptr);
|
||||
EXPECT_NE(tSma.expr, nullptr);
|
||||
tstrncpy(tSma.expr, expr, tSma.exprLen + 1);
|
||||
|
||||
tSma.tagsFilterLen = strlen(tagsFilter);
|
||||
tSma.tagsFilter = (char *)taosMemoryCalloc(1, tSma.tagsFilterLen + 1);
|
||||
ASSERT_NE(tSma.tagsFilter, nullptr);
|
||||
EXPECT_NE(tSma.tagsFilter, nullptr);
|
||||
tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1);
|
||||
|
||||
SMeta *pMeta = NULL;
|
||||
|
@ -327,11 +333,11 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
pMeta = metaOpen(smaTestDir, pMetaCfg, NULL);
|
||||
assert(pMeta != NULL);
|
||||
// save index 1
|
||||
ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||
EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0);
|
||||
|
||||
// step 2: insert data
|
||||
STsdb *pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(STsdb));
|
||||
STsdbCfg *pCfg = &pTsdb->config;
|
||||
STsdb *pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(STsdb));
|
||||
STsdbCfg *pCfg = &pTsdb->config;
|
||||
|
||||
pTsdb->pMeta = pMeta;
|
||||
pTsdb->vgId = 2;
|
||||
|
@ -364,7 +370,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
strncpy(pDisks.dir, "/var/lib/taos", TSDB_FILENAME_LEN);
|
||||
int32_t numOfDisks = 1;
|
||||
pTsdb->pTfs = tfsOpen(&pDisks, numOfDisks);
|
||||
ASSERT_NE(pTsdb->pTfs, nullptr);
|
||||
EXPECT_NE(pTsdb->pTfs, nullptr);
|
||||
|
||||
// generate SSubmitReq msg and update expired window
|
||||
int16_t schemaVer = 0;
|
||||
|
@ -374,7 +380,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
uint32_t msgLen = sizeof(SSubmitReq) + mockBlkNum * sizeof(SSubmitBlk) + mockBlkNum * mockRowNum * mockRowLen;
|
||||
|
||||
SSubmitReq *pMsg = (SSubmitReq *)taosMemoryCalloc(1, msgLen);
|
||||
ASSERT_NE(pMsg, nullptr);
|
||||
EXPECT_NE(pMsg, nullptr);
|
||||
pMsg->version = htobe64(schemaVer);
|
||||
pMsg->numOfBlocks = htonl(mockBlkNum);
|
||||
pMsg->length = htonl(msgLen);
|
||||
|
@ -400,20 +406,99 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(tdScanAndConvertSubmitMsg(pMsg), TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(tdScanAndConvertSubmitMsg(pMsg), TSDB_CODE_SUCCESS);
|
||||
|
||||
ASSERT_EQ(tsdbUpdateSmaWindow(pTsdb, (const char *)pMsg), 0);
|
||||
EXPECT_EQ(tsdbUpdateSmaWindow(pTsdb, (const char *)pMsg), 0);
|
||||
|
||||
// init
|
||||
int32_t allocCnt = 0;
|
||||
int32_t allocStep = 16384;
|
||||
int32_t buffer = 1024;
|
||||
void *buf = NULL;
|
||||
ASSERT_EQ(tsdbMakeRoom(&buf, allocStep), 0);
|
||||
int32_t bufSize = taosTSizeof(buf);
|
||||
int32_t numOfTables = 10;
|
||||
col_id_t numOfCols = 4096;
|
||||
ASSERT_GT(numOfCols, 0);
|
||||
const int32_t tSmaGroupSize = 4;
|
||||
const int32_t tSmaNumOfTags = 2;
|
||||
const int64_t tSmaGroupId = 12345670;
|
||||
const col_id_t tSmaNumOfCols = 9; // binary/nchar/varbinary/varchar are only used for tags for group by conditions.
|
||||
const int32_t tSmaNumOfRows = 2;
|
||||
|
||||
SArray *pDataBlocks = taosArrayInit(tSmaGroupSize, sizeof(SSDataBlock *));
|
||||
EXPECT_NE(pDataBlocks, nullptr);
|
||||
int32_t tSmaTypeArray[tSmaNumOfCols] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_INT,
|
||||
TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT,
|
||||
TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_VARCHAR, TSDB_DATA_TYPE_NCHAR};
|
||||
// last 2 columns for group by tags
|
||||
// int32_t tSmaTypeArray[tSmaNumOfCols] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL};
|
||||
const char *tSmaGroupbyTags[tSmaGroupSize * tSmaNumOfTags] = {"BeiJing", "HaiDian", "BeiJing", "ChaoYang",
|
||||
"ShangHai", "PuDong", "ShangHai", "MinHang"};
|
||||
TSKEY tSmaSKeyMs = (int64_t)1648535332 * 1000;
|
||||
int64_t tSmaIntervalMs = tSma.interval * 60 * 1000;
|
||||
int64_t tSmaInitVal = 0;
|
||||
|
||||
for (int32_t g = 0; g < tSmaGroupSize; ++g) {
|
||||
SSDataBlock *pDataBlock = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
EXPECT_NE(pDataBlock, nullptr);
|
||||
pDataBlock->pBlockAgg = NULL;
|
||||
pDataBlock->info.numOfCols = tSmaNumOfCols;
|
||||
pDataBlock->info.rows = tSmaNumOfRows;
|
||||
pDataBlock->info.groupId = tSmaGroupId + g;
|
||||
|
||||
pDataBlock->pDataBlock = taosArrayInit(tSmaNumOfCols, sizeof(SColumnInfoData *));
|
||||
EXPECT_NE(pDataBlock->pDataBlock, nullptr);
|
||||
for (int32_t c = 0; c < tSmaNumOfCols; ++c) {
|
||||
|
||||
SColumnInfoData *pColInfoData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
EXPECT_NE(pColInfoData, nullptr);
|
||||
|
||||
pColInfoData->info.type = tSmaTypeArray[c];
|
||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
pColInfoData->info.bytes = 100; // update accordingly
|
||||
} else {
|
||||
pColInfoData->info.bytes = TYPE_BYTES[pColInfoData->info.type];
|
||||
}
|
||||
pColInfoData->pData = (char *)taosMemoryCalloc(1, tSmaNumOfRows * pColInfoData->info.bytes);
|
||||
|
||||
for (int32_t r = 0; r < tSmaNumOfRows; ++r) {
|
||||
void *pCellData = pColInfoData->pData + r * pColInfoData->info.bytes;
|
||||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
*(TSKEY *)pCellData = tSmaSKeyMs + tSmaIntervalMs * r;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
*(bool *)pCellData = (bool)tSmaInitVal++;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
*(int *)pCellData = (int)tSmaInitVal++;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
*(uint64_t *)pCellData = (uint64_t)tSmaInitVal++;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
*(int16_t *)pCellData = (int16_t)tSmaInitVal++;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
*(float *)pCellData = (float)tSmaInitVal++;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
*(double *)pCellData = (double)tSmaInitVal++;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_VARCHAR: // city
|
||||
varDataSetLen(pCellData, strlen(tSmaGroupbyTags[g * 2]));
|
||||
memcpy(varDataVal(pCellData), tSmaGroupbyTags[g * 2], varDataLen(pCellData));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR: // district
|
||||
varDataSetLen(pCellData, strlen(tSmaGroupbyTags[g * 2 + 1]));
|
||||
memcpy(varDataVal(pCellData), tSmaGroupbyTags[g * 2 + 1], varDataLen(pCellData));
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, 1); // add definition
|
||||
break;
|
||||
}
|
||||
}
|
||||
// push SColumnInfoData
|
||||
taosArrayPush(pDataBlock->pDataBlock, &pColInfoData);
|
||||
}
|
||||
// push SSDataBlock
|
||||
taosArrayPush(pDataBlocks, &pDataBlock);
|
||||
}
|
||||
|
||||
// execute
|
||||
EXPECT_EQ(tsdbInsertTSmaData(pTsdb, tSma.indexUid, (const char *)pDataBlocks), TSDB_CODE_SUCCESS);
|
||||
|
||||
#if 0
|
||||
STSmaDataWrapper *pSmaData = NULL;
|
||||
|
@ -432,7 +517,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
int32_t tableDataLen = sizeof(STSmaTbData);
|
||||
for (col_id_t c = 0; c < numOfCols; ++c) {
|
||||
if (bufSize - len - tableDataLen < buffer) {
|
||||
ASSERT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
|
||||
EXPECT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0);
|
||||
pSmaData = (STSmaDataWrapper *)buf;
|
||||
pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len);
|
||||
bufSize = taosTSizeof(buf);
|
||||
|
@ -459,31 +544,36 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
}
|
||||
pSmaData->dataLen = (len - sizeof(STSmaDataWrapper));
|
||||
|
||||
ASSERT_GE(bufSize, pSmaData->dataLen);
|
||||
EXPECT_GE(bufSize, pSmaData->dataLen);
|
||||
// execute
|
||||
ASSERT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
|
||||
EXPECT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS);
|
||||
#endif
|
||||
|
||||
SSDataBlock *pSmaData = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
|
||||
|
||||
|
||||
// step 3: query
|
||||
uint32_t checkDataCnt = 0;
|
||||
for (int32_t t = 0; t < numOfTables; ++t) {
|
||||
for (col_id_t c = 0; c < numOfCols; ++c) {
|
||||
ASSERT_EQ(tsdbGetTSmaData(pTsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t,
|
||||
c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1),
|
||||
TSDB_CODE_SUCCESS);
|
||||
++checkDataCnt;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(tsdbGetTSmaData(pTsdb, NULL, indexUid1, skey1, 1), TSDB_CODE_SUCCESS);
|
||||
++checkDataCnt;
|
||||
|
||||
printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt);
|
||||
|
||||
// release data
|
||||
taosMemoryFreeClear(pMsg);
|
||||
taosTZfree(buf);
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pDataBlocks); ++i) {
|
||||
SSDataBlock *pDataBlock = *(SSDataBlock **)taosArrayGet(pDataBlocks, i);
|
||||
int32_t numOfOutput = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t j = 0; j < numOfOutput; ++j) {
|
||||
SColumnInfoData *pColInfoData = *(SColumnInfoData **)taosArrayGet(pDataBlock->pDataBlock, j);
|
||||
colDataDestroy(pColInfoData);
|
||||
taosMemoryFreeClear(pColInfoData);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pDataBlock->pDataBlock);
|
||||
taosMemoryFreeClear(pDataBlock->pBlockAgg);
|
||||
taosMemoryFreeClear(pDataBlock);
|
||||
}
|
||||
taosArrayDestroy(pDataBlocks);
|
||||
|
||||
// release meta
|
||||
tdDestroyTSma(&tSma);
|
||||
tfsClose(pTsdb->pTfs);
|
||||
|
|
|
@ -161,20 +161,8 @@ typedef struct STaskCostInfo {
|
|||
typedef struct SOperatorCostInfo {
|
||||
uint64_t openCost;
|
||||
uint64_t execCost;
|
||||
// uint64_t totalRows;
|
||||
// uint64_t totalBytes;
|
||||
} SOperatorCostInfo;
|
||||
|
||||
typedef struct {
|
||||
int64_t vgroupLimit;
|
||||
int64_t ts;
|
||||
} SOrderedPrjQueryInfo;
|
||||
|
||||
typedef struct {
|
||||
char* tags;
|
||||
SArray* pResult; // SArray<SStddevInterResult>
|
||||
} SInterResult;
|
||||
|
||||
// The basic query information extracted from the SQueryInfo tree to support the
|
||||
// execution of query in a data node.
|
||||
typedef struct STaskAttr {
|
||||
|
@ -230,7 +218,6 @@ typedef struct STaskAttr {
|
|||
SColumnInfo* tagColList;
|
||||
int32_t numOfFilterCols;
|
||||
int64_t* fillVal;
|
||||
SOrderedPrjQueryInfo prjInfo; // limit value for each vgroup, only available in global order projection query.
|
||||
|
||||
SSingleColumnFilterInfo* pFilterInfo;
|
||||
// SFilterInfo *pFilters;
|
||||
|
@ -245,8 +232,9 @@ struct SOperatorInfo;
|
|||
|
||||
typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, char **result, int32_t *length);
|
||||
typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, char *result, int32_t length);
|
||||
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* param);
|
||||
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* param, bool* newgroup);
|
||||
|
||||
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr);
|
||||
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr, bool* newgroup);
|
||||
typedef void (*__optr_close_fn_t)(void* param, int32_t num);
|
||||
|
||||
typedef struct STaskIdInfo {
|
||||
|
@ -267,7 +255,8 @@ typedef struct SExecTaskInfo {
|
|||
uint64_t totalRows; // total number of rows
|
||||
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
||||
char* sql; // query sql string
|
||||
jmp_buf env; //
|
||||
jmp_buf env; // jump to this position when error happens.
|
||||
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
||||
struct SOperatorInfo* pRoot;
|
||||
} SExecTaskInfo;
|
||||
|
||||
|
@ -330,11 +319,12 @@ typedef struct SOperatorInfo {
|
|||
SResultInfo resultInfo;
|
||||
struct SOperatorInfo** pDownstream; // downstram pointer list
|
||||
int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator
|
||||
__optr_fn_t getNextFn;
|
||||
__optr_fn_t cleanupFn;
|
||||
__optr_close_fn_t closeFn;
|
||||
__optr_open_fn_t _openFn; // DO NOT invoke this function directly
|
||||
__optr_encode_fn_t encodeResultRow; //
|
||||
__optr_fn_t getNextFn;
|
||||
__optr_fn_t getStreamResFn; // execute the aggregate in the stream model.
|
||||
__optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP
|
||||
__optr_close_fn_t closeFn;
|
||||
__optr_encode_fn_t encodeResultRow;
|
||||
__optr_decode_fn_t decodeResultRow;
|
||||
} SOperatorInfo;
|
||||
|
||||
|
@ -363,18 +353,18 @@ typedef struct SQInfo {
|
|||
STaskCostInfo summary;
|
||||
} SQInfo;
|
||||
|
||||
enum {
|
||||
DATA_NOT_READY = 0x1,
|
||||
DATA_READY = 0x2,
|
||||
DATA_EXHAUSTED = 0x3,
|
||||
};
|
||||
typedef enum {
|
||||
EX_SOURCE_DATA_NOT_READY = 0x1,
|
||||
EX_SOURCE_DATA_READY = 0x2,
|
||||
EX_SOURCE_DATA_EXHAUSTED = 0x3,
|
||||
} EX_SOURCE_STATUS;
|
||||
|
||||
typedef struct SSourceDataInfo {
|
||||
struct SExchangeInfo *pEx;
|
||||
int32_t index;
|
||||
SRetrieveTableRsp *pRsp;
|
||||
uint64_t totalRows;
|
||||
int32_t status;
|
||||
int32_t index;
|
||||
SRetrieveTableRsp *pRsp;
|
||||
uint64_t totalRows;
|
||||
EX_SOURCE_STATUS status;
|
||||
} SSourceDataInfo;
|
||||
|
||||
typedef struct SLoadRemoteDataInfo {
|
||||
|
@ -383,12 +373,6 @@ typedef struct SLoadRemoteDataInfo {
|
|||
uint64_t totalElapsed; // total elapsed time
|
||||
} SLoadRemoteDataInfo;
|
||||
|
||||
enum {
|
||||
EX_SOURCE_DATA_NOT_READY = 0x1,
|
||||
EX_SOURCE_DATA_READY = 0x2,
|
||||
EX_SOURCE_DATA_EXHAUSTED = 0x3,
|
||||
};
|
||||
|
||||
typedef struct SExchangeInfo {
|
||||
SArray* pSources;
|
||||
SArray* pSourceDataInfo;
|
||||
|
@ -484,16 +468,18 @@ typedef struct SAggSupporter {
|
|||
} SAggSupporter;
|
||||
|
||||
typedef struct STableIntervalOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SGroupResInfo groupResInfo;
|
||||
SInterval interval;
|
||||
STimeWindow win;
|
||||
int32_t precision;
|
||||
bool timeWindowInterpo;
|
||||
char **pRow;
|
||||
SAggSupporter aggSup;
|
||||
STableQueryInfo *pCurrent;
|
||||
int32_t order;
|
||||
SOptrBasicInfo binfo; // basic info
|
||||
SGroupResInfo groupResInfo; // multiple results build supporter
|
||||
SInterval interval; // interval info
|
||||
STimeWindow win; // query time range
|
||||
bool timeWindowInterpo; // interpolation needed or not
|
||||
char **pRow; // previous row/tuple of already processed datablock
|
||||
SAggSupporter aggSup; // aggregate supporter
|
||||
STableQueryInfo *pCurrent; // current tableQueryInfo struct
|
||||
int32_t order; // current SSDataBlock scan order
|
||||
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
|
||||
SArray *pUpdatedWindow; // updated time window due to the input data block from the downstream operator.
|
||||
SColumnInfoData timeWindowData; // query time window info for scalar function execution.
|
||||
} STableIntervalOperatorInfo;
|
||||
|
||||
typedef struct SAggOperatorInfo {
|
||||
|
@ -695,12 +681,6 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
|
|||
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema,
|
||||
int32_t numOfOutput);
|
||||
|
||||
void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols, SSDataBlock* pBlock);
|
||||
bool doFilterDataBlock(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols, int32_t numOfRows, int8_t* p);
|
||||
void doCompactSDataBlock(SSDataBlock* pBlock, int32_t numOfRows, int8_t* p);
|
||||
|
||||
SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numOfRows);
|
||||
|
||||
void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols);
|
||||
|
||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
||||
|
@ -734,7 +714,7 @@ int32_t getMaximumIdleDurationSec();
|
|||
|
||||
void doInvokeUdf(struct SUdfInfo* pUdfInfo, SqlFunctionCtx* pCtx, int32_t idx, int32_t type);
|
||||
void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status);
|
||||
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId);
|
||||
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, EOPTR_EXEC_MODEL model);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
|
|||
}
|
||||
|
||||
qTaskInfo_t pTaskInfo = NULL;
|
||||
code = qCreateExecTask(streamReadHandle, 0, 0, plan, &pTaskInfo, NULL);
|
||||
code = qCreateExecTask(streamReadHandle, 0, 0, plan, &pTaskInfo, NULL, OPTR_EXEC_MODEL_STREAM);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// TODO: destroy SSubplan & pTaskInfo
|
||||
terrno = code;
|
||||
|
|
|
@ -51,11 +51,12 @@ static void freeqinfoFn(void *qhandle) {
|
|||
qDestroyTask(*handle);
|
||||
}
|
||||
|
||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle) {
|
||||
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan,
|
||||
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, EOPTR_EXEC_MODEL model) {
|
||||
assert(readHandle != NULL && pSubplan != NULL);
|
||||
SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo;
|
||||
|
||||
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId);
|
||||
int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, model);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
|
|
@ -1014,8 +1014,35 @@ static int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* p
|
|||
return num;
|
||||
}
|
||||
|
||||
static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, int32_t offset, int32_t forwardStep, TSKEY* tsCol,
|
||||
// query_range_start, query_range_end, window_duration, window_start, window_end
|
||||
static void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow) {
|
||||
pColData->info.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
pColData->info.bytes = sizeof(int64_t);
|
||||
|
||||
blockDataEnsureColumnCapacity(pColData, 5);
|
||||
colDataAppendInt64(pColData, 0, &pQueryWindow->skey);
|
||||
colDataAppendInt64(pColData, 1, &pQueryWindow->ekey);
|
||||
|
||||
int64_t interval = 0;
|
||||
colDataAppendInt64(pColData, 2, &interval); // this value may be variable in case of 'n' and 'y'.
|
||||
colDataAppendInt64(pColData, 3, &pQueryWindow->skey);
|
||||
colDataAppendInt64(pColData, 4, &pQueryWindow->ekey);
|
||||
}
|
||||
|
||||
static void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin) {
|
||||
int64_t* ts = (int64_t*)pColData->pData;
|
||||
|
||||
int64_t duration = pWin->ekey - pWin->skey + 1;
|
||||
ts[2] = duration; // set the duration
|
||||
ts[3] = pWin->skey; // window start key
|
||||
ts[4] = pWin->ekey + 1; // window end key
|
||||
}
|
||||
|
||||
static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol,
|
||||
int32_t numOfTotal, int32_t numOfOutput, int32_t order) {
|
||||
SScalarParam intervalParam = {.numOfRows = 5, .columnData = pTimeWindowData}; //TODO move out of this function
|
||||
updateTimeWindowInfo(pTimeWindowData, pWin);
|
||||
|
||||
for (int32_t k = 0; k < numOfOutput; ++k) {
|
||||
pCtx[k].startTs = pWin->skey;
|
||||
|
||||
|
@ -1038,6 +1065,21 @@ static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, int32_t of
|
|||
pCtx[k].isAggSet = false;
|
||||
}
|
||||
|
||||
if (fmIsWindowPseudoColumnFunc(pCtx[k].functionId)) {
|
||||
SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[k]);
|
||||
char* p = GET_ROWCELL_INTERBUF(pEntryInfo);
|
||||
|
||||
SScalarParam out = {.columnData = NULL};
|
||||
out.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
out.columnData->info.type = TSDB_DATA_TYPE_BIGINT;
|
||||
out.columnData->info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
|
||||
out.columnData->pData = p;
|
||||
pCtx[k].sfp.process(&intervalParam, 1, &out);
|
||||
pEntryInfo->numOfRes = 1;
|
||||
pEntryInfo->hasResult = ',';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (functionNeedToExecute(&pCtx[k])) {
|
||||
pCtx[k].fpSet.process(&pCtx[k]);
|
||||
}
|
||||
|
@ -1054,7 +1096,7 @@ static int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext,
|
|||
int32_t order = pInfo->order;
|
||||
bool ascQuery = (order == TSDB_ORDER_ASC);
|
||||
|
||||
int32_t precision = pInfo->precision;
|
||||
int32_t precision = pInterval->precision;
|
||||
getNextTimeWindow(pInterval, precision, order, pNext);
|
||||
|
||||
// next time window is not in current block
|
||||
|
@ -1489,15 +1531,19 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc
|
|||
}
|
||||
}
|
||||
|
||||
static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock,
|
||||
int32_t tableGroupId) {
|
||||
static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, int32_t tableGroupId) {
|
||||
STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*)pOperatorInfo->info;
|
||||
|
||||
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
|
||||
int32_t numOfOutput = pOperatorInfo->numOfOutput;
|
||||
|
||||
SArray* pUpdated = NULL;
|
||||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||
pUpdated = taosArrayInit(4, sizeof(SResultRowPosition));
|
||||
}
|
||||
|
||||
int32_t step = 1;
|
||||
bool ascQuery = true;
|
||||
bool ascScan = true;
|
||||
|
||||
int32_t prevIndex = pResultRowInfo->curPos;
|
||||
|
||||
|
@ -1509,10 +1555,10 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey);
|
||||
}
|
||||
|
||||
int32_t startPos = ascQuery ? 0 : (pSDataBlock->info.rows - 1);
|
||||
TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascQuery);
|
||||
int32_t startPos = ascScan? 0 : (pSDataBlock->info.rows - 1);
|
||||
TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascScan);
|
||||
|
||||
STimeWindow win = getActiveTimeWindow(pResultRowInfo, ts, &pInfo->interval, pInfo->precision, &pInfo->win);
|
||||
STimeWindow win = getActiveTimeWindow(pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win);
|
||||
bool masterScan = true;
|
||||
|
||||
SResultRow* pResult = NULL;
|
||||
|
@ -1523,6 +1569,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
taosArrayPush(pUpdated, &pos);
|
||||
}
|
||||
|
||||
int32_t forwardStep = 0;
|
||||
TSKEY ekey = win.ekey;
|
||||
forwardStep =
|
||||
|
@ -1534,8 +1585,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already.
|
||||
SResultRow* pRes = getResultRow(pResultRowInfo, j);
|
||||
if (pRes->closed) {
|
||||
assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) &&
|
||||
resultRowInterpolated(pRes, RESULT_ROW_END_INTERP));
|
||||
assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && resultRowInterpolated(pRes, RESULT_ROW_END_INTERP));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1548,14 +1598,13 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
}
|
||||
|
||||
assert(!resultRowInterpolated(pResult, RESULT_ROW_END_INTERP));
|
||||
|
||||
doTimeWindowInterpolation(pOperatorInfo, &pInfo->binfo, pSDataBlock->pDataBlock, *(TSKEY*)pInfo->pRow[0], -1,
|
||||
tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP);
|
||||
|
||||
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
|
||||
setNotInterpoWindowKey(pInfo->binfo.pCtx, pOperatorInfo->numOfOutput, RESULT_ROW_START_INTERP);
|
||||
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &w, startPos, 0, tsCols, pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &w, &pInfo->timeWindowData, startPos, 0, tsCols, pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||
}
|
||||
|
||||
// restore current time window
|
||||
|
@ -1570,8 +1619,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
// window start key interpolation
|
||||
doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &win, startPos, forwardStep,
|
||||
pInfo->order, false);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &win, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput,
|
||||
TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &win, &pInfo->timeWindowData, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||
|
||||
STimeWindow nextWin = win;
|
||||
while (1) {
|
||||
|
@ -1589,6 +1637,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
taosArrayPush(pUpdated, &pos);
|
||||
}
|
||||
|
||||
ekey = nextWin.ekey; // reviseWindowEkey(pQueryAttr, &nextWin);
|
||||
forwardStep =
|
||||
getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
||||
|
@ -1596,15 +1649,15 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
// window start(end) key interpolation
|
||||
doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &nextWin, startPos, forwardStep,
|
||||
pInfo->order, false);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &nextWin, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput,
|
||||
TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &nextWin, &pInfo->timeWindowData, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||
}
|
||||
|
||||
if (pInfo->timeWindowInterpo) {
|
||||
int32_t rowIndex = ascQuery ? (pSDataBlock->info.rows - 1) : 0;
|
||||
int32_t rowIndex = ascScan ? (pSDataBlock->info.rows - 1) : 0;
|
||||
saveDataBlockLastRow(pInfo->pRow, pSDataBlock->pDataBlock, rowIndex, pSDataBlock->info.numOfCols);
|
||||
}
|
||||
|
||||
return pUpdated;
|
||||
// updateResultRowInfoActiveIndex(pResultRowInfo, &pInfo->win, pRuntimeEnv->current->lastKey, true, false);
|
||||
}
|
||||
|
||||
|
@ -1841,7 +1894,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
}
|
||||
|
||||
int32_t rowIndex = j - num;
|
||||
doApplyFunctions(pCtx, &w, rowIndex, num, NULL, pBlock->info.rows, pOperator->numOfOutput, TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pCtx, &w, NULL, rowIndex, num, NULL, pBlock->info.rows, pOperator->numOfOutput, TSDB_ORDER_ASC);
|
||||
|
||||
// assign the group keys or user input constant values if required
|
||||
doAssignGroupKeys(pCtx, pOperator->numOfOutput, pBlock->info.rows, rowIndex);
|
||||
|
@ -1859,7 +1912,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
}
|
||||
|
||||
int32_t rowIndex = pBlock->info.rows - num;
|
||||
doApplyFunctions(pCtx, &w, rowIndex, num, NULL, pBlock->info.rows, pOperator->numOfOutput, TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pCtx, &w, NULL, rowIndex, num, NULL, pBlock->info.rows, pOperator->numOfOutput, TSDB_ORDER_ASC);
|
||||
doAssignGroupKeys(pCtx, pOperator->numOfOutput, pBlock->info.rows, rowIndex);
|
||||
}
|
||||
}
|
||||
|
@ -1910,8 +1963,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
|||
}
|
||||
|
||||
// pInfo->numOfRows data belong to the current session window
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &window, pInfo->start, pInfo->numOfRows, NULL, pBlock->info.rows, numOfOutput,
|
||||
TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &window, NULL, pInfo->start, pInfo->numOfRows, NULL, pBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||
|
||||
pInfo->curWindow.skey = tsList[j];
|
||||
pInfo->curWindow.ekey = tsList[j];
|
||||
|
@ -1931,8 +1983,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
|||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &window, pInfo->start, pInfo->numOfRows, NULL, pBlock->info.rows, numOfOutput,
|
||||
TSDB_ORDER_ASC);
|
||||
doApplyFunctions(pInfo->binfo.pCtx, &window, NULL, pInfo->start, pInfo->numOfRows, NULL, pBlock->info.rows, numOfOutput, TSDB_ORDER_ASC);
|
||||
}
|
||||
|
||||
static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
|
||||
|
@ -1999,11 +2050,7 @@ static bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (functionId == FUNCTION_TS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isRowEntryCompleted(pResInfo) || functionId == FUNCTION_TAG_DUMMY || functionId == FUNCTION_TS_DUMMY) {
|
||||
if (isRowEntryCompleted(pResInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2118,6 +2165,9 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
|
|||
pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
|
||||
} else {
|
||||
fmGetScalarFuncExecFuncs(pCtx->functionId, &pCtx->sfp);
|
||||
if (pCtx->sfp.getEnv != NULL) {
|
||||
pCtx->sfp.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
|
||||
}
|
||||
}
|
||||
pCtx->resDataInfo.interBufSize = env.calcMemSize;
|
||||
} else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN) {
|
||||
|
@ -3590,6 +3640,42 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD
|
|||
}
|
||||
}
|
||||
|
||||
void finalizeUpdatedResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SArray* pUpdateList,
|
||||
int32_t* rowCellInfoOffset) {
|
||||
size_t num = taosArrayGetSize(pUpdateList);
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SResultRowPosition* pPos = taosArrayGet(pUpdateList, i);
|
||||
|
||||
SFilePage* bufPage = getBufPage(pBuf, pPos->pageId);
|
||||
SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->offset);
|
||||
|
||||
for (int32_t j = 0; j < numOfOutput; ++j) {
|
||||
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset);
|
||||
|
||||
struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo;
|
||||
if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pCtx[j].fpSet.process) { // TODO set the dummy function.
|
||||
pCtx[j].fpSet.finalize(&pCtx[j]);
|
||||
}
|
||||
|
||||
if (pRow->numOfRows < pResInfo->numOfRes) {
|
||||
pRow->numOfRows = pResInfo->numOfRes;
|
||||
}
|
||||
}
|
||||
|
||||
releaseBufPage(pBuf, bufPage);
|
||||
/*
|
||||
* set the number of output results for group by normal columns, the number of output rows usually is 1 except
|
||||
* the top and bottom query
|
||||
*/
|
||||
// buf->numOfRows = (uint16_t)getNumOfResult(pCtx, numOfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
static bool hasMainOutput(STaskAttr* pQueryAttr) {
|
||||
for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) {
|
||||
int32_t functionId = getExprFunctionId(&pQueryAttr->pExpr1[i]);
|
||||
|
@ -3680,7 +3766,6 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv* pRuntimeEnv, SResultRow* pRes
|
|||
|
||||
void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx,
|
||||
int32_t numOfOutput, int32_t* rowCellInfoOffset) {
|
||||
// Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset);
|
||||
|
||||
|
@ -3688,6 +3773,11 @@ void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, S
|
|||
if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fmIsWindowPseudoColumnFunc(pCtx[i].functionId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// int32_t functionId = pCtx[i].functionId;
|
||||
// if (functionId < 0) {
|
||||
// continue;
|
||||
|
@ -4032,8 +4122,7 @@ static void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDa
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t orderType =
|
||||
TSDB_ORDER_ASC; //(pQueryAttr->pGroupbyExpr != NULL) ? pQueryAttr->pGroupbyExpr->orderType : TSDB_ORDER_ASC;
|
||||
int32_t orderType = TSDB_ORDER_ASC;
|
||||
doCopyToSDataBlock(pBuf, pGroupResInfo, orderType, pBlock, rowCapacity, rowCellOffset);
|
||||
|
||||
// add condition (pBlock->info.rows >= 1) just to runtime happy
|
||||
|
@ -5074,12 +5163,12 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
|||
for (int32_t i = 0; i < totalSources; ++i) {
|
||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
||||
|
||||
if (pDataInfo->status == DATA_EXHAUSTED) {
|
||||
if (pDataInfo->status == EX_SOURCE_DATA_EXHAUSTED) {
|
||||
completed += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pDataInfo->status != DATA_READY) {
|
||||
if (pDataInfo->status != EX_SOURCE_DATA_READY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -5093,7 +5182,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
|||
" try next",
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, i + 1, pDataInfo->totalRows,
|
||||
pExchangeInfo->loadInfo.totalRows);
|
||||
pDataInfo->status = DATA_EXHAUSTED;
|
||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||
completed += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -5111,16 +5200,15 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
|||
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pDataInfo->totalRows,
|
||||
pLoadInfo->totalRows, pLoadInfo->totalSize, i + 1, totalSources);
|
||||
pDataInfo->status = DATA_EXHAUSTED;
|
||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||
} else {
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64
|
||||
", totalBytes:%" PRIu64,
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64 ", totalBytes:%" PRIu64,
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pLoadInfo->totalRows,
|
||||
pLoadInfo->totalSize);
|
||||
}
|
||||
|
||||
if (pDataInfo->status != DATA_EXHAUSTED) {
|
||||
pDataInfo->status = DATA_NOT_READY;
|
||||
if (pDataInfo->status != EX_SOURCE_DATA_EXHAUSTED) {
|
||||
pDataInfo->status = EX_SOURCE_DATA_NOT_READY;
|
||||
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
@ -5223,7 +5311,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
|||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1,
|
||||
pDataInfo->totalRows, pLoadInfo->totalRows);
|
||||
|
||||
pDataInfo->status = DATA_EXHAUSTED;
|
||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||
pExchangeInfo->current += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -5240,7 +5328,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
|||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pRes->info.rows, pDataInfo->totalRows,
|
||||
pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1, totalSources);
|
||||
|
||||
pDataInfo->status = DATA_EXHAUSTED;
|
||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||
pExchangeInfo->current += 1;
|
||||
} else {
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, totalRows:%" PRIu64
|
||||
|
@ -6798,37 +6886,6 @@ static SSDataBlock* doLimit(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
return pBlock;
|
||||
}
|
||||
|
||||
static SSDataBlock* doFilter(void* param, bool* newgroup) {
|
||||
SOperatorInfo* pOperator = (SOperatorInfo*)param;
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SFilterOperatorInfo* pCondInfo = pOperator->info;
|
||||
STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
|
||||
|
||||
while (1) {
|
||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||
SSDataBlock* pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup);
|
||||
publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||
|
||||
if (pBlock == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
doSetFilterColumnInfo(pCondInfo->pFilterInfo, pCondInfo->numOfFilterCols, pBlock);
|
||||
assert(pRuntimeEnv->pTsBuf == NULL);
|
||||
filterRowsInDataBlock(pRuntimeEnv, pCondInfo->pFilterInfo, pCondInfo->numOfFilterCols, pBlock, true);
|
||||
|
||||
if (pBlock->info.rows > 0) {
|
||||
return pBlock;
|
||||
}
|
||||
}
|
||||
|
||||
doSetOperatorCompleted(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||
if (OPTR_IS_OPENED(pOperator)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -6837,8 +6894,8 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
|||
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
||||
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
// STimeWindow win = pQueryAttr->window;
|
||||
bool newgroup = false;
|
||||
// STimeWindow win = {0};
|
||||
bool newgroup = false;
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
|
||||
while (1) {
|
||||
|
@ -6851,7 +6908,6 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
||||
|
||||
// the pDataBlock are always the same one, no need to call this again
|
||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
||||
|
@ -6874,6 +6930,10 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||
return pOperator->getStreamResFn(pOperator, newgroup);
|
||||
}
|
||||
|
||||
pTaskInfo->code = pOperator->_openFn(pOperator);
|
||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||
return NULL;
|
||||
|
@ -6890,7 +6950,60 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
|
|||
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||
}
|
||||
|
||||
static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) {
|
||||
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) {
|
||||
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity,
|
||||
pInfo->binfo.rowCellInfoOffset);
|
||||
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
}
|
||||
return pInfo->binfo.pRes;
|
||||
}
|
||||
|
||||
// STimeWindow win = {0};
|
||||
*newgroup = false;
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
|
||||
SArray* pUpdated = NULL;
|
||||
|
||||
while (1) {
|
||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||
|
||||
if (pBlock == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
// The timewindows that overlaps the timestamps of the input pBlock need to be recalculated and return to the caller.
|
||||
// Note that all the time window are not close till now.
|
||||
|
||||
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
||||
// the pDataBlock are always the same one, no need to call this again
|
||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
||||
pUpdated = hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
||||
}
|
||||
|
||||
finalizeUpdatedResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, pUpdated, pInfo->binfo.rowCellInfoOffset);
|
||||
|
||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity,
|
||||
pInfo->binfo.rowCellInfoOffset);
|
||||
|
||||
ASSERT(pInfo->binfo.pRes->info.rows > 0);
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
|
||||
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||
}
|
||||
|
||||
static SSDataBlock* doAllIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) {
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -7514,8 +7627,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
|
||||
//(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery));
|
||||
int32_t numOfRows = 1;
|
||||
int32_t code =
|
||||
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, pTaskInfo->id.str);
|
||||
int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, pTaskInfo->id.str);
|
||||
pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) {
|
||||
goto _error;
|
||||
|
@ -7523,18 +7635,18 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
|
||||
setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo);
|
||||
|
||||
pOperator->name = "TableAggregate";
|
||||
pOperator->name = "TableAggregate";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG;
|
||||
pOperator->blockingOptr = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfOutput = numOfCols;
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->_openFn = doOpenAggregateOptr;
|
||||
pOperator->getNextFn = getAggregateResult;
|
||||
pOperator->closeFn = destroyAggOperatorInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->_openFn = doOpenAggregateOptr;
|
||||
pOperator->getNextFn = getAggregateResult;
|
||||
pOperator->closeFn = destroyAggOperatorInfo;
|
||||
pOperator->encodeResultRow = aggEncodeResultRow;
|
||||
pOperator->decodeResultRow = aggDecodeResultRow;
|
||||
|
||||
|
@ -7711,16 +7823,16 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
|
|||
// initResultRowInfo(&pBInfo->resultRowInfo, 8);
|
||||
// setFunctionResultOutput(pBInfo, MAIN_SCAN);
|
||||
|
||||
pOperator->name = "ProjectOperator";
|
||||
pOperator->name = "ProjectOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT;
|
||||
pOperator->blockingOptr = false;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfOutput = num;
|
||||
pOperator->_openFn = operatorDummyOpenFn;
|
||||
pOperator->getNextFn = doProjectOperation;
|
||||
pOperator->closeFn = destroyProjectOperatorInfo;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfOutput = num;
|
||||
pOperator->_openFn = operatorDummyOpenFn;
|
||||
pOperator->getNextFn = doProjectOperation;
|
||||
pOperator->closeFn = destroyProjectOperatorInfo;
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
@ -7735,39 +7847,6 @@ _error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int32_t* numOfFilterCols) {
|
||||
#if 0
|
||||
SColumnInfo* pCols = taosMemoryCalloc(numOfOutput, sizeof(SColumnInfo));
|
||||
|
||||
int32_t numOfFilter = 0;
|
||||
for(int32_t i = 0; i < numOfOutput; ++i) {
|
||||
if (pExpr[i].base.flist.numOfFilters > 0) {
|
||||
numOfFilter += 1;
|
||||
}
|
||||
|
||||
pCols[i].type = pExpr[i].base.resSchema.type;
|
||||
pCols[i].bytes = pExpr[i].base.resSchema.bytes;
|
||||
pCols[i].colId = pExpr[i].base.resSchema.colId;
|
||||
|
||||
pCols[i].flist.numOfFilters = pExpr[i].base.flist.numOfFilters;
|
||||
if (pCols[i].flist.numOfFilters != 0) {
|
||||
pCols[i].flist.filterInfo = taosMemoryCalloc(pCols[i].flist.numOfFilters, sizeof(SColumnFilterInfo));
|
||||
memcpy(pCols[i].flist.filterInfo, pExpr[i].base.flist.filterInfo, pCols[i].flist.numOfFilters * sizeof(SColumnFilterInfo));
|
||||
} else {
|
||||
// avoid runtime error
|
||||
pCols[i].flist.filterInfo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
assert(numOfFilter > 0);
|
||||
|
||||
*numOfFilterCols = numOfFilter;
|
||||
return pCols;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo) {
|
||||
SLimitOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SLimitOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
|
@ -7778,17 +7857,18 @@ SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, SLimit* pLimit
|
|||
pInfo->limit = *pLimit;
|
||||
pInfo->currentOffset = pLimit->offset;
|
||||
|
||||
pOperator->name = "LimitOperator";
|
||||
pOperator->name = "LimitOperator";
|
||||
// pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LIMIT;
|
||||
pOperator->blockingOptr = false;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->_openFn = operatorDummyOpenFn;
|
||||
pOperator->getNextFn = doLimit;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->_openFn = operatorDummyOpenFn;
|
||||
pOperator->getNextFn = doLimit;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
|
@ -7805,17 +7885,18 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->precision = TSDB_TIME_PRECISION_MILLI;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->execModel = pTaskInfo->execModel;
|
||||
|
||||
pInfo->win.skey = INT64_MIN;
|
||||
pInfo->win.ekey = INT64_MAX;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->win.skey = 0;
|
||||
pInfo->win.ekey = INT64_MAX;
|
||||
|
||||
int32_t numOfRows = 4096;
|
||||
int32_t code =
|
||||
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str);
|
||||
int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str);
|
||||
initExecTimeWindowInfo(&pInfo->timeWindowData, &pInfo->win);
|
||||
|
||||
// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
||||
if (code != TSDB_CODE_SUCCESS /* || pInfo->pTableQueryInfo == NULL*/) {
|
||||
goto _error;
|
||||
|
@ -7823,17 +7904,18 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
|
||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1);
|
||||
|
||||
pOperator->name = "TimeIntervalAggOperator";
|
||||
pOperator->name = "TimeIntervalAggOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERVAL;
|
||||
pOperator->blockingOptr = true;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->_openFn = doOpenIntervalAgg;
|
||||
pOperator->getNextFn = doBuildIntervalResult;
|
||||
pOperator->closeFn = destroyIntervalOperatorInfo;
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
pOperator->_openFn = doOpenIntervalAgg;
|
||||
pOperator->getNextFn = doBuildIntervalResult;
|
||||
pOperator->getStreamResFn= doStreamIntervalAgg;
|
||||
pOperator->closeFn = destroyIntervalOperatorInfo;
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -8555,6 +8637,23 @@ static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, i
|
|||
return s;
|
||||
}
|
||||
|
||||
static SColumn* createColumn(int32_t blockId, int32_t slotId, SDataType* pType) {
|
||||
SColumn* pCol = taosMemoryCalloc(1, sizeof(SColumn));
|
||||
if (pCol == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pCol->slotId = slotId;
|
||||
pCol->bytes = pType->bytes;
|
||||
pCol->type = pType->type;
|
||||
pCol->scale = pType->scale;
|
||||
pCol->precision = pType->precision;
|
||||
pCol->dataBlockId = blockId;
|
||||
|
||||
return pCol;
|
||||
}
|
||||
|
||||
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs) {
|
||||
int32_t numOfFuncs = LIST_LENGTH(pNodeList);
|
||||
int32_t numOfGroupKeys = 0;
|
||||
|
@ -8586,18 +8685,11 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
|
||||
pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||
pExp->base.numOfParams = 1;
|
||||
pExp->base.pParam[0].pCol = taosMemoryCalloc(1, sizeof(SColumn));
|
||||
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
|
||||
SDataType* pType = &pColNode->node.resType;
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pColNode->colName);
|
||||
|
||||
SColumn* pCol = pExp->base.pParam[0].pCol;
|
||||
pCol->slotId = pColNode->slotId; // TODO refactor
|
||||
pCol->bytes = pType->bytes;
|
||||
pCol->type = pType->type;
|
||||
pCol->scale = pType->scale;
|
||||
pCol->precision = pType->precision;
|
||||
pExp->base.pParam[0].pCol = createColumn(pColNode->dataBlockId, pColNode->slotId, pType);
|
||||
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
} else if (nodeType(pTargetNode->pExpr) == QUERY_NODE_FUNCTION) {
|
||||
pExp->pExpr->nodeType = QUERY_NODE_FUNCTION;
|
||||
SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr;
|
||||
|
@ -8608,8 +8700,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
|
||||
pExp->pExpr->_function.functionId = pFuncNode->funcId;
|
||||
pExp->pExpr->_function.pFunctNode = pFuncNode;
|
||||
strncpy(pExp->pExpr->_function.functionName, pFuncNode->functionName,
|
||||
tListLen(pExp->pExpr->_function.functionName));
|
||||
strncpy(pExp->pExpr->_function.functionName, pFuncNode->functionName, tListLen(pExp->pExpr->_function.functionName));
|
||||
|
||||
// TODO: value parameter needs to be handled
|
||||
int32_t numOfParam = LIST_LENGTH(pFuncNode->pParameterList);
|
||||
|
@ -8620,21 +8711,12 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
for (int32_t j = 0; j < numOfParam; ++j) {
|
||||
SNode* p1 = nodesListGetNode(pFuncNode->pParameterList, j);
|
||||
if (p1->type == QUERY_NODE_COLUMN) {
|
||||
SColumnNode* pcn = (SColumnNode*)p1; // TODO refactor
|
||||
SColumnNode* pcn = (SColumnNode*) p1;
|
||||
|
||||
pExp->base.pParam[j].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
pExp->base.pParam[j].pCol = taosMemoryCalloc(1, sizeof(SColumn));
|
||||
SColumn* pCol = pExp->base.pParam[j].pCol;
|
||||
|
||||
pCol->slotId = pcn->slotId;
|
||||
pCol->bytes = pcn->node.resType.bytes;
|
||||
pCol->type = pcn->node.resType.type;
|
||||
pCol->scale = pcn->node.resType.scale;
|
||||
pCol->precision = pcn->node.resType.precision;
|
||||
pCol->dataBlockId = pcn->dataBlockId;
|
||||
pExp->base.pParam[j].pCol = createColumn(pcn->dataBlockId, pcn->slotId, &pcn->node.resType);
|
||||
} else if (p1->type == QUERY_NODE_VALUE) {
|
||||
SValueNode* pvn = (SValueNode*)p1;
|
||||
|
||||
pExp->base.pParam[j].type = FUNC_PARAM_TYPE_VALUE;
|
||||
}
|
||||
}
|
||||
|
@ -8644,21 +8726,14 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
|
||||
pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||
pExp->base.numOfParams = 1;
|
||||
pExp->base.pParam[0].pCol = taosMemoryCalloc(1, sizeof(SColumn));
|
||||
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
|
||||
SDataType* pType = &pNode->node.resType;
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
|
||||
pType->precision, pNode->node.aliasName);
|
||||
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pNode->node.aliasName);
|
||||
|
||||
pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr;
|
||||
|
||||
SColumn* pCol = pExp->base.pParam[0].pCol;
|
||||
pCol->slotId = pTargetNode->slotId; // TODO refactor
|
||||
pCol->bytes = pType->bytes;
|
||||
pCol->type = pType->type;
|
||||
pCol->scale = pType->scale;
|
||||
pCol->precision = pType->precision;
|
||||
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
|
||||
pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -8667,12 +8742,13 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
|||
return pExprs;
|
||||
}
|
||||
|
||||
static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId) {
|
||||
static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPTR_EXEC_MODEL model) {
|
||||
SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo));
|
||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||
|
||||
pTaskInfo->cost.created = taosGetTimestampMs();
|
||||
pTaskInfo->id.queryId = queryId;
|
||||
pTaskInfo->execModel = model;
|
||||
|
||||
char* p = taosMemoryCalloc(1, 128);
|
||||
snprintf(p, 128, "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, queryId);
|
||||
|
@ -8692,17 +8768,15 @@ static SArray* extractColumnInfo(SNodeList* pNodeList);
|
|||
static SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols);
|
||||
static SArray* createSortInfo(SNodeList* pNodeList);
|
||||
|
||||
SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
||||
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
||||
uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
|
||||
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pPhyNode)) {
|
||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
tsdbReaderT pDataReader =
|
||||
doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||
SArray* pColList =
|
||||
extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
|
||||
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count,
|
||||
pScanPhyNode->reverse, pColList, pTaskInfo);
|
||||
|
@ -8745,7 +8819,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
assert(size == 1);
|
||||
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0);
|
||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
|
||||
int32_t num = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(((SProjectPhysiNode*)pPhyNode)->pProjections, NULL, &num);
|
||||
|
@ -8757,7 +8831,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
|
||||
int32_t num = 0;
|
||||
|
||||
|
@ -8778,7 +8852,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
|
||||
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
|
||||
|
||||
|
@ -8787,11 +8861,12 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
|
||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||
|
||||
SInterval interval = {.interval = pIntervalPhyNode->interval,
|
||||
.sliding = pIntervalPhyNode->sliding,
|
||||
SInterval interval = {.interval = pIntervalPhyNode->interval,
|
||||
.sliding = pIntervalPhyNode->sliding,
|
||||
.intervalUnit = pIntervalPhyNode->intervalUnit,
|
||||
.slidingUnit = pIntervalPhyNode->slidingUnit,
|
||||
.offset = pIntervalPhyNode->offset};
|
||||
.slidingUnit = pIntervalPhyNode->slidingUnit,
|
||||
.offset = pIntervalPhyNode->offset,
|
||||
.precision = TSDB_TIME_PRECISION_MILLI};
|
||||
return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, &interval, pTableGroupInfo, pTaskInfo);
|
||||
}
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SORT == nodeType(pPhyNode)) {
|
||||
|
@ -8799,7 +8874,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
assert(size == 1);
|
||||
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0);
|
||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
|
||||
SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode;
|
||||
|
||||
|
@ -8811,7 +8886,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
assert(size == 1);
|
||||
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0);
|
||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
|
||||
SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode;
|
||||
|
||||
|
@ -8827,7 +8902,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
|
|||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SPhysiNode* pChildNode = taosArrayGetP(pPhyNode->pChildren, i);
|
||||
SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
||||
return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo);
|
||||
}
|
||||
}*/
|
||||
|
@ -8972,11 +9047,11 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
|||
for (int32_t i = 0; i < num; ++i) {
|
||||
SSlotDescNode* pNode = (SSlotDescNode*)nodesListGetNode(pOutputNodeList->pSlots, i);
|
||||
SColMatchInfo* info = taosArrayGet(pList, pNode->slotId);
|
||||
// if (pNode->output) {
|
||||
(*numOfOutputCols) += 1;
|
||||
// } else {
|
||||
// info->output = false;
|
||||
// }
|
||||
if (pNode->output) {
|
||||
(*numOfOutputCols) += 1;
|
||||
} else {
|
||||
info->output = false;
|
||||
}
|
||||
}
|
||||
|
||||
return pList;
|
||||
|
@ -9034,18 +9109,18 @@ _error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId) {
|
||||
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, EOPTR_EXEC_MODEL model) {
|
||||
uint64_t queryId = pPlan->id.queryId;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
*pTaskInfo = createExecTaskInfo(queryId, taskId);
|
||||
*pTaskInfo = createExecTaskInfo(queryId, taskId, model);
|
||||
if (*pTaskInfo == NULL) {
|
||||
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
goto _complete;
|
||||
}
|
||||
|
||||
STableGroupInfo group = {0};
|
||||
(*pTaskInfo)->pRoot = doCreateOperatorTreeNode(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &group);
|
||||
(*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &group);
|
||||
if (NULL == (*pTaskInfo)->pRoot) {
|
||||
code = terrno;
|
||||
goto _complete;
|
||||
|
|
|
@ -944,7 +944,7 @@ TEST(testCase, build_executor_tree_Test) {
|
|||
int32_t code = qStringToSubplan(msg, &plan);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
code = qCreateExecTask(&handle, 2, 1, plan, (void**) &pTaskInfo, &sinkHandle);
|
||||
code = qCreateExecTask(&handle, 2, 1, plan, (void**) &pTaskInfo, &sinkHandle, OPTR_EXEC_MODEL_BATCH);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -315,31 +315,31 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "_qstartts",
|
||||
.type = FUNCTION_TYPE_QSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = stubCheckAndGetResultType,
|
||||
.getEnvFunc = NULL,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.sprocessFunc = qStartTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_qendts",
|
||||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = stubCheckAndGetResultType,
|
||||
.getEnvFunc = NULL,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.sprocessFunc = qEndTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_wstartts",
|
||||
.type = FUNCTION_TYPE_QSTARTTS,
|
||||
.type = FUNCTION_TYPE_WSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = stubCheckAndGetResultType,
|
||||
.getEnvFunc = NULL,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.sprocessFunc = winStartTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
|
@ -347,9 +347,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = stubCheckAndGetResultType,
|
||||
.getEnvFunc = NULL,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.sprocessFunc = winEndTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
|
@ -357,9 +357,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.type = FUNCTION_TYPE_WDURATION,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = stubCheckAndGetResultType,
|
||||
.getEnvFunc = NULL,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.sprocessFunc = winDurFunction,
|
||||
.finalizeFunc = NULL
|
||||
}
|
||||
};
|
||||
|
@ -368,6 +368,7 @@ const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFun
|
|||
|
||||
int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
|
||||
switch(pFunc->funcType) {
|
||||
case FUNCTION_TYPE_WDURATION:
|
||||
case FUNCTION_TYPE_COUNT:
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||
break;
|
||||
|
@ -400,14 +401,18 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
|
|||
}
|
||||
case FUNCTION_TYPE_CONCAT:
|
||||
case FUNCTION_TYPE_ROWTS:
|
||||
case FUNCTION_TYPE_TBNAME:
|
||||
case FUNCTION_TYPE_QSTARTTS:
|
||||
case FUNCTION_TYPE_QENDTS:
|
||||
case FUNCTION_TYPE_WSTARTTS:
|
||||
case FUNCTION_TYPE_WENDTS:
|
||||
case FUNCTION_TYPE_WDURATION:
|
||||
case FUNCTION_TYPE_TBNAME: {
|
||||
// todo
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_QENDTS:
|
||||
case FUNCTION_TYPE_QSTARTTS:
|
||||
case FUNCTION_TYPE_WENDTS:
|
||||
case FUNCTION_TYPE_WSTARTTS: {
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_ABS:
|
||||
case FUNCTION_TYPE_CEIL:
|
||||
|
|
|
@ -92,6 +92,7 @@ int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet) {
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
pFpSet->process = funcMgtBuiltins[funcId].sprocessFunc;
|
||||
pFpSet->getEnv = funcMgtBuiltins[funcId].getEnvFunc;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,42 +116,6 @@ bool exprTreeApplyFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp
|
|||
return param->nodeFilterFn(pItem, pExpr->_node.info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) {
|
||||
tbufWriteUint8(bw, expr->nodeType);
|
||||
|
||||
if (expr->nodeType == TEXPR_VALUE_NODE) {
|
||||
SVariant* pVal = expr->pVal;
|
||||
|
||||
tbufWriteUint32(bw, pVal->nType);
|
||||
if (pVal->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
tbufWriteInt32(bw, pVal->nLen);
|
||||
tbufWrite(bw, pVal->pz, pVal->nLen);
|
||||
} else {
|
||||
tbufWriteInt64(bw, pVal->i);
|
||||
}
|
||||
|
||||
} else if (expr->nodeType == TEXPR_COL_NODE) {
|
||||
SSchema* pSchema = expr->pSchema;
|
||||
tbufWriteInt16(bw, pSchema->colId);
|
||||
tbufWriteInt16(bw, pSchema->bytes);
|
||||
tbufWriteUint8(bw, pSchema->type);
|
||||
tbufWriteString(bw, pSchema->name);
|
||||
|
||||
} else if (expr->nodeType == TEXPR_BINARYEXPR_NODE) {
|
||||
tbufWriteUint8(bw, expr->_node.optr);
|
||||
exprTreeToBinaryImpl(bw, expr->_node.pLeft);
|
||||
exprTreeToBinaryImpl(bw, expr->_node.pRight);
|
||||
}
|
||||
}
|
||||
|
||||
void exprTreeToBinary(SBufferWriter* bw, tExprNode* expr) {
|
||||
if (expr != NULL) {
|
||||
exprTreeToBinaryImpl(bw, expr);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: these three functions should be made global
|
||||
static void* exception_calloc(size_t nmemb, size_t size) {
|
||||
void* p = taosMemoryCalloc(nmemb, size);
|
||||
|
@ -230,97 +194,6 @@ tExprNode* exprTreeFromBinary(const void* data, size_t size) {
|
|||
return exprTreeFromBinaryImpl(&br);
|
||||
}
|
||||
|
||||
tExprNode* exprTreeFromTableName(const char* tbnameCond) {
|
||||
if (!tbnameCond) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t anchor = CLEANUP_GET_ANCHOR();
|
||||
|
||||
tExprNode* expr = exception_calloc(1, sizeof(tExprNode));
|
||||
CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL);
|
||||
|
||||
expr->nodeType = TEXPR_BINARYEXPR_NODE;
|
||||
|
||||
tExprNode* left = exception_calloc(1, sizeof(tExprNode));
|
||||
expr->_node.pLeft = left;
|
||||
|
||||
left->nodeType = TEXPR_COL_NODE;
|
||||
SSchema* pSchema = exception_calloc(1, sizeof(SSchema));
|
||||
left->pSchema = pSchema;
|
||||
|
||||
// *pSchema = NULL;//*tGetTbnameColumnSchema();
|
||||
|
||||
tExprNode* right = exception_calloc(1, sizeof(tExprNode));
|
||||
expr->_node.pRight = right;
|
||||
|
||||
if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_LIKE, QUERY_COND_REL_PREFIX_LIKE_LEN) == 0) {
|
||||
right->nodeType = TEXPR_VALUE_NODE;
|
||||
expr->_node.optr = OP_TYPE_LIKE;
|
||||
SVariant* pVal = exception_calloc(1, sizeof(SVariant));
|
||||
right->pVal = pVal;
|
||||
size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN) + 1;
|
||||
pVal->pz = exception_malloc(len);
|
||||
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN, len);
|
||||
pVal->nType = TSDB_DATA_TYPE_BINARY;
|
||||
pVal->nLen = (int32_t)len;
|
||||
|
||||
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_MATCH, QUERY_COND_REL_PREFIX_MATCH_LEN) == 0) {
|
||||
right->nodeType = TEXPR_VALUE_NODE;
|
||||
expr->_node.optr = OP_TYPE_MATCH;
|
||||
SVariant* pVal = exception_calloc(1, sizeof(SVariant));
|
||||
right->pVal = pVal;
|
||||
size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN) + 1;
|
||||
pVal->pz = exception_malloc(len);
|
||||
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN, len);
|
||||
pVal->nType = TSDB_DATA_TYPE_BINARY;
|
||||
pVal->nLen = (int32_t)len;
|
||||
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_NMATCH, QUERY_COND_REL_PREFIX_NMATCH_LEN) == 0) {
|
||||
right->nodeType = TEXPR_VALUE_NODE;
|
||||
expr->_node.optr = OP_TYPE_NMATCH;
|
||||
SVariant* pVal = exception_calloc(1, sizeof(SVariant));
|
||||
right->pVal = pVal;
|
||||
size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN) + 1;
|
||||
pVal->pz = exception_malloc(len);
|
||||
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN, len);
|
||||
pVal->nType = TSDB_DATA_TYPE_BINARY;
|
||||
pVal->nLen = (int32_t)len;
|
||||
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN) == 0) {
|
||||
right->nodeType = TEXPR_VALUE_NODE;
|
||||
expr->_node.optr = OP_TYPE_IN;
|
||||
SVariant* pVal = exception_calloc(1, sizeof(SVariant));
|
||||
right->pVal = pVal;
|
||||
pVal->nType = TSDB_DATA_TYPE_POINTER_ARRAY;
|
||||
pVal->arr = taosArrayInit(2, POINTER_BYTES);
|
||||
|
||||
const char* cond = tbnameCond + QUERY_COND_REL_PREFIX_IN_LEN;
|
||||
for (const char *e = cond; *e != 0; e++) {
|
||||
if (*e == TS_PATH_DELIMITER[0]) {
|
||||
cond = e + 1;
|
||||
} else if (*e == ',') {
|
||||
size_t len = e - cond;
|
||||
char* p = exception_malloc(len + VARSTR_HEADER_SIZE);
|
||||
STR_WITH_SIZE_TO_VARSTR(p, cond, (VarDataLenT)len);
|
||||
cond += len;
|
||||
taosArrayPush(pVal->arr, &p);
|
||||
}
|
||||
}
|
||||
|
||||
if (*cond != 0) {
|
||||
size_t len = strlen(cond) + VARSTR_HEADER_SIZE;
|
||||
|
||||
char* p = exception_malloc(len);
|
||||
STR_WITH_SIZE_TO_VARSTR(p, cond, (VarDataLenT)(len - VARSTR_HEADER_SIZE));
|
||||
taosArrayPush(pVal->arr, &p);
|
||||
}
|
||||
|
||||
taosArraySortString(pVal->arr, taosArrayCompareString);
|
||||
}
|
||||
|
||||
CLEANUP_EXECUTE_TO(anchor, false);
|
||||
return expr;
|
||||
}
|
||||
|
||||
void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
|
||||
SBufferReader br = tbufInitReader(buf, len, false);
|
||||
uint32_t type = tbufReadUint32(&br);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#include "tunaryoperator.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO dynamic define these functions
|
||||
//_unary_scalar_fn_t getUnaryScalarOperatorFn(int32_t operator) {
|
||||
// assert(0);
|
||||
//}
|
||||
|
||||
//bool isStringOperatorFn(int32_t op) {
|
||||
// return op == FUNCTION_LENGTH;
|
||||
//}
|
|
@ -82,6 +82,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(STableOptions));
|
||||
case QUERY_NODE_INDEX_OPTIONS:
|
||||
return makeNode(type, sizeof(SIndexOptions));
|
||||
case QUERY_NODE_EXPLAIN_OPTIONS:
|
||||
return makeNode(type, sizeof(SExplainOptions));
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return makeNode(type, sizeof(SSetOperator));
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -132,6 +134,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SCreateTopicStmt));
|
||||
case QUERY_NODE_DROP_TOPIC_STMT:
|
||||
return makeNode(type, sizeof(SDropTopicStmt));
|
||||
case QUERY_NODE_EXPLAIN_STMT:
|
||||
return makeNode(type, sizeof(SExplainStmt));
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
|
|
|
@ -159,6 +159,10 @@ SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId);
|
|||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName);
|
||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName);
|
||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
||||
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
||||
SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal);
|
||||
SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal);
|
||||
SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -339,6 +339,18 @@ cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C).
|
|||
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); }
|
||||
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
|
||||
|
||||
/************************************************ select **************************************************************/
|
||||
cmd ::= EXPLAIN analyze_opt(A) explain_options(B) query_expression(C). { pCxt->pRootNode = createExplainStmt(pCxt, A, B, C); }
|
||||
|
||||
%type analyze_opt { bool }
|
||||
%destructor analyze_opt { }
|
||||
analyze_opt(A) ::= . { A = false; }
|
||||
analyze_opt(A) ::= ANALYZE. { A = true; }
|
||||
|
||||
explain_options(A) ::= . { A = createDefaultExplainOptions(pCxt); }
|
||||
explain_options(A) ::= explain_options(B) VERBOSE NK_BOOL(C). { A = setExplainVerbose(pCxt, B, &C); }
|
||||
explain_options(A) ::= explain_options(B) RATIO NK_FLOAT(C). { A = setExplainRatio(pCxt, B, &C); }
|
||||
|
||||
/************************************************ select **************************************************************/
|
||||
cmd ::= query_expression(A). { pCxt->pRootNode = A; }
|
||||
|
||||
|
|
|
@ -1316,3 +1316,30 @@ SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, cons
|
|||
}
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt) {
|
||||
SExplainOptions* pOptions = nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->verbose = TSDB_DEFAULT_EXPLAIN_VERBOSE;
|
||||
pOptions->ratio = TSDB_DEFAULT_EXPLAIN_RATIO;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal) {
|
||||
((SExplainOptions*)pOptions)->verbose = (0 == strncasecmp(pVal->z, "true", pVal->n));
|
||||
return pOptions;
|
||||
}
|
||||
|
||||
SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal) {
|
||||
((SExplainOptions*)pOptions)->ratio = strtod(pVal->z, NULL);
|
||||
return pOptions;
|
||||
}
|
||||
|
||||
SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery) {
|
||||
SExplainStmt* pStmt = nodesMakeNode(QUERY_NODE_EXPLAIN_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->analyze = analyze;
|
||||
pStmt->pOptions = (SExplainOptions*)pOptions;
|
||||
pStmt->pQuery = pQuery;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ static SKeyword keywordTable[] = {
|
|||
{"ACCOUNT", TK_ACCOUNT},
|
||||
{"ALL", TK_ALL},
|
||||
{"ALTER", TK_ALTER},
|
||||
{"ANALYZE", TK_ANALYZE},
|
||||
{"AND", TK_AND},
|
||||
{"AS", TK_AS},
|
||||
{"ASC", TK_ASC},
|
||||
|
@ -56,6 +57,7 @@ static SKeyword keywordTable[] = {
|
|||
{"DOUBLE", TK_DOUBLE},
|
||||
{"DROP", TK_DROP},
|
||||
{"EXISTS", TK_EXISTS},
|
||||
{"EXPLAIN", TK_EXPLAIN},
|
||||
{"FILE_FACTOR", TK_FILE_FACTOR},
|
||||
{"FILL", TK_FILL},
|
||||
{"FLOAT", TK_FLOAT},
|
||||
|
@ -110,6 +112,7 @@ static SKeyword keywordTable[] = {
|
|||
{"QNODES", TK_QNODES},
|
||||
{"QSTARTTS", TK_QSTARTTS},
|
||||
{"QUORUM", TK_QUORUM},
|
||||
{"RATIO", TK_RATIO},
|
||||
{"REPLICA", TK_REPLICA},
|
||||
{"RETENTIONS", TK_RETENTIONS},
|
||||
{"ROLLUP", TK_ROLLUP},
|
||||
|
@ -144,6 +147,7 @@ static SKeyword keywordTable[] = {
|
|||
{"USING", TK_USING},
|
||||
{"VALUES", TK_VALUES},
|
||||
{"VARCHAR", TK_VARCHAR},
|
||||
{"VERBOSE", TK_VERBOSE},
|
||||
{"VGROUPS", TK_VGROUPS},
|
||||
{"WAL", TK_WAL},
|
||||
{"WDURATION", TK_WDURATION},
|
||||
|
@ -224,7 +228,6 @@ static SKeyword keywordTable[] = {
|
|||
// {"DETACH", TK_DETACH},
|
||||
// {"EACH", TK_EACH},
|
||||
// {"END", TK_END},
|
||||
// {"EXPLAIN", TK_EXPLAIN},
|
||||
// {"FAIL", TK_FAIL},
|
||||
// {"FOR", TK_FOR},
|
||||
// {"IGNORE", TK_IGNORE},
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct STranslateContext {
|
|||
SCmdMsgInfo* pCmdMsg;
|
||||
SHashObj* pDbs;
|
||||
SHashObj* pTables;
|
||||
SExplainOptions* pExplainOpt;
|
||||
} STranslateContext;
|
||||
|
||||
typedef struct SFullDatabaseName {
|
||||
|
@ -673,6 +674,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
switch (nodeType(pTable)) {
|
||||
case QUERY_NODE_REAL_TABLE: {
|
||||
SRealTableNode* pRealTable = (SRealTableNode*)pTable;
|
||||
pRealTable->ratio = (NULL != pCxt->pExplainOpt ? pCxt->pExplainOpt->ratio : 1.0);
|
||||
SName name;
|
||||
code = getTableMetaImpl(pCxt,
|
||||
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta));
|
||||
|
@ -680,10 +682,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName);
|
||||
}
|
||||
code = setTableVgroupList(pCxt, &name, pRealTable);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addNamespace(pCxt, pRealTable);
|
||||
}
|
||||
code = addNamespace(pCxt, pRealTable);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_TEMP_TABLE: {
|
||||
|
@ -1804,6 +1805,13 @@ static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pSt
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateExplain(STranslateContext* pCxt, SExplainStmt* pStmt) {
|
||||
if (pStmt->analyze) {
|
||||
pCxt->pExplainOpt = pStmt->pOptions;
|
||||
}
|
||||
return translateQuery(pCxt, pStmt->pQuery);
|
||||
}
|
||||
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pNode)) {
|
||||
|
@ -1885,6 +1893,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||
code = translateAlterLocal(pCxt, (SAlterLocalStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_EXPLAIN_STMT:
|
||||
code = translateExplain(pCxt, (SExplainStmt*)pNode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1903,7 +1914,11 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
|
|||
}
|
||||
|
||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
||||
if (NULL != pRoot && QUERY_NODE_SELECT_STMT == nodeType(pRoot)) {
|
||||
if (NULL == pRoot) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pRoot)) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*) pRoot;
|
||||
*numOfCols = LIST_LENGTH(pSelect->pProjectionList);
|
||||
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||
|
@ -1921,6 +1936,14 @@ int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** p
|
|||
strcpy((*pSchema)[index].name, pExpr->aliasName);
|
||||
index +=1;
|
||||
}
|
||||
} else if (QUERY_NODE_EXPLAIN_STMT == nodeType(pRoot)) {
|
||||
*numOfCols = 1;
|
||||
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||
if (NULL == (*pSchema)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(*pSchema)[0].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2505,6 +2528,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
switch (nodeType(pQuery->pRoot)) {
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
case QUERY_NODE_EXPLAIN_STMT:
|
||||
pQuery->haveResultSet = true;
|
||||
pQuery->directRpc = false;
|
||||
pQuery->msgType = TDMT_VND_QUERY;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -647,3 +647,16 @@ TEST_F(ParserTest, dropTopic) {
|
|||
bind("drop topic if exists tp1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, explain) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("explain SELECT * FROM t1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("explain analyze SELECT * FROM t1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("explain analyze verbose true ratio 0.01 SELECT * FROM t1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
|
|
@ -197,6 +197,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
|||
strcpy(pScan->tableName.dbname, pRealTable->table.dbName);
|
||||
strcpy(pScan->tableName.tname, pRealTable->table.tableName);
|
||||
pScan->showRewrite = pCxt->pPlanCxt->showRewrite;
|
||||
pScan->ratio = pRealTable->ratio;
|
||||
|
||||
// set columns to scan
|
||||
SNodeList* pCols = NULL;
|
||||
|
@ -704,6 +705,8 @@ static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogi
|
|||
return createSelectLogicNode(pCxt, (SSelectStmt*)pStmt, pLogicNode);
|
||||
case QUERY_NODE_VNODE_MODIF_STMT:
|
||||
return createVnodeModifLogicNode(pCxt, (SVnodeModifOpStmt*)pStmt, pLogicNode);
|
||||
case QUERY_NODE_EXPLAIN_STMT:
|
||||
return createQueryLogicNode(pCxt, ((SExplainStmt*)pStmt)->pQuery, pLogicNode);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -398,6 +398,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
|||
|
||||
pTableScan->scanFlag = pScanLogicNode->scanFlag;
|
||||
pTableScan->scanRange = pScanLogicNode->scanRange;
|
||||
pTableScan->ratio = pScanLogicNode->ratio;
|
||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
||||
pSubplan->execNodeStat.tableNum = pScanLogicNode->pVgroupList->vgroups[0].numOfTable;
|
||||
|
@ -1095,6 +1096,16 @@ static void destoryPhysiPlanContext(SPhysiPlanContext* pCxt) {
|
|||
taosArrayDestroyEx(pCxt->pLocationHelper, destoryLocationHash);
|
||||
}
|
||||
|
||||
static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
||||
if (QUERY_NODE_EXPLAIN_STMT == nodeType(pCxt->pAstRoot)) {
|
||||
SExplainStmt* pStmt = (SExplainStmt*)pCxt->pAstRoot;
|
||||
pPlan->explainInfo.mode = pStmt->analyze ? EXPLAIN_MODE_ANALYZE : EXPLAIN_MODE_STATIC;
|
||||
pPlan->explainInfo.verbose = pStmt->pOptions->verbose;
|
||||
} else {
|
||||
pPlan->explainInfo.mode = EXPLAIN_MODE_DISABLE;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan, SArray* pExecNodeList) {
|
||||
SPhysiPlanContext cxt = {
|
||||
.pPlanCxt = pCxt,
|
||||
|
@ -1106,7 +1117,12 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
|
|||
if (NULL == cxt.pLocationHelper) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = doCreatePhysiPlan(&cxt, pLogicPlan, pPlan);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
setExplainInfo(pCxt, *pPlan);
|
||||
}
|
||||
|
||||
destoryPhysiPlanContext(&cxt);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -282,3 +282,16 @@ TEST_F(PlannerTest, createSmaIndex) {
|
|||
bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, explain) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("explain SELECT * FROM t1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("explain analyze SELECT * FROM t1");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
bind("explain analyze verbose true ratio 0.01 SELECT * FROM t1");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
|
|
@ -959,7 +959,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType) {
|
|||
QW_ERR_JRET(code);
|
||||
}
|
||||
|
||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle);
|
||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, OPTR_EXEC_MODEL_BATCH);
|
||||
if (code) {
|
||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||
QW_ERR_JRET(code);
|
||||
|
|
|
@ -288,7 +288,7 @@ _return:
|
|||
SCL_RET(code);
|
||||
}
|
||||
|
||||
int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
||||
int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
||||
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||
sclError("invalid function parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
|
@ -420,7 +420,7 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
|||
SFunctionNode *node = (SFunctionNode *)*pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
ctx->code = sclExecFuncion(node, ctx, &output);
|
||||
ctx->code = sclExecFunction(node, ctx, &output);
|
||||
if (ctx->code) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
|
|||
SFunctionNode *node = (SFunctionNode *)pNode;
|
||||
SScalarParam output = {0};
|
||||
|
||||
ctx->code = sclExecFuncion(node, ctx, &output);
|
||||
ctx->code = sclExecFunction(node, ctx, &output);
|
||||
if (ctx->code) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
|||
|
||||
int32_t code = 0;
|
||||
SScalarCtx ctx = {0};
|
||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == ctx.pRes) {
|
||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -689,7 +689,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
|||
|
||||
int32_t code = 0;
|
||||
SScalarCtx ctx = {.code = 0, .pBlockList = pBlockList};
|
||||
|
||||
// TODO: OPT performance
|
||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
if (NULL == ctx.pRes) {
|
||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||
|
@ -716,6 +716,3 @@ _return:
|
|||
sclFreeRes(ctx.pRes);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -377,3 +377,34 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf
|
|||
}
|
||||
}
|
||||
|
||||
bool getTimePseudoFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||
pEnv->calcMemSize = sizeof(int64_t);
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t qStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0));
|
||||
}
|
||||
|
||||
int32_t qEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 1));
|
||||
}
|
||||
|
||||
int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 2));
|
||||
}
|
||||
|
||||
int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 3));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
ASSERT(inputNum == 1);
|
||||
colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 4));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
|
@ -18,12 +18,6 @@
|
|||
#define TDB_BTREE_ROOT 0x1
|
||||
#define TDB_BTREE_LEAF 0x2
|
||||
|
||||
#define TDB_BTREE_PAGE_IS_ROOT(flags) TDB_FLAG_HAS(flags, TDB_BTREE_ROOT)
|
||||
#define TDB_BTREE_PAGE_IS_LEAF(flags) TDB_FLAG_HAS(flags, TDB_BTREE_LEAF)
|
||||
#define TDB_BTREE_ASSERT_FLAG(flags) \
|
||||
ASSERT(TDB_FLAG_IS(flags, TDB_BTREE_ROOT) || TDB_FLAG_IS(flags, TDB_BTREE_LEAF) || \
|
||||
TDB_FLAG_IS(flags, TDB_BTREE_ROOT | TDB_BTREE_LEAF) || TDB_FLAG_IS(flags, 0))
|
||||
|
||||
struct SBTree {
|
||||
SPgno root;
|
||||
int keyLen;
|
||||
|
@ -40,8 +34,13 @@ struct SBTree {
|
|||
|
||||
#define TDB_BTREE_PAGE_COMMON_HDR u8 flags;
|
||||
|
||||
#define TDB_BTREE_PAGE_GET_FLAGS(PAGE) (PAGE)->pData[0]
|
||||
#define TDB_BTREE_PAGE_GET_FLAGS(PAGE) (PAGE)->pData[0]
|
||||
#define TDB_BTREE_PAGE_SET_FLAGS(PAGE, flags) ((PAGE)->pData[0] = (flags))
|
||||
#define TDB_BTREE_PAGE_IS_ROOT(PAGE) (TDB_BTREE_PAGE_GET_FLAGS(PAGE) & TDB_BTREE_ROOT)
|
||||
#define TDB_BTREE_PAGE_IS_LEAF(PAGE) (TDB_BTREE_PAGE_GET_FLAGS(PAGE) & TDB_BTREE_LEAF)
|
||||
#define TDB_BTREE_ASSERT_FLAG(flags) \
|
||||
ASSERT(TDB_FLAG_IS(flags, TDB_BTREE_ROOT) || TDB_FLAG_IS(flags, TDB_BTREE_LEAF) || \
|
||||
TDB_FLAG_IS(flags, TDB_BTREE_ROOT | TDB_BTREE_LEAF) || TDB_FLAG_IS(flags, 0))
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
TDB_BTREE_PAGE_COMMON_HDR
|
||||
|
@ -58,15 +57,15 @@ typedef struct {
|
|||
} SBtreeInitPageArg;
|
||||
|
||||
typedef struct {
|
||||
int kLen;
|
||||
u8 *pKey;
|
||||
int vLen;
|
||||
u8 *pVal;
|
||||
SPgno pgno;
|
||||
u8 *pTmpSpace;
|
||||
int kLen;
|
||||
const u8 *pKey;
|
||||
int vLen;
|
||||
const u8 *pVal;
|
||||
SPgno pgno;
|
||||
u8 *pBuf;
|
||||
} SCellDecoder;
|
||||
|
||||
static int tdbBtCursorMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||
static int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||
static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2);
|
||||
static int tdbBtreeOpenImpl(SBTree *pBt);
|
||||
static int tdbBtreeZeroPage(SPage *pPage, void *arg);
|
||||
|
@ -77,7 +76,7 @@ static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pD
|
|||
static int tdbBtreeBalance(SBTC *pBtc);
|
||||
static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell);
|
||||
static int tdbBtcMoveToNext(SBTC *pBtc);
|
||||
static int tdbBtcMoveDownward(SBTC *pBtc, SPgno pgno);
|
||||
static int tdbBtcMoveDownward(SBTC *pBtc);
|
||||
static int tdbBtcMoveUpward(SBTC *pBtc);
|
||||
|
||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, SBTree **ppBt) {
|
||||
|
@ -94,9 +93,9 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, S
|
|||
}
|
||||
|
||||
// pBt->keyLen
|
||||
pBt->keyLen = keyLen;
|
||||
pBt->keyLen = keyLen < 0 ? TDB_VARIANT_LEN : keyLen;
|
||||
// pBt->valLen
|
||||
pBt->valLen = valLen;
|
||||
pBt->valLen = valLen < 0 ? TDB_VARIANT_LEN : valLen;
|
||||
// pBt->pPager
|
||||
pBt->pPager = pPager;
|
||||
// pBt->kcmpr
|
||||
|
@ -137,7 +136,7 @@ int tdbBtCursorInsert(SBTC *pBtc, const void *pKey, int kLen, const void *pVal,
|
|||
int cret;
|
||||
SBTree *pBt;
|
||||
|
||||
ret = tdbBtCursorMoveTo(pBtc, pKey, kLen, &cret);
|
||||
ret = tdbBtcMoveTo(pBtc, pKey, kLen, &cret);
|
||||
if (ret < 0) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
|
@ -200,7 +199,7 @@ int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen
|
|||
|
||||
tdbBtcOpen(&btc, pBt);
|
||||
|
||||
tdbBtCursorMoveTo(&btc, pKey, kLen, &cret);
|
||||
tdbBtcMoveTo(&btc, pKey, kLen, &cret);
|
||||
|
||||
if (cret) {
|
||||
return cret;
|
||||
|
@ -230,7 +229,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
|
||||
tdbBtcOpen(&btc, pBt);
|
||||
|
||||
tdbBtCursorMoveTo(&btc, pKey, kLen, &cret);
|
||||
tdbBtcMoveTo(&btc, pKey, kLen, &cret);
|
||||
if (cret) {
|
||||
return cret;
|
||||
}
|
||||
|
@ -257,106 +256,6 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int tdbBtCursorMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||
int ret;
|
||||
SBTree *pBt;
|
||||
SPager *pPager;
|
||||
|
||||
pBt = pBtc->pBt;
|
||||
pPager = pBt->pPager;
|
||||
|
||||
if (pBtc->iPage < 0) {
|
||||
ASSERT(pBtc->iPage == -1);
|
||||
ASSERT(pBtc->idx == -1);
|
||||
|
||||
// Move from the root
|
||||
ret = tdbPagerFetchPage(pPager, pBt->root, &(pBtc->pPage), tdbBtreeInitPage, pBt);
|
||||
if (ret < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pBtc->iPage = 0;
|
||||
|
||||
if (TDB_PAGE_TOTAL_CELLS(pBtc->pPage) == 0) {
|
||||
// Current page is empty
|
||||
// ASSERT(TDB_FLAG_IS(TDB_PAGE_FLAGS(pBtc->pPage), TDB_BTREE_ROOT | TDB_BTREE_LEAF));
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int lidx, ridx, midx, c, nCells;
|
||||
SCell *pCell;
|
||||
SPage *pPage;
|
||||
SCellDecoder cd = {0};
|
||||
|
||||
pPage = pBtc->pPage;
|
||||
nCells = TDB_PAGE_TOTAL_CELLS(pPage);
|
||||
lidx = 0;
|
||||
ridx = nCells - 1;
|
||||
|
||||
ASSERT(nCells > 0);
|
||||
|
||||
for (;;) {
|
||||
if (lidx > ridx) break;
|
||||
|
||||
midx = (lidx + ridx) >> 1;
|
||||
|
||||
pCell = tdbPageGetCell(pPage, midx);
|
||||
ret = tdbBtreeDecodeCell(pPage, pCell, &cd);
|
||||
if (ret < 0) {
|
||||
// TODO: handle error
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Compare the key values
|
||||
c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen);
|
||||
if (c < 0) {
|
||||
/* input-key < cell-key */
|
||||
ridx = midx - 1;
|
||||
} else if (c > 0) {
|
||||
/* input-key > cell-key */
|
||||
lidx = midx + 1;
|
||||
} else {
|
||||
/* input-key == cell-key */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Move downward or break
|
||||
u8 flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
u8 leaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
if (leaf) {
|
||||
pBtc->idx = midx;
|
||||
*pCRst = c;
|
||||
break;
|
||||
} else {
|
||||
if (c <= 0) {
|
||||
pBtc->idx = midx;
|
||||
tdbBtcMoveDownward(pBtc, cd.pgno);
|
||||
} else {
|
||||
pBtc->idx = midx + 1;
|
||||
if (midx == nCells - 1) {
|
||||
/* Move to right-most child */
|
||||
tdbBtcMoveDownward(pBtc, ((SIntHdr *)pBtc->pPage->pData)->pgno);
|
||||
} else {
|
||||
pCell = tdbPageGetCell(pPage, pBtc->idx);
|
||||
tdbBtreeDecodeCell(pPage, pCell, &cd);
|
||||
tdbBtcMoveDownward(pBtc, cd.pgno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO: Move the cursor from a some position instead of a clear state
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2) {
|
||||
int mlen;
|
||||
int cret;
|
||||
|
@ -416,7 +315,7 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
|||
|
||||
pBt = (SBTree *)arg;
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
isLeaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
isLeaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
|
||||
ASSERT(flags == TDB_BTREE_PAGE_GET_FLAGS(pPage));
|
||||
|
||||
|
@ -442,15 +341,15 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
|||
static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
|
||||
u8 flags;
|
||||
SBTree *pBt;
|
||||
u8 isLeaf;
|
||||
u8 leaf;
|
||||
|
||||
flags = ((SBtreeInitPageArg *)arg)->flags;
|
||||
pBt = ((SBtreeInitPageArg *)arg)->pBt;
|
||||
isLeaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
leaf = flags & TDB_BTREE_LEAF;
|
||||
|
||||
tdbPageZero(pPage, isLeaf ? sizeof(SLeafHdr) : sizeof(SIntHdr), tdbBtreeCellSize);
|
||||
tdbPageZero(pPage, leaf ? sizeof(SLeafHdr) : sizeof(SIntHdr), tdbBtreeCellSize);
|
||||
|
||||
if (isLeaf) {
|
||||
if (leaf) {
|
||||
SLeafHdr *pLeafHdr = (SLeafHdr *)(pPage->pData);
|
||||
pLeafHdr->flags = flags;
|
||||
|
||||
|
@ -495,7 +394,7 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild) {
|
|||
|
||||
pPager = pRoot->pPager;
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pRoot);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(pRoot);
|
||||
|
||||
// Allocate a new child page
|
||||
zArg.flags = TDB_FLAG_REMOVE(flags, TDB_BTREE_ROOT);
|
||||
|
@ -561,7 +460,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
|||
|
||||
SPgno pgno;
|
||||
if (sIdx + i == nCells) {
|
||||
ASSERT(!TDB_BTREE_PAGE_IS_LEAF(TDB_BTREE_PAGE_GET_FLAGS(pParent)));
|
||||
ASSERT(!TDB_BTREE_PAGE_IS_LEAF(pParent));
|
||||
pgno = ((SIntHdr *)(pParent->pData))->pgno;
|
||||
} else {
|
||||
pCell = tdbPageGetCell(pParent, sIdx + i);
|
||||
|
@ -575,7 +474,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
|||
}
|
||||
}
|
||||
// copy the parent key out if child pages are not leaf page
|
||||
childNotLeaf = !TDB_BTREE_PAGE_IS_LEAF(TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]));
|
||||
childNotLeaf = !TDB_BTREE_PAGE_IS_LEAF(pOlds[0]);
|
||||
if (childNotLeaf) {
|
||||
for (int i = 0; i < nOlds; i++) {
|
||||
if (sIdx + i < TDB_PAGE_TOTAL_CELLS(pParent)) {
|
||||
|
@ -849,9 +748,8 @@ static int tdbBtreeBalance(SBTC *pBtc) {
|
|||
for (;;) {
|
||||
iPage = pBtc->iPage;
|
||||
pPage = pBtc->pPage;
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
root = TDB_BTREE_PAGE_IS_ROOT(flags);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
root = TDB_BTREE_PAGE_IS_ROOT(pPage);
|
||||
|
||||
// when the page is not overflow and not too empty, the balance work
|
||||
// is finished. Just break out the balance loop.
|
||||
|
@ -892,23 +790,17 @@ static int tdbBtreeBalance(SBTC *pBtc) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef TDB_BTREE_CELL // =========================================================
|
||||
static int tdbBtreeEncodePayload(SPage *pPage, u8 *pPayload, const void *pKey, int kLen, const void *pVal, int vLen,
|
||||
int *szPayload) {
|
||||
// TDB_BTREE_CELL =====================
|
||||
static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const void *pKey, int kLen, const void *pVal,
|
||||
int vLen, int *szPayload) {
|
||||
int nPayload;
|
||||
|
||||
ASSERT(pKey != NULL);
|
||||
|
||||
if (pVal == NULL) {
|
||||
vLen = 0;
|
||||
}
|
||||
|
||||
nPayload = kLen + vLen;
|
||||
if (nPayload <= pPage->maxLocal) {
|
||||
// General case without overflow
|
||||
memcpy(pPayload, pKey, kLen);
|
||||
if (nPayload + nHeader <= pPage->maxLocal) {
|
||||
// no overflow page is needed
|
||||
memcpy(pCell + nHeader, pKey, kLen);
|
||||
if (pVal) {
|
||||
memcpy(pPayload + kLen, pVal, vLen);
|
||||
memcpy(pCell + nHeader + kLen, pVal, vLen);
|
||||
}
|
||||
|
||||
*szPayload = nPayload;
|
||||
|
@ -923,10 +815,8 @@ static int tdbBtreeEncodePayload(SPage *pPage, u8 *pPayload, const void *pKey, i
|
|||
return 0;
|
||||
}
|
||||
|
||||
// TODO: allow vLen = 0
|
||||
static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const void *pVal, int vLen, SCell *pCell,
|
||||
int *szCell) {
|
||||
u8 flags;
|
||||
u8 leaf;
|
||||
int nHeader;
|
||||
int nPayload;
|
||||
|
@ -934,11 +824,11 @@ static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const vo
|
|||
|
||||
ASSERT(pPage->kLen == TDB_VARIANT_LEN || pPage->kLen == kLen);
|
||||
ASSERT(pPage->vLen == TDB_VARIANT_LEN || pPage->vLen == vLen);
|
||||
ASSERT(pKey != NULL && kLen > 0);
|
||||
|
||||
nPayload = 0;
|
||||
nHeader = 0;
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
|
||||
// 1. Encode Header part
|
||||
/* Encode SPgno if interior page */
|
||||
|
@ -960,38 +850,42 @@ static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const vo
|
|||
}
|
||||
|
||||
// 2. Encode payload part
|
||||
if (leaf && vLen > 0) {
|
||||
ret = tdbBtreeEncodePayload(pPage, pCell + nHeader, pKey, kLen, pVal, vLen, &nPayload);
|
||||
} else {
|
||||
ret = tdbBtreeEncodePayload(pPage, pCell + nHeader, pKey, kLen, NULL, 0, &nPayload);
|
||||
if ((!leaf) || pPage->vLen == 0) {
|
||||
pVal = NULL;
|
||||
vLen = 0;
|
||||
}
|
||||
|
||||
ret = tdbBtreeEncodePayload(pPage, pCell, nHeader, pKey, kLen, pVal, vLen, &nPayload);
|
||||
if (ret < 0) {
|
||||
// TODO: handle error
|
||||
return -1;
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*szCell = nHeader + nPayload;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tdbBtreeDecodePayload(SPage *pPage, const u8 *pPayload, SCellDecoder *pDecoder) {
|
||||
static int tdbBtreeDecodePayload(SPage *pPage, const SCell *pCell, int nHeader, SCellDecoder *pDecoder) {
|
||||
int nPayload;
|
||||
|
||||
ASSERT(pDecoder->pKey == NULL);
|
||||
|
||||
if (pDecoder->pVal) {
|
||||
nPayload = pDecoder->kLen + pDecoder->vLen;
|
||||
} else {
|
||||
ASSERT(!TDB_BTREE_PAGE_IS_LEAF(pPage));
|
||||
nPayload = pDecoder->kLen;
|
||||
} else {
|
||||
nPayload = pDecoder->kLen + pDecoder->vLen;
|
||||
}
|
||||
|
||||
if (nPayload <= pPage->maxLocal) {
|
||||
// General case without overflow
|
||||
pDecoder->pKey = (void *)pPayload;
|
||||
if (!pDecoder->pVal) {
|
||||
pDecoder->pVal = (void *)(pPayload + pDecoder->kLen);
|
||||
if (nHeader + nPayload <= pPage->maxLocal) {
|
||||
// no over flow case
|
||||
pDecoder->pKey = pCell + nHeader;
|
||||
if (pDecoder->pVal == NULL && pDecoder->vLen > 0) {
|
||||
pDecoder->pVal = pCell + nHeader + pDecoder->kLen;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
{
|
||||
// TODO: handle overflow case
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -999,16 +893,13 @@ static int tdbBtreeDecodePayload(SPage *pPage, const u8 *pPayload, SCellDecoder
|
|||
return 0;
|
||||
}
|
||||
|
||||
// TODO: here has problem
|
||||
static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder) {
|
||||
u8 flags;
|
||||
u8 leaf;
|
||||
int nHeader;
|
||||
int ret;
|
||||
|
||||
nHeader = 0;
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
|
||||
// Clear the state of decoder
|
||||
pDecoder->kLen = -1;
|
||||
|
@ -1033,13 +924,14 @@ static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pD
|
|||
}
|
||||
|
||||
if (pPage->vLen == TDB_VARIANT_LEN) {
|
||||
ASSERT(leaf);
|
||||
nHeader += tdbGetVarInt(pCell + nHeader, &(pDecoder->vLen));
|
||||
} else {
|
||||
pDecoder->vLen = pPage->vLen;
|
||||
}
|
||||
|
||||
// 2. Decode payload part
|
||||
ret = tdbBtreeDecodePayload(pPage, pCell + nHeader, pDecoder);
|
||||
ret = tdbBtreeDecodePayload(pPage, pCell, nHeader, pDecoder);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1048,16 +940,14 @@ static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pD
|
|||
}
|
||||
|
||||
static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell) {
|
||||
u8 flags;
|
||||
u8 isLeaf;
|
||||
u8 leaf;
|
||||
int szCell;
|
||||
int kLen = 0, vLen = 0;
|
||||
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
isLeaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
leaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
szCell = 0;
|
||||
|
||||
if (!isLeaf) {
|
||||
if (!leaf) {
|
||||
szCell += sizeof(SPgno);
|
||||
}
|
||||
|
||||
|
@ -1067,21 +957,28 @@ static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell) {
|
|||
kLen = pPage->kLen;
|
||||
}
|
||||
|
||||
if (isLeaf) {
|
||||
if (pPage->vLen == TDB_VARIANT_LEN) {
|
||||
szCell += tdbGetVarInt(pCell + szCell, &vLen);
|
||||
} else {
|
||||
vLen = pPage->vLen;
|
||||
}
|
||||
if (pPage->vLen == TDB_VARIANT_LEN) {
|
||||
ASSERT(leaf);
|
||||
szCell += tdbGetVarInt(pCell + szCell, &vLen);
|
||||
} else if (leaf) {
|
||||
vLen = pPage->vLen;
|
||||
}
|
||||
|
||||
szCell = szCell + kLen + vLen;
|
||||
|
||||
return szCell;
|
||||
if (szCell <= pPage->maxLocal) {
|
||||
return szCell;
|
||||
}
|
||||
|
||||
{
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// TDB_BTREE_CELL
|
||||
|
||||
#endif
|
||||
|
||||
// TDB_BTREE_CURSOR =====================
|
||||
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt) {
|
||||
pBtc->pBt = pBt;
|
||||
pBtc->iPage = -1;
|
||||
|
@ -1095,7 +992,6 @@ int tdbBtcMoveToFirst(SBTC *pBtc) {
|
|||
int ret;
|
||||
SBTree *pBt;
|
||||
SPager *pPager;
|
||||
u8 flags;
|
||||
SCell *pCell;
|
||||
SPgno pgno;
|
||||
|
||||
|
@ -1110,23 +1006,43 @@ int tdbBtcMoveToFirst(SBTC *pBtc) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(TDB_BTREE_PAGE_IS_ROOT(pBtc->pPage));
|
||||
|
||||
pBtc->iPage = 0;
|
||||
pBtc->idx = 0;
|
||||
if (TDB_PAGE_TOTAL_CELLS(pBtc->pPage) > 0) {
|
||||
pBtc->idx = 0;
|
||||
} else {
|
||||
// no any data, point to an invalid position
|
||||
ASSERT(TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage));
|
||||
pBtc->idx = -1;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
// move from a position
|
||||
ASSERT(0);
|
||||
int iPage = 0;
|
||||
|
||||
for (; iPage < pBtc->iPage; iPage++) {
|
||||
ASSERT(pBtc->idxStack[iPage] >= 0);
|
||||
if (pBtc->idxStack[iPage]) break;
|
||||
}
|
||||
|
||||
// move upward
|
||||
for (;;) {
|
||||
if (pBtc->iPage == 0) {
|
||||
pBtc->idx = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pBtc->iPage < iPage) break;
|
||||
tdbBtcMoveUpward(pBtc);
|
||||
}
|
||||
}
|
||||
|
||||
// move downward
|
||||
for (;;) {
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pBtc->pPage);
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break;
|
||||
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(flags)) break;
|
||||
|
||||
pCell = tdbPageGetCell(pBtc->pPage, 0);
|
||||
pgno = *(SPgno *)pCell;
|
||||
|
||||
ret = tdbBtcMoveDownward(pBtc, pgno);
|
||||
ret = tdbBtcMoveDownward(pBtc);
|
||||
if (ret < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
|
@ -1142,7 +1058,6 @@ int tdbBtcMoveToLast(SBTC *pBtc) {
|
|||
int ret;
|
||||
SBTree *pBt;
|
||||
SPager *pPager;
|
||||
u8 flags;
|
||||
SPgno pgno;
|
||||
|
||||
pBt = pBtc->pBt;
|
||||
|
@ -1164,18 +1079,15 @@ int tdbBtcMoveToLast(SBTC *pBtc) {
|
|||
|
||||
// move downward
|
||||
for (;;) {
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pBtc->pPage);
|
||||
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(flags)) {
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||
// TODO: handle empty case
|
||||
ASSERT(TDB_PAGE_TOTAL_CELLS(pBtc->pPage) > 0);
|
||||
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
|
||||
break;
|
||||
} else {
|
||||
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage);
|
||||
pgno = ((SIntHdr *)pBtc->pPage->pData)->pgno;
|
||||
|
||||
ret = tdbBtcMoveDownward(pBtc, pgno);
|
||||
ret = tdbBtcMoveDownward(pBtc);
|
||||
if (ret < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
|
@ -1186,11 +1098,6 @@ int tdbBtcMoveToLast(SBTC *pBtc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) {
|
||||
SCell *pCell;
|
||||
SCellDecoder cd;
|
||||
|
@ -1233,11 +1140,9 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) {
|
|||
|
||||
static int tdbBtcMoveToNext(SBTC *pBtc) {
|
||||
int nCells;
|
||||
SPgno pgno;
|
||||
SCell *pCell;
|
||||
u8 flags;
|
||||
|
||||
ASSERT(TDB_BTREE_PAGE_IS_LEAF(TDB_BTREE_PAGE_GET_FLAGS(pBtc->pPage)));
|
||||
ASSERT(TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage));
|
||||
|
||||
if (pBtc->idx < 0) return -1;
|
||||
|
||||
|
@ -1270,18 +1175,11 @@ static int tdbBtcMoveToNext(SBTC *pBtc) {
|
|||
// Move downward
|
||||
for (;;) {
|
||||
nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pPage);
|
||||
if (pBtc->idx < nCells) {
|
||||
pCell = tdbPageGetCell(pBtc->pPage, pBtc->idx);
|
||||
pgno = *(SPgno *)pCell;
|
||||
} else {
|
||||
pgno = ((SIntHdr *)pBtc->pPage->pData)->pgno;
|
||||
}
|
||||
|
||||
tdbBtcMoveDownward(pBtc, pgno);
|
||||
tdbBtcMoveDownward(pBtc);
|
||||
pBtc->idx = 0;
|
||||
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pBtc->pPage);
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(flags)) {
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1289,13 +1187,20 @@ static int tdbBtcMoveToNext(SBTC *pBtc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtcClose(SBTC *pBtc) {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
static int tdbBtcMoveDownward(SBTC *pBtc) {
|
||||
int ret;
|
||||
SPgno pgno;
|
||||
SCell *pCell;
|
||||
|
||||
static int tdbBtcMoveDownward(SBTC *pBtc, SPgno pgno) {
|
||||
int ret;
|
||||
ASSERT(pBtc->idx >= 0);
|
||||
ASSERT(!TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage));
|
||||
|
||||
if (pBtc->idx < TDB_PAGE_TOTAL_CELLS(pBtc->pPage)) {
|
||||
pCell = tdbPageGetCell(pBtc->pPage, pBtc->idx);
|
||||
pgno = ((SPgno *)pCell)[0];
|
||||
} else {
|
||||
pgno = ((SIntHdr *)pBtc->pPage->pData)->pgno;
|
||||
}
|
||||
|
||||
pBtc->pgStack[pBtc->iPage] = pBtc->pPage;
|
||||
pBtc->idxStack[pBtc->iPage] = pBtc->idx;
|
||||
|
@ -1306,6 +1211,7 @@ static int tdbBtcMoveDownward(SBTC *pBtc, SPgno pgno) {
|
|||
ret = tdbPagerFetchPage(pBtc->pBt->pPager, pgno, &pBtc->pPage, tdbBtreeInitPage, pBtc->pBt);
|
||||
if (ret < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1314,7 +1220,7 @@ static int tdbBtcMoveDownward(SBTC *pBtc, SPgno pgno) {
|
|||
static int tdbBtcMoveUpward(SBTC *pBtc) {
|
||||
if (pBtc->iPage == 0) return -1;
|
||||
|
||||
// tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage);
|
||||
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage);
|
||||
|
||||
pBtc->iPage--;
|
||||
pBtc->pPage = pBtc->pgStack[pBtc->iPage];
|
||||
|
@ -1323,6 +1229,117 @@ static int tdbBtcMoveUpward(SBTC *pBtc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||
int ret;
|
||||
SBTree *pBt;
|
||||
SPager *pPager;
|
||||
|
||||
pBt = pBtc->pBt;
|
||||
pPager = pBt->pPager;
|
||||
|
||||
if (pBtc->iPage < 0) {
|
||||
ASSERT(pBtc->iPage == -1);
|
||||
ASSERT(pBtc->idx == -1);
|
||||
|
||||
// Move from the root
|
||||
ret = tdbPagerFetchPage(pPager, pBt->root, &(pBtc->pPage), tdbBtreeInitPage, pBt);
|
||||
if (ret < 0) {
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pBtc->iPage = 0;
|
||||
|
||||
if (TDB_PAGE_TOTAL_CELLS(pBtc->pPage) == 0) {
|
||||
// Current page is empty
|
||||
// ASSERT(TDB_FLAG_IS(TDB_PAGE_FLAGS(pBtc->pPage), TDB_BTREE_ROOT | TDB_BTREE_LEAF));
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int lidx, ridx, midx, c, nCells;
|
||||
SCell *pCell;
|
||||
SPage *pPage;
|
||||
SCellDecoder cd = {0};
|
||||
|
||||
pPage = pBtc->pPage;
|
||||
nCells = TDB_PAGE_TOTAL_CELLS(pPage);
|
||||
lidx = 0;
|
||||
ridx = nCells - 1;
|
||||
|
||||
ASSERT(nCells > 0);
|
||||
|
||||
for (;;) {
|
||||
if (lidx > ridx) break;
|
||||
|
||||
midx = (lidx + ridx) >> 1;
|
||||
|
||||
pCell = tdbPageGetCell(pPage, midx);
|
||||
ret = tdbBtreeDecodeCell(pPage, pCell, &cd);
|
||||
if (ret < 0) {
|
||||
// TODO: handle error
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Compare the key values
|
||||
c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen);
|
||||
if (c < 0) {
|
||||
/* input-key < cell-key */
|
||||
ridx = midx - 1;
|
||||
} else if (c > 0) {
|
||||
/* input-key > cell-key */
|
||||
lidx = midx + 1;
|
||||
} else {
|
||||
/* input-key == cell-key */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Move downward or break
|
||||
u8 leaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
if (leaf) {
|
||||
pBtc->idx = midx;
|
||||
*pCRst = c;
|
||||
break;
|
||||
} else {
|
||||
if (c <= 0) {
|
||||
pBtc->idx = midx;
|
||||
} else {
|
||||
pBtc->idx = midx + 1;
|
||||
}
|
||||
tdbBtcMoveDownward(pBtc);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO: Move the cursor from a some position instead of a clear state
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtcClose(SBTC *pBtc) {
|
||||
if (pBtc->iPage < 0) return 0;
|
||||
|
||||
for (;;) {
|
||||
ASSERT(pBtc->pPage);
|
||||
|
||||
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage);
|
||||
|
||||
pBtc->iPage--;
|
||||
if (pBtc->iPage < 0) break;
|
||||
|
||||
pBtc->pPage = pBtc->pgStack[pBtc->iPage];
|
||||
pBtc->idx = pBtc->idxStack[pBtc->iPage];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// TDB_BTREE_CURSOR
|
||||
|
||||
// TDB_BTREE_DEBUG =====================
|
||||
#ifndef NODEBUG
|
||||
typedef struct {
|
||||
SPgno pgno;
|
||||
|
@ -1336,17 +1353,14 @@ typedef struct {
|
|||
SBtPageInfo btPageInfos[20];
|
||||
|
||||
void tdbBtPageInfo(SPage *pPage, int idx) {
|
||||
u8 flags;
|
||||
SBtPageInfo *pBtPageInfo;
|
||||
|
||||
pBtPageInfo = btPageInfos + idx;
|
||||
|
||||
pBtPageInfo->pgno = TDB_PAGE_PGNO(pPage);
|
||||
|
||||
flags = TDB_BTREE_PAGE_GET_FLAGS(pPage);
|
||||
|
||||
pBtPageInfo->root = TDB_BTREE_PAGE_IS_ROOT(flags);
|
||||
pBtPageInfo->leaf = TDB_BTREE_PAGE_IS_LEAF(flags);
|
||||
pBtPageInfo->root = TDB_BTREE_PAGE_IS_ROOT(pPage);
|
||||
pBtPageInfo->leaf = TDB_BTREE_PAGE_IS_LEAF(pPage);
|
||||
|
||||
pBtPageInfo->rChild = 0;
|
||||
if (!pBtPageInfo->leaf) {
|
||||
|
@ -1357,3 +1371,4 @@ void tdbBtPageInfo(SPage *pPage, int idx) {
|
|||
pBtPageInfo->nOvfl = pPage->nOverflow;
|
||||
}
|
||||
#endif
|
||||
// TDB_BTREE_DEBUG
|
|
@ -35,7 +35,6 @@ struct SBTC {
|
|||
int idx;
|
||||
int idxStack[BTREE_MAX_DEPTH + 1];
|
||||
SPage *pgStack[BTREE_MAX_DEPTH + 1];
|
||||
void *pBuf;
|
||||
};
|
||||
|
||||
// SBTree
|
||||
|
@ -49,7 +48,6 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
int tdbBtcOpen(SBTC *pCur, SBTree *pBt);
|
||||
int tdbBtcMoveToFirst(SBTC *pBtc);
|
||||
int tdbBtcMoveToLast(SBTC *pBtc);
|
||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen);
|
||||
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||
int tdbBtcClose(SBTC *pBtc);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef TdThreadSpinlock tdb_spinlock_t;
|
|||
#define tdbSpinlockDestroy taosThreadSpinDestroy
|
||||
#define tdbSpinlockLock taosThreadSpinLock
|
||||
#define tdbSpinlockUnlock taosThreadSpinUnlock
|
||||
#define tdbSpinlockTrylock pthread_spin_trylock
|
||||
#define tdbSpinlockTrylock taosThreadSpinTrylock
|
||||
|
||||
/* mutex lock */
|
||||
typedef TdThreadMutex tdb_mutex_t;
|
||||
|
|
|
@ -758,7 +758,7 @@ void taosBlockSIGPIPE() {
|
|||
sigset_t signal_mask;
|
||||
sigemptyset(&signal_mask);
|
||||
sigaddset(&signal_mask, SIGPIPE);
|
||||
int32_t rc = taosThreadSigmask(SIG_BLOCK, &signal_mask, NULL);
|
||||
int32_t rc = taosThreadSigMask(SIG_BLOCK, &signal_mask, NULL);
|
||||
if (rc != 0) {
|
||||
// printf("failed to block SIGPIPE");
|
||||
}
|
||||
|
@ -876,7 +876,7 @@ void taosSetMaskSIGPIPE() {
|
|||
sigset_t signal_mask;
|
||||
sigemptyset(&signal_mask);
|
||||
sigaddset(&signal_mask, SIGPIPE);
|
||||
int32_t rc = taosThreadSigmask(SIG_SETMASK, &signal_mask, NULL);
|
||||
int32_t rc = taosThreadSigMask(SIG_SETMASK, &signal_mask, NULL);
|
||||
if (rc != 0) {
|
||||
// printf("failed to setmask SIGPIPE");
|
||||
}
|
||||
|
|
|
@ -14,132 +14,341 @@
|
|||
*/
|
||||
|
||||
#define ALLOW_FORBID_FUNC
|
||||
#include <pthread.h>
|
||||
#include "os.h"
|
||||
|
||||
// int32_t taosThreadSetnameNp(TdThread thread, const char *name) {
|
||||
// return pthread_setname_np(thread,name);
|
||||
// }
|
||||
|
||||
int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int pshared) {
|
||||
return pthread_spin_init(lock, pshared);
|
||||
int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg) {
|
||||
return pthread_create(tid, attr, start, arg);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) {
|
||||
return pthread_mutex_init(mutex, attr);
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr * attr) {
|
||||
return pthread_attr_destroy(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) {
|
||||
return pthread_spin_destroy(lock);
|
||||
int32_t taosThreadAttrGetDetachState(const TdThreadAttr * attr, int32_t *detachstate) {
|
||||
return pthread_attr_getdetachstate(attr, detachstate);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_destroy(mutex);
|
||||
int32_t taosThreadAttrGetInheritSched(const TdThreadAttr * attr, int32_t *inheritsched) {
|
||||
return pthread_attr_getinheritsched(attr, inheritsched);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinLock(TdThreadSpinlock *lock) {
|
||||
return pthread_spin_lock(lock);
|
||||
int32_t taosThreadAttrGetSchedParam(const TdThreadAttr * attr, struct sched_param *param) {
|
||||
return pthread_attr_getschedparam(attr, param);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexLock(TdThreadMutex *mutex) {
|
||||
return pthread_mutex_lock(mutex);
|
||||
int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr * attr, int32_t *policy) {
|
||||
return pthread_attr_getschedpolicy(attr, policy);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock) {
|
||||
return pthread_spin_unlock(lock);
|
||||
int32_t taosThreadAttrGetScope(const TdThreadAttr * attr, int32_t *contentionscope) {
|
||||
return pthread_attr_getscope(attr, contentionscope);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) {
|
||||
return pthread_mutex_unlock(mutex);
|
||||
int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize) {
|
||||
return pthread_attr_getstacksize(attr, stacksize);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) {
|
||||
return pthread_rwlock_rdlock(rwlock);
|
||||
int32_t taosThreadAttrInit(TdThreadAttr * attr) {
|
||||
return pthread_attr_init(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock) {
|
||||
return pthread_rwlock_wrlock(rwlock);
|
||||
int32_t taosThreadAttrSetDetachState(TdThreadAttr * attr, int32_t detachstate) {
|
||||
return pthread_attr_setdetachstate(attr, detachstate);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock) {
|
||||
return pthread_rwlock_unlock(rwlock);
|
||||
int32_t taosThreadAttrSetInheritSched(TdThreadAttr * attr, int32_t inheritsched) {
|
||||
return pthread_attr_setinheritsched(attr, inheritsched);
|
||||
}
|
||||
|
||||
void taosThreadTestCancel(void) {
|
||||
return pthread_testcancel();
|
||||
int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_param *param) {
|
||||
return pthread_attr_setschedparam(attr, param);
|
||||
}
|
||||
|
||||
int32_t taosThreadAttrInit(TdThreadAttr *attr) {
|
||||
return pthread_attr_init(attr);
|
||||
int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy) {
|
||||
return pthread_attr_setschedpolicy(attr, policy);
|
||||
}
|
||||
|
||||
int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void*(*start)(void*), void *arg) {
|
||||
return pthread_create(tid, attr, start, arg);
|
||||
int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope) {
|
||||
return pthread_attr_setscope(attr, contentionscope);
|
||||
}
|
||||
|
||||
int32_t taosThreadOnce(TdThreadOnce *onceControl, void(*initRoutine)(void)) {
|
||||
return pthread_once(onceControl, initRoutine);
|
||||
int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) {
|
||||
return pthread_attr_setstacksize(attr, stacksize);
|
||||
}
|
||||
|
||||
int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachState) {
|
||||
return pthread_attr_setdetachstate(attr, detachState);
|
||||
int32_t taosThreadBarrierDestroy(TdThreadBarrier * barrier) {
|
||||
return pthread_barrier_destroy(barrier);
|
||||
}
|
||||
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr *attr) {
|
||||
return pthread_attr_destroy(attr);
|
||||
int32_t taosThreadBarrierInit(TdThreadBarrier * barrier, const TdThreadBarrierAttr * attr, uint32_t count) {
|
||||
return pthread_barrier_init(barrier, attr, count);
|
||||
}
|
||||
|
||||
int32_t taosThreadJoin(TdThread thread, void **pValue) {
|
||||
return pthread_join(thread, pValue);
|
||||
int32_t taosThreadBarrierWait(TdThreadBarrier * barrier) {
|
||||
return pthread_barrier_wait(barrier);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr) {
|
||||
return pthread_rwlock_init(rwlock, attr);
|
||||
int32_t taosThreadBarrierAttrDestroy(TdThreadBarrierAttr * attr) {
|
||||
return pthread_barrierattr_destroy(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock) {
|
||||
return pthread_rwlock_destroy(rwlock);
|
||||
int32_t taosThreadBarrierAttrGetPshared(const TdThreadBarrierAttr * attr, int32_t *pshared) {
|
||||
return pthread_barrierattr_getpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondSignal(TdThreadCond *cond) {
|
||||
return pthread_cond_signal(cond);
|
||||
int32_t taosThreadBarrierAttrInit(TdThreadBarrierAttr * attr) {
|
||||
return pthread_barrierattr_init(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr) {
|
||||
return pthread_cond_init(cond, attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond *cond) {
|
||||
return pthread_cond_broadcast(cond);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondDestroy(TdThreadCond *cond) {
|
||||
return pthread_cond_destroy(cond);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) {
|
||||
return pthread_cond_wait(cond, mutex);
|
||||
}
|
||||
|
||||
TdThread taosThreadSelf(void) {
|
||||
return pthread_self();
|
||||
}
|
||||
|
||||
// int32_t taosThreadGetW32ThreadIdNp(TdThread thread) {
|
||||
// return pthread_getw32threadid_np(thread);
|
||||
// }
|
||||
|
||||
int32_t taosThreadEqual(TdThread t1, TdThread t2) {
|
||||
return pthread_equal(t1, t2);
|
||||
}
|
||||
|
||||
int32_t taosThreadSigmask(int how, sigset_t const *set, sigset_t *oset) {
|
||||
return pthread_sigmask(how, set, oset);
|
||||
int32_t taosThreadBarrierAttrSetPshared(TdThreadBarrierAttr * attr, int32_t pshared) {
|
||||
return pthread_barrierattr_setpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadCancel(TdThread thread) {
|
||||
return pthread_cancel(thread);
|
||||
return pthread_cancel(thread);
|
||||
}
|
||||
|
||||
int32_t taosThreadKill(TdThread thread, int sig) {
|
||||
return pthread_kill(thread, sig);
|
||||
int32_t taosThreadCondDestroy(TdThreadCond * cond) {
|
||||
return pthread_cond_destroy(cond);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr) {
|
||||
return pthread_cond_init(cond, attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondSignal(TdThreadCond * cond) {
|
||||
return pthread_cond_signal(cond);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond * cond) {
|
||||
return pthread_cond_broadcast(cond);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex) {
|
||||
return pthread_cond_wait(cond, mutex);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondTimedWait(TdThreadCond * cond, TdThreadMutex * mutex, const struct timespec *abstime) {
|
||||
return pthread_cond_timedwait(cond, mutex, abstime);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr) {
|
||||
return pthread_condattr_destroy(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr * attr, int32_t *pshared) {
|
||||
return pthread_condattr_getpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr) {
|
||||
return pthread_condattr_init(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr * attr, int32_t pshared) {
|
||||
return pthread_condattr_setpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadDetach(TdThread thread) {
|
||||
return pthread_detach(thread);
|
||||
}
|
||||
|
||||
int32_t taosThreadEqual(TdThread t1, TdThread t2) {
|
||||
return pthread_equal(t1, t2);
|
||||
}
|
||||
|
||||
void taosThreadExit(void *valuePtr) {
|
||||
return pthread_exit(valuePtr);
|
||||
}
|
||||
|
||||
int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param) {
|
||||
return pthread_getschedparam(thread, policy, param);
|
||||
}
|
||||
|
||||
void *taosThreadGetSpecific(TdThreadKey key) {
|
||||
return pthread_getspecific(key);
|
||||
}
|
||||
|
||||
int32_t taosThreadJoin(TdThread thread, void **valuePtr) {
|
||||
return pthread_join(thread, valuePtr);
|
||||
}
|
||||
|
||||
int32_t taosThreadKeyCreate(TdThreadKey * key, void(*destructor)(void *)) {
|
||||
return pthread_key_create(key, destructor);
|
||||
}
|
||||
|
||||
int32_t taosThreadKeyDelete(TdThreadKey key) {
|
||||
return pthread_key_delete(key);
|
||||
}
|
||||
|
||||
int32_t taosThreadKill(TdThread thread, int32_t sig) {
|
||||
return pthread_kill(thread, sig);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) {
|
||||
return pthread_mutex_consistent(mutex);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_destroy(mutex);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexInit(TdThreadMutex * mutex, const TdThreadMutexAttr * attr) {
|
||||
return pthread_mutex_init(mutex, attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexLock(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime) {
|
||||
return pthread_mutex_timedlock(mutex, abstime);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexTryLock(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_trylock(mutex);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr) {
|
||||
return pthread_mutexattr_destroy(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *pshared) {
|
||||
return pthread_mutexattr_getpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrGetRobust(const TdThreadMutexAttr * attr, int32_t * robust) {
|
||||
return pthread_mutexattr_getrobust(attr, robust);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind) {
|
||||
return pthread_mutexattr_gettype(attr, kind);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr) {
|
||||
return pthread_mutexattr_init(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared) {
|
||||
return pthread_mutexattr_setpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrSetRobust(TdThreadMutexAttr * attr, int32_t robust) {
|
||||
return pthread_mutexattr_setrobust(attr, robust);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr * attr, int32_t kind) {
|
||||
return pthread_mutexattr_settype(attr, kind);
|
||||
}
|
||||
|
||||
int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void)) {
|
||||
return pthread_once(onceControl, initRoutine);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_destroy(rwlock);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock * rwlock, const TdThreadRwlockAttr * attr) {
|
||||
return pthread_rwlock_init(rwlock, attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_rdlock(rwlock);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime) {
|
||||
return pthread_rwlock_timedrdlock(rwlock, abstime);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockTimedWrlock(TdThreadRwlock * rwlock, const struct timespec *abstime) {
|
||||
return pthread_rwlock_timedwrlock(rwlock, abstime);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_tryrdlock(rwlock);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_trywrlock(rwlock);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_unlock(rwlock);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_wrlock(rwlock);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr) {
|
||||
return pthread_rwlockattr_destroy(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr * attr, int32_t *pshared) {
|
||||
return pthread_rwlockattr_getpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr) {
|
||||
return pthread_rwlockattr_init(attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr * attr, int32_t pshared) {
|
||||
return pthread_rwlockattr_setpshared(attr, pshared);
|
||||
}
|
||||
|
||||
TdThread taosThreadSelf(void) {
|
||||
return pthread_self();
|
||||
}
|
||||
|
||||
int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) {
|
||||
return pthread_setcancelstate(state, oldstate);
|
||||
}
|
||||
|
||||
int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) {
|
||||
return pthread_setcanceltype(type, oldtype);
|
||||
}
|
||||
|
||||
int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param) {
|
||||
return pthread_setschedparam(thread, policy, param);
|
||||
}
|
||||
|
||||
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) {
|
||||
return pthread_setspecific(key, value);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock) {
|
||||
return pthread_spin_destroy(lock);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared) {
|
||||
return pthread_spin_init(lock, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinLock(TdThreadSpinlock * lock) {
|
||||
return pthread_spin_lock(lock);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock) {
|
||||
return pthread_spin_trylock(lock);
|
||||
}
|
||||
|
||||
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock) {
|
||||
return pthread_spin_unlock(lock);
|
||||
}
|
||||
|
||||
void taosThreadTestCancel(void) {
|
||||
return pthread_testcancel();
|
||||
}
|
||||
|
||||
int32_t taosThreadSigMask(int32_t how, sigset_t const *set, sigset_t * oset) {
|
||||
return pthread_sigmask(how, set, oset);
|
||||
}
|
||||
|
||||
int32_t taosThreadSigWait(const sigset_t * set, int32_t *sig) {
|
||||
return sigwait(set, sig);
|
||||
}
|
|
@ -63,27 +63,27 @@ static inline int32_t CEIL8(int32_t v) {
|
|||
static int32_t taosProcInitMutex(SProcQueue *pQueue) {
|
||||
TdThreadMutexAttr mattr = {0};
|
||||
|
||||
if (pthread_mutexattr_init(&mattr) != 0) {
|
||||
if (taosThreadMutexAttrInit(&mattr) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
uError("failed to init mutex while init attr since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) {
|
||||
pthread_mutexattr_destroy(&mattr);
|
||||
if (taosThreadMutexAttrSetPshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) {
|
||||
taosThreadMutexAttrDestroy(&mattr);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
uError("failed to init mutex while set shared since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosThreadMutexInit(&pQueue->mutex, &mattr) != 0) {
|
||||
pthread_mutexattr_destroy(&mattr);
|
||||
taosThreadMutexDestroy(&pQueue->mutex);
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
uError("failed to init mutex since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_mutexattr_destroy(&mattr);
|
||||
taosThreadMutexAttrDestroy(&mattr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,6 @@ static void taosProcDestroySem(SProcQueue *pQueue) {
|
|||
tsem_destroy(pQueue->sem);
|
||||
pQueue->sem = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void taosProcCleanupQueue(SProcQueue *pQueue) {
|
||||
|
@ -318,7 +317,7 @@ SProcObj *taosProcInit(const SProcCfg *pCfg) {
|
|||
pProc->pChildQueue = taosProcInitQueue(pCfg->name, pCfg->isChild, (char *)pCfg->shm.ptr + cstart, csize);
|
||||
pProc->pParentQueue = taosProcInitQueue(pCfg->name, pCfg->isChild, (char *)pCfg->shm.ptr + pstart, psize);
|
||||
if (pProc->pChildQueue == NULL || pProc->pParentQueue == NULL) {
|
||||
taosProcCleanupQueue(pProc->pChildQueue);
|
||||
// taosProcCleanupQueue(pProc->pChildQueue);
|
||||
taosMemoryFree(pProc);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -422,8 +421,8 @@ void taosProcCleanup(SProcObj *pProc) {
|
|||
if (pProc != NULL) {
|
||||
uDebug("proc:%s, clean up", pProc->name);
|
||||
taosProcStop(pProc);
|
||||
taosProcCleanupQueue(pProc->pChildQueue);
|
||||
taosProcCleanupQueue(pProc->pParentQueue);
|
||||
// taosProcCleanupQueue(pProc->pChildQueue);
|
||||
// taosProcCleanupQueue(pProc->pParentQueue);
|
||||
taosMemoryFree(pProc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ TEST_F(UtilTestQueue, 01_fork) {
|
|||
|
||||
int err;
|
||||
pthread_mutexattr_t mattr;
|
||||
if ((err = pthread_mutexattr_init(&mattr)) < 0) {
|
||||
if ((err = taosThreadMutexAttrInit(&mattr)) < 0) {
|
||||
printf("mutex addr init error:%s\n", strerror(err));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((err = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) < 0) {
|
||||
if ((err = taosThreadMutexAttrSetPshared(&mattr, PTHREAD_PROCESS_SHARED)) < 0) {
|
||||
printf("mutex addr get shared error:%s\n", strerror(err));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ TEST_F(UtilTestQueue, 01_fork) {
|
|||
int mid = shmget(IPC_PRIVATE, sizeof(pthread_mutex_t), 0600);
|
||||
m = (pthread_mutex_t*)shmat(mid, NULL, 0);
|
||||
|
||||
if ((err = pthread_mutex_init(m, &mattr)) < 0) {
|
||||
if ((err = taosThreadMutexInit(m, &mattr)) < 0) {
|
||||
printf("mutex mutex init error:%s\n", strerror(err));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ TEST_F(UtilTestQueue, 01_fork) {
|
|||
|
||||
taosThreadAttrDestroy(&mattr);
|
||||
//销毁mutex
|
||||
pthread_mutex_destroy(m);
|
||||
taosThreadMutexDestroy(m);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -1,199 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = d_db
|
||||
$tbPrefix = d_tb
|
||||
$mtPrefix = d_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$val = $x * 60000
|
||||
$ms = 1519833600000 + $val
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(*) from $mt
|
||||
print select count(*) from $mt ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sleep 1000
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
sleep 3000
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 6000
|
||||
|
||||
sql use $db
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(*) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
sql select count(tbcol) from $tb where ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
sql select count(tbcol) as b from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select count(tbcol) as b from $tb interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $tb interval(1d)
|
||||
print ===> $data01
|
||||
if $data01 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step7
|
||||
sql select count(*) from $mt
|
||||
print select count(*) from $mt ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $mt
|
||||
print ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step8
|
||||
sql select count(tbcol) as c from $mt where ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 50 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as c from $mt where tgcol < 5
|
||||
print ===> $data00
|
||||
if $data00 != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 25 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step9
|
||||
sql select count(tbcol) as b from $mt interval(1m)
|
||||
print select count(tbcol) as b from $mt interval(1m) ===> $data01
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $mt interval(1d)
|
||||
print ===> $data02
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step10
|
||||
print select count(tbcol) as b from $mt group by tgcol
|
||||
sql select count(tbcol) as b from $mt group by tgcol
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $rows != $tbNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step11
|
||||
sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $rows != 50 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,212 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/deploy.sh -n dnode2 -i 2
|
||||
system sh/deploy.sh -n dnode3 -i 3
|
||||
system sh/deploy.sh -n dnode4 -i 4
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode2 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode3 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode4 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sql connect
|
||||
|
||||
sql create dnode $hostname2
|
||||
sql create dnode $hostname3
|
||||
sql create dnode $hostname4
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
system sh/exec.sh -n dnode3 -s start
|
||||
system sh/exec.sh -n dnode4 -s start
|
||||
$x = 0
|
||||
createDnode:
|
||||
$x = $x + 1
|
||||
sleep 1000
|
||||
if $x == 20 then
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes;
|
||||
if $data4_2 == offline then
|
||||
goto createDnode
|
||||
endi
|
||||
if $data4_3 == offline then
|
||||
goto createDnode
|
||||
endi
|
||||
if $data4_4 == offline then
|
||||
goto createDnode
|
||||
endi
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = r3v3_db
|
||||
$tbPrefix = r3v3_tb
|
||||
$mtPrefix = r3v3_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$val = $x * 60000
|
||||
$ms = 1519833600000 + $val
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sleep 100
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(*) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
sql select count(tbcol) from $tb where ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
sql select count(tbcol) as b from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select count(tbcol) as b from $tb interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $tb interval(1d)
|
||||
print ===> $data01
|
||||
if $data01 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step7
|
||||
print select count(*) from $mt
|
||||
sql select count(*) from $mt
|
||||
print ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $mt
|
||||
print ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step8
|
||||
sql select count(tbcol) as c from $mt where ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 50 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as c from $mt where tgcol < 5
|
||||
print ===> $data00
|
||||
if $data00 != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 25 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step9
|
||||
sql select count(tbcol) as b from $mt interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $mt interval(1d)
|
||||
print ===> $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step10
|
||||
sql select count(tbcol) as b from $mt group by tgcol
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $rows != $tbNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step11
|
||||
sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $rows != 50 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,113 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
sql create database vdb0
|
||||
sql create table vdb0.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
sql create table vdb0.vtb00 using vdb0.mt tags( 0 )
|
||||
sql create table vdb0.vtb01 using vdb0.mt tags( 0 )
|
||||
|
||||
sql create database vdb1
|
||||
sql create table vdb1.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
sql_error create table vdb1.vtb10 using vdb0.mt tags( 1 )
|
||||
sql_error create table vdb1.vtb11 using vdb0.mt tags( 1 )
|
||||
sql create table vdb1.vtb10 using vdb1.mt tags( 1 )
|
||||
sql create table vdb1.vtb11 using vdb1.mt tags( 1 )
|
||||
|
||||
sql create database vdb2
|
||||
sql create table vdb2.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
sql_error create table vdb2.vtb20 using vdb0.mt tags( 2 )
|
||||
sql_error create table vdb2.vtb21 using vdb0.mt tags( 2 )
|
||||
sql create table vdb2.vtb20 using vdb2.mt tags( 2 )
|
||||
sql create table vdb2.vtb21 using vdb2.mt tags( 2 )
|
||||
|
||||
sql create database vdb3
|
||||
sql create table vdb3.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
sql_error create table vdb3.vtb20 using vdb0.mt tags( 2 )
|
||||
sql_error create table vdb3.vtb21 using vdb0.mt tags( 2 )
|
||||
sql create table vdb3.vtb30 using vdb3.mt tags( 3 )
|
||||
sql create table vdb3.vtb31 using vdb3.mt tags( 3 )
|
||||
|
||||
print =============== step2
|
||||
sql insert into vdb0.vtb00 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30)
|
||||
sql insert into vdb0.vtb01 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30)
|
||||
sql insert into vdb1.vtb10 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31)
|
||||
sql insert into vdb1.vtb11 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31)
|
||||
sql insert into vdb2.vtb20 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32)
|
||||
sql insert into vdb2.vtb21 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32)
|
||||
sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33)
|
||||
sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33)
|
||||
sql select * from vdb0.mt
|
||||
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
sql insert into vdb0.vtb00 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60)
|
||||
sql insert into vdb0.vtb01 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60)
|
||||
sql insert into vdb1.vtb10 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61)
|
||||
sql insert into vdb1.vtb11 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61)
|
||||
sql insert into vdb2.vtb20 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62)
|
||||
sql insert into vdb2.vtb21 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62)
|
||||
sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63)
|
||||
sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63)
|
||||
sql select * from vdb0.mt
|
||||
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
sql insert into vdb0.vtb00 values(1519833600006, 60) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 60) (1519833600007, 70)
|
||||
sql insert into vdb1.vtb10 values(1519833600006, 61) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 61) (1519833600007, 71)
|
||||
sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 62) (1519833600007, 72)
|
||||
sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73)
|
||||
sql select * from vdb0.mt
|
||||
|
||||
if $rows != 16 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql insert into vdb0.vtb00 values(1519833600008, 80) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 80) (1519833600007, 70)
|
||||
sql insert into vdb1.vtb10 values(1519833600008, 81) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 81) (1519833600007, 71)
|
||||
sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 82) (1519833600007, 72)
|
||||
sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73)
|
||||
sql select * from vdb0.mt
|
||||
|
||||
if $rows != 17 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
sql insert into vdb0.vtb00 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb10 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb20 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb30 values(1519833600009, 90) (1519833600010, 100)
|
||||
sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb11 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb21 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb31 values(1519833600009, 90) (1519833600010, 100)
|
||||
|
||||
sql select * from vdb0.mt
|
||||
|
||||
if $rows != 21 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step7
|
||||
sql insert into vdb0.vtb00 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb10 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb20 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb30 values(1519833600012, 120) (1519833600011, 110)
|
||||
sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb11 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb21 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb31 values(1519833600012, 120) (1519833600011, 110)
|
||||
|
||||
sql select * from vdb0.mt
|
||||
|
||||
if $rows != 25 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,179 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = v3_db
|
||||
$tbPrefix = v3_tb
|
||||
$mtPrefix = v3_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$val = $x * 60000
|
||||
$ms = 1519833600000 + $val
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(*) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
sql select count(tbcol) from $tb where ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
sql select count(tbcol) as b from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select count(tbcol) as b from $tb interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $tb interval(1d)
|
||||
print ===> $data01
|
||||
if $data01 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step7
|
||||
sql select count(*) from $mt
|
||||
print ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $mt
|
||||
print ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step8
|
||||
sql select count(tbcol) as c from $mt where ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 50 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as c from $mt where tgcol < 5
|
||||
print ===> $data00
|
||||
if $data00 != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000
|
||||
print ===> $data00
|
||||
if $data00 != 25 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step9
|
||||
sql select count(tbcol) as b from $mt interval(1m)
|
||||
print ===> $data01
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $mt interval(1d)
|
||||
print ===> $data01
|
||||
if $data01 != 200 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step10
|
||||
sql select count(tbcol) as b from $mt group by tgcol
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $rows != $tbNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step11
|
||||
sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol
|
||||
print ===> $data01
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $rows != 50 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -39,4 +39,13 @@
|
|||
./test.sh -f tsim/tmq/basic.sim
|
||||
./test.sh -f tsim/tmq/basic1.sim
|
||||
|
||||
# --- stable
|
||||
./test.sh -f tsim/stable/disk.sim
|
||||
./test.sh -f tsim/stable/dnode3.sim
|
||||
./test.sh -f tsim/stable/metrics.sim
|
||||
./test.sh -f tsim/stable/refcount.sim
|
||||
# ./test.sh -f tsim/stable/show.sim
|
||||
./test.sh -f tsim/stable/values.sim
|
||||
./test.sh -f tsim/stable/vnode3.sim
|
||||
|
||||
#======================b1-end===============
|
||||
|
|
|
@ -68,7 +68,7 @@ gitPullBranchInfo $TDengineBrVer
|
|||
compileTDengineVersion
|
||||
|
||||
taos_dir=${projectDir}/debug/tools/shell
|
||||
taosd_dir=${projectDir}/debug/source/dnode/mgmt/main
|
||||
taosd_dir=${projectDir}/debug/source/dnode/mgmt
|
||||
exec_process_dir=${projectDir}/debug/tests/test/c
|
||||
|
||||
rm -f /usr/bin/taos
|
||||
|
|
|
@ -0,0 +1,443 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/deploy.sh -n dnode2 -i 2
|
||||
system sh/deploy.sh -n dnode3 -i 3
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
system sh/exec.sh -n dnode3 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
check_dnode_ready:
|
||||
$loop_cnt = $loop_cnt + 1
|
||||
sleep 200
|
||||
if $loop_cnt == 10 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes
|
||||
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != ready then
|
||||
goto check_dnode_ready
|
||||
endi
|
||||
|
||||
sql connect
|
||||
sql create dnode $hostname port 7200
|
||||
sql create dnode $hostname port 7300
|
||||
|
||||
$loop_cnt = 0
|
||||
check_dnode_ready_1:
|
||||
$loop_cnt = $loop_cnt + 1
|
||||
sleep 200
|
||||
if $loop_cnt == 10 then
|
||||
print ====> dnode not ready!
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes
|
||||
print ===> rows: $rows
|
||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||
print ===> $data20 $data21 $data22 $data23 $data24 $data25
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != localhost:7100 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != ready then
|
||||
goto check_dnode_ready_1
|
||||
endi
|
||||
if $data14 != ready then
|
||||
goto check_dnode_ready_1
|
||||
endi
|
||||
if $data24 != ready then
|
||||
goto check_dnode_ready_1
|
||||
endi
|
||||
|
||||
print ============= create database
|
||||
#database_option: {
|
||||
# BLOCKS value [3~1000, default: 6]
|
||||
# | CACHE value [default: 16M]
|
||||
# | CACHELAST value [0, 1, 2, 3]
|
||||
# | COMP [0 | 1 | 2]
|
||||
# | DAYS value [unit is minutes]
|
||||
# | FSYNC value [0 ~ 180000 ms]
|
||||
# | MAXROWS value [default: 4096]
|
||||
# | MINROWS value [default: 100]
|
||||
# | KEEP value [days, 365000]
|
||||
# | PRECISION ['ms' | 'us' | 'ns']
|
||||
# | QUORUM value [1 | 2]
|
||||
# | REPLICA value [1 | 3]
|
||||
# | TTL value [unit is day, min=1]
|
||||
# | WAL value [1 | 2]
|
||||
# | VGROUPS value [default: 2]
|
||||
# | SINGLE_STABLE [0 | 1]
|
||||
# | STREAM_MODE [0 | 1]
|
||||
|
||||
sql create database db BLOCKS 7 CACHE 3 CACHELAST 3 COMP 0 DAYS 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' QUORUM 1 REPLICA 3 TTL 7 WAL 2 VGROUPS 6 SINGLE_STABLE 1 STREAM_MODE 1
|
||||
sql show databases
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||
print ====> dataX_db
|
||||
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
|
||||
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data0_db != db then # name
|
||||
return -1
|
||||
endi
|
||||
if $data2_db != 6 then # vgroups
|
||||
return -1
|
||||
endi
|
||||
if $data3_db != 0 then # ntables
|
||||
return -1
|
||||
endi
|
||||
if $data4_db != 3 then # replica
|
||||
return -1
|
||||
endi
|
||||
if $data5_db != 1 then # quorum
|
||||
return -1
|
||||
endi
|
||||
if $data6_db != 240 then # days
|
||||
return -1
|
||||
endi
|
||||
if $data7_db != 1000,1000,1000 then # keep
|
||||
return -1
|
||||
endi
|
||||
if $data8_db != 3 then # cache
|
||||
return -1
|
||||
endi
|
||||
if $data9_db != 7 then # blocks
|
||||
return -1
|
||||
endi
|
||||
if $data10_db != 10 then # minrows
|
||||
return -1
|
||||
endi
|
||||
if $data11_db != 8000 then # maxrows
|
||||
return -1
|
||||
endi
|
||||
if $data12_db != 2 then # wal
|
||||
return -1
|
||||
endi
|
||||
if $data13_db != 1000 then # fsync
|
||||
return -1
|
||||
endi
|
||||
if $data14_db != 0 then # comp
|
||||
return -1
|
||||
endi
|
||||
if $data15_db != 3 then # cachelast
|
||||
return -1
|
||||
endi
|
||||
if $data16_db != ns then # precision
|
||||
return -1
|
||||
endi
|
||||
|
||||
print ============== not support modify options: name, create_time, vgroups, ntables
|
||||
sql_error alter database db name dba
|
||||
sql_error alter database db create_time "2022-03-03 15:08:13.329"
|
||||
sql_error alter database db vgroups -1
|
||||
sql_error alter database db vgroups 0
|
||||
sql_error alter database db vgroups 2
|
||||
sql_error alter database db vgroups 20
|
||||
sql_error alter database db ntables -1
|
||||
sql_error alter database db ntables 0
|
||||
sql_error alter database db ntables 1
|
||||
sql_error alter database db ntables 10
|
||||
|
||||
#print ============== modify replica
|
||||
sql_error alter database db replica 2
|
||||
sql_error alter database db replica 5
|
||||
sql_error alter database db replica -1
|
||||
sql_error alter database db replica 0
|
||||
#sql alter database db replica 1
|
||||
#sql show databases
|
||||
#print replica: $data4_db
|
||||
#if $data4_db != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#sql alter database db replica 3
|
||||
#sql show databases
|
||||
#print replica: $data4_db
|
||||
#if $data4_db != 3 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print ============== modify quorum
|
||||
sql alter database db quorum 2
|
||||
sql show databases
|
||||
print quorum $data5_db
|
||||
if $data5_db != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db quorum 1
|
||||
sql show databases
|
||||
print quorum $data5_db
|
||||
if $data5_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql_error alter database db quorum -1
|
||||
sql_error alter database db quorum 0
|
||||
sql_error alter database db quorum 3
|
||||
sql_error alter database db quorum 4
|
||||
sql_error alter database db quorum 5
|
||||
|
||||
#print ============== modify days
|
||||
#sql alter database db days 480
|
||||
#sql show databases
|
||||
#print days $data6_db
|
||||
#if $data6_db != 480 then # days
|
||||
# return -1
|
||||
#endi
|
||||
#sql alter database db days 360
|
||||
#sql show databases
|
||||
#print days $data6_db
|
||||
#if $data6_db != 360 then # days
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
sql_error alter database db days 0
|
||||
#sql_error alter database db days 14400 # set over than keep
|
||||
|
||||
|
||||
print ============== modify keep
|
||||
sql alter database db keep 2000
|
||||
sql show databases
|
||||
print keep $data7_db
|
||||
if $data7_db != 1000,1000,2000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#sql alter database db keep 1000,2000
|
||||
#sql show databases
|
||||
#print keep $data7_db
|
||||
#if $data7_db != 500,500,500 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
#sql alter database db keep 40,50
|
||||
#sql alter database db keep 30,31
|
||||
#sql alter database db keep 20
|
||||
#sql_error alter database db keep 10.0
|
||||
#sql_error alter database db keep 9
|
||||
#sql_error alter database db keep 1
|
||||
sql_error alter database db keep 0
|
||||
sql_error alter database db keep -1
|
||||
#sql_error alter database db keep 365001
|
||||
|
||||
print ============== modify cache
|
||||
#sql alter database db cache 12
|
||||
#sql show databases
|
||||
#print cache $data8_db
|
||||
#if $data8_db != 12 then
|
||||
# return -1
|
||||
#endi
|
||||
#sql alter database db cache 1
|
||||
#sql show databases
|
||||
#print cache $data8_db
|
||||
#if $data8_db != 6 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#sql_error alter database db cache 60
|
||||
#sql_error alter database db cache 50
|
||||
#sql_error alter database db cache 20
|
||||
#sql_error alter database db cache 3
|
||||
#sql_error alter database db cache 129
|
||||
#sql_error alter database db cache 300
|
||||
sql_error alter database db cache 0
|
||||
sql_error alter database db cache -1
|
||||
|
||||
print ============== modify blocks
|
||||
sql alter database db blocks 3
|
||||
sql show databases
|
||||
print blocks $data9_db
|
||||
if $data9_db != 3 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db blocks 11
|
||||
sql show databases
|
||||
print blocks $data9_db
|
||||
if $data9_db != 11 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql alter database db blocks 40
|
||||
sql alter database db blocks 30
|
||||
sql alter database db blocks 20
|
||||
sql alter database db blocks 10
|
||||
sql_error alter database db blocks 2
|
||||
sql_error alter database db blocks 1
|
||||
sql_error alter database db blocks 0
|
||||
sql_error alter database db blocks -1
|
||||
sql_error alter database db blocks 10001
|
||||
|
||||
#print ============== modify minrows
|
||||
#sql alter database db minrows 8
|
||||
#sql show databases
|
||||
#print minrows $data10_db
|
||||
#if $data10_db != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#sql alter database db minrows 200
|
||||
#sql show databases
|
||||
#print minrows $data10_db
|
||||
#if $data10_db != 200 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#sql alter database db minrows 11
|
||||
#sql show databases
|
||||
#print minrows $data10_db
|
||||
#if $data10_db != 11 then
|
||||
# return -1
|
||||
#endi
|
||||
#sql_error alter database db minrows 8000
|
||||
#sql_error alter database db minrows 8001
|
||||
|
||||
#print ============== modify maxrows
|
||||
#sql alter database db maxrows 1000
|
||||
#sql show databases
|
||||
#print maxrows $data11_db
|
||||
#if $data11_db != 1000 then
|
||||
# return -1
|
||||
#endi
|
||||
#sql alter database db maxrows 2000
|
||||
#sql show databases
|
||||
#print maxrows $data11_db
|
||||
#if $data11_db != 2000 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#sql_error alter database db maxrows 11 # equal minrows
|
||||
#sql_error alter database db maxrows 10 # little than minrows
|
||||
|
||||
print ============== step wal
|
||||
sql alter database db wal 1
|
||||
sql show databases
|
||||
print wal $data12_db
|
||||
if $data12_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db wal 2
|
||||
sql show databases
|
||||
print wal $data12_db
|
||||
if $data12_db != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql_error alter database db wal 0
|
||||
sql_error alter database db wal 3
|
||||
sql_error alter database db wal 100
|
||||
sql_error alter database db wal -1
|
||||
|
||||
print ============== modify fsync
|
||||
sql alter database db fsync 2000
|
||||
sql show databases
|
||||
print fsync $data13_db
|
||||
if $data13_db != 2000 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db fsync 500
|
||||
sql show databases
|
||||
print fsync $data13_db
|
||||
if $data13_db != 500 then
|
||||
return -1
|
||||
endi
|
||||
sql_error alter database db fsync 0
|
||||
sql_error alter database db fsync -1
|
||||
|
||||
print ============== modify comp
|
||||
sql alter database db comp 1
|
||||
sql show databases
|
||||
print comp $data14_db
|
||||
if $data14_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db comp 2
|
||||
sql show databases
|
||||
print comp $data14_db
|
||||
if $data14_db != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db comp 1
|
||||
sql show databases
|
||||
print comp $data14_db
|
||||
if $data14_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db comp 0
|
||||
sql show databases
|
||||
print comp $data14_db
|
||||
if $data14_db != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql_error alter database db comp 3
|
||||
sql_error alter database db comp 4
|
||||
sql_error alter database db comp 5
|
||||
sql_error alter database db comp -1
|
||||
|
||||
print ============== modify cachelast [0, 1, 2, 3]
|
||||
sql alter database db cachelast 2
|
||||
sql show databases
|
||||
print cachelast $data15_db
|
||||
if $data15_db != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db cachelast 1
|
||||
sql show databases
|
||||
print cachelast $data15_db
|
||||
if $data15_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db cachelast 0
|
||||
sql show databases
|
||||
print cachelast $data15_db
|
||||
if $data15_db != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db cachelast 2
|
||||
sql show databases
|
||||
print cachelast $data15_db
|
||||
if $data15_db != 2 then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db cachelast 3
|
||||
sql show databases
|
||||
print cachelast $data15_db
|
||||
if $data15_db != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql_error alter database db comp 4
|
||||
sql_error alter database db comp 10
|
||||
sql_error alter database db comp -1
|
||||
|
||||
print ============== modify precision
|
||||
sql alter database db precision 'ms'
|
||||
sql show databases
|
||||
print precision $data16_db
|
||||
if $data16_db != ms then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db precision 'us'
|
||||
sql show databases
|
||||
print precision $data16_db
|
||||
if $data16_db != us then
|
||||
return -1
|
||||
endi
|
||||
sql alter database db precision 'ns'
|
||||
sql show databases
|
||||
print precision $data16_db
|
||||
if $data16_db != ns then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql_error alter database db prec 'xs'
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,206 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = d_db
|
||||
$tbPrefix = d_tb
|
||||
$mtPrefix = d_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$val = $x * 60000
|
||||
$ms = 1519833600000 + $val
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $mt
|
||||
print select count(tbcol) from $mt ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sleep 1000
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
sleep 3000
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 6000
|
||||
|
||||
sql use $db
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
# TODO : where condition
|
||||
# sql select count(tbcol) from $tb where ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 5 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step4
|
||||
sql select count(tbcol) as b from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select count(tbcol) as b from $tb interval(1m)
|
||||
print ===> $data00
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $tb interval(1d)
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
# TODO
|
||||
# sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
|
||||
# print ===> $data00
|
||||
# if $data00 != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
# if $rows != 5 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step7
|
||||
# TODO
|
||||
# sql select count(*) from $mt
|
||||
# print select count(*) from $mt ===> $data00
|
||||
# if $data00 != $totalNum then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
sql select count(tbcol) from $mt
|
||||
print ===> $data00
|
||||
if $data00 != $totalNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step8
|
||||
# TODO
|
||||
# sql select count(tbcol) as c from $mt where ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 50 then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) as c from $mt where tgcol < 5
|
||||
# print ===> $data00
|
||||
# if $data00 != 100 then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 25 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step9
|
||||
# TODO : count from stable
|
||||
# sql select count(tbcol) as b from $mt interval(1m)
|
||||
# print select count(tbcol) as b from $mt interval(1m) ===> $data01
|
||||
# if $data01 != 10 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
# sql select count(tbcol) as b from $mt interval(1d)
|
||||
# print ===> $data02
|
||||
# if $data01 != 200 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step10
|
||||
# TODO
|
||||
# print select count(tbcol) as b from $mt group by tgcol
|
||||
# sql select count(tbcol) as b from $mt group by tgcol
|
||||
# print ===> $data00
|
||||
# if $data00 != $rowNum then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
# if $rows != $tbNum then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
print =============== step11
|
||||
# TODO : where condition
|
||||
# sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol
|
||||
# print ===> $data01
|
||||
# if $data01 != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
# if $rows != 50 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,213 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/deploy.sh -n dnode2 -i 2
|
||||
system sh/deploy.sh -n dnode3 -i 3
|
||||
system sh/deploy.sh -n dnode4 -i 4
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode2 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode3 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode4 -c walLevel -v 1
|
||||
# system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
# system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
|
||||
# system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
|
||||
# system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sql connect
|
||||
|
||||
sql create dnode $hostname PORT 7200
|
||||
sql create dnode $hostname PORT 7300
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
system sh/exec.sh -n dnode3 -s start
|
||||
system sh/exec.sh -n dnode4 -s start
|
||||
$x = 0
|
||||
createDnode:
|
||||
$x = $x + 1
|
||||
sleep 1000
|
||||
if $x == 20 then
|
||||
return -1
|
||||
endi
|
||||
sql show dnodes;
|
||||
if $data4_2 == offline then
|
||||
goto createDnode
|
||||
endi
|
||||
if $data4_3 == offline then
|
||||
goto createDnode
|
||||
endi
|
||||
if $data4_4 == offline then
|
||||
goto createDnode
|
||||
endi
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = r3v3_db
|
||||
$tbPrefix = r3v3_tb
|
||||
$mtPrefix = r3v3_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$val = $x * 60000
|
||||
$ms = 1519833600000 + $val
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sleep 100
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(*) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
# TODO : where condition
|
||||
# sql select count(tbcol) from $tb where ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 5 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step4
|
||||
sql select count(tbcol) as b from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select count(tbcol) as b from $tb interval(1m)
|
||||
print ===> $data00
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $tb interval(1d)
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
# sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
|
||||
# print ===> $data00
|
||||
# if $data00 != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
# if $rows != 5 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step7
|
||||
# print select count(*) from $mt
|
||||
# sql select count(*) from $mt
|
||||
# print ===> $data00
|
||||
# if $data00 != $totalNum then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) from $mt
|
||||
# print ===> $data00
|
||||
# if $data00 != $totalNum then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step8
|
||||
# sql select count(tbcol) as c from $mt where ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 50 then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) as c from $mt where tgcol < 5
|
||||
# print ===> $data00
|
||||
# if $data00 != 100 then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 25 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step9
|
||||
# TODO : group by in stable
|
||||
# sql select count(tbcol) as b from $mt interval(1m)
|
||||
# print ===> $data00
|
||||
# if $data00 != 10 then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) as b from $mt interval(1d)
|
||||
# print ===> $data00
|
||||
# if $data00 != 200 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step10
|
||||
# sql select count(tbcol) as b from $mt group by tgcol
|
||||
# print ===> $data00
|
||||
# if $data00 != $rowNum then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# if $rows != $tbNum then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step11
|
||||
# sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol
|
||||
# print ===> $data00
|
||||
# if $data00 != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
# if $rows != 50 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -45,13 +45,14 @@ endi
|
|||
if $data00 != $mt then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select * from $mt
|
||||
if $rows != 0 then
|
||||
if $data04 != 1 then
|
||||
return -1
|
||||
endi
|
||||
# TODO : select * from stable
|
||||
# sql select * from $mt
|
||||
# if $rows != 0 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step4
|
||||
$i = 0
|
||||
|
@ -68,9 +69,9 @@ sql show tables
|
|||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != $mt then
|
||||
return -1
|
||||
endi
|
||||
# if $data03 != $mt then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
|
@ -79,9 +80,9 @@ endi
|
|||
if $data00 != $mt then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 3 then
|
||||
return -1
|
||||
endi
|
||||
# if $data04 != 3 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step5
|
||||
$i = 0
|
||||
|
@ -99,28 +100,28 @@ sleep 8000
|
|||
|
||||
print =============== step6
|
||||
|
||||
sql select * from $mt
|
||||
print select * from $mt ==> $rows $data00
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
# sql select * from $mt
|
||||
# print select * from $mt ==> $rows $data00
|
||||
# if $rows != 3 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step7
|
||||
sql select * from $mt where sp = 1
|
||||
print select * from $mt where sp = 1 ==> $rows $data00
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
# sql select * from $mt where sp = 1
|
||||
# print select * from $mt where sp = 1 ==> $rows $data00
|
||||
# if $rows != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step8
|
||||
sql drop table $mt
|
||||
|
||||
print =============== step9
|
||||
|
||||
sql show tables
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
#sql show tables
|
||||
#if $rows != 0 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
sql show stables
|
||||
if $rows != 0 then
|
||||
|
@ -129,7 +130,7 @@ endi
|
|||
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 0 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
|
@ -16,11 +16,11 @@ sql create table d1.t2 (ts timestamp, i int);
|
|||
sql create table d1.t3 (ts timestamp, i int);
|
||||
sql insert into d1.t1 values(now, 1);
|
||||
sql insert into d1.t2 values(now, 1);
|
||||
sql drop table d1.t1;
|
||||
# sql drop table d1.t1;
|
||||
sql drop database d1;
|
||||
|
||||
sql show databases;
|
||||
if $rows != 0 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -32,24 +32,24 @@ sql create table d2.t2 (ts timestamp, i int);
|
|||
sql create table d2.t3 (ts timestamp, i int);
|
||||
sql insert into d2.t1 values(now, 1);
|
||||
sql insert into d2.t2 values(now, 1);
|
||||
sql drop table d2.t1;
|
||||
sql drop table d2.t2;
|
||||
sql drop table d2.t3;
|
||||
|
||||
sql show d2.tables;
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
# sql drop table d2.t1;
|
||||
# sql drop table d2.t2;
|
||||
# sql drop table d2.t3;
|
||||
#
|
||||
# sql show d2.tables;
|
||||
# if $rows != 0 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
sql show d2.vgroups;
|
||||
if $rows != 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql drop database d2;
|
||||
|
||||
sql show databases;
|
||||
if $rows != 0 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -61,24 +61,24 @@ sql create table d3.t1 using d3.st tags(1);
|
|||
sql create table d3.t2 using d3.st tags(1);
|
||||
sql create table d3.t3 using d3.st tags(1);
|
||||
sql insert into d3.t1 values(now, 1);
|
||||
sql drop table d3.t1;
|
||||
sql drop table d3.t2;
|
||||
sql drop table d3.t3;
|
||||
|
||||
sql show d3.tables;
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
# sql drop table d3.t1;
|
||||
# sql drop table d3.t2;
|
||||
# sql drop table d3.t3;
|
||||
#
|
||||
# sql show d3.tables;
|
||||
# if $rows != 0 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
sql show d3.vgroups;
|
||||
if $rows != 0 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql drop database d3;
|
||||
|
||||
sql show databases;
|
||||
if $rows != 0 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -90,13 +90,13 @@ sql create table d4.t1 using d4.st tags(1);
|
|||
sql create table d4.t2 using d4.st tags(1);
|
||||
sql create table d4.t3 using d4.st tags(1);
|
||||
sql insert into d4.t1 values(now, 1);
|
||||
sql drop table d4.t1;
|
||||
# sql drop table d4.t1;
|
||||
sql drop table d4.st;
|
||||
|
||||
sql show d4.tables;
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
#
|
||||
# sql show d4.tables;
|
||||
# if $rows != 0 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
sql show d4.stables;
|
||||
if $rows != 0 then
|
||||
|
@ -106,7 +106,7 @@ endi
|
|||
sql drop database d4;
|
||||
|
||||
sql show databases;
|
||||
if $rows != 0 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -118,12 +118,12 @@ sql create table d5.t1 using d5.st tags(1);
|
|||
sql create table d5.t2 using d5.st tags(1);
|
||||
sql create table d5.t3 using d5.st tags(1);
|
||||
sql insert into d5.t1 values(now, 1);
|
||||
sql drop table d5.t1;
|
||||
# sql drop table d5.t1;
|
||||
|
||||
sql drop database d5;
|
||||
|
||||
sql show databases;
|
||||
if $rows != 0 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
|
@ -10,6 +10,7 @@ sql connect
|
|||
print ======================== create stable
|
||||
|
||||
sql create database d1
|
||||
sql use d1
|
||||
|
||||
$x = 0
|
||||
while $x < 128
|
||||
|
@ -18,6 +19,22 @@ while $x < 128
|
|||
$x = $x + 1
|
||||
endw
|
||||
|
||||
print ======================== describe stables
|
||||
# TODO : create stable error
|
||||
$m = 0
|
||||
while $m < 128
|
||||
$tb = s . $m
|
||||
$filter = ' . $tb
|
||||
$filter = $filter . '
|
||||
sql show stables like $filter
|
||||
# print sql : show stables like $filter ==> $rows
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
$m = $m + 1
|
||||
endw
|
||||
|
||||
|
||||
print ======================== show stables
|
||||
|
||||
sql show d1.stables
|
|
@ -0,0 +1,121 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
sql create database vdb0
|
||||
sql create table vdb0.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
sql create table vdb0.vtb00 using vdb0.mt tags( 0 )
|
||||
sql create table vdb0.vtb01 using vdb0.mt tags( 0 )
|
||||
|
||||
sql create database vdb1
|
||||
sql create table vdb1.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
# sql_error create table vdb1.vtb10 using vdb0.mt tags( 1 )
|
||||
# sql_error create table vdb1.vtb11 using vdb0.mt tags( 1 )
|
||||
sql create table vdb1.vtb10 using vdb1.mt tags( 1 )
|
||||
sql create table vdb1.vtb11 using vdb1.mt tags( 1 )
|
||||
|
||||
sql create database vdb2
|
||||
sql create table vdb2.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
# sql_error create table vdb2.vtb20 using vdb0.mt tags( 2 )
|
||||
# sql_error create table vdb2.vtb21 using vdb0.mt tags( 2 )
|
||||
sql create table vdb2.vtb20 using vdb2.mt tags( 2 )
|
||||
sql create table vdb2.vtb21 using vdb2.mt tags( 2 )
|
||||
|
||||
sql create database vdb3
|
||||
sql create table vdb3.mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
# sql_error create table vdb3.vtb20 using vdb0.mt tags( 2 )
|
||||
# sql_error create table vdb3.vtb21 using vdb0.mt tags( 2 )
|
||||
sql create table vdb3.vtb30 using vdb3.mt tags( 3 )
|
||||
sql create table vdb3.vtb31 using vdb3.mt tags( 3 )
|
||||
|
||||
print =============== step2
|
||||
sql insert into vdb0.vtb00 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30)
|
||||
sql insert into vdb0.vtb01 values (1519833600000 , 10) (1519833600001, 20) (1519833600002, 30)
|
||||
sql insert into vdb1.vtb10 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31)
|
||||
sql insert into vdb1.vtb11 values (1519833600000 , 11) (1519833600001, 21) (1519833600002, 31)
|
||||
sql insert into vdb2.vtb20 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32)
|
||||
sql insert into vdb2.vtb21 values (1519833600000 , 12) (1519833600001, 22) (1519833600002, 32)
|
||||
sql insert into vdb3.vtb30 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33)
|
||||
sql insert into vdb3.vtb31 values (1519833600000 , 13) (1519833600001, 23) (1519833600002, 33)
|
||||
# sql select * from vdb0.mt
|
||||
sql select ts from vdb0.mt
|
||||
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
sql insert into vdb0.vtb00 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60)
|
||||
sql insert into vdb0.vtb01 values (1519833600003 , 40) (1519833600005, 50) (1519833600004, 60)
|
||||
sql insert into vdb1.vtb10 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61)
|
||||
sql insert into vdb1.vtb11 values (1519833600003 , 41) (1519833600005, 51) (1519833600004, 61)
|
||||
sql insert into vdb2.vtb20 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62)
|
||||
sql insert into vdb2.vtb21 values (1519833600003 , 42) (1519833600005, 52) (1519833600004, 62)
|
||||
sql insert into vdb3.vtb30 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63)
|
||||
sql insert into vdb3.vtb31 values (1519833600003 , 43) (1519833600005, 53) (1519833600004, 63)
|
||||
# TODO : select * from stable
|
||||
# sql select * from vdb0.mt
|
||||
sql select ts from vdb0.mt
|
||||
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step4
|
||||
# TODO : insert into diffrent table
|
||||
# sql insert into vdb0.vtb00 values(1519833600006, 60) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 60) (1519833600007, 70)
|
||||
# sql insert into vdb1.vtb10 values(1519833600006, 61) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 61) (1519833600007, 71)
|
||||
# sql insert into vdb2.vtb20 values(1519833600006, 62) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 62) (1519833600007, 72)
|
||||
# sql insert into vdb3.vtb30 values(1519833600006, 63) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 63) (1519833600007, 73)
|
||||
# # sql select * from vdb0.mt
|
||||
# sql select ts from vdb0.mt
|
||||
#
|
||||
# if $rows != 16 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step5
|
||||
# sql insert into vdb0.vtb00 values(1519833600008, 80) (1519833600007, 70) vdb0.vtb01 values(1519833600006, 80) (1519833600007, 70)
|
||||
# sql insert into vdb1.vtb10 values(1519833600008, 81) (1519833600007, 71) vdb1.vtb11 values(1519833600006, 81) (1519833600007, 71)
|
||||
# sql insert into vdb2.vtb20 values(1519833600008, 82) (1519833600007, 72) vdb2.vtb21 values(1519833600006, 82) (1519833600007, 72)
|
||||
# sql insert into vdb3.vtb30 values(1519833600008, 83) (1519833600007, 73) vdb3.vtb31 values(1519833600006, 83) (1519833600007, 73)
|
||||
# # sql select * from vdb0.mt
|
||||
# sql select ts from vdb0.mt
|
||||
#
|
||||
# if $rows != 17 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step6
|
||||
# sql insert into vdb0.vtb00 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb10 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb20 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb30 values(1519833600009, 90) (1519833600010, 100)
|
||||
# sql insert into vdb0.vtb01 values(1519833600009, 90) (1519833600010, 100) vdb1.vtb11 values(1519833600009, 90) (1519833600010, 100) vdb2.vtb21 values(1519833600009, 90) (1519833600010, 100) vdb3.vtb31 values(1519833600009, 90) (1519833600010, 100)
|
||||
#
|
||||
# # sql select * from vdb0.mt
|
||||
# sql select ts from vdb0.mt
|
||||
#
|
||||
# if $rows != 21 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step7
|
||||
# sql insert into vdb0.vtb00 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb10 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb20 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb30 values(1519833600012, 120) (1519833600011, 110)
|
||||
# sql insert into vdb0.vtb01 values(1519833600012, 120) (1519833600011, 110) vdb1.vtb11 values(1519833600012, 120) (1519833600011, 110) vdb2.vtb21 values(1519833600012, 120) (1519833600011, 110) vdb3.vtb31 values(1519833600012, 120) (1519833600011, 110)
|
||||
#
|
||||
# # sql select * from vdb0.mt
|
||||
# sql select ts from vdb0.mt
|
||||
#
|
||||
# if $rows != 25 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,181 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======================== dnode1 start
|
||||
|
||||
$dbPrefix = v3_db
|
||||
$tbPrefix = v3_tb
|
||||
$mtPrefix = v3_mt
|
||||
$tbNum = 10
|
||||
$rowNum = 20
|
||||
$totalNum = 200
|
||||
|
||||
print =============== step1
|
||||
$i = 0
|
||||
$db = $dbPrefix . $i
|
||||
$mt = $mtPrefix . $i
|
||||
|
||||
sql create database $db
|
||||
sql use $db
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$val = $x * 60000
|
||||
$ms = 1519833600000 + $val
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
sql show vgroups
|
||||
print vgroups ==> $rows
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(*) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step3
|
||||
# TODO : where condition
|
||||
# sql select count(tbcol) from $tb where ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 5 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step4
|
||||
sql select count(tbcol) as b from $tb
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step5
|
||||
sql select count(tbcol) as b from $tb interval(1m)
|
||||
print ===> $data00
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol) as b from $tb interval(1d)
|
||||
print ===> $data00
|
||||
if $data00 != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== step6
|
||||
# sql select count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
|
||||
# print ===> $data00
|
||||
# if $data00 != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
# if $rows != 5 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print =============== step7
|
||||
# TODO : count(*) err
|
||||
# sql select count(*) from $mt
|
||||
# print ===> $data00
|
||||
# if $data00 != $totalNum then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) from $mt
|
||||
# print ===> $data00
|
||||
# if $data00 != $totalNum then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step8
|
||||
# sql select count(tbcol) as c from $mt where ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 50 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
# sql select count(tbcol) as c from $mt where tgcol < 5
|
||||
# print ===> $data00
|
||||
# if $data00 != 100 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
# sql select count(tbcol) as c from $mt where tgcol < 5 and ts <= 1519833840000
|
||||
# print ===> $data00
|
||||
# if $data00 != 25 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step9
|
||||
# sql select count(tbcol) as b from $mt interval(1m)
|
||||
# print ===> $data00
|
||||
# if $data00 != 10 then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# sql select count(tbcol) as b from $mt interval(1d)
|
||||
# print ===> $data00
|
||||
# if $data00 != 200 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step10
|
||||
# sql select count(tbcol) as b from $mt group by tgcol
|
||||
# print ===> $data00
|
||||
# if $data00 != $rowNum then
|
||||
# return -1
|
||||
# endi
|
||||
#
|
||||
# if $rows != $tbNum then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== step11
|
||||
# sql select count(tbcol) as b from $mt where ts <= 1519833840000 interval(1m) group by tgcol
|
||||
# print ===> $data01
|
||||
# if $data01 != 1 then
|
||||
# return -1
|
||||
# endi
|
||||
# if $rows != 50 then
|
||||
# return -1
|
||||
# endi
|
||||
|
||||
print =============== clear
|
||||
sql drop database $db
|
||||
sql show databases
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -66,15 +66,15 @@ print =============== will support: * from stb; function from stb/ctb
|
|||
|
||||
sql create topic topic_stb_column as select ts, c1, c3 from stb
|
||||
#sql create topic topic_stb_all as select * from stb
|
||||
#sql create topic topic_stb_function as select ts, abs(c1), sina(c2) from stb
|
||||
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||
|
||||
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||
sql create topic topic_ctb_all as select * from ct0
|
||||
#sql create topic topic_ctb_function as select ts, abs(c1), sina(c2) from ct0
|
||||
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||
|
||||
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||
sql create topic topic_ntb_all as select * from ntb
|
||||
#sql create topic topic_ntb_function as select ts, abs(c1), sina(c2) from ntb
|
||||
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||
|
||||
sql show tables
|
||||
if $rows != 3 then
|
||||
|
@ -147,6 +147,13 @@ endi
|
|||
# return -1
|
||||
#endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2"
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2"
|
||||
print cmd result----> $system_content
|
||||
if $system_content != @{consume success: 20, 0}@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2"
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2"
|
||||
print cmd result----> $system_content
|
||||
|
@ -161,6 +168,13 @@ if $system_content != @{consume success: 10, 0}@ then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2"
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2"
|
||||
print cmd result----> $system_content
|
||||
if $system_content != @{consume success: 10, 0}@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2"
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2"
|
||||
print cmd result----> $system_content
|
||||
|
@ -175,6 +189,13 @@ if $system_content != @{consume success: 20, 0}@ then
|
|||
return -1
|
||||
endi
|
||||
|
||||
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2"
|
||||
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2"
|
||||
print cmd result----> $system_content
|
||||
if $system_content != @{consume success: 20, 0}@ then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== create database , vgroup 4
|
||||
$dbNamme = d1
|
||||
sql create database $dbNamme vgroups 4
|
||||
|
|
|
@ -387,11 +387,12 @@ void perf_loop(tmq_t* tmq, tmq_list_t* topics, int32_t totalMsgs, int64_t walLog
|
|||
printf("subscribe err\n");
|
||||
return;
|
||||
}
|
||||
/*taosSsleep(3);*/
|
||||
int32_t batchCnt = 0;
|
||||
int32_t skipLogNum = 0;
|
||||
int64_t startTime = taosGetTimestampUs();
|
||||
while (running) {
|
||||
tmq_message_t* tmqmessage = tmq_consumer_poll(tmq, 1);
|
||||
tmq_message_t* tmqmessage = tmq_consumer_poll(tmq, 3000);
|
||||
if (tmqmessage) {
|
||||
batchCnt++;
|
||||
skipLogNum += tmqGetSkipLogNum(tmqmessage);
|
||||
|
|
|
@ -226,7 +226,7 @@ void loop_consume(tmq_t* tmq) {
|
|||
int32_t totalRows = 0;
|
||||
int32_t skipLogNum = 0;
|
||||
while (running) {
|
||||
tmq_message_t* tmqMsg = tmq_consumer_poll(tmq, 1);
|
||||
tmq_message_t* tmqMsg = tmq_consumer_poll(tmq, 3000);
|
||||
if (tmqMsg) {
|
||||
totalMsgs++;
|
||||
|
||||
|
|
Loading…
Reference in New Issue